@@ -250,7 +250,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
250
250
< MemoryRouter initialEntries = { [ '/' ] } >
251
251
< SentryRoutes >
252
252
< Route path = "/about" element = { < div > About</ div > } >
253
- < Route path = "/about/ us" element = { < div > us</ div > } />
253
+ < Route path = "us" element = { < div > us</ div > } />
254
254
</ Route >
255
255
< Route path = "/" element = { < Navigate to = "/about/us" /> } />
256
256
</ SentryRoutes >
@@ -287,7 +287,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
287
287
< MemoryRouter initialEntries = { [ '/' ] } >
288
288
< SentryRoutes >
289
289
< Route path = "/about" element = { < div > About</ div > } >
290
- < Route path = "/about/ :page" element = { < div > page</ div > } />
290
+ < Route path = ":page" element = { < div > page</ div > } />
291
291
</ Route >
292
292
< Route path = "/" element = { < Navigate to = "/about/us" /> } />
293
293
</ SentryRoutes >
@@ -324,8 +324,8 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
324
324
< MemoryRouter initialEntries = { [ '/' ] } >
325
325
< SentryRoutes >
326
326
< 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 > } />
329
329
</ Route >
330
330
</ Route >
331
331
< Route path = "/" element = { < Navigate to = "/stores/foo/products/234" /> } />
@@ -391,6 +391,55 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
391
391
} ) ;
392
392
} ) ;
393
393
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
+
394
443
it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
395
444
const client = createMockBrowserClient ( ) ;
396
445
setCurrentClient ( client ) ;
@@ -410,7 +459,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
410
459
< MemoryRouter initialEntries = { [ '/' ] } >
411
460
< SentryRoutes >
412
461
< Route path = "/about" element = { < div > About</ div > } >
413
- < Route path = "/about/ :page" element = { < div > page</ div > } />
462
+ < Route path = ":page" element = { < div > page</ div > } />
414
463
</ Route >
415
464
< Route path = "/" element = { < Navigate to = "/about/us" /> } />
416
465
</ SentryRoutes >
@@ -639,7 +688,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
639
688
element : < div > About</ div > ,
640
689
children : [
641
690
{
642
- path : '/about/ us' ,
691
+ path : 'us' ,
643
692
element : < div > us</ div > ,
644
693
} ,
645
694
] ,
@@ -689,7 +738,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
689
738
element : < div > About</ div > ,
690
739
children : [
691
740
{
692
- path : '/about/ :page' ,
741
+ path : ':page' ,
693
742
element : < div > page</ div > ,
694
743
} ,
695
744
] ,
@@ -739,11 +788,11 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
739
788
element : < div > Stores</ div > ,
740
789
children : [
741
790
{
742
- path : '/stores/ :storeId' ,
791
+ path : ':storeId' ,
743
792
element : < div > Store</ div > ,
744
793
children : [
745
794
{
746
- path : '/stores/:storeId/ products/:productId' ,
795
+ path : 'products/:productId' ,
747
796
element : < div > Product</ div > ,
748
797
} ,
749
798
] ,
0 commit comments