Skip to content

feat(core): Add route provider API for parameterized route resolution - #23551

Draft
logaretm wants to merge 1 commit into
developfrom
awad/route-provider-api
Draft

feat(core): Add route provider API for parameterized route resolution#23551
logaretm wants to merge 1 commit into
developfrom
awad/route-provider-api

Conversation

@logaretm

@logaretm logaretm commented Aug 24, 2026

Copy link
Copy Markdown
Member

Adds the route provider API to core so framework SDKs can register how to resolve a URL to a parameterized route, and wires up bfcacheMetricsIntegration as the first consumer since that is where the fragmentation currently produces a raw URL on a metric dimension.

bfcacheMetrics keeps its pathname fallback, so nothing changes until a provider is registered.

closes #23556

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.56 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.75 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.76 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.68 kB - -
@sentry/browser (incl. Tracing, Replay) 88.23 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.63 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.93 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.85 kB - -
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.62 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 50.94 kB - -
@sentry/vue 35.73 kB - -
@sentry/vue (incl. Tracing) 51.02 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.72 kB +1.23% +372 B 🔺
CDN Bundle (incl. Tracing) 49.77 kB +0.79% +387 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.98 kB +1.24% +402 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 51.66 kB +0.8% +405 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.51 kB +0.47% +337 B 🔺
CDN Bundle (incl. Tracing, Replay) 87.24 kB +0.44% +377 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.09 kB +0.41% +361 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 93.13 kB +0.37% +336 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.06 kB +0.45% +422 B 🔺
CDN Bundle - uncompressed 91.23 kB +1.43% +1.28 kB 🔺
CDN Bundle (incl. Tracing) - uncompressed 148.48 kB +0.88% +1.28 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.53 kB +1.34% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.17 kB +0.84% +1.28 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.69 kB +0.57% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.98 kB +0.49% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.65 kB +0.48% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.68 kB +0.46% +1.28 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.35 kB +0.45% +1.28 kB 🔺
@sentry/nextjs (client) 53.56 kB - -
@sentry/sveltekit (client) 49.19 kB - -
@sentry/core/server 65.67 kB - -
@sentry/core/browser 52.26 kB +0.77% +395 B 🔺
@sentry/node 123.77 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.53 kB - -
@sentry/node - without tracing 88.03 kB +0.02% +14 B 🔺
@sentry/node - without channel injection 103.18 kB +0.03% +22 B 🔺
@sentry/aws-serverless 96.42 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 201.04 kB - -
@sentry/cloudflare (withSentry) 500.26 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/route-provider-api branch 3 times, most recently from 905570f to 488ffe0 Compare August 24, 2026 20:57
@logaretm
logaretm requested review from Lms24 and msonnb August 31, 2026 14:17
@logaretm

Copy link
Copy Markdown
Member Author

I requested a draft review because I need opinions on this stack but may not be around to merge this till next week.

@Lms24 Lms24 left a comment

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.

I thought a bit about the router provider and I like the idea of it! Initially, I was wondering if we could just get away with a url -> route map or cache. But the idea of having a "live" resolver for the framework SDKs that support resolving a url to a route is a good one! Bonus points that this is not something users have to configure but is (for now) baked into browserTracingIntegrations. We can see where exactly this makes more sense as we split up the integration into sub integrations.

I suggest running this by the framework WG since it will primarily concern framework SDKs. I looked into a couple of the stacked framework PRs and the changes look fairly minimal which is nice!

Just had some minor nits for now

* Normalizes to a real `URL` so providers never have to parse, and relative locations (which memory
* routers hand around) resolve against the document.
*/
function toURLObject(url: string): URL | undefined {

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.

l: I think we already have a helper like this in core 🤔

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.

l: As long as we're planning on adding the provider only to browser-side SDKs, can we move this to browser-utils? Francesco is working on moving all browser-specific exports over, so I think we can take the shortcut and add it to utils right away.

Framework SDKs can register a provider that resolves a URL to a low-cardinality
route name, so integrations stop each reaching for the route their own way.

Wires up `bfcacheIntegration` as the first consumer: its segment name ends up as
a metric dimension, where an unparameterized URL is unbounded cardinality.
@logaretm
logaretm force-pushed the awad/route-provider-api branch from 488ffe0 to 3754c50 Compare August 31, 2026 16:39
@logaretm

Copy link
Copy Markdown
Member Author

We can see where exactly this makes more sense as we split up the integration into sub integrations.

That was one of my goals, breaking up the dependency between route parameterization and tracing because parameterization could be needed in logs/metrics/errors or whatever.

This brings me to the next point, so it feels like we need a breaking change to break up this dependency in those frameworks, for example the Vue SDK accepts the router in browserTracingIntegration options, meaning we have no access to the router passively otherwise. Tanstack is in the same boat, seems like the other SDKs are fine tho.

The base API is fine, but I will need to do some more work on the stack in downstream SDKs.

I suggest running this by the framework WG since it will primarily concern framework SDKs. I looked into a couple of the stacked framework PRs and the changes look fairly minimal which is nice!

Will post in the channel!

@logaretm

logaretm commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

This was a 9 PR stack. It's now only a few, I wanted to record the reasoning.

Every provider ended up registered inside a tracing integration, which is the coupling the work was meant to break. The deletions I expected only unlock once browserTracingIntegration names spans from the provider, and currently half the framework SDKs have a few blockers:

  • Route sometimes is only available through browserTracingIntegration like Vue and Tanstack.
  • Some routing instrumentation implementation is cache based rather than matcher based, which limits the functionality here.
  • Some SDKs have to do lifecycle adjustments, rather than starting a span on history change, they need their own hooks to listen for.

So these 2 PRs do the smallest useful thing, parameterization that doesn't need tracing and that only fits in Next.js and Remix because these are only ones that have decoupled implementations (by virtue of the routes being accessible globally), Astro may also fit as well.

I think what I have here is a good base that we can either merge today and improve later, or expand on the base API to address these concerns.

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.

Route parameterization is fragmented across browser integrations

2 participants