-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry.client.config.ts
More file actions
68 lines (62 loc) · 2.04 KB
/
sentry.client.config.ts
File metadata and controls
68 lines (62 loc) · 2.04 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
67
68
import * as Sentry from "@sentry/nextjs"
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENVIRONMENT,
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.01,
replaysOnErrorSampleRate: 1.0,
// Filter out browser extension errors and other known non-critical errors
ignoreErrors: [
// Browser extension errors
"runtime.sendMessage",
"chrome.runtime",
"browser.runtime",
"Extension context invalidated",
"Non-Error promise rejection captured",
// Network errors that are not actionable
"NetworkError",
"Failed to fetch",
"Load failed",
// Ad blocker related
"AdBlock",
"blocked",
// Third-party script errors
"Script error",
"Javascript error: Do not have Permission",
],
// Filter errors before sending to Sentry
beforeSend(event, hint) {
const error = hint.originalException || hint.syntheticException
const errorMessage =
(error instanceof Error ? error.message : String(error || "")) ||
event.message ||
""
// Ignore browser extension related errors
if (
errorMessage.includes("runtime.sendMessage") ||
errorMessage.includes("Extension context") ||
errorMessage.includes("chrome.runtime") ||
errorMessage.includes("browser.runtime")
) {
return null; // Don't send to Sentry
}
// Ignore errors from browser extensions (check stack trace)
if (event.exception?.values) {
for (const exception of event.exception.values) {
if (exception.stacktrace?.frames) {
for (const frame of exception.stacktrace.frames) {
// Check if error originates from chrome-extension:// or moz-extension://
if (
frame.filename?.includes("chrome-extension://") ||
frame.filename?.includes("moz-extension://") ||
frame.filename?.includes("safari-extension://")
) {
return null; // Don't send to Sentry
}
}
}
}
}
return event; // Send other errors normally
},
})