forked from microsoft/vscode-java-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperimentationService.ts
More file actions
37 lines (29 loc) · 1.45 KB
/
experimentationService.ts
File metadata and controls
37 lines (29 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { ExtensionContext } from 'vscode';
import { addContextProperty, sendInfo } from 'vscode-extension-telemetry-wrapper';
import { getExperimentationServiceAsync, 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(): IExperimentationService {
return expService;
}
export async function initExpService(context: ExtensionContext): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson: {[key: string]: any} = require('../package.json');
const extensionName: string = `${packageJson['publisher']}.${packageJson['name']}`;
const extensionVersion: string = packageJson['version'];
expService = await getExperimentationServiceAsync(extensionName, extensionVersion,
TargetPopulation.Public, new ExperimentationTelemetry(), context.globalState);
}