Skip to content

feat(integrations): Export pluggable integrations directly #8842

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

Closed
wants to merge 1 commit into from

Conversation

mydea
Copy link
Member

@mydea mydea commented Aug 18, 2023

This PR re-exports all pluggable integrations from @sentry/integrations from the browser/node packages.

This mean you can use them like this:

import * as Sentry from '@sentry/browser';

Sentry.init({
  // other stuff
  integrations: [
    new Sentry.Integrations.ExtraErrorData()
  ]
});

We already depend on treeshaking in a bunch of other places, and this change means there is really nothing you'd ever need to install manually in addition to your SDK package, also ensuring we generally always have consistent versions etc.

@mydea mydea requested review from lforst, Lms24 and AbhiPrasad August 18, 2023 12:18
@mydea mydea self-assigned this Aug 18, 2023
@mydea mydea changed the title feat: Export pluggable integrations directly feat(integrations): Export pluggable integrations directly Aug 18, 2023
(statement: { specifiers: [{ imported?: { name: string }; name?: string }] }, source: string) => {
// We only want to handle the integrations import if it doesn't come from the @sentry/browser re-export
// In that case, we just want to leave it alone
if (
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this change, this fails for all tests as the build output of webpack includes the import from @sentry/integrations by default and tries to "fix" it in there, but it also does not contain an imported field so it just fails.

@@ -29,7 +29,6 @@
"tslib": "^2.4.1 || ^1.9.3"
},
"devDependencies": {
"@sentry/browser": "7.64.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

This would have been a circular dependency, so got rid of this (similar to what we had to do for replay)

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 75.19 KB (+0.46% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.17 KB (+0.2% 🔺)
@sentry/browser - Webpack (gzipped) 21.85 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 69.72 KB (+0.27% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 28.18 KB (+0.1% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 20.18 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 219.95 KB (+0.41% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 84.78 KB (+0.13% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 59.86 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.04 KB (+0.09% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 75.21 KB (+15.62% 🔺)
@sentry/react - Webpack (gzipped) 21.88 KB (+0.18% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 93.03 KB (+0.41% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.7 KB (+0.19% 🔺)

@@ -16,6 +17,7 @@ const INTEGRATIONS = {
...windowIntegrations,
...CoreIntegrations,
...BrowserIntegrations,
...PluggableIntegrations,
Copy link
Contributor

@lforst lforst Aug 18, 2023

Choose a reason for hiding this comment

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

h: This will not tree-shake as soon as people import Integrations (and not even access one of the pluggable ones) because the spread operator (or in fact assigning an object) is a runtime operation. It's for the same reason we have BrowserTracing as a direct export and not under Integrations.

We need to do the same here - exporting the pluggable integrations top level.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, that makes sense of course... I wonder actually if we should then completely get rid of the Integrations key and move all of these to the top level instead? 🤔 And then maybe suffix them with Integration or something like this...:

export { Dedupe as DedupeIntegration } from '@sentry/integrations';
// etc

IMHO it would be a bit weird to have the default integrations be available under Integrations and the pluggable ones directly at the root 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

In the next major we should remove the Integrations object for sure. I agree having them in separate places is weird. I think we could export everything top level.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

2 participants