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 universal buildMetadata function #7404

Closed
wants to merge 1 commit into from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 10, 2023

While working on adding client and server init functions for the SvelteKit SDK, I noticed that we use utility functions both in Remix and NextJS to add SDK metadata to the init options. These functions are identical and we need the same functionality in SvelteKit as well. Therefore, this PR introduces a universal buildMetadata function in the core package which we can use in all three SDKs (follow-up PR for NextJS and Remix coming soon).

Why core? Because we need the SDK_VERSION constant. The alternative would be to move this function to the utils package and pass the version as a parameter. Happy to do this if reviewers prefer it. Otherwise, I think it's fine to leave it in core.

ref #7348

@Lms24 Lms24 added the Package: core Issues related to the Sentry Core SDK label Mar 10, 2023
@Lms24 Lms24 self-assigned this Mar 10, 2023
@Lms24 Lms24 requested review from a team, lforst and AbhiPrasad and removed request for a team March 10, 2023 09:36
* @param sdkName name of the SDK (e.g. 'nextjs')
* @param packageNames list of package names (e.g. ['nextjs', 'react'])
*/
export function buildMetadata(options: Options, sdkName: string, packageNames: string[]): void {
Copy link
Member

Choose a reason for hiding this comment

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

l: I would suggest either making this function pure (ie. making it return a new obj) or call it something like applyMetadata() because it mutates the passed options object.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we move forward with this (see other comments), I think I'm gonna go with applyMetadata for bundle size reasons

@AbhiPrasad
Copy link
Member

I attempted this back in Dec here #4196 - but elected not to move forward with it because it didn't give as much bundle size wins as a I thought, but maybe we just go ahead with it anyway.

@Lms24
Copy link
Member Author

Lms24 commented Mar 10, 2023

I attempted this back in Dec here #4196 - but elected not to move forward with it because it didn't give as much bundle size wins as a I thought, but maybe we just go ahead with it anyway.

My motivation wasn't bundle size but rather that it'd be duplication (triplication) of functionality. I think in terms of bundle size there shouldn't be a significant change 🤔 (although it seems there was last time in your PR 🤔 If it turns out there is still a significant increase, then let's drop it)

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.24 KB (+0.11% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 62.95 KB (+0.11% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.87 KB (+0.1% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55.87 KB (+0.12% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.62 KB (+0.11% 🔺)
@sentry/browser - Webpack (minified) 67.39 KB (+0.1% 🔺)
@sentry/react - Webpack (gzipped + minified) 20.65 KB (+0.12% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 48.54 KB (+0.17% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.51 KB (+0.23% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.76 KB (+0.21% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.17 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 37.19 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.18 KB (+0.09% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 54.35 KB (+0.04% 🔺)

@lforst
Copy link
Member

lforst commented Mar 10, 2023

Screenshot 2023-03-10 at 10 47 41

Is size bot acting up again? This PR shouldn't increase any bundle size.

@Lms24
Copy link
Member Author

Lms24 commented Mar 10, 2023

Ok, size-bot isn't happy about this. Then let's go with duplication - closing this.

@Lms24 Lms24 closed this Mar 10, 2023
@Lms24
Copy link
Member Author

Lms24 commented Mar 10, 2023

Is size bot acting up again? This PR shouldn't increase any bundle size.

No I think size-bot might actually be right. Before, we could mangle the function name but now it's exported. Also, there's an extra param that wasn't there before. Although I'm surprised myself about the drastic increase... but it correlates with #4196

@Lms24 Lms24 deleted the lms/extract-buildMetadata branch December 3, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: core Issues related to the Sentry Core SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants