forked from cocor-tech/moistello-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry.client.config.ts
More file actions
39 lines (37 loc) · 1.24 KB
/
Copy pathsentry.client.config.ts
File metadata and controls
39 lines (37 loc) · 1.24 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
import * as Sentry from "@sentry/nextjs"
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN
if (dsn) {
Sentry.init({
dsn,
environment: process.env.NODE_ENV ?? "production",
tracesSampleRate: 0.1,
beforeSend(event: any) {
if (event.request?.url) {
event.request.url = event.request.url.replace(
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
"[email]"
)
}
if (event.exception?.values) {
for (const exc of event.exception.values) {
if (exc.value) {
exc.value = exc.value
.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, "[email]")
.replace(/G[A-Za-z0-9]{55}/g, "[stellar-address]")
.replace(/0x[a-fA-F0-9]{40}/g, "[evm-address]")
}
}
}
return event
},
beforeBreadcrumb(breadcrumb: any) {
if (breadcrumb.message) {
breadcrumb.message = breadcrumb.message
.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, "[email]")
}
return breadcrumb
},
})
} else {
console.warn("[Sentry] NEXT_PUBLIC_SENTRY_DSN not configured. Error monitoring is disabled. Set NEXT_PUBLIC_SENTRY_DSN in your environment to enable Sentry error tracking.")
}