Skip to content

fix(react/solid/vue): Instrument TanStack Router navigations via onBeforeLoad/onResolved#21975

Merged
chargome merged 1 commit into
developfrom
cg/js-2927-tanstack-redirect
Jul 6, 2026
Merged

fix(react/solid/vue): Instrument TanStack Router navigations via onBeforeLoad/onResolved#21975
chargome merged 1 commit into
developfrom
cg/js-2927-tanstack-redirect

Conversation

@chargome

@chargome chargome commented Jul 6, 2026

Copy link
Copy Markdown
Member

Currently we only instrument navigations via onBeforeNavigate. This hook is surpressed in TanStack after any redirect was thrown.

This PR changes the mechanics to instrument via onBeforeLoad/onResolved, both are unaffected by redirects. Verified this in E2E.

Note that currently the integration is duplicated in the specific SDKs, while the code is almost identical. We can follow up by moving this into browser maybe, but out of scope for this PR

closes #21966

@chargome chargome self-assigned this Jul 6, 2026
@linear-code

linear-code Bot commented Jul 6, 2026

Copy link
Copy Markdown

JS-2927

@chargome

chargome commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7c4f5eb. Configure here.

@chargome chargome marked this pull request as ready for review July 6, 2026 11:17
@chargome chargome requested a review from a team as a code owner July 6, 2026 11:17
@chargome chargome requested review from andreiborza, mydea, nicohrubec and s1gr1d and removed request for a team July 6, 2026 11:17
it('subscribes to router navigation events when instrumentNavigation is true', () => {
const integration = tanstackRouterBrowserTracingIntegration(mockRouter, {
instrumentNavigation: true,
instrumentPageLoad: false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: Why was this added here? The test still asserts only "when instrumentNavigation is true" (same in the test below)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was just added for testing the navigation events in isolation. This way it's cleaner and easier to test router.subscribe above.

@chargome chargome merged commit 989396c into develop Jul 6, 2026
150 checks passed
@chargome chargome deleted the cg/js-2927-tanstack-redirect branch July 6, 2026 11:50
Sign up for free to 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.

TanStack Router integration navigation spans does not work with throw redirect in loaders

3 participants