fix(nextjs): Allow onUncaughtException integration to remain excluded - #6148
Merged
lobsterkatie merged 4 commits intoNov 8, 2022
Merged
Conversation
Contributor
size-limit report 📦
|
Lms24
approved these changes
Nov 8, 2022
lobsterkatie
deleted the
kmclb-nextjs-allow-default-integration-exclusion
branch
November 8, 2022 07:48
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.
In the nextjs SDK, the
addOrUpdateIntegrationfunction 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/browseror@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 theaddOrUpdateIntegrationlogic 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
integrationsoption inSentry.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 namedallowExclusionByUser. If it's set totrue, we'll perform the check and respect the user's choice. If it's set tofalseor 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
onUncaughtExceptionintegration in the nextjs defaults. This PR therefore also applies the above change to that default instance.Finally, the test suite for
addOrUpdateIntegrationhas been entirely reworked, to ensure that it covers all possible cases.Supersedes #6142.