Skip to content

Commit 0e7c492

Browse files
authored
feat(sveltekit): Always add browserTracingIntegration (#13322)
closes #13011 ref: #13318
1 parent 899c571 commit 0e7c492

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

packages/sveltekit/src/client/sdk.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { applySdkMetadata, hasTracingEnabled } from '@sentry/core';
1+
import { applySdkMetadata } from '@sentry/core';
22
import type { BrowserOptions } from '@sentry/svelte';
33
import { getDefaultIntegrations as getDefaultSvelteIntegrations } from '@sentry/svelte';
44
import { WINDOW, init as initSvelteSdk } from '@sentry/svelte';
@@ -41,15 +41,13 @@ export function init(options: BrowserOptions): Client | undefined {
4141
}
4242

4343
function getDefaultIntegrations(options: BrowserOptions): Integration[] | undefined {
44-
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside
45-
// will get treeshaken away
44+
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
45+
// in which case everything inside will get tree-shaken away
4646
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
47-
if (hasTracingEnabled(options)) {
48-
return [...getDefaultSvelteIntegrations(options), svelteKitBrowserTracingIntegration()];
49-
}
47+
return [...getDefaultSvelteIntegrations(options), svelteKitBrowserTracingIntegration()];
5048
}
5149

52-
return undefined;
50+
return getDefaultSvelteIntegrations(options);
5351
}
5452

5553
/**

packages/sveltekit/test/client/sdk.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('Sentry client SDK', () => {
4646
['tracesSampleRate', { tracesSampleRate: 0 }],
4747
['tracesSampler', { tracesSampler: () => 1.0 }],
4848
['enableTracing', { enableTracing: true }],
49+
['no tracing option set', {}],
4950
])('adds a browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => {
5051
init({
5152
dsn: 'https://[email protected]/1337',
@@ -56,19 +57,6 @@ describe('Sentry client SDK', () => {
5657
expect(browserTracing).toBeDefined();
5758
});
5859

59-
it.each([
60-
['enableTracing', { enableTracing: false }],
61-
['no tracing option set', {}],
62-
])("doesn't add a browserTracingIntegration integration if tracing is disabled via %s", (_, tracingOptions) => {
63-
init({
64-
dsn: 'https://[email protected]/1337',
65-
...tracingOptions,
66-
});
67-
68-
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
69-
expect(browserTracing).toBeUndefined();
70-
});
71-
7260
it("doesn't add a browserTracingIntegration if `__SENTRY_TRACING__` is set to false", () => {
7361
// This is the closest we can get to unit-testing the `__SENTRY_TRACING__` tree-shaking guard
7462
// IRL, the code to add the integration would most likely be removed by the bundler.

0 commit comments

Comments
 (0)