Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.1.0",
"publisher": "vscjava",
"preview": true,
"aiKey": "67d4461e-ccba-418e-8082-1bd0acfe8516",
"icon": "logo.png",
"keywords": [
"java",
Expand All @@ -13,7 +14,7 @@
"debugger"
],
"engines": {
"vscode": "^1.14.0"
"vscode": "^1.15.0"
},
"categories": [
"Debuggers"
Expand Down Expand Up @@ -199,5 +200,8 @@
"tslint": "^5.7.0",
"typescript": "^2.0.3",
"vscode": "^1.1.5"
},
"dependencies": {
"vscode-extension-telemetry": "0.0.8"
}
}
30 changes: 16 additions & 14 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

export const VSCODE_STARTDEBUG = "vscode.startDebug";

export const VSCODE_ADD_DEBUGCONFIGURATION = "debug.addConfiguration";

export const JAVA_START_DEBUGSESSION = "vscode.java.startDebugSession";

export const JAVA_RESOLVE_CLASSPATH = "vscode.java.resolveClasspath";

export const JAVA_BUILD_WORKSPACE = "vscode.java.buildWorkspace";

export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

export const VSCODE_STARTDEBUG = "vscode.startDebug";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have so many changes in this file?


export const VSCODE_ADD_DEBUGCONFIGURATION = "debug.addConfiguration";

export const JAVA_START_DEBUGSESSION = "vscode.java.startDebugSession";

export const JAVA_RESOLVE_CLASSPATH = "vscode.java.resolveClasspath";

export const JAVA_BUILD_WORKSPACE = "vscode.java.buildWorkspace";

export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";

export const JAVA_FETCH_USAGE_DATA = "vscode.java.fetchUsageData";
29 changes: 28 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as path from "path";
import * as vscode from "vscode";
import * as commands from "./commands";
import TelemetryReporter from "vscode-extension-telemetry";

const status: any = {};

Expand Down Expand Up @@ -61,6 +62,28 @@ export function activate(context: vscode.ExtensionContext) {
}
}
});

// Telemetry.
const extensionPackage = require(context.asAbsolutePath("./package.json"));
if (extensionPackage) {
const packageInfo = {
name: extensionPackage.name,
version: extensionPackage.version,
aiKey: extensionPackage.aiKey,
};
if (packageInfo.aiKey) {
const reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
vscode.debug.onDidTerminateDebugSession(() => {
fetchUsageData().then(ret => {
if (Array.isArray(ret) && ret.length) {
ret.forEach(entry => {
reporter.sendTelemetryEvent("usageData", entry, {});
});
}
});
});
}
}
}

// this method is called when your extension is deactivated
Expand All @@ -75,6 +98,10 @@ function resolveClasspath(mainClass, projectName) {
return executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_CLASSPATH, mainClass, projectName);
}

function fetchUsageData() {
return executeJavaLanguageServerCommand(commands.JAVA_FETCH_USAGE_DATA);
}

function executeJavaLanguageServerCommand(...rest) {
return vscode.commands.executeCommand(commands.JAVA_EXECUTE_WORKSPACE_COMMAND, ...rest);
}
}