-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstrumentation-client.ts
More file actions
75 lines (63 loc) · 2.18 KB
/
instrumentation-client.ts
File metadata and controls
75 lines (63 loc) · 2.18 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
69
70
71
72
73
74
75
// biome-ignore lint/performance/noNamespaceImport: Sentry SDK requires namespace import
import * as Sentry from '@sentry/nextjs';
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN;
const sentryEnabled = Boolean(dsn) && process.env.NEXT_PUBLIC_SENTRY_ENABLED !== 'false';
const sentryDebug = process.env.NEXT_PUBLIC_SENTRY_DEBUG === 'true';
Sentry.init({
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT ?? process.env.NODE_ENV,
dsn,
// Enable whenever DSN exists unless explicitly disabled
enabled: sentryEnabled,
// Opt-in verbose SDK logs when troubleshooting
debug: sentryDebug,
// Sample rate for error events (1.0 = 100%)
sampleRate: 1.0,
// Disable performance monitoring (not needed, saves quota)
tracesSampleRate: 0,
// Disable session replay (privacy)
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
// Capture console.error as breadcrumbs
integrations: [
Sentry.breadcrumbsIntegration({
console: true,
dom: true,
fetch: true,
history: true,
}),
],
// Scrub sensitive data before sending
beforeSend(event) {
// Remove any potential sensitive data
if (event.request?.data) {
event.request.data = '[Filtered]';
}
// Scrub sensitive headers (same as server config)
if (event.request?.headers) {
const filtered = { ...event.request.headers };
for (const key of ['authorization', 'cookie', 'set-cookie']) {
if (key in filtered) filtered[key] = '[Filtered]';
}
event.request.headers = filtered;
}
return event;
},
// Ignore errors from browser extensions (by source URL)
denyUrls: [/extensions\//i, /^chrome-extension:\/\//, /^moz-extension:\/\//],
// Ignore common non-actionable errors
ignoreErrors: [
// Network errors (user's connection)
'Network request failed',
'Failed to fetch',
'Load failed',
// User rejected wallet actions (not bugs)
'User rejected',
'User denied',
'user rejected transaction',
// WalletConnect noise
'Missing or invalid topic',
'Pairing already exists',
],
});
// Required for Next.js navigation instrumentation
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;