diff --git a/apps/api/src/app/app.controller.ts b/apps/api/src/app/app.controller.ts index 17d71021..bd03615f 100644 --- a/apps/api/src/app/app.controller.ts +++ b/apps/api/src/app/app.controller.ts @@ -10,4 +10,10 @@ export class AppController { health(): string { return 'UP' } + + @Get('break') + @Public() + break(): string { + throw new Error('Broken') + } } diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 40a9e89e..a184d909 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -46,14 +46,17 @@ class CustomLogger implements LoggerService { async function initializeSentry() { if (!process.env.SENTRY_DSN) { - throw new Error('Missing environment variable: SENTRY_DSN') + Logger.error('Missing environment variable: SENTRY_DSN') + process.exit(1) } + Sentry.init({ dsn: process.env.SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'e2e', environment: process.env.NODE_ENV || 'production', - tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE) || 1.0, - profilesSampleRate: Number(process.env.SENTRY_PROFILES_SAMPLE_RATE) || 1.0, + tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE) || 1.0, + profilesSampleRate: + parseFloat(process.env.SENTRY_PROFILES_SAMPLE_RATE) || 1.0, integrations: [new ProfilingIntegration()], debug: process.env.NODE_ENV.startsWith('dev') }) diff --git a/apps/api/webpack.config.js b/apps/api/webpack.config.js index f9ff52be..9f2033e8 100644 --- a/apps/api/webpack.config.js +++ b/apps/api/webpack.config.js @@ -1,15 +1,18 @@ const { composePlugins, withNx } = require('@nx/webpack') const { sentryWebpackPlugin } = require('@sentry/webpack-plugin') + module.exports = composePlugins( withNx({ target: 'node', devtool: 'source-map', plugins: [ - sentryWebpackPlugin({ - org: process.env.SENTRY_ORG, - project: process.env.SENTRY_PROJECT, - authToken: process.env.SENTRY_AUTH_TOKEN - }) + ...((process.env.NODE_ENV || 'production') === 'production' + ? sentryWebpackPlugin({ + org: process.env.SENTRY_ORG, + project: process.env.SENTRY_PROJECT, + authToken: process.env.SENTRY_AUTH_TOKEN + }) + : []) ] }), (config) => { diff --git a/package.json b/package.json index 5ea798fd..951169eb 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "db:format": "nx run api:prisma:format", "db:reset": "nx run api:prisma:reset", "prepare": "husky install", - "sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist" + "sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist || echo 'Failed to upload source maps to Sentry'" }, "devDependencies": { "@nestjs/schematics": "^10.0.3", diff --git a/tsconfig.base.json b/tsconfig.base.json index a3a3fed6..2083a484 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -8,7 +8,6 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, - "noEmitHelpers": true, "target": "es2015", "module": "esnext", "lib": ["es2020", "dom"],