fix: sentry init is using the wrong environment (#4940)

In the previous PR #4912 it seems that I forgot to pass the environment
on the backend.
Here is a quick fix!

I also added some "doc" in the the .env.example
This commit is contained in:
Quentin G 2024-04-12 12:27:35 +02:00 committed by GitHub
parent f47fe62742
commit a6b38d76ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 3 deletions

View File

@ -152,7 +152,10 @@ import TabItem from '@theme/TabItem';
['LOGGER_IS_BUFFER_ENABLED', 'true', 'Buffer the logs before sending them to the logging driver'],
['LOG_LEVELS', 'error,warn', "The loglevels which are logged to the logging driver. Can include: 'log', 'warn', 'error'"],
['EXCEPTION_HANDLER_DRIVER', 'sentry', "The exception handler driver can be: 'console' or 'sentry'"],
['SENTRY_ENVIRONMENT', 'main', 'The sentry environment used if sentry logging driver is selected'],
['SENTRY_RELEASE', 'latest', 'The sentry release used if sentry logging driver is selected'],
['SENTRY_DSN', 'https://xxx@xxx.ingest.sentry.io/xxx', 'The sentry logging endpoint used if sentry logging driver is selected'],
['SENTRY_FRONT_DSN', 'https://xxx@xxx.ingest.sentry.io/xxx', 'The sentry logging endpoint used by the frontend if sentry logging driver is selected'],
]}></OptionTable>

View File

@ -39,7 +39,10 @@ SIGN_IN_PREFILLED=true
# LOGGER_DRIVER=console
# LOGGER_IS_BUFFER_ENABLED=true
# EXCEPTION_HANDLER_DRIVER=sentry
# SENTRY_ENVIRONMENT=main
# SENTRY_RELEASE=latest
# SENTRY_DSN=https://xxx@xxx.ingest.sentry.io/xxx
# SENTRY_FRONT_DSN=https://xxx@xxx.ingest.sentry.io/xxx
# LOG_LEVELS=error,warn
# MESSAGE_QUEUE_TYPE=pg-boss
# REDIS_HOST=127.0.0.1

View File

@ -41,7 +41,7 @@ export class ClientConfigResolver {
sentry: {
environment: this.environmentService.get('SENTRY_ENVIRONMENT'),
release: this.environmentService.get('SENTRY_RELEASE'),
dsn: this.environmentService.get('SENTRY_DSN_FRONT'),
dsn: this.environmentService.get('SENTRY_FRONT_DSN'),
},
};

View File

@ -235,7 +235,7 @@ export class EnvironmentVariables {
(env) => env.EXCEPTION_HANDLER_DRIVER === ExceptionHandlerDriver.Sentry,
)
@IsString()
SENTRY_DSN_FRONT: string;
SENTRY_FRONT_DSN: string;
@ValidateIf(
(env) => env.EXCEPTION_HANDLER_DRIVER === ExceptionHandlerDriver.Sentry,

View File

@ -14,6 +14,7 @@ export class ExceptionHandlerSentryDriver
{
constructor(options: ExceptionHandlerSentryDriverFactoryOptions['options']) {
Sentry.init({
environment: options.environment,
release: options.release,
dsn: options.dsn,
integrations: [
@ -25,7 +26,6 @@ export class ExceptionHandlerSentryDriver
],
tracesSampleRate: 0.1,
profilesSampleRate: 0.3,
environment: options.debug ? 'development' : 'production',
debug: options.debug,
});
}