8000 Adopt TAS client by jdneo · Pull Request #959 · microsoft/vscode-java-debug · GitHub
[go: up one dir, main page]

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
37 changes: 33 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@
"lodash": "^4.17.20",
"uuid": "^8.3.1",
"vscode-extension-telemetry": "^0.1.6",
"vscode-extension-telemetry-wrapper": "^0.8.0"
"vscode-extension-telemetry-wrapper": "^0.9.0",
"vscode-tas-client": "^0.1.17"
}
}
38 changes: 38 additions & 0 deletions src/experimentationService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import * as vscode from "vscode";
import { addContextProperty, sendInfo } from "vscode-extension-telemetry-wrapper";
import { getExperimentationService, IExperimentationService, IExperimentationTelemetry, TargetPopulation } from "vscode-tas-client";

class ExperimentationTelemetry implements IExperimentationTelemetry {

public setSharedProperty(name: string, value: string): void {
addContextProperty(name, value);
}

public postEvent(eventName: string, props: Map<string, string>): void {
const payload: any = { __event_name__: eventName };
for (const [key, value] of props) {
payload[key] = value;
}

sendInfo("", payload);
}
}

let expService: IExperimentationService;

export function getExpService() {
return expService;
}

export function initExpService(context: vscode.ExtensionContext): void {
const packageJson: {[key: string]: any} = require("../package.json");
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the path relationship will change after webpack, i would prefer to use the absolute path to get the package.json content.

const extensionPackage = JSON.parse(fs.readFileSync(context.asAbsolutePath("./package.json"), "utf-8"));

Copy link
Member Author

Choose a reason for hiding this comment

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

webpack can handle that. It will become something like

const packageJson = __webpack_require__(JSON.parse(<content of the package.json in string format>));

// tslint:disable: no-string-literal
const extensionName = `${packageJson["publisher"]}.${packageJson["name"]}`;
const extensionVersion = packageJson["version"];
// tslint:enable: no-string-literal
expService = getExperimentationService(extensionName, extensionVersion,
TargetPopulation.Public, new ExperimentationTelemetry(), context.globalState);
}
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { JavaDebugConfigurationProvider } from "./configurationProvider";
import { HCR_EVENT, JAVA_LANGID, USER_NOTIFICATION_EVENT } from "./constants";
import { NotificationBar } from "./customWidget";
import { initializeCodeLensProvider, startDebugging } from "./debugCodeLensProvider";
import { initExpService } from "./experimentationService";
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace, NO_BUTTON, YES_BUTTON } from "./hotCodeReplace";
import { JavaDebugAdapterDescriptorFactory } from "./javaDebugAdapterDescriptorFactory";
import { logJavaException, logJavaInfo } from "./javaLogger";
Expand All @@ -36,6 +37,7 @@ function initializeExtension(_operationId: string, context: vscode.ExtensionCont
// Deprecated
logger.initialize(context, true);

initExpService(context);
registerDebugEventListener(context);
context.subscriptions.push(logger);
context.subscriptions.push(vscode.window.registerTerminalLinkProvider(new JavaTerminalLinkProvder()));
Expand Down
0