-
Notifications
You must be signed in to change notification settings - Fork 2
/
sentry.client.config.ts
86 lines (73 loc) · 2.62 KB
/
sentry.client.config.ts
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
85
86
// This file configures the initialization of Sentry on the client.
// The config you add 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'
import { SENTRY_DSN, sentryIsDev } from './sentry.common'
const breadcrumbsToConsole = false
Sentry.init({
dsn: SENTRY_DSN,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: sentryIsDev,
// Environments are case sensitive. The environment name can't contain newlines, spaces or forward slashes, can't be the string "None", or exceed 64 characters.
environment: process.env.NODE_ENV ?? 'unknown',
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1,
replaysOnErrorSampleRate: 0.1,
// This sets the sample rate to be 1%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.01,
// Only report events to Sentry when not in development
beforeSend(event: Sentry.Event) {
if (!sentryIsDev) {
return null
}
switch (event.level) {
case 'error':
// eslint-disable-next-line no-console
console.error(event)
break
case 'warning':
// eslint-disable-next-line no-console
console.warn(event)
break
case 'info':
// eslint-disable-next-line no-console
console.info(event)
break
default:
// eslint-disable-next-line no-console
console.log(event)
}
return event // Continue with sending the event
},
beforeBreadcrumb(breadcrumb: Sentry.Breadcrumb) {
if (sentryIsDev && breadcrumbsToConsole) {
switch (breadcrumb.level) {
case 'error':
// eslint-disable-next-line no-console
console.error(breadcrumb)
break
case 'warning':
// eslint-disable-next-line no-console
console.warn(breadcrumb)
break
case 'info':
// eslint-disable-next-line no-console
console.info(breadcrumb)
break
default:
// eslint-disable-next-line no-console
console.log(breadcrumb)
}
}
return breadcrumb
},
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
// integrations: [
// new Sentry.Replay({
// // Additional Replay configuration goes in here, for example:
// maskAllText: true,
// blockAllMedia: true,
// }),
// ],
})