Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Allow onUncaughtException integration to remain excluded #6148

Merged

Conversation

lobsterkatie
Copy link
Member

In the nextjs SDK, the addOrUpdateIntegration function exists to force the inclusion of certain integrations with certain options set. If such an integration is included in the underlying SDK's default integrations, however, (in other words, if it's included in the defaults set by @sentry/browser or @sentry/node), it's possible for the user to have actively chosen to exclude it, which we would then be overriding. This PR adds to the addOrUpdateIntegration logic to provide the ability to respect that choice.

The only way for a user to choose to filter out a default integration is by providing a function as their integrations option in Sentry.init(). Therefore, when handling the function case, we can check if a given integration is included in the return value, and if it's not, not add the default instance we otherwise would. This is controlled by a flag on that default instance named allowExclusionByUser. If it's set to true, we'll perform the check and respect the user's choice. If it's set to false or not set at all, we'll continue to behave as we have, forcing the inclusion of the given integration.

The inspiration for this change is our recent inclusion of the onUncaughtException integration in the nextjs defaults. This PR therefore also applies the above change to that default instance.

Finally, the test suite for addOrUpdateIntegration has been entirely reworked, to ensure that it covers all possible cases.

Supersedes #6142.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.49 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 60.35 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.12 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 53.67 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.86 KB (0%)
@sentry/browser - Webpack (minified) 65.12 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.88 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 45.81 KB (+0.06% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.24 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.62 KB (-0.01% 🔽)

@lobsterkatie lobsterkatie merged commit b428d14 into master Nov 8, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-allow-default-integration-exclusion branch November 8, 2022 07:48
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.

None yet

2 participants