Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite96a2cd

Browse files
authored
Merge pull request#286 from coderoad/sentry/only-in-prod
sentry only in production
2 parentsb63c31b +18cbb40 commite96a2cd

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

‎src/services/sentry/init.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { init } from '@sentry/node'
22
import{SENTRY_DSN,NODE_ENV}from'../../environment'
33

44
if(SENTRY_DSN){
5-
init({
6-
dsn:SENTRY_DSN,
7-
environment:NODE_ENV,
8-
})
5+
if(NODE_ENV==='production'){
6+
init({
7+
dsn:SENTRY_DSN,
8+
environment:NODE_ENV,
9+
})
10+
}
911
}

‎src/services/sentry/onError.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import*assentryfrom'@sentry/node'
22
// import { Scope } from '@sentry/hub'
3-
import{VERSION}from'../../environment'
3+
import{VERSION,NODE_ENV}from'../../environment'
44

55
constonError=(error:Error)=>{
6-
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
7-
sentry.withScope((scope:any)=>{
8-
scope.setTag('VERSION',VERSION)
9-
// if (user) {
10-
// scope.setUser({
11-
// id: user.id,
12-
// email: user.email || 'unknown',
13-
// })
14-
// }
15-
sentry.captureException(error)
16-
})
6+
if(NODE_ENV==='production'){
7+
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
8+
sentry.withScope((scope:any)=>{
9+
scope.setTag('VERSION',VERSION)
10+
// if (user) {
11+
// scope.setUser({
12+
// id: user.id,
13+
// email: user.email || 'unknown',
14+
// })
15+
// }
16+
sentry.captureException(error)
17+
})
18+
}
1719
}
1820

1921
exportdefaultonError

‎web-app/src/services/sentry/init.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as sentry from '@sentry/browser'
22
import{NODE_ENV,SENTRY_DSN}from'../../environment'
33

44
try{
5-
if(SENTRY_DSN){
5+
if(SENTRY_DSN&&NODE_ENV==='production'){
66
sentry.init({
77
dsn:SENTRY_DSN,
88
environment:NODE_ENV,
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import*assentryfrom'@sentry/browser'
22
// import { Scope } from '@sentry/hub'
3-
import{VERSION}from'../../environment'
3+
import{VERSION,NODE_ENV}from'../../environment'
44

55
constonError=(error:Error)=>{
6-
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
7-
sentry.withScope((scope:any)=>{
8-
scope.setTag('VERSION',VERSION)
9-
// if (user) {
10-
// scope.setUser({
11-
// id: user.id,
12-
// email: user.email || 'unknown',
13-
// })
14-
// }
15-
sentry.captureException(error)
16-
})
6+
if(NODE_ENV==='production'){
7+
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
8+
sentry.withScope((scope:any)=>{
9+
scope.setTag('VERSION',VERSION)
10+
// if (user) {
11+
// scope.setUser({
12+
// id: user.id,
13+
// email: user.email || 'unknown',
14+
// })
15+
// }
16+
sentry.captureException(error)
17+
})
18+
}
1719
}
1820

1921
exportdefaultonError

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp