Skip to content

Commit 2195ce6

Browse files
authored
ref(tracing): Require to pass client to startBrowserTracing*Span utils (#10410)
So we can be client-safe when extending the integration.
1 parent 9fe67aa commit 2195ce6

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/tracing-internal/src/browser/browserTracingIntegration.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable max-lines, complexity */
22
import type { IdleTransaction } from '@sentry/core';
3-
import { getClient } from '@sentry/core';
43
import { getCurrentHub } from '@sentry/core';
54
import {
65
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
@@ -11,6 +10,7 @@ import {
1110
startIdleTransaction,
1211
} from '@sentry/core';
1312
import type {
13+
Client,
1414
IntegrationFn,
1515
StartSpanOptions,
1616
Transaction,
@@ -336,7 +336,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
336336
origin: 'auto.pageload.browser',
337337
metadata: { source: 'url' },
338338
};
339-
startBrowserTracingPageLoadSpan(context);
339+
startBrowserTracingPageLoadSpan(client, context);
340340
}
341341

342342
if (options.instrumentNavigation && client.emit) {
@@ -364,7 +364,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
364364
metadata: { source: 'url' },
365365
};
366366

367-
startBrowserTracingNavigationSpan(context);
367+
startBrowserTracingNavigationSpan(client, context);
368368
}
369369
});
370370
}
@@ -395,9 +395,8 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
395395
* Manually start a page load span.
396396
* This will only do something if the BrowserTracing integration has been setup.
397397
*/
398-
export function startBrowserTracingPageLoadSpan(spanOptions: StartSpanOptions): void {
399-
const client = getClient();
400-
if (!client || !client.emit) {
398+
export function startBrowserTracingPageLoadSpan(client: Client, spanOptions: StartSpanOptions): void {
399+
if (!client.emit) {
401400
return;
402401
}
403402

@@ -408,9 +407,8 @@ export function startBrowserTracingPageLoadSpan(spanOptions: StartSpanOptions):
408407
* Manually start a navigation span.
409408
* This will only do something if the BrowserTracing integration has been setup.
410409
*/
411-
export function startBrowserTracingNavigationSpan(spanOptions: StartSpanOptions): void {
412-
const client = getClient();
413-
if (!client || !client.emit) {
410+
export function startBrowserTracingNavigationSpan(client: Client, spanOptions: StartSpanOptions): void {
411+
if (!client.emit) {
414412
return;
415413
}
416414

0 commit comments

Comments
 (0)