feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle#6025
feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle#6025
Conversation
…et from bundle Mirrors the existing `includeWebReplay` option. When set to `false`, `@sentry-internal/feedback` (and related subpackages) are resolved to an empty module, removing the web user-feedback widget from the bundle. Refactored the shared resolver logic into `buildSentryPackageExcludeResolver` so `withSentryResolver` and the new `withSentryFeedbackResolver` both call into it instead of duplicating the resolver body. Closes #5629
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
|
|
@sentry review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d82da05. Configure here.
| export function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig { | ||
| function buildSentryPackageExcludeResolver( | ||
| config: MetroConfig, | ||
| include: boolean | undefined, |
There was a problem hiding this comment.
just include feels like a bit of a weird name, somewhat unintuitive and leads to a question of what exactly we're trying to include here
…eExcludeResolver Addresses review feedback: bare `include` is ambiguous in the helper — `includePackage` makes the intent obvious alongside `moduleRegex`.
| * Adds the Sentry user feedback widget package for web. | ||
| * @default true | ||
| */ | ||
| includeFeedback?: boolean; |
There was a problem hiding this comment.
Lets be more specific with the naming so it points out to be only include the web replay
| includeFeedback?: boolean; | |
| includeWebFeedback?: boolean; |
| - Include your resolverRequest on your metroconfig. | ||
| - Update your Metro version to 0.68 or higher. | ||
| - Set includeWebReplay as true on your metro config. | ||
| - Set ${optionName} as true on your metro config. |
There was a problem hiding this comment.
q: why this change?
| - Expose scope-level attributes API (`setAttribute`, `setAttributes`, `removeAttribute`) bridging to native SDKs ([#6009](https://github.com/getsentry/sentry-react-native/pull/6009)) | ||
| - Expose screenshot masking options (`screenshot.maskAllText`, `screenshot.maskAllImages`, `screenshot.maskedViewClasses`, `screenshot.unmaskedViewClasses`) for error screenshots ([#6007](https://github.com/getsentry/sentry-react-native/pull/6007)) | ||
| - Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984)) | ||
| - Add `includeFeedback` Metro config option to exclude `@sentry-internal/feedback` from the bundle ([#6025](https://github.com/getsentry/sentry-react-native/pull/6025)) |
There was a problem hiding this comment.
since a release was done on main branch, this changelog may be out of sync
📢 Type of change
📜 Description
Adds an
includeFeedbackoption toSentryMetroConfigOptions(used by bothwithSentryConfigandgetSentryExpoConfig). When set tofalse, a Metro resolver returns{ type: 'empty' }for any module matching@sentry(?:-internal)?/feedback, removing the web user-feedback widget from the bundle.Example:
Also factored the shared resolver logic into
buildSentryPackageExcludeResolver, sowithSentryResolver(replay) and the newwithSentryFeedbackResolverno longer duplicate the resolver body.💡 Motivation and Context
Users who do not use the feedback feature are still paying for
@sentry-internal/feedbackin their bundle (see the expo-atlas screenshot in the linked issue). The existingincludeWebReplayoption solves the same problem for replay; this PR mirrors that pattern for feedback.Closes #5629
💚 How did you test it?
packages/core/test/tools/metroconfig.test.tsfor the newwithSentryFeedbackResolver, covering:includeFeedbacktrue/false/undefined acrossweb/android/ios/nullplatforms@sentry-internal/feedbackand@sentry/feedbackmodule namesprocess.exit(-1)yarn test:tools— 254 passedyarn test(full suite) — passingyarn lint— passingyarn circularDepCheck— passingyarn build— passing📝 Checklist
sendDefaultPIIis enabled🔮 Next steps