Skip to content

ref(tracing): Remove BrowserTracing logging flag default value #4708

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

Merged
merged 2 commits into from
Mar 14, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Mar 11, 2022

In the BrowserTracing integration, we use a flag as a way to delay logging a warning message from the constructor until we can guarantee the logger has been enabled. Until now, that flag defaulted to false, which has prevented it from being treeshaken, even in non-debug bundles in which it's not otherwise touched.

This PR makes the flag optional, and removes the default value. Since undefined is falsy there are no runtime behavior changes, but the fact that it's never used, not even to be set to a default value, allows it to be fully removed by treeshaking. Here's the difference in the non-minified, non-debug ES5 tracing bundle, before and after:

image

Ref: https://getsentry.atlassian.net/browse/WEB-696

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2022

size-limit report

Path Base Size (af7081c) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.37 KB 19.37 KB -0.02% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 61.92 KB 61.92 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.04 KB 18.04 KB +0.01% 🔺
@sentry/browser - ES6 CDN Bundle (minified) 55.32 KB 55.32 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.3 KB 22.3 KB 0%
@sentry/browser - Webpack (minified) 76.58 KB 76.58 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.33 KB 22.33 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.56 KB 46.56 KB -0.01% 🔽
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.25 KB 25.25 KB -0.04% 🔽
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.65 KB 23.64 KB -0.04% 🔽

@lobsterkatie lobsterkatie force-pushed the kmclb-use-closure-for-BrowserTracing-flag branch from 844cd0f to 197acf2 Compare March 11, 2022 19:37
@lobsterkatie lobsterkatie changed the title ref(tracing): Use closure for BrowserTracing logging flag ref(tracing): Remove BrowserTracing logging flag default value Mar 11, 2022
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM!

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!

@lobsterkatie lobsterkatie merged commit 451bc82 into master Mar 14, 2022
@lobsterkatie lobsterkatie deleted the kmclb-use-closure-for-BrowserTracing-flag branch March 14, 2022 19:58
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.

3 participants