Skip to content

Commit

Permalink
Merge pull request #201 from microsoft/telemetry_616537
Browse files Browse the repository at this point in the history
running code
  • Loading branch information
Sumit Kumar committed Jun 11, 2020
2 parents dc62406 + d8bbdc4 commit bd4e44f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.2.6",
"publisher": "Microsoft",
"description": "PostgreSQL extension for Azure Data Studio",
"aiKey": "AIF-5574968e-856d-40d2-af67-c89a14e76412",
"aiKey": "c2c974c2-f342-42c8-b85b-b79436a86603",
"icon": "images/extension-icon.png",
"repository": {
"url": "https://github.com/Microsoft/azuredatastudio-postgresql"
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function activate(context: vscode.ExtensionContext) {
return;
}

Telemetry.initialize(context);
let config: IConfig = JSON.parse(JSON.stringify(baseConfig));
config.installDirectory = path.join(__dirname, config.installDirectory);
config.proxy = vscode.workspace.getConfiguration('http').get('proxy');
Expand Down Expand Up @@ -205,4 +206,5 @@ function generateHandleServerProviderEvent() {

// this method is called when your extension is deactivated
export function deactivate(): void {
Telemetry.dispose();
}
12 changes: 8 additions & 4 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Telemetry {
private static reporter: TelemetryReporter;
private static userId: string;
private static platformInformation: PlatformInformation;
private static disabled: boolean = true; // Disable the telemetry for public preview
private static disabled: boolean = false; // Disable the telemetry for public preview

// Get the unique ID for the current user of the extension
public static getUserId(): Promise<string> {
Expand Down Expand Up @@ -81,7 +81,7 @@ export class Telemetry {
/**
* Initialize the telemetry reporter for use.
*/
public static initialize(): void {
public static initialize(context: vscode.ExtensionContext): void {
if (typeof this.reporter === 'undefined') {
// Check if the user has opted out of telemetry
if (!vscode.workspace.getConfiguration('telemetry').get<boolean>('enableTelemetry', true)) {
Expand All @@ -91,6 +91,8 @@ export class Telemetry {

let packageInfo = Utils.getPackageInfo();
this.reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
// ensure it gets property disposed
context.subscriptions.push(this.reporter);
}
}

Expand Down Expand Up @@ -149,6 +151,10 @@ export class Telemetry {
this.reporter.sendTelemetryEvent(eventName, properties, measures);
});
}
/**
* This will ensure all pending events get flushed
*/
static dispose(){this.reporter.dispose()}
}

/**
Expand Down Expand Up @@ -205,5 +211,3 @@ export class LanguageClientErrorHandler implements ErrorHandler {
return CloseAction.DoNotRestart;
}
}

Telemetry.initialize();

0 comments on commit bd4e44f

Please sign in to comment.