From 8582fbc144568dbab1f385a45c85ed5dc874cf78 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 29 Jan 2024 14:24:30 +0100 Subject: [PATCH] ref(tracing): Implement changes to new `browserTracingIntegration` This implements changes to the new integration, based on feedback from the team. --- packages/browser/src/index.ts | 2 - .../src/browser/browserTracingIntegration.ts | 58 ++++--------------- .../tracing-internal/src/browser/index.ts | 2 - packages/tracing-internal/src/index.ts | 2 - 4 files changed, 11 insertions(+), 53 deletions(-) diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index 658dff61716b..408a64081a02 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -60,8 +60,6 @@ export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, - disableDefaultBrowserTracingNavigationSpan, - disableDefaultBrowserTracingPageLoadSpan, } from '@sentry-internal/tracing'; export type { RequestInstrumentationOptions } from '@sentry-internal/tracing'; export { diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index 8184ad058039..3f7979895db9 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -75,12 +75,14 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions { /** * If a span should be created on page load. + * If this is set to `false`, this integration will not start the default page load span. * Default: true */ instrumentPageLoad: boolean; /** * If a span should be created on navigation (history change). + * If this is set to `false`, this integration will not start the default navigation spans. * Default: true */ instrumentNavigation: boolean; @@ -144,9 +146,6 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = { ...defaultRequestInstrumentationOptions, }; -let shouldUseDefaultPageLoadSpan = true; -let shouldUseDefaultNavigationSpan = true; - /** * The Browser Tracing integration automatically instruments browser pageload/navigation * actions as transactions, and captures requests, metrics and errors as spans. @@ -323,13 +322,6 @@ export const _browserTracingIntegration = ((_options: Partial { - // We check this inside of the hook handler, so that if a custom instrumentation triggers this, - // we don't need to check this option in the instrumentation, but can simply invoke it - // without needing to know the options of this integration - if (!options.instrumentNavigation) { - return; - } - if (activeSpan) { DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`); // If there's an open transaction on the scope, we need to finish it before creating an new one. @@ -339,13 +331,6 @@ export const _browserTracingIntegration = ((_options: Partial { - // We check this inside of the hook handler, so that if a custom instrumentation triggers this, - // we don't need to check this option in the instrumentation, but can simply invoke it - // without needing to know the options of this integration - if (!options.instrumentPageLoad) { - return; - } - if (activeSpan) { DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`); // If there's an open transaction on the scope, we need to finish it before creating an new one. @@ -355,7 +340,7 @@ export const _browserTracingIntegration = ((_options: Partial