Skip to content

Commit af7fc5c

Browse files
committed
add method to disable defaults
1 parent e4fc705 commit af7fc5c

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

packages/browser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export {
6060
browserTracingIntegration,
6161
startBrowserTracingNavigationSpan,
6262
startBrowserTracingPageLoadSpan,
63+
disableDefaultBrowserTracingNavigationSpan,
64+
disableDefaultBrowserTracingPageLoadSpan,
6365
} from '@sentry-internal/tracing';
6466
export type { RequestInstrumentationOptions } from '@sentry-internal/tracing';
6567
export {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,22 @@ export function startBrowserTracingNavigationSpan(spanOptions: StartSpanOptions)
458458
shouldUseDefaultNavigationSpan = false;
459459
}
460460

461+
/**
462+
* Use this method if you want to disable the default navigation span.
463+
* This is useful if you want to add custom routing instrumentation.
464+
*/
465+
export function disableDefaultBrowserTracingNavigationSpan(disable = true): void {
466+
shouldUseDefaultNavigationSpan = !disable;
467+
}
468+
469+
/**
470+
* Use this method if you want to disable the default page load span.
471+
* This is useful if you want to add custom routing instrumentation.
472+
*/
473+
export function disableDefaultBrowserTracingPageLoadSpan(disable = true): void {
474+
shouldUseDefaultPageLoadSpan = !disable;
475+
}
476+
461477
/** Returns the value of a meta tag */
462478
export function getMetaContent(metaName: string): string | undefined {
463479
// Can't specify generic to `getDomElement` because tracing can be used

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export {
77
browserTracingIntegration,
88
startBrowserTracingNavigationSpan,
99
startBrowserTracingPageLoadSpan,
10+
disableDefaultBrowserTracingNavigationSpan,
11+
disableDefaultBrowserTracingPageLoadSpan,
1012
} from './browserTracingIntegration';
1113

1214
export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './request';

packages/tracing-internal/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export {
1717
browserTracingIntegration,
1818
startBrowserTracingNavigationSpan,
1919
startBrowserTracingPageLoadSpan,
20+
disableDefaultBrowserTracingNavigationSpan,
21+
disableDefaultBrowserTracingPageLoadSpan,
2022
BROWSER_TRACING_INTEGRATION_ID,
2123
instrumentOutgoingRequests,
2224
defaultRequestInstrumentationOptions,

0 commit comments

Comments
 (0)