88 startBrowserTracingPageLoadSpan ,
99 WINDOW ,
1010} from '@sentry/browser' ;
11- import type { Client , Integration , Span , TransactionSource } from '@sentry/core' ;
11+ import type { Client , Integration , Span } from '@sentry/core' ;
1212import {
1313 addNonEnumerableProperty ,
1414 debug ,
@@ -41,14 +41,7 @@ import type {
4141 UseRoutes ,
4242} from '../types' ;
4343import { checkRouteForAsyncHandler } from './lazy-routes' ;
44- import {
45- getNormalizedName ,
46- initializeRouterUtils ,
47- locationIsInsideDescendantRoute ,
48- prefixWithSlash ,
49- rebuildRoutePathFromAllRoutes ,
50- resolveRouteNameAndSource ,
51- } from './utils' ;
44+ import { initializeRouterUtils , resolveRouteNameAndSource } from './utils' ;
5245
5346let _useEffect : UseEffect ;
5447let _useLocation : UseLocation ;
@@ -732,7 +725,7 @@ function updatePageloadTransaction({
732725 : ( _matchRoutes ( allRoutes || routes , location , basename ) as unknown as RouteMatch [ ] ) ;
733726
734727 if ( branches ) {
735- const [ name , source ] = getTransactionNameAndSource ( location , routes , branches , basename , allRoutes ) ;
728+ const [ name , source ] = resolveRouteNameAndSource ( location , routes , allRoutes || routes , branches , basename ) ;
736729
737730 getCurrentScope ( ) . setTransactionName ( name || '/' ) ;
738731
@@ -746,33 +739,6 @@ function updatePageloadTransaction({
746739 }
747740}
748741
749- /**
750- * Extracts the transaction name and source from the route information.
751- */
752- function getTransactionNameAndSource (
753- location : Location ,
754- routes : RouteObject [ ] ,
755- branches : RouteMatch [ ] ,
756- basename : string | undefined ,
757- allRoutes : RouteObject [ ] | undefined ,
758- ) : [ string , TransactionSource ] {
759- let name : string | undefined ;
760- let source : TransactionSource = 'url' ;
761-
762- const isInDescendantRoute = locationIsInsideDescendantRoute ( location , allRoutes || routes ) ;
763-
764- if ( isInDescendantRoute ) {
765- name = prefixWithSlash ( rebuildRoutePathFromAllRoutes ( allRoutes || routes , location ) ) ;
766- source = 'route' ;
767- }
768-
769- if ( ! isInDescendantRoute || ! name ) {
770- [ name , source ] = getNormalizedName ( routes , location , branches , basename ) ;
771- }
772-
773- return [ name || '/' , source ] ;
774- }
775-
776742/**
777743 * Patches the span.end() method to update the transaction name one last time before the span is sent.
778744 * This handles cases where the span is cancelled early (e.g., document.hidden) before lazy routes have finished loading.
@@ -805,10 +771,7 @@ function patchSpanEnd(
805771 const branches = _matchRoutes ( currentAllRoutes || routes , location , basename ) as unknown as RouteMatch [ ] ;
806772
807773 if ( branches ) {
808- const [ name , source ] =
809- spanType === 'pageload'
810- ? getTransactionNameAndSource ( location , routes , branches , basename , currentAllRoutes )
811- : resolveRouteNameAndSource ( location , routes , currentAllRoutes , branches , basename ) ;
774+ const [ name , source ] = resolveRouteNameAndSource ( location , routes , currentAllRoutes , branches , basename ) ;
812775
813776 // Only update if we have a valid name
814777 if ( name && ( spanType === 'pageload' || ! spanJson . timestamp ) ) {
0 commit comments