Skip to content

Commit 962dbc1

Browse files
Lms24claude
andcommitted
ref(core): Tree-shake spanStreamingIntegration when tracing is disabled
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 9f59f8c commit 962dbc1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/browser/src/sdk.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { makeFetchTransport } from './transports/fetch';
2525
import { normalizeStringifyValue } from './normalizeStringifyValue';
2626
import { checkAndWarnIfIsEmbeddedBrowserExtension } from './utils/detectBrowserExtension';
2727

28+
declare const __SENTRY_TRACING__: boolean;
29+
2830
/** Get the default integrations for the browser SDK. */
2931
export function getDefaultIntegrations(_options: Options): Integration[] {
3032
/**
@@ -116,7 +118,11 @@ export function init(options: BrowserOptions = {}): Client | undefined {
116118
defaultIntegrations,
117119
});
118120

119-
if (options.traceLifecycle !== 'static' && !integrations.some(integration => integration.name === 'SpanStreaming')) {
121+
if (
122+
(typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) &&
123+
options.traceLifecycle !== 'static' &&
124+
!integrations.some(integration => integration.name === 'SpanStreaming')
125+
) {
120126
integrations.push(spanStreamingIntegration());
121127
}
122128

packages/core/src/server-runtime-client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export interface ServerRuntimeClientOptions extends ClientOptions<BaseTransportO
2525
serverName?: string;
2626
}
2727

28+
declare const __SENTRY_TRACING__: boolean;
29+
2830
/**
2931
* The Sentry Server Runtime Client SDK.
3032
*/
@@ -43,7 +45,11 @@ export class ServerRuntimeClient<
4345
// When span streaming is enabled (`traceLifecycle: 'stream'`), the `spanStreamingIntegration`
4446
// is required to flush spans. We add it here so the individual server SDKs don't have to.
4547
// A user-provided `spanStreamingIntegration` always takes precedence over the one we add.
46-
if (options.traceLifecycle !== 'static' && !options.integrations.some(i => i.name === 'SpanStreaming')) {
48+
if (
49+
(typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) &&
50+
options.traceLifecycle !== 'static' &&
51+
!options.integrations.some(i => i.name === 'SpanStreaming')
52+
) {
4753
options.integrations.push(spanStreamingIntegration());
4854
}
4955

0 commit comments

Comments
 (0)