Skip to content

fix(loader): Ensure we add integrations#47082

Merged
mydea merged 2 commits intomasterfrom
fn/loader-integrations-concat
Apr 11, 2023
Merged

fix(loader): Ensure we add integrations#47082
mydea merged 2 commits intomasterfrom
fn/loader-integrations-concat

Conversation

@mydea
Copy link
Copy Markdown
Member

@mydea mydea commented Apr 7, 2023

I noticed one gap in our new loader implementation, namely that if you configure any integrations yourself, the defaults will not be added anymore.

This PR fixes this by ensuring we add them only if they haven't been added by the user.

Tests for this upcoming in sentry-javascript.

@mydea mydea self-assigned this Apr 7, 2023
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Apr 7, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2023

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

integrations can be an function 😢 - we'll have to account for that use case as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmmm, good point! I would tend to ignore this case for now (=do not register default integrations if this is a function). WDYT? I think everything else would be a bit tricky, probably...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yup i think its fine to ignore! it is pretty advanced config, so we can add a note in the docs about it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍 updated this, also updating the script in sentry-javascript PR and adding a test for this here: getsentry/sentry-javascript@386cd2b

Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

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

code looks good to me

}

// We want to ensure to only add default integrations if they haven't been added by the user.
function setupDefaultIntegrations(config: any, SDK: any) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not a blocker but isn't there a better type that we could use here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IMHO We'd need to port all the types from JS-SDK into here to make this meaningful. It may be worthwhile to generally add more types here, but we'd need to start at the top there - I'd keep this for a follow up PR :)


// We want to ensure to only add default integrations if they haven't been added by the user.
function setupDefaultIntegrations(config: any, SDK: any) {
const integrations: {name: string}[] = config.integrations || [];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const integrations: {name: string}[] = config.integrations || [];
const integrations: {name: string}[] = config.integrations ?? [];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This transpiles into a slightly more verbose form, which we generally try to avoid for ES5 code, as it adds a few - in this case unnecessary - bytes. In this case, I think || is fine. (Working on the JS SDK burns this into your brain xD)

@mydea mydea merged commit 8074a05 into master Apr 11, 2023
@mydea mydea deleted the fn/loader-integrations-concat branch April 11, 2023 07:46
snigdhas pushed a commit that referenced this pull request Apr 11, 2023
I noticed one gap in our new loader implementation, namely that if you
configure any integrations yourself, the defaults will not be added
anymore.

This PR fixes this by ensuring we add them only if they haven't been
added by the user.
schew2381 pushed a commit that referenced this pull request Apr 12, 2023
I noticed one gap in our new loader implementation, namely that if you
configure any integrations yourself, the defaults will not be added
anymore.

This PR fixes this by ensuring we add them only if they haven't been
added by the user.
schew2381 pushed a commit that referenced this pull request Apr 12, 2023
I noticed one gap in our new loader implementation, namely that if you
configure any integrations yourself, the defaults will not be added
anymore.

This PR fixes this by ensuring we add them only if they haven't been
added by the user.
owensk pushed a commit that referenced this pull request Apr 17, 2023
I noticed one gap in our new loader implementation, namely that if you
configure any integrations yourself, the defaults will not be added
anymore.

This PR fixes this by ensuring we add them only if they haven't been
added by the user.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants