chore: Do not enable sentry for dev and test environments
This commit is contained in:
@@ -3,10 +3,13 @@ import * as Tracing from '@sentry/tracing';
|
||||
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const isSentryEnabled = !!appConfig.sentryDsn;
|
||||
const isSentryEnabled = () => {
|
||||
if (appConfig.isDev || appConfig.isTest) return false;
|
||||
return !!appConfig.sentryDsn;
|
||||
};
|
||||
|
||||
export function init(app) {
|
||||
if (!isSentryEnabled) return;
|
||||
if (!isSentryEnabled()) return;
|
||||
|
||||
return Sentry.init({
|
||||
enabled: !!appConfig.sentryDsn,
|
||||
@@ -21,19 +24,19 @@ export function init(app) {
|
||||
}
|
||||
|
||||
export function attachRequestHandler(app) {
|
||||
if (!isSentryEnabled) return;
|
||||
if (!isSentryEnabled()) return;
|
||||
|
||||
app.use(Sentry.Handlers.requestHandler());
|
||||
}
|
||||
|
||||
export function attachTracingHandler(app) {
|
||||
if (!isSentryEnabled) return;
|
||||
if (!isSentryEnabled()) return;
|
||||
|
||||
app.use(Sentry.Handlers.tracingHandler());
|
||||
}
|
||||
|
||||
export function attachErrorHandler(app) {
|
||||
if (!isSentryEnabled) return;
|
||||
if (!isSentryEnabled()) return;
|
||||
|
||||
app.use(
|
||||
Sentry.Handlers.errorHandler({
|
||||
@@ -46,7 +49,7 @@ export function attachErrorHandler(app) {
|
||||
}
|
||||
|
||||
export function captureException(exception, captureContext) {
|
||||
if (!isSentryEnabled) return;
|
||||
if (!isSentryEnabled()) return;
|
||||
|
||||
return Sentry.captureException(exception, captureContext);
|
||||
}
|
||||
|
Reference in New Issue
Block a user