Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"@nestjs/schedule": "^6.0.0",
"@nestjs/swagger": "^11.1.6",
"@nestjs/typeorm": "^11.0.0",
"@sentry/nestjs": "^9.40.0",
"@sentry/profiling-node": "^9.40.0",
"aws-sdk": "^2.1692.0",
"axios": "^1.10.0",
"class-transformer": "^0.5.1",
Expand Down
18 changes: 18 additions & 0 deletions src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
} from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import type { Express } from 'express';
import redoc from 'redoc-express';
import { GlobalResponseInterceptor, HttpExceptionFilter } from '@gglk/common';
Expand Down Expand Up @@ -86,3 +88,19 @@ export function ApplicationSwaggerConfig(app: INestApplication) {
},
});
}

export function ApplicationSentryConfig() {
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
],

sendDefaultPii: true,

// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SentryModule } from '@sentry/nestjs/setup';
import { DataSourceConfigService } from '@gglk/common';
import { EvaluationModule } from '@gglk/evaluation/evaluation.module';
import { PictureModule } from '@gglk/picture/picture.module';
Expand All @@ -21,6 +22,7 @@ import { UserModule } from './user/user.module';
useClass: DataSourceConfigService,
inject: [ConfigService],
}),
SentryModule.forRoot(),
UserModule,
AuthModule,
EvaluationModule,
Expand Down
2 changes: 2 additions & 0 deletions src/common/filter/http-exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
ExceptionFilter,
HttpException,
} from '@nestjs/common';
import { SentryExceptionCaptured } from '@sentry/nestjs';
import { Response } from 'express';
import { BaseException } from '../exception';

@Catch(HttpException)
export class HttpExceptionFilter implements ExceptionFilter {
@SentryExceptionCaptured()
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {
ApplicationNestConfig,
ApplicationRedocConfig,
ApplicationSentryConfig,
ApplicationSwaggerConfig,
} from '@gglk/app.config';
import { AppModule } from '@gglk/app.module';
Expand All @@ -12,8 +13,9 @@
ApplicationNestConfig(app);
ApplicationSwaggerConfig(app);
ApplicationRedocConfig(app);
ApplicationSentryConfig();

await app.listen(process.env.PORT ?? 8000);
}

bootstrap();

Check warning on line 21 in src/main.ts

View workflow job for this annotation

GitHub Actions / validate

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
Loading
Loading