Skip to content

Commit 9c95528

Browse files
authored
Merge pull request coderoad#80 from ShMcK/feature/sentry
Feature/sentry
2 parents e2e100a + 8c07886 commit 9c95528

File tree

27 files changed

+631
-950
lines changed

27 files changed

+631
-950
lines changed

package-lock.json

Lines changed: 354 additions & 869 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"watch": "tsc -watch -p ./"
3232
},
3333
"dependencies": {
34+
"@sentry/electron": "^1.2.0",
35+
"@sentry/node": "^5.11.0",
3436
"chokidar": "^3.3.0",
3537
"dotenv": "^8.2.0",
3638
"jsdom": "^15.2.1"
@@ -48,6 +50,7 @@
4850
"eslint": "^6.8.0",
4951
"eslint-config-prettier": "^6.9.0",
5052
"eslint-plugin-prettier": "^3.1.2",
53+
"graphql": "^14.5.8",
5154
"prettier": "^1.19.1",
5255
"ts-jest": "^24.3.0",
5356
"typescript": "^3.7.4",

src/actions/setupActions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as git from '../services/git'
44
import loadWatchers from './utils/loadWatchers'
55
import openFiles from './utils/openFiles'
66
import runCommands from './utils/runCommands'
7+
import onError from '../services/sentry/onError'
78

89
const setupActions = async (
910
workspaceRoot: vscode.WorkspaceFolder,
@@ -16,7 +17,7 @@ const setupActions = async (
1617
if (commits) {
1718
for (const commit of commits) {
1819
// TODO handle git errors
19-
await git.loadCommit(commit)
20+
await git.loadCommit(commit).catch(onError)
2021
}
2122
}
2223

@@ -27,7 +28,7 @@ const setupActions = async (
2728
loadWatchers(watchers || [], workspaceRoot.uri)
2829

2930
// 4. run command
30-
await runCommands(commands || [], send)
31+
await runCommands(commands || [], send).catch(onError)
3132
}
3233

3334
export default setupActions

src/actions/solutionActions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import * as T from 'typings'
22
import * as vscode from 'vscode'
33
import * as git from '../services/git'
44
import setupActions from './setupActions'
5+
import onError from '../services/sentry/onError'
56

67
const solutionActions = async (
78
workspaceRoot: vscode.WorkspaceFolder,
89
stepActions: T.StepActions,
910
send: (action: T.Action) => void,
1011
): Promise<void> => {
1112
await git.clear()
12-
return setupActions(workspaceRoot, stepActions, send)
13+
return setupActions(workspaceRoot, stepActions, send).catch(onError)
1314
}
1415

1516
export default solutionActions

src/actions/tutorialConfig.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from 'vscode'
44
import { COMMANDS } from '../editor/commands'
55
import languageMap from '../editor/languageMap'
66
import * as git from '../services/git'
7+
import onError from '../services/sentry/onError'
78

89
interface TutorialConfigParams {
910
config: T.TutorialConfig
@@ -13,13 +14,14 @@ interface TutorialConfigParams {
1314

1415
const tutorialConfig = async (
1516
{ config, alreadyConfigured }: TutorialConfigParams,
16-
onError: (msg: T.ErrorMessage) => void,
17+
handleError: (msg: T.ErrorMessage) => void,
1718
) => {
1819
if (!alreadyConfigured) {
1920
// setup git, add remote
2021
await git.initIfNotExists().catch(error => {
22+
onError(new Error('Git not found'))
2123
// failed to setup git
22-
onError({
24+
handleError({
2325
title: error.message,
2426
description:
2527
'Be sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',
@@ -28,7 +30,8 @@ const tutorialConfig = async (
2830

2931
// TODO if remote not already set
3032
await git.setupRemote(config.repo.uri).catch(error => {
31-
onError({ title: error.message, description: 'Remove your current Git project and restarting' })
33+
onError(error)
34+
handleError({ title: error.message, description: 'Remove your current Git project and restarting' })
3235
})
3336
}
3437

src/environment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ require('dotenv').config({
33
})
44

55
interface Environment {
6+
VERSION: string
7+
NODE_ENV: string
68
LOG: boolean
79
}
810

911
const environment: Environment = {
12+
VERSION: process.env.VERSION || 'unknown',
13+
NODE_ENV: process.env.NODE_ENV || 'production',
1014
LOG: (process.env.LOG || '').toLowerCase() === 'true',
1115
}
1216

src/extension.ts

Lines changed: 3 additions & 0 deletions
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/git/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import node from '../node'
22
import logger from '../logger'
3+
import onError from '../sentry/onError'
34

45
const gitOrigin = 'coderoad'
56

@@ -76,13 +77,18 @@ export async function version(): Promise<string | boolean> {
7677
return `${major}${minor}${patch}`
7778
}
7879
}
79-
throw new Error('Git not installed. Please install Git')
80+
const message = 'Git not installed. Please install Git'
81+
const error = new Error(message)
82+
onError(error)
83+
throw error
8084
}
8185

8286
async function init(): Promise<void> {
8387
const { stderr } = await node.exec('git init')
8488
if (stderr) {
85-
throw new Error('Error initializing Git')
89+
const error = new Error('Error initializing Git')
90+
onError(error)
91+
throw error
8692
}
8793
}
8894

src/services/node/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fs from 'fs'
33
import { join } from 'path'
44
import { promisify } from 'util'
55
import * as vscode from 'vscode'
6+
import onError from '../sentry/onError'
67

78
const asyncExec = promisify(cpExec)
89

@@ -12,7 +13,9 @@ class Node {
1213
// set workspace root for node executions
1314
const workspaceRoots: vscode.WorkspaceFolder[] | undefined = vscode.workspace.workspaceFolders
1415
if (!workspaceRoots || !workspaceRoots.length) {
15-
throw new Error('No workspace root path')
16+
const error = new Error('No workspace root path')
17+
onError(error)
18+
throw error
1619
}
1720
const workspaceRoot: vscode.WorkspaceFolder = workspaceRoots[0]
1821
this.workspaceRootPath = workspaceRoot.uri.path

src/services/sentry/init.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { init } from '@sentry/node'
2+
import environment from '../../environment'
3+
4+
init({
5+
dsn: 'https://df4a6ae19e8b44ed9a87ae4432dab9df@sentry.io/1889368',
6+
environment: environment.NODE_ENV,
7+
})

0 commit comments

Comments
 (0)