@@ -122,6 +122,39 @@ describe('reactRouterV6BrowserTracingIntegration (v6.4)', () => {
122122 } ) ;
123123 } ) ;
124124
125+ it ( "updates the scope's `transactionName` on a pageload" , ( ) => {
126+ const client = createMockBrowserClient ( ) ;
127+ setCurrentClient ( client ) ;
128+
129+ client . addIntegration (
130+ reactRouterV6BrowserTracingIntegration ( {
131+ useEffect : React . useEffect ,
132+ useLocation,
133+ useNavigationType,
134+ createRoutesFromChildren,
135+ matchRoutes,
136+ } ) ,
137+ ) ;
138+ const sentryCreateBrowserRouter = wrapCreateBrowserRouter ( createMemoryRouter as CreateRouterFunction ) ;
139+
140+ const router = sentryCreateBrowserRouter (
141+ [
142+ {
143+ path : '/' ,
144+ element : < div > TEST</ div > ,
145+ } ,
146+ ] ,
147+ {
148+ initialEntries : [ '/' ] ,
149+ } ,
150+ ) ;
151+
152+ // @ts -expect-error router is fine
153+ render ( < RouterProvider router = { router } /> ) ;
154+
155+ expect ( getCurrentScope ( ) . getScopeData ( ) ?. transactionName ) . toEqual ( '/' ) ;
156+ } ) ;
157+
125158 it ( 'starts a navigation transaction' , ( ) => {
126159 const client = createMockBrowserClient ( ) ;
127160 setCurrentClient ( client ) ;
@@ -590,5 +623,42 @@ describe('reactRouterV6BrowserTracingIntegration (v6.4)', () => {
590623 } ,
591624 } ) ;
592625 } ) ;
626+
627+ it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
628+ const client = createMockBrowserClient ( ) ;
629+ setCurrentClient ( client ) ;
630+
631+ client . addIntegration (
632+ reactRouterV6BrowserTracingIntegration ( {
633+ useEffect : React . useEffect ,
634+ useLocation,
635+ useNavigationType,
636+ createRoutesFromChildren,
637+ matchRoutes,
638+ } ) ,
639+ ) ;
640+ const sentryCreateBrowserRouter = wrapCreateBrowserRouter ( createMemoryRouter as CreateRouterFunction ) ;
641+
642+ const router = sentryCreateBrowserRouter (
643+ [
644+ {
645+ path : '/' ,
646+ element : < Navigate to = "/about" /> ,
647+ } ,
648+ {
649+ path : 'about' ,
650+ element : < div > About</ div > ,
651+ } ,
652+ ] ,
653+ {
654+ initialEntries : [ '/' ] ,
655+ } ,
656+ ) ;
657+
658+ // @ts -expect-error router is fine
659+ render ( < RouterProvider router = { router } /> ) ;
660+
661+ expect ( getCurrentScope ( ) . getScopeData ( ) ?. transactionName ) . toEqual ( '/about' ) ;
662+ } ) ;
593663 } ) ;
594664} ) ;
0 commit comments