From 7de446cb780716d59b1e113d41059b382ace6519 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 29 Jul 2026 14:34:47 +0200 Subject: [PATCH] ref(core): Tree-shake `spanStreamingIntegration` when tracing is disabled Co-Authored-By: Claude Opus 5 (1M context) --- packages/browser/src/sdk.ts | 8 +++++++- packages/core/src/server-runtime-client.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 0309aed98248..ae17fb2d1637 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -25,6 +25,8 @@ import { makeFetchTransport } from './transports/fetch'; import { normalizeStringifyValue } from './normalizeStringifyValue'; import { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension'; +declare const __SENTRY_TRACING__: boolean; + /** Get the default integrations for the browser SDK. */ export function getDefaultIntegrations(_options: Options): Integration[] { /** @@ -116,7 +118,11 @@ export function init(options: BrowserOptions = {}): Client | undefined { defaultIntegrations, }); - if (options.traceLifecycle !== 'static' && !integrations.some(integration => integration.name === 'SpanStreaming')) { + if ( + (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) && + options.traceLifecycle !== 'static' && + !integrations.some(integration => integration.name === 'SpanStreaming') + ) { integrations.push(spanStreamingIntegration()); } diff --git a/packages/core/src/server-runtime-client.ts b/packages/core/src/server-runtime-client.ts index ae564663f6c7..ba91ece87ac9 100644 --- a/packages/core/src/server-runtime-client.ts +++ b/packages/core/src/server-runtime-client.ts @@ -25,6 +25,8 @@ export interface ServerRuntimeClientOptions extends ClientOptions i.name === 'SpanStreaming')) { + if ( + (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) && + options.traceLifecycle !== 'static' && + !options.integrations.some(i => i.name === 'SpanStreaming') + ) { options.integrations.push(spanStreamingIntegration()); }