Skip to content

Commit ef3af92

Browse files
Lms24cursoragent
andcommitted
feat(react): Set url.template, url.path and url.full on routing spans
Adds url.template to React Router v3–v6 and v4/v5 instrumentation, fixes TanStack React Router navigation url.path/url.full to use the target location, and updates unit and e2e tests. part of #21921 Co-Authored-By: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0d98fb5 commit ef3af92

26 files changed

Lines changed: 524 additions & 101 deletions

File tree

dev-packages/e2e-tests/test-applications/react-17/tests/transactions.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ test('sends a pageload transaction with a parameterized URL', async ({ page }) =
1515
trace: {
1616
op: 'pageload',
1717
origin: 'auto.pageload.react.reactrouter_v6',
18+
data: {
19+
'sentry.source': 'route',
20+
'url.template': '/',
21+
'url.path': '/',
22+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
23+
},
1824
},
1925
},
2026
transaction: '/',
@@ -46,6 +52,12 @@ test('sends a navigation transaction with a parameterized URL', async ({ page })
4652
trace: {
4753
op: 'navigation',
4854
origin: 'auto.navigation.react.reactrouter_v6',
55+
data: {
56+
'sentry.source': 'route',
57+
'url.template': '/user/:id',
58+
'url.path': '/user/5',
59+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
60+
},
4961
},
5062
},
5163
transaction: '/user/:id',

dev-packages/e2e-tests/test-applications/react-create-browser-router/tests/transactions.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ test('Captures a pageload transaction', async ({ page }) => {
3131
'sentry.origin': 'auto.pageload.react.reactrouter_v6',
3232
'sentry.sample_rate': 1,
3333
'sentry.source': 'route',
34+
'url.template': '/',
35+
'url.path': '/',
36+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/$/),
3437
}),
3538
op: 'pageload',
3639
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -58,6 +61,9 @@ test('Captures a navigation transaction', async ({ page }) => {
5861
'sentry.origin': 'auto.navigation.react.reactrouter_v6',
5962
'sentry.sample_rate': 1,
6063
'sentry.source': 'route',
64+
'url.template': '/user/:id',
65+
'url.path': '/user/5',
66+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/user\/5$/),
6167
}),
6268
links: [
6369
{
@@ -106,6 +112,9 @@ test('Captures a lazy pageload transaction', async ({ page }) => {
106112
'sentry.origin': 'auto.pageload.react.reactrouter_v6',
107113
'sentry.sample_rate': 1,
108114
'sentry.source': 'route',
115+
'url.template': '/lazy-loaded-user/:id/:innerId',
116+
'url.path': '/lazy-loaded-user/5/foo',
117+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/lazy-loaded-user\/5\/foo$/),
109118
}),
110119
op: 'pageload',
111120
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -159,6 +168,9 @@ test('Captures a lazy navigation transaction', async ({ page }) => {
159168
'sentry.origin': 'auto.navigation.react.reactrouter_v6',
160169
'sentry.sample_rate': 1,
161170
'sentry.source': 'route',
171+
'url.template': '/lazy-loaded-user/:id/:innerId',
172+
'url.path': '/lazy-loaded-user/5/foo',
173+
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/lazy-loaded-user\/5\/foo$/),
162174
}),
163175
links: [
164176
{

0 commit comments

Comments
 (0)