Skip to content

feat(browser): Warn on duplicate browserTracingIntegration #16042

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 3 commits into from
Apr 14, 2025

Conversation

mydea
Copy link
Member

@mydea mydea commented Apr 14, 2025

Closes #16040

this logs a warning if a user adds multiple instances of browserTracingIntegration. If this is done, this can lead to potentially weird things (e.g. we add multiple handlers etc).

This is especially relevant for react, as there are multiple different integrations there that users may add.

@mydea mydea requested review from lforst, Lms24 and s1gr1d April 14, 2025 09:36
@mydea mydea self-assigned this Apr 14, 2025
Copy link
Contributor

github-actions bot commented Apr 14, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.28 KB - -
@sentry/browser - with treeshaking flags 23.12 KB - -
@sentry/browser (incl. Tracing) 36.99 KB +0.12% +42 B 🔺
@sentry/browser (incl. Tracing, Replay) 74.17 KB +0.04% +30 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.55 KB +0.06% +41 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 78.83 KB +0.05% +34 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 90.65 KB +0.05% +45 B 🔺
@sentry/browser (incl. Feedback) 39.68 KB - -
@sentry/browser (incl. sendFeedback) 27.9 KB - -
@sentry/browser (incl. FeedbackAsync) 32.67 KB - -
@sentry/react 25.09 KB - -
@sentry/react (incl. Tracing) 38.91 KB +0.12% +44 B 🔺
@sentry/vue 27.51 KB - -
@sentry/vue (incl. Tracing) 38.71 KB +0.1% +39 B 🔺
@sentry/svelte 23.32 KB - -
CDN Bundle 24.51 KB - -
CDN Bundle (incl. Tracing) 36.98 KB +0.1% +37 B 🔺
CDN Bundle (incl. Tracing, Replay) 72.03 KB +0.05% +34 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 77.18 KB +0.03% +22 B 🔺
CDN Bundle - uncompressed 71.47 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.34 KB +0.1% +111 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 220.63 KB +0.05% +111 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.16 KB +0.05% +111 B 🔺
@sentry/nextjs (client) 40.53 KB +0.1% +38 B 🔺
@sentry/sveltekit (client) 37.44 KB +0.14% +52 B 🔺
@sentry/node 143.23 KB - -
@sentry/node - without tracing 96.47 KB - -
@sentry/aws-serverless 120.77 KB - -

View base workflow run

@mydea mydea merged commit bd7205b into develop Apr 14, 2025
119 checks passed
@mydea mydea deleted the fn/warn-multiple-integrations branch April 14, 2025 10:38

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [Sentry.browserTracingIntegration(), Sentry.browserTracingIntegration()],
Copy link

Choose a reason for hiding this comment

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

I just hit a problem where I had Sentry.reactRouterV7BrowserTracingIntegration alongside Sentry.browserTracingIntegration, and after some search I found your comment here that unblocked me (thank you!)

It would be nice if the warning would be shown when 2 conflicting tracing integrations are loaded at Sentry.init time, but I understand it might be difficult to implement.

Maybe, an alternative would be to emphasis on this exclusivity in both the code (https://github.com/getsentry/sentry-javascript/blob/develop/packages/react-router/src/client/tracingIntegration.ts) and in the official sentry docs as well (https://docs.sentry.io/platforms/javascript/guides/react/features/react-router/v7/#usage-with-useroutes-hook)?

Suggestion in the docs:

If you specify your route definitions as an object to the useRoutes hook, replace your Sentry.browserTracingIntegration to Sentry.reactRouterV7BrowserTracingIntegration inside Sentry.init

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.

Warn for duplicate browserTracingIntegrations
3 participants