Skip to content

Commit

Permalink
ref(tracing): Require to pass client to startBrowserTracing*Span ut…
Browse files Browse the repository at this point in the history
…ils (#10410)

So we can be client-safe when extending the integration.
  • Loading branch information
mydea committed Jan 30, 2024
1 parent 9fe67aa commit 2195ce6
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable max-lines, complexity */
import type { IdleTransaction } from '@sentry/core';
import { getClient } from '@sentry/core';
import { getCurrentHub } from '@sentry/core';
import {
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
Expand All @@ -11,6 +10,7 @@ import {
startIdleTransaction,
} from '@sentry/core';
import type {
Client,
IntegrationFn,
StartSpanOptions,
Transaction,
Expand Down Expand Up @@ -336,7 +336,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
origin: 'auto.pageload.browser',
metadata: { source: 'url' },
};
startBrowserTracingPageLoadSpan(context);
startBrowserTracingPageLoadSpan(client, context);
}

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

startBrowserTracingNavigationSpan(context);
startBrowserTracingNavigationSpan(client, context);
}
});
}
Expand Down Expand Up @@ -395,9 +395,8 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
* Manually start a page load span.
* This will only do something if the BrowserTracing integration has been setup.
*/
export function startBrowserTracingPageLoadSpan(spanOptions: StartSpanOptions): void {
const client = getClient();
if (!client || !client.emit) {
export function startBrowserTracingPageLoadSpan(client: Client, spanOptions: StartSpanOptions): void {
if (!client.emit) {
return;
}

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

Expand Down

0 comments on commit 2195ce6

Please sign in to comment.