-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
56 lines (51 loc) · 1.79 KB
/
Copy pathinstrumentation.ts
File metadata and controls
56 lines (51 loc) · 1.79 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
import * as Sentry from '@sentry/nextjs';
import {tracesSampler} from 'sentry-docs/tracesSampler';
export function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampler,
traceLifecycle: 'stream',
enableLogs: true,
debug: false,
environment: process.env.NODE_ENV === 'development' ? 'development' : undefined,
integrations: [Sentry.consoleLoggingIntegration()],
// Filter sensitive metric attributes (no PII in metrics)
beforeSendMetric: metric => {
// Remove any accidentally added PII attributes
if (metric.attributes) {
// Remove user queries if accidentally added
delete metric.attributes.user_query;
// Remove full URLs
delete metric.attributes.full_url;
delete metric.attributes.full_path;
}
return metric;
},
});
}
if (process.env.NEXT_RUNTIME === 'edge') {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampler,
traceLifecycle: 'stream',
enableLogs: true,
debug: false,
environment: process.env.NODE_ENV === 'development' ? 'development' : undefined,
integrations: [Sentry.consoleLoggingIntegration()],
// Filter sensitive metric attributes (no PII in metrics)
beforeSendMetric: metric => {
// Remove any accidentally added PII attributes
if (metric.attributes) {
// Remove user queries if accidentally added
delete metric.attributes.user_query;
// Remove full URLs
delete metric.attributes.full_url;
delete metric.attributes.full_path;
}
return metric;
},
});
}
}
export const onRequestError = Sentry.captureRequestError;