mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Add experimentation to Microsoft auth (#226107)
* Add experimentation to Microsoft auth So that we can gradually roll out MSAL support. * correct order
This commit is contained in:
committed by
GitHub
parent
b8ad412410
commit
c125b90d41
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as vscode from 'vscode';
|
||||
import { getExperimentationService, IExperimentationService, IExperimentationTelemetry, TargetPopulation } from 'vscode-tas-client';
|
||||
|
||||
export async function createExperimentationService(
|
||||
context: vscode.ExtensionContext,
|
||||
experimentationTelemetry: IExperimentationTelemetry,
|
||||
isPreRelease: boolean,
|
||||
): Promise<IExperimentationService> {
|
||||
const id = context.extension.id;
|
||||
const version = context.extension.packageJSON['version'];
|
||||
|
||||
const service = getExperimentationService(
|
||||
id,
|
||||
version,
|
||||
isPreRelease ? TargetPopulation.Insiders : TargetPopulation.Public,
|
||||
experimentationTelemetry,
|
||||
context.globalState,
|
||||
) as unknown as IExperimentationService;
|
||||
await service.initializePromise;
|
||||
await service.initialFetch;
|
||||
return service;
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import TelemetryReporter, { TelemetryEventProperties } from '@vscode/extension-telemetry';
|
||||
import { IExperimentationTelemetry } from 'vscode-tas-client';
|
||||
|
||||
export const enum MicrosoftAccountType {
|
||||
AAD = 'aad',
|
||||
@@ -11,12 +12,29 @@ export const enum MicrosoftAccountType {
|
||||
Unknown = 'unknown'
|
||||
}
|
||||
|
||||
export class MicrosoftAuthenticationTelemetryReporter {
|
||||
export class MicrosoftAuthenticationTelemetryReporter implements IExperimentationTelemetry {
|
||||
private sharedProperties: Record<string, string> = {};
|
||||
protected _telemetryReporter: TelemetryReporter;
|
||||
constructor(aiKey: string) {
|
||||
this._telemetryReporter = new TelemetryReporter(aiKey);
|
||||
}
|
||||
|
||||
get telemetryReporter(): TelemetryReporter {
|
||||
return this._telemetryReporter;
|
||||
}
|
||||
|
||||
setSharedProperty(name: string, value: string): void {
|
||||
this.sharedProperties[name] = value;
|
||||
}
|
||||
|
||||
postEvent(eventName: string, props: Map<string, string>): void {
|
||||
const eventProperties: TelemetryEventProperties = { ...this.sharedProperties, ...Object.fromEntries(props) };
|
||||
this._telemetryReporter.sendTelemetryEvent(
|
||||
eventName,
|
||||
eventProperties
|
||||
);
|
||||
}
|
||||
|
||||
sendLoginEvent(scopes: readonly string[]): void {
|
||||
/* __GDPR__
|
||||
"login" : {
|
||||
|
||||
Reference in New Issue
Block a user