Skip to content

Commit

Permalink
chore: resolve comments
Browse files Browse the repository at this point in the history
* add `sentry_env` instead of `node_env`
  • Loading branch information
HarshPatel5940 committed Feb 18, 2024
1 parent 4f4f4ec commit 4809f31
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SENTRY_PROJECT=
SENTRY_TRACES_SAMPLE_RATE=
SENTRY_PROFILES_SAMPLE_RATE=

SENTRY_ENV=
SMTP_HOST=
SMTP_PORT=
SMTP_EMAIL_ADDRESS=
Expand Down
6 changes: 0 additions & 6 deletions apps/api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ export class AppController {
health(): string {
return 'UP'
}

@Get('break')
@Public()
break(): string {
throw new Error('Broken')
}
}
8 changes: 5 additions & 3 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import * as Sentry from '@sentry/node'
import { ProfilingIntegration } from '@sentry/profiling-node'

export const sentryEnv = process.env.SENTRY_ENV || 'production'

class CustomLogger implements LoggerService {
log(message: string) {
this.info(message)
Expand Down Expand Up @@ -52,13 +54,13 @@ async function initializeSentry() {

Sentry.init({
dsn: process.env.SENTRY_DSN,
enabled: process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'e2e',
environment: process.env.NODE_ENV || 'production',
enabled: sentryEnv !== 'test' && sentryEnv !== 'e2e',
environment: sentryEnv,
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')
debug: process.env.SENTRY_ENV.startsWith('dev')
})
}

Expand Down
15 changes: 9 additions & 6 deletions apps/api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ module.exports = composePlugins(
target: 'node',
devtool: 'source-map',
plugins: [
...((process.env.NODE_ENV || 'production') === 'production'
? sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN
})
...(process.env.SENTRY_ENV === 'production' ||
process.env.SENTRY_ENV === 'stage'
? [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN
})
]
: [])
]
}),
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing-to-keyshade/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ description: Get to know the environment you are working with

Here's the description of the environment variables used in the project. You can find the values for these variables in \`.env.example\`.

* **NODE\_ENV**: The The environment in which the app is running. It can be either 'development', 'production', or 'test'. Please note that it's not mandatory, it will default to "production" enviroment for the sentry configuration.
* **DATABASE\_URL**: The URL of the PSQL database to connect to. This is used by the [Prisma Client](https://www.prisma.io/docs/orm/prisma-client) to connect to the database.
* **SUPABASE\_API\_URL**: The URL of the Supabase API. This is used by the [Supabase Client](https://supabase.io/docs/reference/javascript/supabase-client) to connect to the Supabase API. Make sure you create a Supabase project and get the API URL from the project settings.
* **SUPABASE\_ANON\_KEY**: The anonymous key of the Supabase project. This is used by the Supabase Client to connect to the Supabase API. Make sure you create a Supabase project and get the anonymous key from the project settings.
Expand All @@ -22,6 +21,7 @@ Here's the description of the environment variables used in the project. You can
* **SENTRY\_PROJECT**: The project ID within your Sentry organization where events will be reported.
* **SENTRY\_TRACES\_SAMPLE\_RATE**: The sample rate for collecting transaction traces in Sentry. It determines the percentage of transactions to capture traces for.
* **SENTRY\_PROFILES\_SAMPLE\_RATE**: The sample rate for collecting performance profiles in Sentry. It determines the percentage of requests to capture performance profiles for.
* **SENTRY\_ENV**: The The environment in which the app is running. It can be either 'development', 'production', or 'test'. Please note that it's not mandatory, it will default to "production" enviroment for the sentry configuration.
* **FROM\_EMAIL**: The display of the email sender title.
* **JWT\_SECRET**: The secret used to sign the JWT tokens. It is insignificant in the development environment.
* **WEB\_FRONTEND\_URL, WORKSPACE\_FRONTEND\_URL**: The URLs of the web and workspace frontend respectively. These are used in the emails sometimes and in other spaces of the application too.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
"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 || echo 'Failed to upload source maps to Sentry'"
"sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist || pnpm run sentry:sourcemaps:exit",
"sentry:sourcemaps:exit": "echo 'Failed to upload source maps to Sentry' && exit 1"
},
"devDependencies": {
"@nestjs/schematics": "^10.0.3",
Expand Down

0 comments on commit 4809f31

Please sign in to comment.