Skip to content

feat(react-router): Set url.template, url.path and url.full on pageload and navigation spans - #22018

Merged
Lms24 merged 4 commits into
developfrom
feat/pageload-url-attrs-react-router
Jul 9, 2026
Merged

feat(react-router): Set url.template, url.path and url.full on pageload and navigation spans#22018
Lms24 merged 4 commits into
developfrom
feat/pageload-url-attrs-react-router

Conversation

@Lms24

@Lms24Lms24 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Applies url.template, url.path and url.full to pageload and navigation root spans for the @sentry/react-router framework integration, including fixes for trailing-slash handling and additional navigation span coverage.

part of #21921

@github-actions

github-actionsBot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

PathSize% ChangeChange
@sentry/browser27.59 kB--
@sentry/browser - with treeshaking flags26.03 kB--
@sentry/browser (incl. Tracing)46.34 kB--
@sentry/browser (incl. Tracing + Span Streaming)48.13 kB--
@sentry/browser (incl. Tracing, Profiling)51.12 kB--
@sentry/browser (incl. Tracing, Replay)85.62 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags75.26 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)90.32 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.97 kB--
@sentry/browser (incl. Feedback)44.76 kB--
@sentry/browser (incl. sendFeedback)32.38 kB--
@sentry/browser (incl. FeedbackAsync)37.51 kB--
@sentry/browser (incl. Metrics)28.67 kB--
@sentry/browser (incl. Logs)28.91 kB--
@sentry/browser (incl. Metrics & Logs)29.59 kB--
@sentry/react29.38 kB--
@sentry/react (incl. Tracing)48.61 kB--
@sentry/vue33.03 kB--
@sentry/vue (incl. Tracing)48.24 kB--
@sentry/svelte27.61 kB--
CDN Bundle30 kB--
CDN Bundle (incl. Tracing)48.32 kB--
CDN Bundle (incl. Logs, Metrics)31.57 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.64 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.81 kB--
CDN Bundle (incl. Tracing, Replay)85.84 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)87.14 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.64 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.92 kB--
CDN Bundle - uncompressed89.35 kB--
CDN Bundle (incl. Tracing) - uncompressed146.1 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.05 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.07 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.78 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.3 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.26 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed282.95 kB--
@sentry/nextjs (client)51.16 kB--
@sentry/sveltekit (client)46.75 kB--
@sentry/core/server78.42 kB--
@sentry/core/browser64.74 kB--
@sentry/node-core62.72 kB--
@sentry/node125.36 kB--
@sentry/node (incl. diagnostics channel injection)135 kB--
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.72 kB+0.01%+1 B 🔺
@sentry/node - without tracing74.05 kB--
@sentry/aws-serverless85.5 kB+0.01%+1 B 🔺
@sentry/cloudflare (withSentry) - minified181.71 kB--
@sentry/cloudflare (withSentry)449.16 kB--

View base workflow run

