Skip to content

Telemetry #394

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 3 commits into from
Jul 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
log tutorial start
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 18, 2020
commit f457a0100fd96f737244002c41b04376706b723e
7 changes: 7 additions & 0 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ 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()
telemetry.activate(subscribe)
}
public deactivate = (): void => {
// cleanup subscriptions/tasks
Expand Down
2 changes: 1 addition & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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
Expand Down
3 changes: 2 additions & 1 deletion src/services/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ interface Measurements {

let reporter: any

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

Expand Down