-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
47 lines (38 loc) · 1.35 KB
/
sentry.server.config.ts
File metadata and controls
47 lines (38 loc) · 1.35 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
import * as Sentry from '@sentry/astro';
// Initialize Sentry for server-side error tracking
Sentry.init({
dsn: process.env.SENTRY_DSN,
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production (0.1 = 10% of transactions)
tracesSampleRate: 1.0,
// Environment (production, development, staging)
environment: process.env.NODE_ENV || 'production',
// Enable debug mode in development
debug: process.env.NODE_ENV === 'development',
// Attach stack traces to all messages
attachStacktrace: true,
// Ignore certain errors on server
ignoreErrors: [
// Expected errors
'ECONNRESET',
'EPIPE',
'ETIMEDOUT',
],
// Filter sensitive data from events before sending to Sentry
beforeSend(event, hint) {
// Remove sensitive headers
if (event.request?.headers) {
delete event.request.headers['authorization'];
delete event.request.headers['cookie'];
delete event.request.headers['x-api-key'];
}
// Remove sensitive query parameters
if (event.request?.query_string) {
const url = new URLSearchParams(event.request.query_string);
if (url.has('token')) url.delete('token');
if (url.has('api_key')) url.delete('api_key');
event.request.query_string = url.toString();
}
return event;
},
});