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): Add optional setup hook to integrations #9556

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Nov 14, 2023

This can be used to replace some of our setupOnce hooks, and does not rely on global state.

I think with this, we are mostly done with the minimal integration API changes for v8. After this, we can:

  1. update setupOnce to not get any arguments (you can just import and use getCurrentHub or whatever if you need it) - this we'll probably do only in v8 itself
  2. Add a new functional form for the integrations. We can support both in v7 and then drop the class form in v8. So integrations would look like this:
export class Console implements Integration {
  public static id = 'Console';
  public name Console.id;
  public constructor(options) {}
  public setupOnce() {}
}

becomes

export const consoleIntegration: IntegrationFn = (options) => {
  return {
    setupOnce() {}
  }
}

And usage becomes:

Sentry.init({
  integrations: [
    // old
    new Sentry.Integrations.Console(options),
    // new
    Sentry.consoleIntegration(options)
   ]
})

This can be used to replace some of our `setupOnce` hooks, and does not rely on global state.
@mydea mydea requested a review from AbhiPrasad November 14, 2023 13:46
@mydea mydea self-assigned this Nov 14, 2023
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 65.43 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 55.64 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 30.99 KB (+0.04% 🔺)
@sentry/browser - Webpack (gzipped) 21.31 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 61.96 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 29.11 KB (+0.04% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 21.25 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 195.46 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 88.37 KB (+0.06% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 63.34 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.82 KB (+0.04% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 65.78 KB (+0.02% 🔺)
@sentry/react - Webpack (gzipped) 21.36 KB (+0.06% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 82.5 KB (+0.02% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.14 KB (+0.03% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16 KB (0%)

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Nice good change!

@mydea mydea merged commit d780165 into develop Nov 21, 2023
87 checks passed
@mydea mydea deleted the fn/integration-setup branch November 21, 2023 13:53
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