-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsentry.client.config.ts
More file actions
66 lines (56 loc) · 1.98 KB
/
sentry.client.config.ts
File metadata and controls
66 lines (56 loc) · 1.98 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Sentry Client Configuration
*
* This file configures the initialization of Sentry on the client (browser).
* The config added here applies whenever a user loads a page in their browser.
* https://docs.sentry.io/platforms/javascript/guides/nextjs/
*/
import * as Sentry from "@sentry/nextjs";
// Only initialize Sentry if DSN is provided
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1.0,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
// Enable replay for 10% of sessions
replaysSessionSampleRate: 0.1,
// If you're not already sampling the entire session, change the sample rate to 100%
// when sampling sessions where errors occur.
replaysOnErrorSampleRate: 1.0,
// Environment tag for filtering
environment: process.env.NODE_ENV,
// Only send errors from production
enabled: process.env.NODE_ENV === "production",
// Filter out common client-side noise
beforeSend(event) {
// Don't send events from browser extensions
if (
event.exception?.values?.some((exception) =>
exception.stacktrace?.frames?.some(
(frame) =>
frame.filename?.includes("chrome-extension://") ||
frame.filename?.includes("moz-extension://")
)
)
) {
return null;
}
return event;
},
// Ignore common benign errors
ignoreErrors: [
// Network errors that happen when user goes offline
"Failed to fetch",
"Load failed",
"NetworkError",
// User cancelled request
"AbortError",
// Browser extensions
"Extension context invalidated",
// React hydration mismatches (usually benign)
"Minified React error",
],
});
}