Skip to content

Commit ca07f5c

Browse files
committed
add web Sentry
1 parent 0213633 commit ca07f5c

File tree

8 files changed

+97
-2
lines changed

8 files changed

+97
-2
lines changed

src/extension.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// init error logging
2+
import './services/sentry/init'
3+
14
import Editor from './editor'
25

36
// vscode editor

src/services/sentry/onError.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as sentry from '@sentry/node'
22
import { Scope } from '@sentry/hub'
33
import environment from '../../environment'
44

5-
const onError = error => {
5+
const onError = (error: Error) => {
66
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
77
sentry.withScope((scope: Scope) => {
88
scope.setTag('VERSION', environment.VERSION)

web-app/package-lock.json

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@alifd/theme-4": "^0.2.3",
3030
"@apollo/react-hooks": "^3.1.3",
3131
"@emotion/core": "^10.0.27",
32+
"@sentry/browser": "^5.11.1",
3233
"apollo-boost": "^0.4.7",
3334
"graphql": "^14.5.8",
3435
"markdown-it": "^10.0.0",

web-app/src/environment.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
// }
77
// }
88

9-
export const GQL_URI: string = process.env.REACT_APP_GQL_URI || 'https://33mf420q4m.execute-api.us-west-2.amazonaws.com/stage/api-stage'
9+
export const GQL_URI: string =
10+
process.env.REACT_APP_GQL_URI || 'https://33mf420q4m.execute-api.us-west-2.amazonaws.com/stage/api-stage'
1011
export const DEBUG: boolean = (process.env.REACT_APP_DEBUG || '').toLowerCase() === 'true'
12+
export const VERSION: string = process.env.VERSION || 'unknown'
13+
export const NODE_ENV: string = process.env.NODE_ENV || 'producton'

web-app/src/index.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import * as React from 'react'
22
import ReactDOM from 'react-dom'
33
import App from './App'
4+
5+
// init error logging
6+
import './services/sentry/init'
7+
// init initial styles
48
import './styles/index.css'
9+
// init listeners
510
import './services/listeners'
611

712
ReactDOM.render(<App />, document.getElementById('root') as HTMLElement)

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

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as sentry from '@sentry/browser'
2+
import { NODE_ENV } from '../../environment'
3+
4+
sentry.init({
5+
dsn: 'https://[email protected]/1889371',
6+
environment: NODE_ENV,
7+
})
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as sentry from '@sentry/node'
2+
import { Scope } from '@sentry/hub'
3+
import { VERSION } from '../../environment'
4+
5+
const onError = (error: Error) => {
6+
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
7+
sentry.withScope((scope: Scope) => {
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+
})
17+
}
18+
19+
export default onError

0 commit comments

Comments
 (0)