Skip to content

Commit 451bc82

Browse files
authored
ref(tracing): Remove BrowserTracing logging flag default value (#4708)
In the `BrowserTracing` integration, we use a flag as a way to delay logging a warning message[1] from the constructor until we can guarantee the logger has been enabled. Until now, that flag defaulted to `false`, which has prevented it from being treeshaken, even in non-debug bundles in which it's not otherwise touched. This PR makes the flag optional, and removes the default value. Since `undefined` is falsy there are no runtime behavior changes, but the fact that it's never used, not even to be set to a default value, allows it to be fully removed by treeshaking. [1] https://github.com/getsentry/sentry-javascript/blob/af7081c9e9be240578cf608048734572ce709ac0/packages/tracing/src/browser/browsertracing.ts#L136-L144
1 parent 670d842 commit 451bc82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class BrowserTracing implements Integration {
126126

127127
private readonly _metrics: MetricsInstrumentation;
128128

129-
private readonly _emitOptionsWarning: boolean = false;
129+
private readonly _emitOptionsWarning?: boolean;
130130

131131
/** Store configured idle timeout so that it can be added as a tag to transactions */
132132
private _configuredIdleTimeout: BrowserTracingOptions['idleTimeout'] | undefined = undefined;
@@ -139,7 +139,7 @@ export class BrowserTracing implements Integration {
139139
if (_options.tracingOrigins && Array.isArray(_options.tracingOrigins) && _options.tracingOrigins.length !== 0) {
140140
tracingOrigins = _options.tracingOrigins;
141141
} else {
142-
this._emitOptionsWarning = true;
142+
isDebugBuild() && (this._emitOptionsWarning = true);
143143
}
144144
}
145145

0 commit comments

Comments
 (0)