Skip to content

Commit

Permalink
issue 191 premilinary research into using nestjs-sentry package
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Apr 3, 2024
1 parent ccd4938 commit 5266741
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .sentryclirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

[auth]
token=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
58 changes: 15 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module } from "@nestjs/common";
import { SentryModule } from "@ntegral/nestjs-sentry";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { ConfigModule } from "@nestjs/config";
Expand All @@ -12,7 +13,6 @@ import { ZoningDistrictModule } from "./zoning-district/zoning-district.module";
import { DbConfig, FeatureFlagConfig, StorageConfig } from "./config";
import { GlobalModule } from "./global/global.module";
import { ZoningDistrictClassModule } from "./zoning-district-class/zoning-district-class.module";

@Module({
imports: [
ConfigModule.forRoot({
Expand All @@ -35,6 +35,13 @@ import { ZoningDistrictClassModule } from "./zoning-district-class/zoning-distri
rootPath: join(__dirname, "..", "openapi"),
exclude: ["/api/(.*)"],
}),
SentryModule.forRoot({
dsn: process.env.SENTRY_DSN,
debug: true,
maxBreadcrumbs: 50,
environment: process.env.SENTRY_ENVIRONMENT,
logLevels: ["error"], //based on sentry.io loglevel //
}),
GlobalModule,
BoroughModule,
LandUseModule,
Expand Down
3 changes: 2 additions & 1 deletion src/global/global.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Global, Module } from "@nestjs/common";
import { DB, DbProvider } from "src/global/providers/db.provider";
import { SentryProvider } from "./providers/sentry-provider";

@Global()
@Module({
providers: [DbProvider],
providers: [DbProvider, SentryProvider],
exports: [DB],
})
export class GlobalModule {}
16 changes: 16 additions & 0 deletions src/global/providers/sentry-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { HttpException } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { SentryInterceptor } from "@ntegral/nestjs-sentry";

export const SentryProvider = {
provide: APP_INTERCEPTOR,
useFactory: () =>
new SentryInterceptor({
filters: [
{
type: HttpException,
filter: (exception: HttpException) => 500 > exception.getStatus(), // Only report 500 errors
},
],
}),
};

0 comments on commit 5266741

Please sign in to comment.