@@ -176,12 +176,7 @@ export function updateNavigationSpan(
176176 // Check if this span has already been named to avoid multiple updates
177177 // But allow updates if this is a forced update (e.g., when lazy routes are loaded)
178178 const hasBeenNamed =
179- ! forceUpdate &&
180- (
181- activeRootSpan as {
182- __sentry_navigation_name_set__ ?: boolean ;
183- }
184- ) ?. __sentry_navigation_name_set__ ;
179+ ! forceUpdate && ( activeRootSpan as { __sentry_navigation_name_set__ ?: boolean } ) ?. __sentry_navigation_name_set__ ;
185180
186181 if ( ! hasBeenNamed ) {
187182 // Get fresh branches for the current location with all loaded routes
@@ -199,14 +194,14 @@ export function updateNavigationSpan(
199194 if ( name && ! spanJson . timestamp ) {
200195 activeRootSpan . updateName ( name ) ;
201196 activeRootSpan . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , source ) ;
202-
203- // Mark this span as having its name set to prevent future updates
204- addNonEnumerableProperty (
205- activeRootSpan as { __sentry_navigation_name_set__ ?: boolean } ,
206- '__sentry_navigation_name_set__' ,
207- true ,
208- ) ;
209197 }
198+
199+ // Mark this span as having its name set to prevent future updates
200+ addNonEnumerableProperty (
201+ activeRootSpan as { __sentry_navigation_name_set__ ?: boolean } ,
202+ '__sentry_navigation_name_set__' ,
203+ true ,
204+ ) ;
210205 }
211206}
212207
@@ -355,13 +350,7 @@ export function createV6CompatibleWrapCreateMemoryRouter<
355350 : router . state . location ;
356351
357352 if ( router . state . historyAction === 'POP' && activeRootSpan ) {
358- updatePageloadTransaction ( {
359- activeRootSpan,
360- location,
361- routes,
362- basename,
363- allRoutes : Array . from ( allRoutes ) ,
364- } ) ;
353+ updatePageloadTransaction ( { activeRootSpan, location, routes, basename, allRoutes : Array . from ( allRoutes ) } ) ;
365354 }
366355
367356 router . subscribe ( ( state : RouterState ) => {
@@ -389,11 +378,7 @@ export function createReactRouterV6CompatibleTracingIntegration(
389378 options : Parameters < typeof browserTracingIntegration > [ 0 ] & ReactRouterOptions ,
390379 version : V6CompatibleVersion ,
391380) : Integration {
392- const integration = browserTracingIntegration ( {
393- ...options ,
394- instrumentPageLoad : false ,
395- instrumentNavigation : false ,
396- } ) ;
381+ const integration = browserTracingIntegration ( { ...options , instrumentPageLoad : false , instrumentNavigation : false } ) ;
397382
398383 const {
399384 useEffect,
@@ -532,13 +517,7 @@ function wrapPatchRoutesOnNavigation(
532517 if ( activeRootSpan && ( spanToJSON ( activeRootSpan ) as { op ?: string } ) . op === 'navigation' ) {
533518 updateNavigationSpan (
534519 activeRootSpan ,
535- {
536- pathname : targetPath ,
537- search : '' ,
538- hash : '' ,
539- state : null ,
540- key : 'default' ,
541- } ,
520+ { pathname : targetPath , search : '' , hash : '' , state : null , key : 'default' } ,
542521 Array . from ( allRoutes ) ,
543522 true , // forceUpdate = true since we're loading lazy routes
544523 _matchRoutes ,
@@ -559,13 +538,7 @@ function wrapPatchRoutesOnNavigation(
559538 if ( pathname ) {
560539 updateNavigationSpan (
561540 activeRootSpan ,
562- {
563- pathname,
564- search : '' ,
565- hash : '' ,
566- state : null ,
567- key : 'default' ,
568- } ,
541+ { pathname, search : '' , hash : '' , state : null , key : 'default' } ,
569542 Array . from ( allRoutes ) ,
570543 false , // forceUpdate = false since this is after lazy routes are loaded
571544 _matchRoutes ,
@@ -612,9 +585,7 @@ export function handleNavigation(opts: {
612585 const isAlreadyInNavigationSpan = spanJson ?. op === 'navigation' ;
613586
614587 // Cross usage can result in multiple navigation spans being created without this check
615- if ( isAlreadyInNavigationSpan && activeSpan && spanJson ) {
616- handleExistingNavigationSpan ( activeSpan , spanJson , name , source , isLazyRouteContext ) ;
617- } else {
588+ if ( ! isAlreadyInNavigationSpan ) {
618589 createNewNavigationSpan ( client , name , source , version , isLazyRouteContext ) ;
619590 }
620591 }
@@ -726,13 +697,7 @@ export function createV6CompatibleWithSentryReactRouterRouting<P extends Record<
726697 } ) ;
727698 isMountRenderPass . current = false ;
728699 } else {
729- handleNavigation ( {
730- location,
731- routes,
732- navigationType,
733- version,
734- allRoutes : Array . from ( allRoutes ) ,
735- } ) ;
700+ handleNavigation ( { location, routes, navigationType, version, allRoutes : Array . from ( allRoutes ) } ) ;
736701 }
737702 } ,
738703 // `props.children` is purposely not included in the dependency array, because we do not want to re-run this effect
@@ -766,43 +731,6 @@ function getActiveRootSpan(): Span | undefined {
766731 return op === 'navigation' || op === 'pageload' ? rootSpan : undefined ;
767732}
768733
769- /**
770- * Handles updating an existing navigation span
771- */
772- export function handleExistingNavigationSpan (
773- activeSpan : Span ,
774- spanJson : ReturnType < typeof spanToJSON > ,
775- name : string ,
776- source : TransactionSource ,
777- isLikelyLazyRoute : boolean ,
778- ) : void {
779- // Check if we've already set the name for this span using a custom property
780- const hasBeenNamed = (
781- activeSpan as {
782- __sentry_navigation_name_set__ ?: boolean ;
783- }
784- ) ?. __sentry_navigation_name_set__ ;
785-
786- if ( ! hasBeenNamed ) {
787- // This is the first time we're setting the name for this span
788- if ( ! spanJson . timestamp ) {
789- activeSpan ?. updateName ( name ) ;
790- }
791-
792- // For lazy routes, don't mark as named yet so it can be updated later
793- if ( ! isLikelyLazyRoute ) {
794- addNonEnumerableProperty (
795- activeSpan as { __sentry_navigation_name_set__ ?: boolean } ,
796- '__sentry_navigation_name_set__' ,
797- true ,
798- ) ;
799- }
800- }
801-
802- // Always set the source attribute to keep it consistent with the current route
803- activeSpan ?. setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , source ) ;
804- }
805-
806734/**
807735 * Creates a new navigation span
808736 */
0 commit comments