Skip to content

ref(browser-utils): Move browser span-start APIs out of core - #23772

Draft
mydea wants to merge 1 commit into
fn/split-core-exportsfrom
fn/move-browser-span-apis-to-browser-utils
Draft

ref(browser-utils): Move browser span-start APIs out of core#23772
mydea wants to merge 1 commit into
fn/split-core-exportsfrom
fn/move-browser-span-apis-to-browser-utils

Conversation

@mydea

@mydea mydea commented Aug 31, 2026

Copy link
Copy Markdown
Member

Stacked on top of #23762 — review/merge that first.

Follow-up to the core entrypoint split: the guarded browser span-start APIs do not belong in @sentry/core. They exist purely so that spanStreamingIntegration is reachable only from code that starts a span, which is a browser-SDK concern, so this moves them down into @sentry/browser-utils (which already sits below @sentry/browser and the framework SDKs).

What moves out of @sentry/core/browser:

  • startSpan / startInactiveSpan / startSpanManual — the guarded wrappers that install span streaming before delegating to the plain core APIs — now live in @sentry/browser-utils. Everything they need is already public on @sentry/core.
  • ensureBrowserSpanStreaming (previously _INTERNAL_ensureBrowserSpanStreaming) moves too, and is now package-private to @sentry/browser-utils. Its only callers are the wrappers and interactionsIntegration.

startIdleSpan stays in @sentry/core/browser, and no longer installs span streaming itself. That responsibility now sits with its callers: interactionsIntegration ensures it in setup(), and browserTracingIntegration continues to ensure it in afterAllSetup (guaranteeing the pageload segment streams with browser tracing alone).

Decisions

  • This is not a breaking change: @sentry/core/browser is introduced by ref(core)!: Split browser/server-only exports out of the default entrypoint #23762 and unreleased, and @sentry/browser still re-exports the wrappers unchanged. The framework SDKs (effect, react-router, svelte, sveltekit) were repointed to packages they already depend on (@sentry/browser / @sentry/svelte), so no new dependencies were added.
  • The wrapper module is the single place that legitimately imports the plain core span APIs in browser-facing code, so it carries a scoped no-unguarded-span-apis suppression — it is itself the guarded variant the rule steers callers toward.
  • browserTracingIntegration can no longer reach the now-private gate, so it installs span streaming inline via core’\s public hasSpanStreamingEnabled + spanStreamingIntegration. This is a small, idempotent duplication of the gate logic; the alternative was keeping ensureBrowserSpanStreaming exported, which we chose not to do.
  • The XhrBreadcrumbData / XhrBreadcrumbHint / BrowserClientReplayOptions types stay in @sentry/core: XhrBreadcrumbHint is referenced by core’\s own Client signatures (moving it would invert the dependency), and BrowserClientReplayOptions was deliberately parked in core to avoid a browser↔replay cycle.

Moves the guarded startSpan/startInactiveSpan/startSpanManual wrappers and the
ensureBrowserSpanStreaming gate from @sentry/core/browser into @sentry/browser-utils,
and decouples startIdleSpan from span streaming.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.56 kB added added
@sentry/browser - with treeshaking flags 26.92 kB added added
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB added added
@sentry/browser (incl. Tracing) 48.77 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 48.78 kB added added
@sentry/browser (incl. Tracing, Profiling) 51.68 kB added added
@sentry/browser (incl. Tracing, Replay) 88.22 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.62 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 92.93 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 105.86 kB added added
@sentry/browser (incl. Feedback) 46.05 kB added added
@sentry/browser (incl. sendFeedback) 33.62 kB added added
@sentry/browser (incl. FeedbackAsync) 38.73 kB added added
@sentry/browser (incl. Metrics) 29.51 kB added added
@sentry/browser (incl. Logs) 29.8 kB added added
@sentry/browser (incl. Metrics & Logs) 30.43 kB added added
@sentry/react 30.3 kB added added
@sentry/react (incl. Tracing) 50.99 kB added added
@sentry/vue 35.74 kB added added
@sentry/vue (incl. Tracing) 51.05 kB added added
@sentry/svelte 28.59 kB added added
CDN Bundle 30.33 kB added added
CDN Bundle (incl. Tracing) 49.36 kB added added
CDN Bundle (incl. Logs, Metrics) 32.58 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 51.26 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB added added
CDN Bundle (incl. Tracing, Replay) 86.88 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.75 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 92.82 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.66 kB added added
CDN Bundle - uncompressed 89.95 kB added added
CDN Bundle (incl. Tracing) - uncompressed 147.22 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.25 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.91 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.72 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.4 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.42 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.09 kB added added
@sentry/nextjs (client) 53.55 kB added added
@sentry/sveltekit (client) 49.23 kB added added
@sentry/core/server 40.64 kB added added
@sentry/core/browser 12.13 kB added added
@sentry/node 123.46 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.02 kB added added
@sentry/node - without tracing 87.76 kB added added
@sentry/node - without channel injection 103.13 kB added added
@sentry/aws-serverless 96.08 kB added added
@sentry/cloudflare (withSentry) - minified 200.72 kB added added
@sentry/cloudflare (withSentry) 499.25 kB added added

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