-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Refactor exposed defaultIntegrations
to getDefaultIntegrations()
#10243
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
Conversation
b3912df
to
c630aba
Compare
size-limit report 📦
|
packages/browser/src/sdk.ts
Outdated
/** Get the default integrations for the browser SDK. */ | ||
export function getDefaultIntegrations(_options: Options): Integration[] { | ||
// eslint-disable-next-line deprecation/deprecation | ||
return defaultIntegrations.slice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we slicing here to return a copy of defaultIntegrations
? I'm fine with that (I guess it doesn't matter if we do that or [...defaultIntegrations]
), but we might wanna add a comment for clarity because it looks like a no-op. I think we do it to avoid mutation of the original array, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is the same as [...defaultIntegrations]
- not sure if there is a perf difference or so there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with slice, just think we should add a comment
c630aba
to
90b4a20
Compare
…ns()` The current implementation has some problems: 1. It is weird that you can accidentally mutate the default integrations of another package 2. We sometimes have logic-based default integrations - e.g. adding an integration only if tracing is enabled, or similar. This means that either we have to add some logic in the _upstream_ SDK to ensure this is still added even if downstream SDKs overwrite default integrations, or we need to duplicate the logic in the _downstream_ SDKs. With this new method, we can instead centralize this, and downstream SDKs simply need to call upstream `getDefaultIntegrations(options)`.
90b4a20
to
e227076
Compare
We should wait for #10243 to merge this, as otherwise we'll get a deprecation/eslint error there.
The current implementation has two problems:
getDefaultIntegrations(options)
.