-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
30 lines (25 loc) · 931 Bytes
/
sentry.server.config.ts
File metadata and controls
30 lines (25 loc) · 931 Bytes
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
import * as Sentry from '@sentry/nextjs';
import { TRPCError } from '@trpc/server';
import { ErrorWithStatus } from './src/utils';
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
if (SENTRY_DSN) {
if (process.env.NODE_ENV === 'production') {
Sentry.init({
dsn: SENTRY_DSN,
tracesSampleRate: 1.0,
release: process.env.SENTRY_RELEASE,
beforeSend: (event, hint) => {
if (
hint.originalException instanceof TRPCError &&
hint.originalException.code !== 'INTERNAL_SERVER_ERROR'
) {
return null;
}
if (hint.originalException instanceof ErrorWithStatus && hint.originalException.statusCode !== 500) {
return null;
}
return event;
},
});
}
}