Skip to content

ref(core): Make spanStreamingIntegration tree-shakeable via __SENTRY_TRACING__ flag - #22835

Merged
Lms24 merged 3 commits into
developfrom
feat/span-streaming-tree-shaking
Aug 6, 2026
Merged

ref(core): Make spanStreamingIntegration tree-shakeable via __SENTRY_TRACING__ flag #22835
Lms24 merged 3 commits into
developfrom
feat/span-streaming-tree-shaking

Conversation

@Lms24

@Lms24 Lms24 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Guards the automatic spanStreamingIntegration push behind __SENTRY_TRACING__ so that bundlers configured to tree-shake tracing can actually drop the integration. This should remove ~2KB of gzipped dead code for anyone who doesn't care about tracing.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.86 kB +0.08% +21 B 🔺
@sentry/browser - with treeshaking flags 28.05 kB +0.08% +22 B 🔺
@sentry/browser (incl. Tracing) 47.27 kB +0.06% +24 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 47.3 kB +0.06% +27 B 🔺
@sentry/browser (incl. Tracing, Profiling) 52.03 kB +0.06% +29 B 🔺
@sentry/browser (incl. Tracing, Replay) 86.61 kB +0.02% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.04 kB +0.04% +30 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 91.31 kB +0.04% +31 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 103.99 kB +0.04% +37 B 🔺
@sentry/browser (incl. Feedback) 47.17 kB +0.08% +36 B 🔺
@sentry/browser (incl. sendFeedback) 34.69 kB +0.07% +22 B 🔺
@sentry/browser (incl. FeedbackAsync) 39.8 kB +0.06% +23 B 🔺
@sentry/browser (incl. Metrics) 30.93 kB +0.07% +21 B 🔺
@sentry/browser (incl. Logs) 31.17 kB +0.08% +22 B 🔺
@sentry/browser (incl. Metrics & Logs) 31.84 kB +0.07% +21 B 🔺
@sentry/react 31.65 kB +0.07% +22 B 🔺
@sentry/react (incl. Tracing) 49.53 kB +0.05% +21 B 🔺
@sentry/vue 34.95 kB +0.07% +23 B 🔺
@sentry/vue (incl. Tracing) 49.27 kB +0.07% +33 B 🔺
@sentry/svelte 29.88 kB +0.08% +23 B 🔺
CDN Bundle 31.89 kB +0.08% +23 B 🔺
CDN Bundle (incl. Tracing) 47.56 kB +0.05% +23 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.43 kB +0.06% +19 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 48.97 kB +0.06% +25 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 72.77 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay) 85.21 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.52 kB +0.03% +24 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.03 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.33 kB +0.03% +21 B 🔺
CDN Bundle - uncompressed 94.68 kB +0.07% +61 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 142.18 kB +0.05% +61 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.3 kB +0.07% +61 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.16 kB +0.05% +61 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224 kB +0.03% +61 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 261.44 kB +0.03% +61 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 265.4 kB +0.03% +61 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.14 kB +0.03% +61 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.1 kB +0.03% +61 B 🔺
@sentry/nextjs (client) 52.1 kB +0.05% +21 B 🔺
@sentry/sveltekit (client) 47.73 kB +0.05% +23 B 🔺
@sentry/core/server 65.55 kB +0.04% +23 B 🔺
@sentry/core/browser 51.88 kB - -
@sentry/node 120.26 kB +0.03% +25 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.94 kB -0.91% -754 B 🔽
@sentry/aws-serverless 92.37 kB +0.03% +19 B 🔺
@sentry/cloudflare (withSentry) - minified 218.7 kB +0.03% +53 B 🔺
@sentry/cloudflare (withSentry) 538.92 kB +0.02% +69 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.37 kB added added

View base workflow run

@Lms24 Lms24 changed the title ref(core): Tree-shake spanStreamingIntegration when tracing is disabled ref(core): Make spanStreamingIntegration tree-shakeable via __SENTRY_TRACING__ flag Jul 29, 2026
@Lms24 Lms24 changed the title ref(core): Make spanStreamingIntegration tree-shakeable via __SENTRY_TRACING__ flag ref(core): Make spanStreamingIntegration tree-shakeable via __SENTRY_TRACING__ flag Jul 29, 2026
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch from 962dbc1 to 7de446c Compare July 29, 2026 15:37
@Lms24
Lms24 force-pushed the feat/before-send-span-streamed-default branch 2 times, most recently from 0ec024e to 4910062 Compare August 3, 2026 12:48
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch from 7de446c to 74a1167 Compare August 3, 2026 12:58
@Lms24
Lms24 force-pushed the feat/before-send-span-streamed-default branch from c3ecf63 to 0749d71 Compare August 3, 2026 14:31
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch from 74a1167 to ee4761d Compare August 3, 2026 14:31
@Lms24
Lms24 force-pushed the feat/before-send-span-streamed-default branch from 9ef7183 to f6cfc05 Compare August 4, 2026 09:23
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch from ee4761d to b568562 Compare August 4, 2026 09:23
@Lms24
Lms24 force-pushed the feat/before-send-span-streamed-default branch from 9dcfb44 to 6fb09a1 Compare August 4, 2026 13:33
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch 2 times, most recently from a43fe54 to a3e7446 Compare August 4, 2026 13:47
@Lms24
Lms24 force-pushed the feat/before-send-span-streamed-default branch from 9810912 to 4d63933 Compare August 4, 2026 13:47
Base automatically changed from feat/before-send-span-streamed-default to develop August 4, 2026 15:34
…bled

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the feat/span-streaming-tree-shaking branch from a3e7446 to f137ca9 Compare August 4, 2026 16:18

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5f02cef. Configure here.

Comment thread .size-limit.js Outdated
Comment thread .size-limit.js Outdated
@Lms24
Lms24 marked this pull request as ready for review August 4, 2026 17:44
@Lms24
Lms24 requested a review from a team as a code owner August 4, 2026 17:44
@Lms24
Lms24 requested review from logaretm and msonnb and removed request for a team August 4, 2026 17:44

@logaretm logaretm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Browser CDN bundle size didn't go down, is something off there?

@Lms24

Lms24 commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

the browser CDN bundle never set the flag because even for errors-only, users can still use Sentry.startSpan. errors-only, only doesn't include the tracing integrations.

This is purely used for shaking out tracing integrations if users don't want any tracing, hence the warning in docs.

SENTRY_TRACING must not be replaced with false when you're using any tracing-related SDK features (for example, Sentry.startSpan()).

I realized this flag isn't used a lot and either could/should be used more, or we should repurpose it. Problem is that every guard increases bundle size for default users 🙃

@Lms24
Lms24 merged commit 64bf6e2 into develop Aug 6, 2026
769 of 772 checks passed
@Lms24
Lms24 deleted the feat/span-streaming-tree-shaking branch August 6, 2026 13:31
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.

2 participants