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

fix(utils): Avoid keeping a reference of last used event #9387

Merged
merged 6 commits into from
Oct 30, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Oct 27, 2023

As discussed some time ago, this changes the dom instrumentation to avoid keeping any reference to an event in the module scope.
Instead, we put a _sentryId non-enumerable property on the event target (if possible) and check based on this.

I also added some tests to verify the expected behavior, also for future changes here.

Fixes #9204

@mydea mydea requested a review from lforst October 27, 2023 09:43
@mydea mydea self-assigned this Oct 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 77.43 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 66.49 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 30.97 KB (+0.12% 🔺)
@sentry/browser - Webpack (gzipped) 21.29 KB (+0.17% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.67 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 28.96 KB (+0.13% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 21.13 KB (+0.18% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 216.41 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 87.85 KB (+0.1% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 62.84 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.75 KB (+0.11% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 77.82 KB (+0.06% 🔺)
@sentry/react - Webpack (gzipped) 21.34 KB (+0.22% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 94.15 KB (+0.05% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 47.86 KB (+0.08% 🔺)

@@ -131,6 +131,9 @@ export function makeTerserPlugin() {
'_meta',
// Object we inject debug IDs into with bundler plugins
'_sentryDebugIds',
// These are used by instrument.ts in utils for identifying HTML elements & events
'_sentryCaptured',
Copy link
Member Author

Choose a reason for hiding this comment

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

good thing we have good integration tests, that captured this! We also forgot this for _sentryCaptured (I guess we have no integration test covering this), so I also added this here @lforst

@mydea mydea merged commit d1515b9 into develop Oct 30, 2023
88 checks passed
@mydea mydea deleted the fn/event-avoid-reference branch October 30, 2023 11: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
2 participants