feat(core): Use react-native-quick-base64 for envelope encoding when available#6314
Draft
alwx wants to merge 2 commits into
Draft
feat(core): Use react-native-quick-base64 for envelope encoding when available#6314alwx wants to merge 2 commits into
alwx wants to merge 2 commits into
Conversation
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 5 more 🤖 This preview updates automatically when you update the PR. |
…available Adds `react-native-quick-base64` as an optional peer dependency. When the package is installed by the consumer, envelope payloads are base64-encoded via its native JSI implementation (~10x faster than the bundled JS encoder). When it is absent, the SDK transparently falls back to the existing `base64-js`-derived encoder in `vendor/base64-js` — no behavior change for users who do not opt in. The encoder is resolved once at first use and cached, so the optional `require` runs at most once per session. Base64 encoding is on the hot path of `RNSentry.captureEnvelope` and is most impactful for large envelopes (profiles, attachments, replays). Closes #4884.
f64591a to
383df08
Compare
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
Adds
react-native-quick-base64as an optional peer dependency of@sentry/react-native. When the package is installed by the consumer, the SDK uses its native JSI base64 encoder (~10x faster than the bundled JS implementation) for envelope payloads on theRNSentry.captureEnvelopehot path. When the package is absent the SDK falls back to the existingbase64-js-derived encoder invendor/base64-js— no behavior change for users who do not opt in.Changes:
packages/core/src/js/utils/base64.ts—encodeToBase64()resolves the encoder once and caches it. Triesrequire('react-native-quick-base64')first; falls back tobase64StringFromByteArrayfromvendor/base64-js.packages/core/src/js/wrapper.ts—captureEnvelopenow callsencodeToBase64(envelopeBytes)instead ofbase64StringFromByteArray(envelopeBytes)directly.packages/core/package.json—react-native-quick-base64 >=3.0.0added topeerDependenciesand markedoptional: trueinpeerDependenciesMeta. No new required deps.CHANGELOG.md— entry under Unreleased / Features.💡 Motivation and Context
Closes #4884.
💚 How did you test it?
Addded tests!
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
react-native-quick-base64in the Sentry docs as a recommended performance install for users shipping large payloads.