Skip to content

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

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

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 📦

⚠️ 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 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.42 kB +0.06% +60 B 🔺
@sentry/browser (incl. Feedback) 47.59 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.72 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 213.99 kB - -
@sentry/cloudflare (withSentry) 528.77 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
Lms24 force-pushed the lms/ref-core-browser-span-apis branch from e69bc0e to c75bc8e Compare August 12, 2026 16:50
@Lms24
Lms24 marked this pull request as ready for review August 13, 2026 09:09
@Lms24
Lms24 requested review from a team as code owners August 13, 2026 09:09
@Lms24
Lms24 requested review from chargome, logaretm, msonnb and s1gr1d and removed request for a team August 13, 2026 09:09
@Lms24
Lms24 force-pushed the lms/ref-core-browser-span-apis branch from c75bc8e to dc5ae72 Compare August 13, 2026 11:46

@chargome chargome 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.

One comment otherwise LGTM

*
* See {@link startInactiveSpan} in `@sentry/core` for details.
*/
export function startInactiveSpan(options: StartSpanOptions): Span {

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.

q: Did you check that our browser SDKs all use this method and not import from core directly? e.g. svelte still does import { debug, startInactiveSpan } from '@sentry/core';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, in the next PR on the stack (#23362)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll merge the two first PR in sync to avoid any temporary issues

Lms24 and others added 2 commits August 13, 2026 18:36
`@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 dc5ae72 to 47848cf Compare August 13, 2026 16:36

@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 1 potential issue.

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 47848cf. Configure here.

spanIsTracerProviderSpan,
} from './utils';
export { startIdleSpan, TRACING_DEFAULTS } from './idleSpan';
export { TRACING_DEFAULTS } from './idleSpan';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Browser span APIs remain ambiguous exports

High Severity

@sentry/core/browser star-exports both the plain startSpan / startInactiveSpan / startSpanManual from the tracing barrel (via shared-exports) and the new browser wrappers, but never disambiguates them. startIdleSpan and spanStreamingIntegration were pulled out of the shared barrel so they do not collide; these three were not. Native ESM treats that as an ambiguous export, CJS __exportStar typically keeps the first (plain) binding, and tsc reports TS2308. The Vitest namespace check can still pass under last-wins bundling, so the browser entry may not actually ship the wrappers this PR is meant to expose.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 47848cf. Configure here.

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.

3 participants