feat: Refactor exposed defaultIntegrations to getDefaultIntegrations()#10243
Merged
feat: Refactor exposed defaultIntegrations to getDefaultIntegrations()#10243
defaultIntegrations to getDefaultIntegrations()#10243Conversation
b3912df to
c630aba
Compare
Contributor
size-limit report 📦
|
Lms24
approved these changes
Jan 18, 2024
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(); |
Member
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
yes, this is the same as [...defaultIntegrations] - not sure if there is a perf difference or so there!
Member
There was a problem hiding this comment.
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
mydea
added a commit
that referenced
this pull request
Jan 19, 2024
We should wait for #10243 to merge this, as otherwise we'll get a deprecation/eslint error there.
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.
The current implementation has two problems:
getDefaultIntegrations(options).