diff --git a/package-lock.json b/package-lock.json index a2521f9..ac4e703 100644 --- a/package-lock.json +++ b/package-lock.json @@ -167,13 +167,14 @@ } }, "applicationinsights": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/applicationinsights/-/applicationinsights-1.0.8.tgz", - "integrity": "sha512-KzOOGdphOS/lXWMFZe5440LUdFbrLpMvh2SaRxn7BmiI550KAoSb2gIhiq6kJZ9Ir3AxRRztjhzif+e5P5IXIg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/applicationinsights/-/applicationinsights-1.7.4.tgz", + "integrity": "sha512-XFLsNlcanpjFhHNvVWEfcm6hr7lu9znnb6Le1Lk5RE03YUV9X2B2n2MfM4kJZRrUdV+C0hdHxvWyv+vWoLfY7A==", "requires": { + "cls-hooked": "^4.2.2", + "continuation-local-storage": "^3.2.1", "diagnostic-channel": "0.2.0", - "diagnostic-channel-publishers": "0.2.1", - "zone.js": "0.7.6" + "diagnostic-channel-publishers": "^0.3.3" } }, "argparse": { @@ -206,6 +207,14 @@ "lodash": "^4.14.0" } }, + "async-hook-jl": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/async-hook-jl/-/async-hook-jl-1.7.6.tgz", + "integrity": "sha512-gFaHkFfSxTjvoxDMYqDuGHlcRyUuamF8s+ZTtJdDzqjws4mCt7v0vuV79/E2Wr2/riMQgtG4/yUtXWs1gZ7JMg==", + "requires": { + "stack-chain": "^1.3.7" + } + }, "async-listener": { "version": "0.6.10", "resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.6.10.tgz", @@ -377,6 +386,16 @@ } } }, + "cls-hooked": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/cls-hooked/-/cls-hooked-4.2.2.tgz", + "integrity": "sha512-J4Xj5f5wq/4jAvcdgoGsL3G103BtWpZrMo8NEinRltN+xpTZdI+M38pyQqhuFU/P792xkMFvnKSf+Lm81U1bxw==", + "requires": { + "async-hook-jl": "^1.7.6", + "emitter-listener": "^1.0.1", + "semver": "^5.4.1" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -482,9 +501,9 @@ } }, "diagnostic-channel-publishers": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.2.1.tgz", - "integrity": "sha1-ji1geottef6IC1SLxYzGvrKIxPM=" + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.5.tgz", + "integrity": "sha512-AOIjw4T7Nxl0G2BoBPhkQ6i7T4bUd9+xvdYizwvG7vVAM1dvr+SDrcUudlmzwH0kbEwdR2V1EcnKT0wAeYLQNQ==" }, "diff": { "version": "4.0.1", @@ -1451,6 +1470,11 @@ "tweetnacl": "~0.14.0" } }, + "stack-chain": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", + "integrity": "sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU=" + }, "stealthy-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", @@ -1633,27 +1657,26 @@ } }, "vscode-extension-telemetry": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.1.1.tgz", - "integrity": "sha512-TkKKG/B/J94DP5qf6xWB4YaqlhWDg6zbbqVx7Bz//stLQNnfE9XS1xm3f6fl24c5+bnEK0/wHgMgZYKIKxPeUA==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.1.6.tgz", + "integrity": "sha512-rbzSg7k4NnsCdF4Lz0gI4jl3JLXR0hnlmfFgsY8CSDYhXgdoIxcre8jw5rjkobY0xhSDhbG7xCjP8zxskySJ/g==", "requires": { - "applicationinsights": "1.0.8" + "applicationinsights": "1.7.4" } }, "vscode-extension-telemetry-wrapper": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/vscode-extension-telemetry-wrapper/-/vscode-extension-telemetry-wrapper-0.3.9.tgz", - "integrity": "sha512-zKm6lOroUdjI3JOIKP/m4bCrnQHHGemkLIB+DvYWobUd6etGEzqtcCmR+ZqVGII/fR6OB4oWAAwmflaaNpTOFg==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/vscode-extension-telemetry-wrapper/-/vscode-extension-telemetry-wrapper-0.8.0.tgz", + "integrity": "sha512-z+PAc7QAMeTZU0Kq0oBn7DVinJDLtyK5DNZV0dSkclXPYlIVAalE5iEWBChXgANxaMWCyJQqCEI60zlZ7r7C/A==", "requires": { - "continuation-local-storage": "^3.2.1", - "uuid": "^3.3.2", - "vscode-extension-telemetry": "^0.1.1" + "uuid": "^3.4.0", + "vscode-extension-telemetry": "^0.1.6" }, "dependencies": { "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" } } }, @@ -1878,11 +1901,6 @@ "lodash": "^4.17.15", "yargs": "^13.3.0" } - }, - "zone.js": { - "version": "0.7.6", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.7.6.tgz", - "integrity": "sha1-+7w50+AmHQmG8boGMG6zrrDSIAk=" } } } diff --git a/package.json b/package.json index 4cb039b..30031fd 100644 --- a/package.json +++ b/package.json @@ -166,7 +166,7 @@ "ms-rest-azure": "^2.5.7", "opn": "5.1.0", "request-promise": "4.2.1", - "vscode-extension-telemetry-wrapper": "^0.3.9" + "vscode-extension-telemetry-wrapper": "^0.8.0" }, "extensionDependencies": [ "ms-vscode.azure-account" diff --git a/src/cloudShell.ts b/src/cloudShell.ts index 22275fd..d1b3805 100644 --- a/src/cloudShell.ts +++ b/src/cloudShell.ts @@ -9,7 +9,7 @@ import * as fsExtra from "fs-extra"; import * as path from "path"; import { MessageItem } from "vscode"; import * as vscode from "vscode"; -import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper"; +import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { AzureAccount, CloudShell } from "./azure-account.api"; import { BaseShell } from "./baseShell"; import { aciConfig, Constants, exportContainerCmd, exportTestScript } from "./constants"; @@ -152,7 +152,7 @@ export class AzureCloudShell extends BaseShell { this.terminal.show(); if (!await this.cloudShell.waitForConnection()) { vscode.window.showErrorMessage("Establish connection to Cloud Shell failed, please try again later."); - TelemetryWrapper.error("connectFail"); + TelemetryWrapper.sendError(Error("connectFail")); return false; } @@ -165,7 +165,7 @@ export class AzureCloudShell extends BaseShell { this.terminal.sendText(`${command}`); return true; } - TelemetryWrapper.error("sendToTerminalFail"); + TelemetryWrapper.sendError(Error("sendToTerminalFail")); return false; } diff --git a/src/extension.ts b/src/extension.ts index 174b33f..5a632d3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,7 +7,7 @@ import * as _ from "lodash"; import * as vscode from "vscode"; -import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper"; +import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { TerraformCommand } from "./shared"; import { TestOption } from "./shared"; import { terraformShellManager } from "./terraformShellManager"; @@ -20,34 +20,34 @@ let fileWatcher: vscode.FileSystemWatcher; export async function activate(ctx: vscode.ExtensionContext) { await checkTerraformInstalled(); - await TelemetryWrapper.initilizeFromJsonFile(ctx.asAbsolutePath("./package.json")); + await TelemetryWrapper.initializeFromJsonFile(ctx.asAbsolutePath("./package.json")); initFileWatcher(ctx); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.init", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.init", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Init); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.plan", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.plan", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Plan); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.apply", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.apply", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Apply); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.destroy", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.destroy", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Destroy); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.refresh", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.refresh", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Refresh); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.validate", () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.validate", () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Validate); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.visualize", async () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.visualize", async () => { if (isTerminalSetToCloudShell()) { const choice: vscode.MessageItem = await vscode.window.showInformationMessage( "Visualization only works locally. Would you like to run it in the integrated terminal?", @@ -76,7 +76,7 @@ export async function activate(ctx: vscode.ExtensionContext) { await terraformShellManager.getShell().runTerraformTests(pick, workingDirectory); })); - ctx.subscriptions.push(TelemetryWrapper.registerCommand("azureTerraform.push", async () => { + ctx.subscriptions.push(TelemetryWrapper.instrumentOperationAsVsCodeCommand("azureTerraform.push", async () => { if (!isTerminalSetToCloudShell()) { vscode.window.showErrorMessage("Push function only available when using cloudshell."); return; diff --git a/src/integratedShell.ts b/src/integratedShell.ts index 1bce1f8..bb29027 100644 --- a/src/integratedShell.ts +++ b/src/integratedShell.ts @@ -10,7 +10,7 @@ import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; import { commands, Uri, ViewColumn } from "vscode"; -import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper"; +import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { BaseShell } from "./baseShell"; import { Constants } from "./constants"; import { TestOption } from "./shared"; @@ -27,12 +27,12 @@ export class IntegratedShell extends BaseShell { // Creates a png of terraform resource graph to visualize the resources under management. public async visualize(): Promise { if (!await isDotInstalled()) { - TelemetryWrapper.error("dotNotInstalled"); + TelemetryWrapper.sendError(Error("dotNotInstalled")); return; } const cwd: string = await selectWorkspaceFolder(); if (!cwd) { - TelemetryWrapper.error("noWorkspaceSelected"); + TelemetryWrapper.sendError(Error("noWorkspaceSelected")); return; } await this.deletePng(cwd); @@ -60,7 +60,7 @@ export class IntegratedShell extends BaseShell { public async runTerraformTests(TestType: string, workingDirectory: string) { if (!await isDockerInstalled()) { - TelemetryWrapper.error("dockerNotInstalled"); + TelemetryWrapper.sendError(Error("dockerNotInstalled")); return; } const containerName: string = settingUtils.getImageNameForTest(); diff --git a/src/terraformShellManager.ts b/src/terraformShellManager.ts index 1f7a3ef..f37931c 100644 --- a/src/terraformShellManager.ts +++ b/src/terraformShellManager.ts @@ -5,7 +5,7 @@ "use strict"; -import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper"; +import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { BaseShell } from "./baseShell"; import { AzureCloudShell } from "./cloudShell"; import { IntegratedShell } from "./integratedShell"; @@ -24,11 +24,8 @@ class TerraformShellManager implements ITerraformShellManager { public getShell(): BaseShell { const isCloudShell: boolean = isTerminalSetToCloudShell(); - const session = TelemetryWrapper.currentSession(); - if (session && session.extraProperties) { - session.extraProperties.isCloudShell = isCloudShell; - } + TelemetryWrapper.addContextProperty("isCloudShell", isCloudShell.toString()); if (isCloudShell) { return this.cloudShell; } diff --git a/src/utils/cloudShellUtils.ts b/src/utils/cloudShellUtils.ts index 7c20a3b..b49b957 100644 --- a/src/utils/cloudShellUtils.ts +++ b/src/utils/cloudShellUtils.ts @@ -6,7 +6,7 @@ "use strict"; import * as request from "request-promise"; -import { TelemetryWrapper } from "vscode-extension-telemetry-wrapper"; +import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { AzureSession, CloudShell } from "../azure-account.api"; export interface IStorageAccount { @@ -21,7 +21,7 @@ export async function getStorageAccountforCloudShell(cloudShell: CloudShell): Pr const token: IToken = await acquireToken(session); const userSettings: IUserSettings | undefined = await getUserSettings(token.accessToken, session.environment.resourceManagerEndpointUrl); if (!userSettings) { - TelemetryWrapper.error("getUserSettingsFail"); + TelemetryWrapper.sendError(Error("getUserSettingsFail")); return; } const storageProfile: any = userSettings.storageProfile; @@ -29,7 +29,7 @@ export async function getStorageAccountforCloudShell(cloudShell: CloudShell): Pr const storageAccountKey: string | undefined = await getStorageAccountKey(token.accessToken, storageAccountSettings[1], storageAccountSettings[3], storageAccountSettings[7]); if (!storageAccountKey) { - TelemetryWrapper.error("getStorageAccountKeyFail"); + TelemetryWrapper.sendError(Error("getStorageAccountKeyFail")); return; }