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

build(core): Do not mangle private methods used by Replay #6493

Merged
merged 2 commits into from Dec 12, 2022

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Dec 12, 2022

In Replay, we access some private methods from the core SDK package from the Client class. Because we mangle private fields by default, our SDK CDN bundles wouldn't expose these methods and fields anymore in their clear name to external callers, such as our Replay CDN bundle, producing runtime errors because the methods were not found.

This PR fixes these errors by explicitly excluding the called private methods from mangling so that they can be accessed externally. This is admittedly not a clean solution but it unblocks minified CDN bundle users. In the long run we can revert this PR once we streamlined Replay event sending into the SDK (#6480) (as well as breadcrumbs via hooks?).

Note: This unfortunately increases bundle size, not just for the Replay CDN bundle, but also for the Browser SDK CDN bundle.

fixes #6466

@mydea
Copy link
Member

mydea commented Dec 12, 2022

Very nice! I made a PR refactoring _withClient, so I think we can leave this in here - that one was relatively easy to refactor: #6494

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.7 KB (+0.08% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 61.04 KB (+0.14% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.49 KB (+0.12% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 54.59 KB (+0.16% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.27 KB (0%)
@sentry/browser - Webpack (minified) 66.25 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.29 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.29 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.68 KB (+0.07% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.13 KB (+0.08% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 41.85 KB (+0.03% 🔺)
@sentry/replay - Webpack (gzipped + minified) 37.89 KB (0%)

Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
@Lms24 Lms24 changed the title fix(replay): Do not mangle private fields used by Replay fix(replay): Do not mangle private methods used by Replay Dec 12, 2022
@Lms24 Lms24 changed the title fix(replay): Do not mangle private methods used by Replay build(core): Do not mangle private methods used by Replay Dec 12, 2022
@Lms24 Lms24 merged commit d36de87 into master Dec 12, 2022
@Lms24 Lms24 deleted the lms-replay-fix-cdn-min branch December 12, 2022 10:24
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.

[Replay] Replay not sending on errors
2 participants