-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstrumentation-client.ts
More file actions
39 lines (29 loc) · 1.15 KB
/
instrumentation-client.ts
File metadata and controls
39 lines (29 loc) · 1.15 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
32
33
34
35
36
37
38
39
// Sentry is loaded via dynamic import() to keep it out of the shared
// framework chunk. This reduces first-load JS by ~130kB gzipped.
// The import executes immediately so the SDK initializes before the
// first user interaction in practice.
let captureTransition: ((url: string, type: string) => void) | null = null;
import("@sentry/nextjs").then(async (Sentry) => {
const { shouldDropClientEvent } = await import("@/lib/sentry");
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
sendDefaultPii: true,
// 100% in dev, 10% in production
tracesSampleRate: process.env.NODE_ENV === "development" ? 1.0 : 0.1,
// Session Replay: 10% of all sessions, 100% of sessions with errors
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
enableLogs: true,
integrations: [Sentry.replayIntegration()],
beforeSend(event) {
return shouldDropClientEvent(event) ? null : event;
},
});
captureTransition = Sentry.captureRouterTransitionStart;
});
export function onRouterTransitionStart(
url: string,
navigationType: "push" | "replace" | "traverse",
) {
captureTransition?.(url, navigationType);
}