All three apps' instrumentation.ts files now call initOtelServerNode directly instead of initSentryServer/initSentryServerNode, closing the startup window where @sentry/nextjs auto-instrumentation could send unscrubbed errors before bindAll() fires. bindOtelInstrumentation no longer calls initOtelServerNode (SDK init belongs at app boot, binding at request scope). Orphaned sentry/ init-server*.ts files deleted; their package.json subpath exports removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
863 B
TypeScript
23 lines
863 B
TypeScript
// apps/web-next/instrumentation.ts
|
|
// Next.js convention: this module runs once on server boot (before any request handler).
|
|
// Initializes the OTel SDK here so PII scrub processors are active from the very first
|
|
// request — before bindAll() fires. Calling initOtelServerNode here (not inside bindAll)
|
|
// closes the startup window where @sentry/nextjs auto-instrumentation could send
|
|
// unscrubbed errors (C1 fix).
|
|
|
|
export async function register() {
|
|
if (
|
|
process.env["NEXT_RUNTIME"] === "nodejs" ||
|
|
process.env["NEXT_RUNTIME"] === "edge"
|
|
) {
|
|
const { initOtelServerNode } = await import(
|
|
"@repo/core-shared/instrumentation/otel/init-server-node"
|
|
);
|
|
initOtelServerNode({
|
|
dsn: process.env["WEB_NEXT_SENTRY_DSN"] ?? "",
|
|
serviceName: "web-next",
|
|
environment: process.env["NODE_ENV"] ?? "development",
|
|
});
|
|
}
|
|
}
|