Skip to content

fix(core): Remove web Replay and Feedback from native bundles by default - #7062

Open
huextrat wants to merge 2 commits into
getsentry:mainfrom
huextrat:fix/metro-exclude-web-replay-feedback-on-native
Open

huextrat wants to merge 2 commits into
getsentry:mainfrom
huextrat:fix/metro-exclude-web-replay-feedback-on-native

Conversation

@huextrat

@huextrat huextrat commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

withSentryConfig and getSentryExpoConfig only installed the web Replay and Feedback resolvers when includeWebReplay / includeWebFeedback was explicitly false, and withSentryConfig defaulted both options to true.

buildSentryPackageExcludeResolver already has a branch that removes these packages on Android and iOS only when the option is undefined:

(includePackage === false || (includePackage === undefined && (platform === 'android' || platform === 'ios')))

Because of the === false guard, that branch could never run, so every native bundle shipped @sentry-internal/replay, @sentry-internal/replay-canvas and @sentry-internal/feedback unless the app opted out by hand.

This PR installs both resolvers unless the option is true:

Option value Android / iOS Web
undefined (new default) removed kept
true kept kept
false removed removed (unchanged)

The JSDoc of both options now describes these three cases. includeWebFeedback does not affect the React Native feedback widget (feedbackIntegration), which does not import @sentry/browser feedback.

💡 Motivation and Context

The 5.32.0 changelog (#4006) announced that Web Replay is excluded from native bundles by default, with includeWebReplay: true to keep it. A late commit in that PR ("set default to true") added the true default and the === false guard, so the announced behaviour never shipped. #3718 asked for the same thing: remove web replay on mobile automatically, with an option to also remove it on web.

These packages never run on native: browserReplayIntegration returns a no-op when notWeb(), and Metro does not tree-shake, so the code is bundled and parsed at startup for nothing. In our production app, setting both options to false removes about 295 KB of Hermes bytecode.

Removing these packages on native is safe:

The only change in behaviour is for an app that imports @sentry/browser Replay or Feedback directly and runs it on Android or iOS, which does not work today anyway. Such an app can set the option to true.

💚 How did you test it?

  • Added tests that build the config with withSentryConfig and getSentryExpoConfig and check the default, true and false cases for @sentry-internal/replay, @sentry-internal/feedback and the @sentry/browser feedback wrappers. These tests fail without the fix.
  • jest --config jest.config.tools.js: 385 tests pass.
  • lint:oxlint, lint:fmt, build:sdk and api-report:check pass (the API report does not change).
  • Our production app (Expo, getSentryExpoConfig) has run with includeWebReplay: false and includeWebFeedback: false on Android and iOS without issues.

I did not run test:sdk, circularDepCheck, or a sample app bundle with this branch.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

🤖 Generated with Claude Code

huextrat and others added 2 commits November 18, 2026 11:30
`includeWebReplay` and `includeWebFeedback` defaulted to `true`, and the
Metro resolvers were only installed when the option was explicitly `false`.
The resolver's `undefined` branch, which removes these packages on Android
and iOS only, could never run, even though the 5.32.0 changelog announced
Web Replay removal from native bundles by default.

Install both resolvers unless the option is `true`:
- `undefined` (default): removed on Android and iOS, kept on web
- `true`: kept on all platforms
- `false`: removed on all platforms

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@huextrat
huextrat marked this pull request as ready for review November 18, 2026 10:35
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Nov 18, 2026

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @huextrat 🙇

Overall the PR and the changed behavior LGTM 🚀

I'll loop in @lucas-zimerman for a final check since he has more context on the original implementation and the follow up 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants