-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
41 lines (36 loc) · 1013 Bytes
/
sentry.server.config.ts
File metadata and controls
41 lines (36 loc) · 1013 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
31
32
33
34
35
36
37
38
39
40
41
import * as Sentry from "@sentry/nextjs";
const dsn = process.env.SENTRY_DSN;
function isRlsViolation(event: Sentry.ErrorEvent): boolean {
return (
event.exception?.values?.some(
(ex) =>
ex.value?.includes("42501") ||
ex.value?.toLowerCase().includes("row-level security") ||
ex.value?.toLowerCase().includes("insufficient privilege")
) ?? false
);
}
if (dsn) {
Sentry.init({
dsn,
tracesSampleRate: 0.2,
environment: process.env.NODE_ENV,
enabled: process.env.NODE_ENV === "production",
beforeSend(event) {
if (event.request?.headers) {
delete event.request.headers["cookie"];
delete event.request.headers["authorization"];
}
if (isRlsViolation(event)) {
event.fingerprint = ["rls-policy-violation-42501"];
event.tags = {
...event.tags,
rls_violation: "true",
sqlstate: "42501",
};
event.level = "fatal";
}
return event;
},
});
}