Skip to content

Commit

Permalink
Debug telemetry reporter (#348)
Browse files Browse the repository at this point in the history
* Debug telemetry reporter

* Adjust to ui changes

* Fix dependence
  • Loading branch information
StephenWeatherford authored Aug 2, 2018
1 parent 6657cf4 commit 084db32
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
8 changes: 6 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"--extensionDevelopmentPath=${workspaceRoot}"
],
"env": {
"NO_TIMEOUTS": "1",
"DEBUGTELEMETRY": "1"
},
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -35,7 +35,11 @@
"outFiles": [
"${workspaceRoot}/out/test"
],
"preLaunchTask": "npm"
"preLaunchTask": "npm",
"env": {
"NO_TIMEOUTS": "1",
"DEBUGTELEMETRY": "1"
}
}
]
}
8 changes: 5 additions & 3 deletions dockerExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as opn from 'opn';
import * as path from 'path';
import * as vscode from 'vscode';
import { AzureUserInput } from 'vscode-azureextensionui';
import { AzureUserInput, createTelemetryReporter, registerUIExtensionVariables } from 'vscode-azureextensionui';
import { ConfigurationParams, DidChangeConfigurationNotification, DocumentSelector, LanguageClient, LanguageClientOptions, Middleware, ServerOptions, TransportKind } from 'vscode-languageclient';
import { buildImage } from './commands/build-image';
import { composeDown, composeRestart, composeUp } from './commands/docker-compose';
Expand Down Expand Up @@ -38,7 +38,7 @@ import { DockerHubImageNode, DockerHubOrgNode, DockerHubRepositoryNode } from '.
import { browseAzurePortal } from './explorer/utils/azureUtils';
import { browseDockerHub, dockerHubLogout } from './explorer/utils/dockerHubUtils';
import { ext } from "./extensionVariables";
import { Reporter } from './telemetry/telemetry';
import { initializeTelemetryReporter, reporter } from './telemetry/telemetry';
import { AzureAccount } from './typings/azure-account.api';

export const FROM_DIRECTIVE_PATTERN = /^\s*FROM\s*([\w-\/:]*)(\s*AS\s*[a-z][a-z0-9-_\\.]*)?$/i;
Expand Down Expand Up @@ -82,7 +82,9 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
}
}

ctx.subscriptions.push(new Reporter(ctx));
registerUIExtensionVariables(ext);
initializeTelemetryReporter(createTelemetryReporter(ctx));
ext.reporter = reporter;

dockerExplorerProvider = new DockerExplorerProvider(azureAccount);
vscode.window.registerTreeDataProvider('dockerExplorer', dockerExplorerProvider);
Expand Down
5 changes: 2 additions & 3 deletions extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { ExtensionContext, OutputChannel } from "vscode";
import { IAzureUserInput } from "vscode-azureextensionui";
import TelemetryReporter from "vscode-extension-telemetry";
import { IAzureUserInput, ITelemetryReporter } from "vscode-azureextensionui";

/**
* Namespace for common variables used throughout the extension. They must be initialized in the activate() method of extension.ts
Expand All @@ -14,5 +13,5 @@ export namespace ext {
export let context: ExtensionContext;
export let outputChannel: OutputChannel;
export let ui: IAzureUserInput;
export let reporter: TelemetryReporter;
export let reporter: ITelemetryReporter;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
"opn": "^5.1.0",
"pom-parser": "^1.1.1",
"request-promise": "^4.2.2",
"vscode-azureextensionui": "~0.15.0",
"vscode-azureextensionui": "^0.16.5",
"vscode-extension-telemetry": "^0.0.6",
"vscode-languageclient": "4.4.0"
}
Expand Down
41 changes: 10 additions & 31 deletions telemetry/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
import vscode = require('vscode');
import TelemetryReporter from 'vscode-extension-telemetry';

export let reporter: TelemetryReporter;

export class Reporter extends vscode.Disposable {

constructor(ctx: vscode.ExtensionContext) {

super(() => reporter.dispose());
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

let packageInfo = getPackageInfo(ctx);
reporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);

}
}
import vscode = require('vscode');
import { createTelemetryReporter, ITelemetryReporter } from 'vscode-azureextensionui';
import { ext } from '../extensionVariables';

interface IPackageInfo {
name: string;
version: string;
aiKey: string;
}
export let reporter: ITelemetryReporter;

function getPackageInfo(context: vscode.ExtensionContext): IPackageInfo {
// tslint:disable-next-line:non-literal-require
let extensionPackage = require(context.asAbsolutePath('./package.json'));
if (extensionPackage) {
return {
name: extensionPackage.name,
version: extensionPackage.version,
aiKey: extensionPackage.aiKey
};
}
return;
export function initializeTelemetryReporter(newReporter: ITelemetryReporter): void {
reporter = newReporter;
}

0 comments on commit 084db32

Please sign in to comment.