1- /* eslint-disable max-lines, complexity */
1+ /* eslint-disable max-lines */
22import type { Hub , IdleTransaction } from '@sentry/core' ;
33import {
44 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
@@ -9,14 +9,7 @@ import {
99 spanToJSON ,
1010 startIdleTransaction ,
1111} from '@sentry/core' ;
12- import type {
13- EventProcessor ,
14- Integration ,
15- StartSpanOptions ,
16- Transaction ,
17- TransactionContext ,
18- TransactionSource ,
19- } from '@sentry/types' ;
12+ import type { EventProcessor , Integration , Transaction , TransactionContext , TransactionSource } from '@sentry/types' ;
2013import { getDomElement , logger , tracingContextFromHeaders } from '@sentry/utils' ;
2114
2215import { DEBUG_BUILD } from '../common/debug-build' ;
@@ -66,49 +59,28 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
6659 */
6760 heartbeatInterval : number ;
6861
69- /**
70- * If a span should be created on location (history) changes.
71- * Default: true
72- */
73- spanOnLocationChange : boolean ;
74-
75- /**
76- * If a span should be created on pageload.
77- * Default: true
78- */
79- spanOnPageLoad : boolean ;
80-
81- /**
82- * Flag spans where tabs moved to background with "cancelled". Browser background tab timing is
83- * not suited towards doing precise measurements of operations. By default, we recommend that this option
84- * be enabled as background transactions can mess up your statistics in nondeterministic ways.
85- *
86- * Default: true
87- */
88- markBackgroundSpan : boolean ;
89-
9062 /**
9163 * Flag to enable/disable creation of `navigation` transaction on history changes.
64+ *
9265 * Default: true
93- * @deprecated Configure `spanOnLocationChange` instead.
9466 */
95- startTransactionOnLocationChange ? : boolean ;
67+ startTransactionOnLocationChange : boolean ;
9668
9769 /**
9870 * Flag to enable/disable creation of `pageload` transaction on first pageload.
71+ *
9972 * Default: true
100- * @deprecated Configure `spanOnPageLoad` instead.
10173 */
102- startTransactionOnPageLoad ? : boolean ;
74+ startTransactionOnPageLoad : boolean ;
10375
10476 /**
10577 * Flag Transactions where tabs moved to background with "cancelled". Browser background tab timing is
10678 * not suited towards doing precise measurements of operations. By default, we recommend that this option
10779 * be enabled as background transactions can mess up your statistics in nondeterministic ways.
80+ *
10881 * Default: true
109- * @deprecated Configure `markBackgroundSpan` instead.
11082 */
111- markBackgroundTransactions ? : boolean ;
83+ markBackgroundTransactions : boolean ;
11284
11385 /**
11486 * If true, Sentry will capture long tasks and add them to the corresponding transaction.
@@ -145,12 +117,6 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
145117 onStartRouteTransaction : ( t : Transaction | undefined , ctx : TransactionContext , getCurrentHub : ( ) => Hub ) => void ;
146118 } > ;
147119
148- /**
149- * A callback which is called before a span for a pageload or navigation is started.
150- * It receives the options passed to `startSpan`, and expects to return an updated options object.
151- */
152- beforeStartSpan ?: ( options : StartSpanOptions ) => StartSpanOptions ;
153-
154120 /**
155121 * beforeNavigate is called before a pageload/navigation transaction is created and allows users to modify transaction
156122 * context data, or drop the transaction entirely (by setting `sampled = false` in the context).
@@ -160,8 +126,6 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
160126 * @param context: The context data which will be passed to `startTransaction` by default
161127 *
162128 * @returns A (potentially) modified context object, with `sampled = false` if the transaction should be dropped.
163- *
164- * @deprecated Use `beforeStartSpan` instead.
165129 */
166130 beforeNavigate ?( this : void , context : TransactionContext ) : TransactionContext | undefined ;
167131
@@ -179,10 +143,10 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
179143
180144const DEFAULT_BROWSER_TRACING_OPTIONS : BrowserTracingOptions = {
181145 ...TRACING_DEFAULTS ,
146+ markBackgroundTransactions : true ,
182147 routingInstrumentation : instrumentRoutingWithDefaults ,
183- spanOnLocationChange : true ,
184- spanOnPageLoad : true ,
185- markBackgroundSpan : true ,
148+ startTransactionOnLocationChange : true ,
149+ startTransactionOnPageLoad : true ,
186150 enableLongTask : true ,
187151 _experiments : { } ,
188152 ...defaultRequestInstrumentationOptions ,
@@ -226,42 +190,20 @@ export class BrowserTracing implements Integration {
226190
227191 private _hasSetTracePropagationTargets : boolean ;
228192
229- public constructor ( _options : Partial < BrowserTracingOptions > = { } ) {
193+ public constructor ( _options ? : Partial < BrowserTracingOptions > ) {
230194 this . name = BROWSER_TRACING_INTEGRATION_ID ;
231195 this . _hasSetTracePropagationTargets = false ;
232196
233197 addTracingExtensions ( ) ;
234198
235199 if ( DEBUG_BUILD ) {
236200 this . _hasSetTracePropagationTargets = ! ! (
201+ _options &&
237202 // eslint-disable-next-line deprecation/deprecation
238203 ( _options . tracePropagationTargets || _options . tracingOrigins )
239204 ) ;
240205 }
241206
242- // Migrate legacy options
243- // TODO v8: Remove this
244- /* eslint-disable deprecation/deprecation */
245- if ( typeof _options . startTransactionOnPageLoad === 'boolean' ) {
246- _options . spanOnPageLoad = _options . startTransactionOnPageLoad ;
247- }
248- if ( typeof _options . startTransactionOnLocationChange === 'boolean' ) {
249- _options . spanOnLocationChange = _options . startTransactionOnLocationChange ;
250- }
251- if ( typeof _options . markBackgroundTransactions === 'boolean' ) {
252- _options . markBackgroundSpan = _options . markBackgroundTransactions ;
253- }
254- /* eslint-enable deprecation/deprecation */
255-
256- // TODO (v8): remove this block after tracingOrigins is removed
257- // Set tracePropagationTargets to tracingOrigins if specified by the user
258- // In case both are specified, tracePropagationTargets takes precedence
259- // eslint-disable-next-line deprecation/deprecation
260- if ( ! _options . tracePropagationTargets && _options . tracingOrigins ) {
261- // eslint-disable-next-line deprecation/deprecation
262- _options . tracePropagationTargets = _options . tracingOrigins ;
263- }
264-
265207 this . options = {
266208 ...DEFAULT_BROWSER_TRACING_OPTIONS ,
267209 ..._options ,
@@ -273,6 +215,15 @@ export class BrowserTracing implements Integration {
273215 this . options . enableLongTask = this . options . _experiments . enableLongTask ;
274216 }
275217
218+ // TODO (v8): remove this block after tracingOrigins is removed
219+ // Set tracePropagationTargets to tracingOrigins if specified by the user
220+ // In case both are specified, tracePropagationTargets takes precedence
221+ // eslint-disable-next-line deprecation/deprecation
222+ if ( _options && ! _options . tracePropagationTargets && _options . tracingOrigins ) {
223+ // eslint-disable-next-line deprecation/deprecation
224+ this . options . tracePropagationTargets = _options . tracingOrigins ;
225+ }
226+
276227 this . _collectWebVitals = startTrackingWebVitals ( ) ;
277228 if ( this . options . enableLongTask ) {
278229 startTrackingLongTasks ( ) ;
@@ -294,9 +245,9 @@ export class BrowserTracing implements Integration {
294245
295246 const {
296247 routingInstrumentation : instrumentRouting ,
297- spanOnPageLoad ,
298- spanOnLocationChange ,
299- markBackgroundSpan ,
248+ startTransactionOnLocationChange ,
249+ startTransactionOnPageLoad ,
250+ markBackgroundTransactions ,
300251 traceFetch,
301252 traceXHR,
302253 shouldCreateSpanForRequest,
@@ -332,11 +283,11 @@ export class BrowserTracing implements Integration {
332283
333284 return transaction ;
334285 } ,
335- spanOnPageLoad ,
336- spanOnLocationChange ,
286+ startTransactionOnPageLoad ,
287+ startTransactionOnLocationChange ,
337288 ) ;
338289
339- if ( markBackgroundSpan ) {
290+ if ( markBackgroundTransactions ) {
340291 registerBackgroundTabDetection ( ) ;
341292 }
342293
@@ -363,14 +314,7 @@ export class BrowserTracing implements Integration {
363314
364315 const hub = this . _getCurrentHub ( ) ;
365316
366- const {
367- // eslint-disable-next-line deprecation/deprecation
368- beforeNavigate,
369- beforeStartSpan,
370- idleTimeout,
371- finalTimeout,
372- heartbeatInterval,
373- } = this . options ;
317+ const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this . options ;
374318
375319 const isPageloadTransaction = context . op === 'pageload' ;
376320
@@ -392,11 +336,7 @@ export class BrowserTracing implements Integration {
392336 trimEnd : true ,
393337 } ;
394338
395- const contextAfterProcessing = beforeStartSpan ? beforeStartSpan ( expandedContext ) : expandedContext ;
396-
397- const modifiedContext =
398- // eslint-disable-next-line deprecation/deprecation
399- typeof beforeNavigate === 'function' ? beforeNavigate ( contextAfterProcessing ) : contextAfterProcessing ;
339+ const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate ( expandedContext ) : expandedContext ;
400340
401341 // For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it
402342 // from being sent to Sentry).
0 commit comments