-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
26 lines (23 loc) · 936 Bytes
/
Copy pathinstrumentation.ts
File metadata and controls
26 lines (23 loc) · 936 Bytes
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
/**
* Next.js 16 instrumentation hook — T22 Sentry wire-up.
*
* `register()` runs once per runtime on boot. We branch on
* `process.env.NEXT_RUNTIME` so the Node.js-only APIs inside
* `sentry.server.config.ts` never load in the edge runtime (and vice
* versa). Without the branch, both config modules are imported in both
* runtimes, and the edge bundle fails at build time.
*
* Sentry SDK `captureRequestError` is re-exported so Next.js can forward
* server/edge request-time errors into Sentry automatically (see
* `https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/`).
*/
import * as Sentry from '@sentry/nextjs';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./sentry.server.config');
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('./sentry.edge.config');
}
}
export const onRequestError = Sentry.captureRequestError;