Skip to content

ref(core): Export browser-specific span start APIs - #23361

Draft
Lms24 wants to merge 2 commits into
developfrom
lms/ref-core-browser-span-apis
Draft

ref(core): Export browser-specific span start APIs#23361
Lms24 wants to merge 2 commits into
developfrom
lms/ref-core-browser-span-apis

Conversation

@Lms24

@Lms24 Lms24 commented Aug 12, 2026

Copy link
Copy Markdown
Member

This PR is a preparation for making spanStreamingIntegration tree-shakeable. End state: Browser Sentry.init /client setup no longer references spanStreamingIntegration in code. Instead, every start*Span* call checks if the integration is already set up. If not, it initializes it. This way, only usage of a span starting API will add the bundle size for spanStreamingIntegration.

Before we make the tree shaking-relevant changes to our browser instrumentation, this PR lays the groundwork:

  • adds a browser-specific variant of startSpan, startInactiveSpan, startSpanManual and startIdleSpan to the @sentry/core/browser subpath export
  • moves the browser-specific spanStreamingIntegration into @sentry/core/browser
  • adds disambiguating types exports so that TS doesn't throw a type error when startSpan et. al. are imported from @sentry/core or any meta framework packages (in user code)

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.28 kB -0.09% -25 B 🔽
@sentry/browser - with treeshaking flags 28.48 kB +0.03% +8 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.67 kB +0.27% +127 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.67 kB +0.25% +117 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.54 kB +0.22% +109 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.01 kB +0.08% +65 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.39 kB +0.09% +69 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.73 kB +0.08% +66 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.4 kB +0.06% +60 B 🔺
@sentry/browser (incl. Feedback) 47.57 kB -0.12% -54 B 🔽
@sentry/browser (incl. sendFeedback) 35.1 kB -0.06% -20 B 🔽
@sentry/browser (incl. FeedbackAsync) 40.21 kB -0.18% -70 B 🔽
@sentry/browser (incl. Metrics) 31.18 kB -0.21% -63 B 🔽
@sentry/browser (incl. Logs) 31.48 kB -0.14% -43 B 🔽
@sentry/browser (incl. Metrics & Logs) 32.12 kB -0.1% -29 B 🔽
@sentry/react 32.02 kB -0.21% -67 B 🔽
@sentry/react (incl. Tracing) 50.87 kB +0.28% +140 B 🔺
@sentry/vue 35.42 kB +0.31% +106 B 🔺
@sentry/vue (incl. Tracing) 50.61 kB +0.24% +118 B 🔺
@sentry/svelte 30.29 kB -0.12% -36 B 🔽
CDN Bundle 31.6 kB -0.03% -7 B 🔽
CDN Bundle (incl. Tracing) 49.02 kB +0.31% +147 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.79 kB -0.02% -6 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 50.91 kB +0.23% +116 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.29 kB -0.02% -12 B 🔽
CDN Bundle (incl. Tracing, Replay) 86.6 kB +0.17% +140 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.44 kB +0.17% +149 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.29 kB +0.15% +130 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.23 kB +0.14% +128 B 🔺
CDN Bundle - uncompressed 93.85 kB +0.01% +7 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 146.94 kB +0.16% +222 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.15 kB +0.01% +7 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.63 kB +0.15% +222 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB +0.01% +7 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.2 kB +0.09% +222 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.88 kB +0.09% +222 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.9 kB +0.08% +222 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.56 kB +0.08% +222 B 🔺
@sentry/nextjs (client) 53.42 kB +0.31% +162 B 🔺
@sentry/sveltekit (client) 49.09 kB +0.28% +135 B 🔺
@sentry/core/server 65.34 kB +0.01% +4 B 🔺
@sentry/core/browser 51.96 kB +0.54% +277 B 🔺
@sentry/node 117.94 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.06 kB +0.01% +1 B 🔺
@sentry/aws-serverless 91.47 kB - -
@sentry/cloudflare (withSentry) - minified 214 kB - -
@sentry/cloudflare (withSentry) 528.8 kB - -

View base workflow run

@Lms24 Lms24 changed the title ref(core): Serve span-start APIs per entry point ref(core): Export browser-specific span start APIs Aug 12, 2026
Lms24 and others added 2 commits August 12, 2026 18:50
`@sentry/core/browser` now exports `startSpan`, `startInactiveSpan`,
`startSpanManual` and `startIdleSpan` variants that install
`spanStreamingIntegration` on the client before starting the span.
`@sentry/core` and `@sentry/core/server` keep serving the plain ones.

This is what lets `@sentry/browser`'s `init()` stop referencing the
integration in a follow-up, so error-only bundles can tree-shake the
whole span streaming graph. `init()` still pushes it here, so nothing
changes behaviourally or size-wise yet.

Because both variants share their names, the root entry's star exports
of `server-exports` and `browser-exports` become ambiguous; `index.ts`
pins them to the plain variants with explicit re-exports. The same
applies to every meta-framework `index.types.ts` that star-exports both
its client and server entry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the lms/ref-core-browser-span-apis branch from e69bc0e to c75bc8e Compare August 12, 2026 16:50
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.

1 participant