Skip to content

feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle#6025

Open
antonis wants to merge 4 commits intomainfrom
feat/metro-include-feedback
Open

feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle#6025
antonis wants to merge 4 commits intomainfrom
feat/metro-include-feedback

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 20, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds an includeFeedback option to SentryMetroConfigOptions (used by both withSentryConfig and getSentryExpoConfig). When set to false, a Metro resolver returns { type: 'empty' } for any module matching @sentry(?:-internal)?/feedback, removing the web user-feedback widget from the bundle.

Example:

const config = getSentryExpoConfig(__dirname, {
  includeFeedback: false,
});

Also factored the shared resolver logic into buildSentryPackageExcludeResolver, so withSentryResolver (replay) and the new withSentryFeedbackResolver no longer duplicate the resolver body.

💡 Motivation and Context

Users who do not use the feedback feature are still paying for @sentry-internal/feedback in their bundle (see the expo-atlas screenshot in the linked issue). The existing includeWebReplay option solves the same problem for replay; this PR mirrors that pattern for feedback.

Closes #5629

💚 How did you test it?

  • Added unit tests in packages/core/test/tools/metroconfig.test.ts for the new withSentryFeedbackResolver, covering:
    • includeFeedback true/false/undefined across web/android/ios/null platforms
    • Both @sentry-internal/feedback and @sentry/feedback module names
    • Falls through to the original resolver for non-feedback modules
    • Old-Metro (<0.68) fallback path with process.exit(-1)
  • yarn test:tools — 254 passed
  • yarn test (full suite) — passing
  • yarn lint — passing
  • yarn circularDepCheck — passing
  • yarn build — passing

📝 Checklist

🔮 Next steps

…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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(core): Add includeFeedback Metro option to exclude feedback widget from bundle by antonis in #6025
  • feat(core): Expose scope-level attributes API by antonis in #6009
  • chore(deps): Force basic-ftp >=5.3.0 to fix GHSA-rp42-5vxx-qpwr by antonis in #6024
  • feat(core): Add GlobalErrorBoundary for non-rendering errors by alwx in #6023
  • chore(deps): update CLI to v3.4.0 by github-actions in #6026
  • feat: Expose screenshot masking options for error screenshots by antonis in #6007
  • fix(replay): Check captureReplay return value in iOS bridge by antonis in #6008
  • chore(deps): bump getsentry/craft from 2.25.2 to 2.25.4 by dependabot in #6019
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.25.2 to 2.25.4 by dependabot in #6021
  • chore(deps): bump github/codeql-action from 4.35.1 to 4.35.2 by dependabot in #6022
  • chore(deps): bump actions/setup-node from 6.3.0 to 6.4.0 by dependabot in #6020
  • ci(danger): Demote Android SDK version mismatch from fail to warn by antonis in #6018
  • chore(deps): update Android SDK to v8.39.1 by github-actions in #6010
  • chore(deps): update JavaScript SDK to v10.49.0 by github-actions in #6011
  • ci: Integrate Warden for AI-powered PR code review by antonis in #6003
  • chore(lint): Fixes lint issue on main by antonis in #6013
  • feat(expo): Warn when prebuilt native projects are missing Sentry config by alwx in #5984

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 8dcac24

Comment thread CHANGELOG.md Outdated
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 20, 2026

@sentry review

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 20, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ 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.

@antonis antonis marked this pull request as ready for review April 20, 2026 11:37
@alwx alwx assigned alwx and unassigned alwx Apr 20, 2026
export function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig {
function buildSentryPackageExcludeResolver(
config: MetroConfig,
include: boolean | undefined,
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.

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

Copy link
Copy Markdown
Contributor Author

@antonis antonis Apr 21, 2026

Choose a reason for hiding this comment

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

Good point @alwx 👍 Renamed to includePackage with 0449f5e

Copy link
Copy Markdown
Contributor

@alwx alwx left a comment

Choose a reason for hiding this comment

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

Added one small comment

antonis added 2 commits April 21, 2026 14:20
…eExcludeResolver

Addresses review feedback: bare `include` is ambiguous in the helper —
`includePackage` makes the intent obvious alongside `moduleRegex`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Metro config flag (similar to includeWebReplay) to remove @sentry-internal/feedback from the bundle

2 participants