feat: add SentryDebugIdPlugin - #1451
Open
elirangoshen wants to merge 1 commit into
Open
Conversation
Stamps a Sentry Debug ID into the bundle and its source map, so Sentry can pair a JS stack trace with the source map that resolves it. This is the Re.Pack counterpart of what @sentry/react-native provides for Metro through createSentryMetroSerializer.
🦋 Changeset detectedLatest commit: ffff910 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@elirangoshen is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
elirangoshen
marked this pull request as ready for review
September 4, 2026 08:22
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.
Summary
Adds
SentryDebugIdPlugin, which stamps a Sentry Debug ID into the bundle and its source map.A Debug ID is a UUID present in both artifacts. The Sentry SDK reports it with every event and Sentry uses it to pair a JS stack trace with the source map that resolves it. For Metro,
@sentry/react-nativeprovides this throughcreateSentryMetroSerializer; Re.Pack currently has no equivalent, so apps that migrate lose JS symbolication.Why
@sentry/webpack-plugindoesn't cover thisTwo independent gaps, both found while migrating a large app (Expensify, ~35MB minified prod bundle) from Metro to Re.Pack:
BannerPluginwith a hardcodedinclude: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/. Re.Pack emitsindex.bundle, so nothing matches and no snippet is injected — silently, no warning.prepareSourceMapForDebugIdUpload()setsdebugId/debug_idon a copy written to the upload directory, never on the emitted asset.@sentry/react-nativeuploads through its own Gradle/Xcode integration, which reads the on-disk map:scripts/copy-debugid.jscopies the ID onto the Hermes composed map andscripts/has-sourcemap-debugid.jsverifies it. Both no-op when the field is absent, so the build succeeds and symbolication quietly fails.The two plugins compose fine — this one handles the Debug ID,
@sentry/webpack-pluginstill handles release creation and upload.Implementation
BannerPlugin, defaultingtestto/\.([cm]?jsx?|bundle)$/— the same patternSourceMapPluginalready uses, so.bundleand.jsoutputs both work.debugIdanddebug_idinto emitted.mapassets inprocessAssetsatPROCESS_ASSETS_STAGE_REPORT, after the devtool stage. Sentry's tooling reads either spelling depending on version, so both are written.RepackPlugin— Sentry is opt-in, so users add the plugin explicitly.Because injection happens through
BannerPlugin, source maps are generated after the banner and account for the added bytes; column offsets are not shifted. Verified against a no-injection build of the same app: the first mapping segment changes (60BAwJA→mqCAwJA) rather than staying identical.Verification
Unit tests do a real Rspack compile through
memfsand assert the bundle stamp matches the map'sdebugId, for bothindex.bundleandindex.jsoutputs.Also verified end to end in the app on iOS and Android production bundles:
debugIddebugId+debug_id)sentry-dbid-<uuid>stamphas-sourcemap-debugid.jscopy-debugid.js→ Hermes mappnpm jest src/plugins/__tests__→ 82 tests pass (7 suites),pnpm --filter @callstack/repack typecheckclean,pnpm biome checkclean. Changeset and a docs page underwebsite/src/latest/api/plugins/included.Env:
@rspack/core2.1.3,react-native0.86.0,@sentry/react-native8.7.0,@sentry/webpack-plugin5.2.0.Open questions for maintainers
packages/plugin-sentrypackage, alongsideplugin-reanimated/plugin-expo-modules? Happy to move it.RepackPlugin. If you'd prefer an opt-in flag there (e.g.sentry: true), that's an easy follow-up.