1- /* eslint-disable max-lines, complexity  */ 
1+ /* eslint-disable max-lines */ 
22import  type  {  IdleTransaction  }  from  '@sentry/core' ; 
3+ import  {  getActiveSpan  }  from  '@sentry/core' ; 
34import  {  getCurrentHub  }  from  '@sentry/core' ; 
45import  { 
56  SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 
@@ -237,7 +238,6 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
237238    latestRouteName  =  finalContext . name ; 
238239    latestRouteSource  =  getSource ( finalContext ) ; 
239240
240-     // eslint-disable-next-line deprecation/deprecation 
241241    if  ( finalContext . sampled  ===  false )  { 
242242      DEBUG_BUILD  &&  logger . log ( `[Tracing] Will not send ${ finalContext . op }  ) ; 
243243    } 
@@ -315,7 +315,10 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
315315          // If there's an open transaction on the scope, we need to finish it before creating an new one. 
316316          activeSpan . end ( ) ; 
317317        } 
318-         activeSpan  =  _createRouteTransaction ( context ) ; 
318+         activeSpan  =  _createRouteTransaction ( { 
319+           op : 'navigation' , 
320+           ...context , 
321+         } ) ; 
319322      } ) ; 
320323
321324      client . on ( 'startPageLoadSpan' ,  ( context : StartSpanOptions )  =>  { 
@@ -324,15 +327,17 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
324327          // If there's an open transaction on the scope, we need to finish it before creating an new one. 
325328          activeSpan . end ( ) ; 
326329        } 
327-         activeSpan  =  _createRouteTransaction ( context ) ; 
330+         activeSpan  =  _createRouteTransaction ( { 
331+           op : 'pageload' , 
332+           ...context , 
333+         } ) ; 
328334      } ) ; 
329335
330336      if  ( options . instrumentPageLoad )  { 
331337        const  context : StartSpanOptions  =  { 
332338          name : WINDOW . location . pathname , 
333339          // pageload should always start at timeOrigin (and needs to be in s, not ms) 
334340          startTimestamp : browserPerformanceTimeOrigin  ? browserPerformanceTimeOrigin  /  1000  : undefined , 
335-           op : 'pageload' , 
336341          origin : 'auto.pageload.browser' , 
337342          attributes : { 
338343            [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'url' , 
@@ -361,7 +366,6 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
361366            startingUrl  =  undefined ; 
362367            const  context : StartSpanOptions  =  { 
363368              name : WINDOW . location . pathname , 
364-               op : 'navigation' , 
365369              origin : 'auto.navigation.browser' , 
366370              attributes : { 
367371                [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'url' , 
@@ -399,16 +403,24 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
399403 * Manually start a page load span. 
400404 * This will only do something if the BrowserTracing integration has been setup. 
401405 */ 
402- export  function  startBrowserTracingPageLoadSpan ( client : Client ,  spanOptions : StartSpanOptions ) : void { 
406+ export  function  startBrowserTracingPageLoadSpan ( client : Client ,  spanOptions : StartSpanOptions ) : Span   |   undefined  { 
403407  client . emit ( 'startPageLoadSpan' ,  spanOptions ) ; 
408+ 
409+   const  span  =  getActiveSpan ( ) ; 
410+   const  op  =  span  &&  spanToJSON ( span ) . op ; 
411+   return  op  ===  'pageload'  ? span  : undefined ; 
404412} 
405413
406414/** 
407415 * Manually start a navigation span. 
408416 * This will only do something if the BrowserTracing integration has been setup. 
409417 */ 
410- export  function  startBrowserTracingNavigationSpan ( client : Client ,  spanOptions : StartSpanOptions ) : void { 
418+ export  function  startBrowserTracingNavigationSpan ( client : Client ,  spanOptions : StartSpanOptions ) : Span   |   undefined  { 
411419  client . emit ( 'startNavigationSpan' ,  spanOptions ) ; 
420+ 
421+   const  span  =  getActiveSpan ( ) ; 
422+   const  op  =  span  &&  spanToJSON ( span ) . op ; 
423+   return  op  ===  'navigation'  ? span  : undefined ; 
412424} 
413425
414426/** Returns the value of a meta tag */ 
0 commit comments