-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
31 lines (27 loc) · 1.16 KB
/
Copy pathinstrumentation.ts
File metadata and controls
31 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as Sentry from '@sentry/nextjs';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
// Turbopack does not auto-load `sentry.server.config.ts`, so server-side
// Sentry.init must be triggered explicitly here or `onRequestError`
// (below) has nothing initialized to capture into. Importing the config
// module runs its `Sentry.init()` at load time.
await import('./sentry.server.config');
const { registerOpenTelemetry } = await import(
'@/lib/observability/opentelemetry'
);
await registerOpenTelemetry();
}
if (process.env.NEXT_RUNTIME === 'edge') {
// Same Turbopack caveat for the edge runtime (middleware / edge routes).
await import('./sentry.edge.config');
}
}
/**
* v4-030: Next.js 15 `onRequestError` hook so RSC + server-action
* errors that don't propagate to a route handler still land in
* Sentry. Pre-fix, errors thrown inside React Server Components
* (page.tsx await calls, server-actions invoked via form actions)
* showed up as generic 500s in Vercel logs but never surfaced in
* the Sentry alert pipeline.
*/
export const onRequestError = Sentry.captureRequestError;