Skip to content

Commit fdb20a0

Browse files
authored
feat(astro): Always add BrowserTracing (#13244)
The bundler-plugins still refer to the option as `excludePerformanceMonitoring` ([here](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/packages/bundler-plugin-core/src/types.ts#L260)), but this is going to be renamed to `excludeTracing`, so I already used the new naming as discussed with @Lms24 and @mydea. closes #13013
1 parent 7fc479f commit fdb20a0

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

packages/astro/src/client/sdk.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getDefaultIntegrations as getBrowserDefaultIntegrations,
55
init as initBrowserSdk,
66
} from '@sentry/browser';
7-
import { applySdkMetadata, hasTracingEnabled } from '@sentry/core';
7+
import { applySdkMetadata } from '@sentry/core';
88
import type { Client, Integration } from '@sentry/types';
99

1010
// Tree-shakable guard to remove all code related to tracing
@@ -26,14 +26,12 @@ export function init(options: BrowserOptions): Client | undefined {
2626
return initBrowserSdk(opts);
2727
}
2828

29-
function getDefaultIntegrations(options: BrowserOptions): Integration[] | undefined {
29+
function getDefaultIntegrations(options: BrowserOptions): Integration[] {
3030
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
31-
// in which case everything inside will get treeshaken away
31+
// in which case everything inside will get tree-shaken away
3232
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
33-
if (hasTracingEnabled(options)) {
34-
return [...getBrowserDefaultIntegrations(options), browserTracingIntegration()];
35-
}
33+
return [...getBrowserDefaultIntegrations(options), browserTracingIntegration()];
34+
} else {
35+
return getBrowserDefaultIntegrations(options);
3636
}
37-
38-
return undefined;
3937
}

packages/astro/test/client/sdk.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('Sentry client SDK', () => {
5353
['tracesSampleRate', { tracesSampleRate: 0 }],
5454
['tracesSampler', { tracesSampler: () => 1.0 }],
5555
['enableTracing', { enableTracing: true }],
56+
['no tracing option set', {}],
5657
])('adds browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => {
5758
init({
5859
dsn: 'https://public@dsn.ingest.sentry.io/1337',
@@ -66,22 +67,6 @@ describe('Sentry client SDK', () => {
6667
expect(browserTracing).toBeDefined();
6768
});
6869

69-
it.each([
70-
['enableTracing', { enableTracing: false }],
71-
['no tracing option set', {}],
72-
])("doesn't add browserTracingIntegration if tracing is disabled via %s", (_, tracingOptions) => {
73-
init({
74-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
75-
...tracingOptions,
76-
});
77-
78-
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations || [];
79-
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
80-
81-
expect(integrationsToInit).not.toContainEqual(expect.objectContaining({ name: 'BrowserTracing' }));
82-
expect(browserTracing).toBeUndefined();
83-
});
84-
8570
it("doesn't add browserTracingIntegration if `__SENTRY_TRACING__` is set to false", () => {
8671
(globalThis as any).__SENTRY_TRACING__ = false;
8772

0 commit comments

Comments
 (0)