@Lms24
Lms24 marked this pull request as ready for review July 7, 2026 15:48
@Lms24
Lms24 requested a review from a team as a code ownerJuly 7, 2026 15:48
@Lms24
Lms24 requested review from chargome, mydea and s1gr1d and removed request for a teamJuly 7, 2026 15:48
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 58bf332 to 30325b3CompareJuly 7, 2026 15:50
Comment threadpackages/react-router/src/client/hydratedRouter.ts
Comment threadpackages/react-router/src/client/utils.ts
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 30325b3 to 481776aCompareJuly 8, 2026 07:36
Comment threadpackages/react-router/src/client/hydratedRouter.ts
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 481776a to 03a93e9CompareJuly 8, 2026 09:29
Comment threadpackages/react-router/src/client/hydratedRouter.ts Outdated
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 03a93e9 to 49a362bCompareJuly 8, 2026 12:29
@Lms24
Lms24 requested a review from a team as a code ownerJuly 8, 2026 13:11
@Lms24
Lms24 requested review from logaretm and removed request for a teamJuly 8, 2026 13:11
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 49a362b to bf7c7d2CompareJuly 8, 2026 13:11
Comment threadpackages/react-router/src/client/hydratedRouter.ts
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from bf7c7d2 to 85266e1CompareJuly 8, 2026 14:22
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch 2 times, most recently from 2265752 to 85266e1CompareJuly 8, 2026 14:42
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 85266e1 to 2265752CompareJuly 8, 2026 14:43
Comment threadpackages/react-router/src/client/utils.ts
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 2265752 to 85266e1CompareJuly 8, 2026 14:46
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 85266e1 to 02a2e89CompareJuly 8, 2026 14:52
Comment threadpackages/react-router/src/client/createClientInstrumentation.ts Outdated
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 02a2e89 to 3142788CompareJuly 8, 2026 14:57
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 3142788 to 3b539caCompareJuly 8, 2026 15:00
Base automatically changed from feat/pageload-url-attrs-astro to developJuly 8, 2026 15:59
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 3b539ca to f841e71CompareJuly 8, 2026 16:08

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f841e71. Configure here.

Comment threadpackages/react-router/src/client/utils.ts
Lms24and others added 4 commits July 9, 2026 09:40
…ad and navigation spans
Extracted from the framework-wide url.template PR into its own PR since
the react-router framework integration needed additional navigation span
and trailing-slash fixes beyond the other framework SDKs.
part of #21921
Co-Authored-By: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Lms24
Lms24force-pushed the feat/pageload-url-attrs-react-router branch from 8923db5 to bdbba44CompareJuly 9, 2026 07:54
Comment on lines +65 to +68
maybeCreateNavigationTransaction(
resolveNavigateArg(args[0]) || '<unknown route>',
resolveNavigateAbsoluteUrl(args[0]),
'url',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: In hydratedRouter.ts, numeric navigations like navigate(-1) are incorrectly treated as path segments, leading to malformed telemetry URLs and transaction names.
Severity: MEDIUM

Suggested Fix

In hydratedRouter.ts, add special handling for numeric navigation arguments, similar to the logic in createClientInstrumentation.ts. Before calling resolveNavigateAbsoluteUrl, check if the navigation argument is a number. If it is, use the current pathname to generate the transaction name and URL, rather than treating the number as a relative path.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/react-router/src/client/hydratedRouter.ts#L65-L68
Potential issue: When the router is used in a mode without the Instrumentation API,
numeric navigations (e.g., `router.navigate(-1)`) are handled incorrectly by
`hydratedRouter.ts`. The numeric argument is passed to `resolveNavigateAbsoluteUrl`,
which treats it as a path segment. This results in malformed telemetry URLs (e.g.,
`https://example.com/current/path/-1`) and incorrect transaction names (e.g., `"-1"`).
This behavior is inconsistent with the correct handling in
`createClientInstrumentation.ts`, which properly identifies numeric navigations and uses
the current pathname.

Also affects:

  • packages/react-router/src/client/utils.ts:76~85

@Lms24
Lms24 merged commit eceb059 into developJul 9, 2026
59 checks passed
@Lms24
Lms24 deleted the feat/pageload-url-attrs-react-router branch July 9, 2026 09:02
Lms24 added a commit that referenced this pull request Jul 10, 2026
…vigations (#22131)
Follow-up to the merged url.* attribute work (#22018): That PR set
`url.template`, `url.path`, and `url.full` on pageload/navigation spans,
but exposed incorrect destination URLs for `navigate(-1)`/`navigate(1)`
and relative `navigate()` targets. Similarly, independent of #22018,
span names of relative navigations were also incorrect.
This PR fixes destination URL updates and span anmes after numeric
navigation (legacy + instrumentation API), route parameterization for
relative navigations via `url.path` matching, and adds E2E coverage for
history back navigation.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Lms24@nicohrubec@s1gr1d