@@ -250,7 +250,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
250250 < MemoryRouter initialEntries = { [ '/' ] } >
251251 < SentryRoutes >
252252 < Route path = "/about" element = { < div > About</ div > } >
253- < Route path = "/about/ us" element = { < div > us</ div > } />
253+ < Route path = "us" element = { < div > us</ div > } />
254254 </ Route >
255255 < Route path = "/" element = { < Navigate to = "/about/us" /> } />
256256 </ SentryRoutes >
@@ -287,7 +287,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
287287 < MemoryRouter initialEntries = { [ '/' ] } >
288288 < SentryRoutes >
289289 < Route path = "/about" element = { < div > About</ div > } >
290- < Route path = "/about/ :page" element = { < div > page</ div > } />
290+ < Route path = ":page" element = { < div > page</ div > } />
291291 </ Route >
292292 < Route path = "/" element = { < Navigate to = "/about/us" /> } />
293293 </ SentryRoutes >
@@ -324,8 +324,8 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
324324 < MemoryRouter initialEntries = { [ '/' ] } >
325325 < SentryRoutes >
326326 < Route path = "/stores" element = { < div > Stores</ div > } >
327- < Route path = "/stores/ :storeId" element = { < div > Store</ div > } >
328- < Route path = "/stores/:storeId/ products/:productId" element = { < div > Product</ div > } />
327+ < Route path = ":storeId" element = { < div > Store</ div > } >
328+ < Route path = "products/:productId" element = { < div > Product</ div > } />
329329 </ Route >
330330 </ Route >
331331 < Route path = "/" element = { < Navigate to = "/stores/foo/products/234" /> } />
@@ -391,6 +391,55 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
391391 } ) ;
392392 } ) ;
393393
394+ it ( 'works with wildcard routes' , ( ) => {
395+ const client = createMockBrowserClient ( ) ;
396+ setCurrentClient ( client ) ;
397+
398+ client . addIntegration (
399+ reactRouterV6BrowserTracingIntegration ( {
400+ useEffect : React . useEffect ,
401+ useLocation,
402+ useNavigationType,
403+ createRoutesFromChildren,
404+ matchRoutes,
405+ } ) ,
406+ ) ;
407+ const SentryRoutes = withSentryReactRouterV6Routing ( Routes ) ;
408+
409+ render (
410+ < MemoryRouter initialEntries = { [ '/' ] } >
411+ < SentryRoutes >
412+ < Route path = "*" element = { < Outlet /> } >
413+ < Route index element = { < Navigate to = "/projects/123/views/234" /> } />
414+ < Route path = "account" element = { < div > Account Page</ div > } />
415+ < Route path = "projects" >
416+ < Route path = "*" element = { < Outlet /> } >
417+ < Route path = ":projectId" element = { < div > Project Page</ div > } >
418+ < Route index element = { < div > Project Page Root</ div > } />
419+ < Route element = { < div > Editor</ div > } >
420+ < Route path = "views/:viewId" element = { < div > View Canvas</ div > } />
421+ < Route path = "spaces/:spaceId" element = { < div > Space Canvas</ div > } />
422+ </ Route >
423+ </ Route >
424+ </ Route >
425+ </ Route >
426+ < Route path = "*" element = { < div > No Match Page</ div > } />
427+ </ Route >
428+ </ SentryRoutes >
429+ </ MemoryRouter > ,
430+ ) ;
431+
432+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 1 ) ;
433+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
434+ name : '/projects/:projectId/views/:viewId' ,
435+ attributes : {
436+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
437+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
438+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v6' ,
439+ } ,
440+ } ) ;
441+ } ) ;
442+
394443 it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
395444 const client = createMockBrowserClient ( ) ;
396445 setCurrentClient ( client ) ;
@@ -410,7 +459,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
410459 < MemoryRouter initialEntries = { [ '/' ] } >
411460 < SentryRoutes >
412461 < Route path = "/about" element = { < div > About</ div > } >
413- < Route path = "/about/ :page" element = { < div > page</ div > } />
462+ < Route path = ":page" element = { < div > page</ div > } />
414463 </ Route >
415464 < Route path = "/" element = { < Navigate to = "/about/us" /> } />
416465 </ SentryRoutes >
@@ -639,7 +688,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
639688 element : < div > About</ div > ,
640689 children : [
641690 {
642- path : '/about/ us' ,
691+ path : 'us' ,
643692 element : < div > us</ div > ,
644693 } ,
645694 ] ,
@@ -689,7 +738,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
689738 element : < div > About</ div > ,
690739 children : [
691740 {
692- path : '/about/ :page' ,
741+ path : ':page' ,
693742 element : < div > page</ div > ,
694743 } ,
695744 ] ,
@@ -739,11 +788,11 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
739788 element : < div > Stores</ div > ,
740789 children : [
741790 {
742- path : '/stores/ :storeId' ,
791+ path : ':storeId' ,
743792 element : < div > Store</ div > ,
744793 children : [
745794 {
746- path : '/stores/:storeId/ products/:productId' ,
795+ path : 'products/:productId' ,
747796 element : < div > Product</ div > ,
748797 } ,
749798 ] ,
0 commit comments