Repository navigation
Expand file tree
/
Copy pathinstrumentation-client.ts
More file actions
84 lines (61 loc) · 2.5 KB
/
Copy pathinstrumentation-client.ts
File metadata and controls
84 lines (61 loc) · 2.5 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
76
77
78
79
80
81
82
83
84
// This file configures the initialization of Sentry on the client.
// The added config here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
export const isProduction = process.env.NODE_ENV === "production";
export const isDevelopment = process.env.NODE_ENV === "development";
const getEnvironmentConfig = () => {
if (isProduction) {
return {
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 0.1,
// Define how likely Replay events are sampled.
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaySessionSampleRate: 0.01,
sampleRate: 1.0,
// Enable logs to be sent to Sentry
enableLogs: false,
};
}
if (isDevelopment) {
return {
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1.0,
// Define how likely Replay events are sampled.
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaySessionSampleRate: 0.1,
sampleRate: 1.0,
// Enable logs to be sent to Sentry
enableLogs: true,
};
}
};
const config = getEnvironmentConfig();
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
environment: process.env.NODE_ENV,
...config,
// Add optional integrations for additional features
integrations: [Sentry.replayIntegration()],
// Define how likely Replay events are sampled when an error occurs.
replaysOnErrorSampleRate: 1.0,
// Enable sending user PII (Personally Identifiable Information)
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
sendDefaultPii: false,
// 트랜잭션 데이터 보내기 직전에 실행되는 메서드로 보낼 데이터를 필터링
beforeSendTransaction(event) {
const transactionName = event.transaction;
const ignoredTransactions = ["/_next/static", "/favicon.ico"];
if (ignoredTransactions.some((ignored) => transactionName?.includes(ignored))) {
return null;
}
const duration = event.timestamp! - event.start_timestamp!;
if (duration < 100) {
return Math.random() < 0.01 ? event : null;
}
return event;
},
});
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;