The app is now wired to GlitchTip with the Sentry SDKs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { ThrottlerModule } from '@nestjs/throttler';
|
||||
import { SentryModule } from '@sentry/nestjs/setup';
|
||||
import configurations from './configs/configurations';
|
||||
import { AuthModule } from './modules/auth/auth.module';
|
||||
import { AppController } from './app.controller';
|
||||
@@ -25,6 +26,7 @@ import { VoiceModule } from './modules/voice/voice.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
SentryModule.forRoot(),
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [configurations],
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
HttpStatus,
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import * as Sentry from '@sentry/nestjs';
|
||||
import type { Response } from 'express';
|
||||
import { AppException, type AppErrorResponse } from './app.exception';
|
||||
import { ErrorCode, type ErrorCodeValue } from './error-codes';
|
||||
@@ -42,6 +43,9 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
this.logger.error(
|
||||
exception instanceof Error ? exception.stack : String(exception),
|
||||
);
|
||||
if (Sentry.getClient()) {
|
||||
Sentry.captureException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
response.status(statusCode).json(body);
|
||||
|
||||
36
backend/src/instrument.ts
Normal file
36
backend/src/instrument.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { config } from 'dotenv';
|
||||
import * as Sentry from '@sentry/nestjs';
|
||||
|
||||
config();
|
||||
|
||||
const dsn = process.env.SENTRY_DSN?.trim();
|
||||
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
environment:
|
||||
process.env.SENTRY_ENVIRONMENT?.trim() ||
|
||||
process.env.NODE_ENV ||
|
||||
'development',
|
||||
release: process.env.SENTRY_RELEASE?.trim() || undefined,
|
||||
sendDefaultPii: false,
|
||||
tracesSampleRate: 0,
|
||||
beforeSend(event) {
|
||||
if (event.request) {
|
||||
delete event.request.cookies;
|
||||
delete event.request.data;
|
||||
if (event.request.headers) {
|
||||
delete event.request.headers.cookie;
|
||||
delete event.request.headers.authorization;
|
||||
delete event.request.headers.Authorization;
|
||||
}
|
||||
}
|
||||
if (event.user) {
|
||||
delete event.user.email;
|
||||
delete event.user.ip_address;
|
||||
delete event.user.username;
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// backend/src/main.ts
|
||||
import './instrument';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { urlencoded } from 'express';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
Reference in New Issue
Block a user