Skip to content

Commit ba5dcf1

Browse files
committed
more improvements
1 parent db28484 commit ba5dcf1

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

packages/nextjs/src/client/browserTracingIntegration.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ export function browserTracingIntegration(
6161
instrumentPageLoad: false,
6262
});
6363

64+
const fullOptions = {
65+
...browserTracingIntegrationInstance.options,
66+
instrumentPageLoad: true,
67+
instrumentNavigation: true,
68+
...options,
69+
};
70+
6471
return {
6572
...browserTracingIntegrationInstance,
66-
options: {
67-
...browserTracingIntegrationInstance.options,
68-
...options,
69-
},
73+
options: fullOptions,
7074
afterAllSetup(client) {
7175
const startPageloadCallback = (startSpanOptions: StartSpanOptions): void => {
7276
startBrowserTracingPageLoadSpan(client, startSpanOptions);
@@ -84,7 +88,7 @@ export function browserTracingIntegration(
8488
nextRouterInstrumentation(
8589
() => undefined,
8690
false,
87-
options?.instrumentNavigation,
91+
fullOptions.instrumentNavigation,
8892
startPageloadCallback,
8993
startNavigationCallback,
9094
);
@@ -94,7 +98,7 @@ export function browserTracingIntegration(
9498
// eslint-disable-next-line deprecation/deprecation
9599
nextRouterInstrumentation(
96100
() => undefined,
97-
options?.instrumentPageLoad,
101+
fullOptions.instrumentPageLoad,
98102
false,
99103
startPageloadCallback,
100104
startNavigationCallback,

packages/nextjs/test/clientSdk.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { BaseClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, spanToJSON } from '@sentry/core';
1+
import {
2+
BaseClient,
3+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
4+
getActiveSpan,
5+
getIsolationScope,
6+
spanToJSON,
7+
} from '@sentry/core';
28
import * as SentryReact from '@sentry/react';
39
import type { BrowserClient } from '@sentry/react';
410
import { browserTracingIntegration } from '@sentry/react';
@@ -35,6 +41,11 @@ function findIntegrationByName(integrations: Integration[] = [], name: string):
3541
const TEST_DSN = 'https://[email protected]/1337';
3642

3743
describe('Client init()', () => {
44+
beforeEach(() => {
45+
getCurrentScope().clear();
46+
getIsolationScope().clear();
47+
});
48+
3849
afterEach(() => {
3950
jest.clearAllMocks();
4051
WINDOW.__SENTRY__.hub = undefined;

packages/sveltekit/src/client/browserTracingIntegration.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,24 @@ export function browserTracingIntegration(
4545
}),
4646
};
4747

48+
const fullOptions = {
49+
...integration.options,
50+
instrumentPageLoad: true,
51+
instrumentNavigation: true,
52+
...options,
53+
};
54+
4855
return {
4956
...integration,
50-
options: {
51-
...integration.options,
52-
...options,
53-
},
57+
options: fullOptions,
5458
afterAllSetup: client => {
5559
integration.afterAllSetup(client);
5660

57-
if (options.instrumentPageLoad !== false) {
61+
if (fullOptions.instrumentPageLoad) {
5862
_instrumentPageload(client);
5963
}
6064

61-
if (options.instrumentNavigation !== false) {
65+
if (fullOptions.instrumentNavigation) {
6266
_instrumentNavigations(client);
6367
}
6468
},

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, getClient, getCurrentScope, spanToJSON } from '@sentry/core';
1+
import {
2+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3+
getActiveSpan,
4+
getClient,
5+
getCurrentScope,
6+
getIsolationScope,
7+
spanToJSON,
8+
} from '@sentry/core';
29
import type { BrowserClient } from '@sentry/svelte';
310
import * as SentrySvelte from '@sentry/svelte';
411
import { SDK_VERSION, WINDOW, browserTracingIntegration } from '@sentry/svelte';
@@ -16,6 +23,11 @@ describe('Sentry client SDK', () => {
1623
WINDOW.__SENTRY__.hub = undefined;
1724
});
1825

26+
beforeEach(() => {
27+
getCurrentScope().clear();
28+
getIsolationScope().clear();
29+
});
30+
1931
it('adds SvelteKit metadata to the SDK options', () => {
2032
expect(svelteInit).not.toHaveBeenCalled();
2133

0 commit comments

Comments
 (0)