Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coderoad/coderoad-vscode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 777d5a3d52a650a64c6664fc3e8c697852a9deb5
Choose a base ref
..
head repository: coderoad/coderoad-vscode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4056f1b20de9f478510b352f0ff82e605ef6464c
Choose a head ref
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@
"watch": "tsc -watch -p ./"
},
"dependencies": {
"@sentry/node": "^5.19.2",
"@types/assert": "^1.5.1",
"@types/jest": "^26.0.4",
"@types/jsdom": "^16.2.3",
@@ -52,7 +51,8 @@
"node-fetch": "^2.6.0",
"semver": "^7.3.2",
"ts-jest": "^26.1.3",
"typescript": "^3.9.7"
"typescript": "^3.9.7",
"vscode-extension-telemetry": "^0.1.6"
},
"devDependencies": {
"eslint-config-prettier": "^6.11.0",
2 changes: 1 addition & 1 deletion src/actions/setupActions.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import * as git from '../services/git'
import loadWatchers from './utils/loadWatchers'
import openFiles from './utils/openFiles'
import runCommands from './utils/runCommands'
import onError from '../services/sentry/onError'
import { onError } from '../services/telemetry'
import logger from '../services/logger'

interface SetupActions {
7 changes: 7 additions & 0 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import { exec } from '../services/node'
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'
import reset from '../services/reset'
import getLastCommitHash from '../services/reset/lastHash'
import { onEvent } from '../services/telemetry'

const readFileAsync = promisify(readFile)

@@ -128,6 +129,12 @@ class Channel implements Channel {
try {
const data: TT.Tutorial = action.payload.tutorial

onEvent('tutorial_start', {
tutorial_id: data.id,
tutorial_version: data.version,
tutorial_title: data.summary.title,
})

// validate extension version
const expectedAppVersion = data.config?.appVersions?.vscode
if (expectedAppVersion) {
11 changes: 10 additions & 1 deletion src/editor/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode'
import { createCommands } from './commands'
import * as telemetry from '../services/telemetry'

class Editor {
// extension context set on activation
@@ -22,17 +23,25 @@ class Editor {
workspaceState: this.vscodeExt.workspaceState,
})

const subscribe = (sub: any) => {
this.vscodeExt.subscriptions.push(sub)
}

// register commands
for (const cmd in commands) {
const command: vscode.Disposable = vscode.commands.registerCommand(cmd, commands[cmd])
this.vscodeExt.subscriptions.push(command)
subscribe(command)
}

telemetry.activate(subscribe)
}
public deactivate = (): void => {
// cleanup subscriptions/tasks
for (const disposable of this.vscodeExt.subscriptions) {
disposable.dispose()
}

telemetry.deactivate()
}
}

9 changes: 5 additions & 4 deletions src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { getWorkspaceRoot } from './services/workspace'
import * as os from 'os'

// CodeRoad version
export const VERSION = 'unknown'
export const VERSION = require('../package.json').version

export const EXTENSION_ID = 'coderoad'

// Node env
export type Env = 'test' | 'local' | 'development' | 'production'
// @ts-ignore
export const NODE_ENV: Env = process.env.NODE_ENV || 'production'
export const NODE_ENV: Env = process.env.NODE_ENV || 'development'

// toggle logging in development
export const LOG = false

// error logging tool
export const SENTRY_DSN: string | null = null
export const INSTRUMENTATION_KEY = '6ff37c76-72f3-48e3-a1b9-d5636f519b7b'

// uri path to the users project workspace
export const WORKSPACE_ROOT: string = getWorkspaceRoot()
3 changes: 0 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// init error logging
import './services/sentry/init'

import Editor from './editor'

// vscode editor
11 changes: 0 additions & 11 deletions src/services/sentry/init.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/services/sentry/onError.ts

This file was deleted.

43 changes: 43 additions & 0 deletions src/services/telemetry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import TelemetryReporter from 'vscode-extension-telemetry'
import { EXTENSION_ID, VERSION, INSTRUMENTATION_KEY, NODE_ENV } from '../../environment'

/**
* Telemetry
* https://github.com/microsoft/vscode-extension-telemetry
*
*/

interface Properties {
[key: string]: string
}

interface Measurements {
[key: string]: number
}

let reporter: any

export const activate = (subscribeFn: (reporter: any) => void): void => {
if (NODE_ENV === 'production') {
reporter = new TelemetryReporter(EXTENSION_ID, VERSION, INSTRUMENTATION_KEY)
subscribeFn(reporter)
}
}

export const deactivate = (): void => {
if (reporter) {
reporter.dispose()
}
}

export const onError = (error: Error, properties?: Properties, measurements?: Measurements): void => {
if (reporter) {
reporter.sendTelemetryException(error, properties, measurements)
}
}

export const onEvent = (eventName: string, properties?: Properties, measurements?: Measurements): void => {
if (reporter) {
reporter.sendTelemetryEvent(eventName, properties, measurements)
}
}
2 changes: 1 addition & 1 deletion src/services/testRunner/index.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import logger from '../logger'
import parser, { ParserOutput } from './parser'
import parseSubtasks from './subtasks'
import { debounce, throttle } from './throttle'
import onError from '../sentry/onError'
import { onError } from '../telemetry'
import { clearOutput, addOutput } from './output'
import { formatFailOutput } from './formatOutput'

2 changes: 1 addition & 1 deletion src/services/webview/render.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSDOM } from 'jsdom'
import * as path from 'path'
import * as vscode from 'vscode'
import onError from '../sentry/onError'
import { onError } from '../telemetry'

const getNonce = (): string => {
let text = ''
Loading