Skip to content

Commit

Permalink
refact: implement code suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshPatel5940 committed Feb 17, 2024
1 parent 44ff01b commit 4f4f4ec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
6 changes: 6 additions & 0 deletions apps/api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ export class AppController {
health(): string {
return 'UP'
}

@Get('break')
@Public()
break(): string {
throw new Error('Broken')
}
}
9 changes: 6 additions & 3 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
13 changes: 8 additions & 5 deletions apps/api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"noEmitHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
Expand Down

0 comments on commit 4f4f4ec

Please sign in to comment.