Skip to content

sentry only in production #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/services/sentry/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
26 changes: 14 additions & 12 deletions src/services/sentry/onError.ts
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion web-app/src/services/sentry/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 14 additions & 12 deletions web-app/src/services/sentry/onError.ts
Original file line number Diff line number Diff line change
@@ -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