Skip to content

feat(nextjs): Register a route provider outside the tracing integration - #23552

Draft
logaretm wants to merge 1 commit into
awad/route-provider-apifrom
awad/route-provider-nextjs
Draft

feat(nextjs): Register a route provider outside the tracing integration#23552
logaretm wants to merge 1 commit into
awad/route-provider-apifrom
awad/route-provider-nextjs

Conversation

@logaretm

@logaretm logaretm commented Aug 24, 2026

Copy link
Copy Markdown
Member

Registers a route provider for Next.js from the manifests already injected at build time, covering both the App Router and the Pages Router.

Registered from init() rather than from browserTracingIntegration, which is the point of the change: both manifests are on the global object before Sentry.init runs, so nothing has to wait for a router or for tracing. bfcacheMetricsIntegration now resolves a parameterized route with browserTracingIntegration absent entirely, and the same will hold for web vitals and interactions as they move over.

The two manifests want the pathname differently, since App Router routes are generated with basePath baked in while Next strips it internally for the Pages Router, so the provider normalizes per manifest.

Part of #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.97 kB +0.78% +413 B 🔺
@sentry/sveltekit (client) 49.19 kB - -
@sentry/core/server 65.67 kB -0.06% -35 B 🔽
@sentry/core/browser 52.26 kB +0.77% +395 B 🔺
@sentry/node 123.77 kB +0.02% +18 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% +21 B 🔺
@sentry/aws-serverless 96.42 kB +0.03% +28 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-nextjs branch 2 times, most recently from 737c9cf to 5d8e20b Compare August 24, 2026 20:17
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 5d8e20b to 464c7d0 Compare August 24, 2026 20:52
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 464c7d0 to 1eb7910 Compare August 24, 2026 20:57
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch 2 times, most recently from 21288e6 to fec1a68 Compare August 31, 2026 17:05
@logaretm
logaretm changed the base branch from awad/route-provider-api to awad/route-provider-tracing-naming August 31, 2026 17:13
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from fec1a68 to 7016bab Compare August 31, 2026 18:19
@logaretm
logaretm changed the base branch from awad/route-provider-tracing-naming to awad/route-provider-api August 31, 2026 18:19
@logaretm logaretm changed the title feat(nextjs): Register a route provider from the build-time route manifest feat(nextjs): Register a route provider outside the tracing integration Aug 31, 2026
Both routers already ship a pure matcher: the App Router has the build-time
route manifest behind `maybeParameterizeRoute`, and the Pages Router matches
against `__BUILD_MANIFEST.sortedPages`. Neither was reachable from anywhere
except the pageload and navigation instrumentation.

Registered from `init()` rather than `browserTracingIntegration`, because both
manifests are on the global object before `Sentry.init` runs. Route
parameterization no longer depends on tracing being enabled, so `bfcacheMetrics`
resolves a parameterized route with `browserTracingIntegration` absent.

The two manifests want the pathname differently, since App Router routes are
generated with `basePath` baked in while Next strips it internally for the Pages
Router, so the provider normalizes per manifest.
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.

1 participant