diff --git a/src/services/sentry/init.ts b/src/services/sentry/init.ts index ae09f339..db9cceff 100644 --- a/src/services/sentry/init.ts +++ b/src/services/sentry/init.ts @@ -2,8 +2,10 @@ import { init } from '@sentry/node' import { SENTRY_DSN, NODE_ENV } from '../../environment' if (SENTRY_DSN) { - init({ - dsn: SENTRY_DSN, - environment: NODE_ENV, - }) + if (NODE_ENV === 'production') { + init({ + dsn: SENTRY_DSN, + environment: NODE_ENV, + }) + } } diff --git a/src/services/sentry/onError.ts b/src/services/sentry/onError.ts index 111c7ddd..1bda04ab 100644 --- a/src/services/sentry/onError.ts +++ b/src/services/sentry/onError.ts @@ -1,19 +1,21 @@ import * as sentry from '@sentry/node' // import { Scope } from '@sentry/hub' -import { VERSION } from '../../environment' +import { VERSION, NODE_ENV } from '../../environment' const onError = (error: Error) => { - // set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node - sentry.withScope((scope: any) => { - scope.setTag('VERSION', VERSION) - // if (user) { - // scope.setUser({ - // id: user.id, - // email: user.email || 'unknown', - // }) - // } - sentry.captureException(error) - }) + if (NODE_ENV === 'production') { + // set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node + sentry.withScope((scope: any) => { + scope.setTag('VERSION', VERSION) + // if (user) { + // scope.setUser({ + // id: user.id, + // email: user.email || 'unknown', + // }) + // } + sentry.captureException(error) + }) + } } export default onError diff --git a/web-app/src/services/sentry/init.tsx b/web-app/src/services/sentry/init.tsx index 8ec119cd..8f71c272 100644 --- a/web-app/src/services/sentry/init.tsx +++ b/web-app/src/services/sentry/init.tsx @@ -2,7 +2,7 @@ import * as sentry from '@sentry/browser' import { NODE_ENV, SENTRY_DSN } from '../../environment' try { - if (SENTRY_DSN) { + if (SENTRY_DSN && NODE_ENV === 'production') { sentry.init({ dsn: SENTRY_DSN, environment: NODE_ENV, diff --git a/web-app/src/services/sentry/onError.ts b/web-app/src/services/sentry/onError.ts index e079970f..94abb9df 100644 --- a/web-app/src/services/sentry/onError.ts +++ b/web-app/src/services/sentry/onError.ts @@ -1,19 +1,21 @@ import * as sentry from '@sentry/browser' // import { Scope } from '@sentry/hub' -import { VERSION } from '../../environment' +import { VERSION, NODE_ENV } from '../../environment' const onError = (error: Error) => { - // set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node - sentry.withScope((scope: any) => { - scope.setTag('VERSION', VERSION) - // if (user) { - // scope.setUser({ - // id: user.id, - // email: user.email || 'unknown', - // }) - // } - sentry.captureException(error) - }) + if (NODE_ENV === 'production') { + // set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node + sentry.withScope((scope: any) => { + scope.setTag('VERSION', VERSION) + // if (user) { + // scope.setUser({ + // id: user.id, + // email: user.email || 'unknown', + // }) + // } + sentry.captureException(error) + }) + } } export default onError