@@ -200,11 +200,11 @@ export function createV6CompatibleWrapUseRoutes(origUseRoutes: UseRoutes, versio
200
200
const normalizedLocation =
201
201
typeof stableLocationParam === 'string' ? { pathname : stableLocationParam } : stableLocationParam ;
202
202
203
- routes . forEach ( route => {
204
- allRoutes . push ( ...getChildRoutesRecursively ( route ) ) ;
205
- } ) ;
206
-
207
203
if ( isMountRenderPass . current ) {
204
+ routes . forEach ( route => {
205
+ allRoutes . push ( ...getChildRoutesRecursively ( route ) ) ;
206
+ } ) ;
207
+
208
208
updatePageloadTransaction ( getActiveRootSpan ( ) , normalizedLocation , routes , undefined , undefined , allRoutes ) ;
209
209
isMountRenderPass . current = false ;
210
210
} else {
@@ -238,16 +238,21 @@ export function handleNavigation(
238
238
}
239
239
240
240
if ( ( navigationType === 'PUSH' || navigationType === 'POP' ) && branches ) {
241
- const [ name , source ] = getNormalizedName ( routes , location , branches , basename ) ;
241
+ let name ,
242
+ source : TransactionSource = 'url' ;
243
+ const isInDescendantRoute = locationIsInsideDescendantRoute ( location , allRoutes || routes ) ;
242
244
243
- let txnName = name ;
245
+ if ( isInDescendantRoute ) {
246
+ name = prefixWithSlash ( rebuildRoutePathFromAllRoutes ( allRoutes || routes , location ) ) ;
247
+ source = 'route' ;
248
+ }
244
249
245
- if ( locationIsInsideDescendantRoute ( location , allRoutes || routes ) ) {
246
- txnName = prefixWithSlash ( rebuildRoutePathFromAllRoutes ( allRoutes || routes , location ) ) ;
250
+ if ( ! isInDescendantRoute || ! name ) {
251
+ [ name , source ] = getNormalizedName ( routes , location , branches , basename ) ;
247
252
}
248
253
249
254
startBrowserTracingNavigationSpan ( client , {
250
- name : txnName ,
255
+ name,
251
256
attributes : {
252
257
[ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : source ,
253
258
[ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
@@ -307,10 +312,6 @@ function pathIsWildcardAndHasChildren(path: string, branch: RouteMatch<string>):
307
312
return ( pathEndsWithWildcard ( path ) && branch . route . children && branch . route . children . length > 0 ) || false ;
308
313
}
309
314
310
- // function pathIsWildcardWithNoChildren(path: string, branch: RouteMatch<string>): boolean {
311
- // return (pathEndsWithWildcard(path) && (!branch.route.children || branch.route.children.length === 0)) || false;
312
- // }
313
-
314
315
function routeIsDescendant ( route : RouteObject ) : boolean {
315
316
return ! ! ( ! route . children && route . element && route . path && route . path . endsWith ( '/*' ) ) ;
316
317
}
@@ -464,18 +465,23 @@ function updatePageloadTransaction(
464
465
: ( _matchRoutes ( routes , location , basename ) as unknown as RouteMatch [ ] ) ;
465
466
466
467
if ( branches ) {
467
- const [ name , source ] = getNormalizedName ( routes , location , branches , basename ) ;
468
+ let name ,
469
+ source : TransactionSource = 'url' ;
470
+ const isInDescendantRoute = locationIsInsideDescendantRoute ( location , allRoutes || routes ) ;
468
471
469
- let txnName = name ;
472
+ if ( isInDescendantRoute ) {
473
+ name = prefixWithSlash ( rebuildRoutePathFromAllRoutes ( allRoutes || routes , location ) ) ;
474
+ source = 'route' ;
475
+ }
470
476
471
- if ( locationIsInsideDescendantRoute ( location , allRoutes || routes ) ) {
472
- txnName = prefixWithSlash ( rebuildRoutePathFromAllRoutes ( allRoutes || routes , location ) ) ;
477
+ if ( ! isInDescendantRoute || ! name ) {
478
+ [ name , source ] = getNormalizedName ( routes , location , branches , basename ) ;
473
479
}
474
480
475
- getCurrentScope ( ) . setTransactionName ( txnName ) ;
481
+ getCurrentScope ( ) . setTransactionName ( name ) ;
476
482
477
483
if ( activeRootSpan ) {
478
- activeRootSpan . updateName ( txnName ) ;
484
+ activeRootSpan . updateName ( name ) ;
479
485
activeRootSpan . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , source ) ;
480
486
}
481
487
}
@@ -507,11 +513,11 @@ export function createV6CompatibleWithSentryReactRouterRouting<P extends Record<
507
513
( ) => {
508
514
const routes = _createRoutesFromChildren ( props . children ) as RouteObject [ ] ;
509
515
510
- routes . forEach ( route => {
511
- allRoutes . push ( ...getChildRoutesRecursively ( route ) ) ;
512
- } ) ;
513
-
514
516
if ( isMountRenderPass . current ) {
517
+ routes . forEach ( route => {
518
+ allRoutes . push ( ...getChildRoutesRecursively ( route ) ) ;
519
+ } ) ;
520
+
515
521
updatePageloadTransaction ( getActiveRootSpan ( ) , location , routes , undefined , undefined , allRoutes ) ;
516
522
isMountRenderPass . current = false ;
517
523
} else {
0 commit comments