Skip to content

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

Open
mydea wants to merge 1 commit into
developfrom
fn/move-browser-span-apis-to-browser-utils
Open

ref(browser-utils): Move browser span-start APIs out of core#23772
mydea wants to merge 1 commit into
developfrom
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.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.56 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.87 kB +0.03% +11 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.87 kB +0.02% +5 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.78 kB -0.01% -3 B 🔽
@sentry/browser (incl. Tracing, Replay) 88.34 kB -0.02% -13 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.73 kB -0.03% -16 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 93.03 kB -0.02% -13 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 106 kB -0.01% -4 B 🔽
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.62 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 51.09 kB +0.07% +31 B 🔺
@sentry/vue 35.74 kB +0.03% +8 B 🔺
@sentry/vue (incl. Tracing) 51.14 kB +0.03% +15 B 🔺
@sentry/svelte 28.59 kB - -
CDN Bundle 30.33 kB -0.05% -14 B 🔽
CDN Bundle (incl. Tracing) 49.48 kB -0.06% -25 B 🔽
CDN Bundle (incl. Logs, Metrics) 32.58 kB +0.01% +1 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 51.4 kB -0.03% -15 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB -0.01% -2 B 🔽
CDN Bundle (incl. Tracing, Replay) 87 kB +0.01% +4 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.87 kB +0.01% +5 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.94 kB +0.01% +8 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.81 kB -0.02% -15 B 🔽
CDN Bundle - uncompressed 89.95 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 147.56 kB +0.01% +6 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.25 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.25 kB +0.01% +6 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.06 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.73 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.76 kB +0.01% +6 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.42 kB +0.01% +6 B 🔺
@sentry/nextjs (client) 53.71 kB +0.05% +25 B 🔺
@sentry/sveltekit (client) 49.31 kB +0.04% +19 B 🔺
@sentry/core/server 40.72 kB -38.14% -25.1 kB 🔽
@sentry/core/browser 12.13 kB -76.65% -39.81 kB 🔽
@sentry/node 123.83 kB +0.01% +4 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.4 kB -0.26% -206 B 🔽
@sentry/node - without tracing 88.13 kB +0.02% +10 B 🔺
@sentry/node - without channel injection 103.26 kB +0.01% +2 B 🔺
@sentry/aws-serverless 96.48 kB +0.01% +7 B 🔺
@sentry/cloudflare (withSentry) - minified 201.21 kB - -
@sentry/cloudflare (withSentry) 500.7 kB +0.01% +2 B 🔺

View base workflow run

@mydea
mydea force-pushed the fn/move-browser-span-apis-to-browser-utils branch from 1d990e7 to 9b6ce01 Compare September 1, 2026 08:34
@mydea
mydea force-pushed the fn/move-browser-span-apis-to-browser-utils branch from 9b6ce01 to ae31677 Compare September 1, 2026 08:36
@mydea
mydea marked this pull request as ready for review September 1, 2026 08:57
@mydea
mydea requested review from a team as code owners September 1, 2026 08:57
@mydea
mydea requested review from logaretm, msonnb, nicohrubec and s1gr1d and removed request for a team September 1, 2026 08:57
Base automatically changed from fn/split-core-exports to develop September 1, 2026 10:07
@mydea
mydea requested review from a team as code owners September 1, 2026 10:07
@mydea
mydea requested review from JPeer264 and isaacs and removed request for a team September 1, 2026 10:07
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>
@mydea
mydea force-pushed the fn/move-browser-span-apis-to-browser-utils branch from ae31677 to 951561d Compare September 1, 2026 10:07
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