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

feat(core): Allow to configure disableIntegrations to opt-out of default integrations #15300

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mydea
Copy link
Member

@mydea mydea commented Feb 5, 2025

This new top-level config allows to opt-out of any added integration, ensuring it is not actually added.

This is mainly designed to opt-out of default integrations, but will also apply to any manually added integration.

There are type hints that should help with usage there, but any key is allowed to keep this flexible. Type hints are manually configured (could not find a way to infer this from integrations, as the names are not statically exposed there...) for now.

image

Usage:

Sentry.init({
  disableIntegrations: { BrowserSession: true, InboundFilters: false }
});

Will disable the browserSessionIntegration but not the inboundFilters one.

Syntax

The linked issue proposed to allow to pass { IntegrationName: false } to defaultIntegrations. While this is a nice API from a users POV, it is trickier than I imagined - the problem is the logic we have around defaultIntergations. E.g. the browser SDK will basically do this:

function init(options) {
  const opts = {
    defaultInterhations: options.defaultIntergations || getDefaultIntergations()
    // ...
  };
}

Which makes it much trickier to handle these things and would require bigger changes in various places 😬 So this PR tries a different approach, by having a new config property for this 🤔 If there are other ideas/thoughts around this, happy to hear them!

Closes #14950

@mydea mydea self-assigned this Feb 5, 2025
This new top-level config allows to opt-out of any added integration, ensuring it is not actually added.

This is mainly designed to opt-out of default integrations, but will also apply to any manually added integration.

There are type hints that should help with usage there, but any key is allowed to keep this flexible. Type hints are manually configured (could not find a way to infer this from integrations, as the names are not statically exposed there...) for now.

Usage:

```js
Sentry.init({
  disableIntegrations: { BrowserSession: true, InboundFilters: false }
});
```

Will disable the browserSessionIntegration but not the inboundFilters one.
@mydea mydea force-pushed the fn/default-integrations-opt-out branch from e99bbf7 to ce18641 Compare February 5, 2025 10:19
Copy link
Contributor

github-actions bot commented Feb 5, 2025

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 22.92 KB +0.13% +30 B 🔺
@sentry/browser - with treeshaking flags 22.79 KB +0.12% +26 B 🔺
@sentry/browser (incl. Tracing) 35.79 KB +0.07% +24 B 🔺
@sentry/browser (incl. Tracing, Replay) 72.6 KB +0.04% +23 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.15 KB +0.04% +22 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.85 KB +0.03% +23 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 89.58 KB +0.03% +21 B 🔺
@sentry/browser (incl. Feedback) 39.86 KB +0.06% +23 B 🔺
@sentry/browser (incl. sendFeedback) 27.55 KB +0.1% +26 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.32 KB +0.07% +23 B 🔺
@sentry/react 24.75 KB +0.09% +22 B 🔺
@sentry/react (incl. Tracing) 37.69 KB +0.06% +21 B 🔺
@sentry/vue 27.12 KB +0.09% +24 B 🔺
@sentry/vue (incl. Tracing) 37.51 KB +0.06% +23 B 🔺
@sentry/svelte 23.05 KB +0.12% +27 B 🔺
CDN Bundle 24.22 KB +0.09% +20 B 🔺
CDN Bundle (incl. Tracing) 35.93 KB +0.05% +16 B 🔺
CDN Bundle (incl. Tracing, Replay) 70.57 KB +0.02% +13 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 75.72 KB +0.03% +16 B 🔺
CDN Bundle - uncompressed 70.82 KB +0.08% +56 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 106.69 KB +0.06% +56 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.55 KB +0.03% +56 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.12 KB +0.03% +56 B 🔺
@sentry/nextjs (client) 38.65 KB +0.05% +18 B 🔺
@sentry/sveltekit (client) 36.31 KB +0.07% +23 B 🔺
@sentry/node 156.54 KB +0.02% +27 B 🔺
@sentry/node - without tracing 97.54 KB +0.03% +20 B 🔺
@sentry/aws-serverless 107.09 KB +0.02% +21 B 🔺

View base workflow run

@mydea
Copy link
Member Author

mydea commented Feb 7, 2025

Once #15307 is merged, we can refactor this to instead allow configuring defaultIntergations: { InboundFilters: false }, which is a better API probably.

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.

Make it easier to opt-out of default integrations
1 participant