From 0f3828b7ba446fd0e1b1d6f5d189d2531e742e63 Mon Sep 17 00:00:00 2001 From: Sergiy Dybskiy Date: Mon, 20 Jul 2026 16:53:17 -0400 Subject: [PATCH] fix(platform): Move instrumentation.ts to repo root so prod builds load it Next.js production builds discover middleware.ts and instrumentation.ts by scanning only rootDir = parent of the pages/ (or app/) directory, with no src/ fallback. When pages/ moved from src/pages to the repo root (da6c9f8e1, Mar 5), rootDir flipped from src/ to the repo root. middleware.ts broke visibly and was moved to the root in that commit, but src/instrumentation.ts was left behind and silently stopped being bundled: hasInstrumentationHook=false, no instrumentation.js or edge-instrumentation.js entries, so register() and Sentry.init never run in the node or edge runtime in production. Since then both docs and develop-docs have emitted zero server-side telemetry: no middleware spans, no http.server spans, no docs.trace.sampled metrics, and no traffic classification. Dev was unaffected because the dev bundler does check src/, which hid the breakage locally. Move instrumentation.ts to the repo root (next to middleware.ts) and import tracesSampler via the sentry-docs path alias. Verified with a local next build: .next/server/ gains instrumentation.js and edge-instrumentation.js, and the edge bundle contains the DSN, tracesSampler, and the docs.trace.sampled metric emission. instrumentation-client.ts stays in src/ because Next resolves it through a webpack alias that checks src/ first. Co-Authored-By: Claude --- src/instrumentation.ts => instrumentation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/instrumentation.ts => instrumentation.ts (97%) diff --git a/src/instrumentation.ts b/instrumentation.ts similarity index 97% rename from src/instrumentation.ts rename to instrumentation.ts index 6bdfd74ba29d7e..e9326579d3ee46 100644 --- a/src/instrumentation.ts +++ b/instrumentation.ts @@ -1,6 +1,6 @@ import * as Sentry from '@sentry/nextjs'; -import {tracesSampler} from './tracesSampler'; +import {tracesSampler} from 'sentry-docs/tracesSampler'; export function register() { if (process.env.NEXT_RUNTIME === 'nodejs') {