diff --git a/package-lock.json b/package-lock.json index 39c1c5cfab..9a827a272f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9898,9 +9898,9 @@ } }, "tas-client": { - "version": "0.0.762", - "resolved": "https://registry.npmjs.org/tas-client/-/tas-client-0.0.762.tgz", - "integrity": "sha512-i4dcYHkk2rnmBHr8RC1IoZVHU9wQT+OmDDnUeRW/vbpjDSCqgL5Qh8KeHs3DizJgqP9MWjLK/Kmqfm8VbD6g3g==", + "version": "0.0.875", + "resolved": "https://registry.npmjs.org/tas-client/-/tas-client-0.0.875.tgz", + "integrity": "sha512-Y375pAWdOAFKAs2gZHVC3SAxGp8vHNRTpl7W6rBaB8YgZbAX0h0NHUubqHtyuNwH6VF9qy2ckagsuXZP0JignQ==", "requires": { "axios": "^0.19.0" } @@ -11146,11 +11146,11 @@ } }, "vscode-tas-client": { - "version": "0.0.757", - "resolved": "https://registry.npmjs.org/vscode-tas-client/-/vscode-tas-client-0.0.757.tgz", - "integrity": "sha512-IXP+vFTIE1HpvYxqm7SuFe/K5N3cPoF4TTH6uYGAeuuYxV586tjYFtK9UmF00ajzcqvLGvsPgxmfgLeX6vUUtA==", + "version": "0.0.864", + "resolved": "https://registry.npmjs.org/vscode-tas-client/-/vscode-tas-client-0.0.864.tgz", + "integrity": "sha512-mRMpeTVQ8Rx3p4yF9y8AABanzbqtLRdJA99dzeQ9MdIHsSEdp0kEwxqayzDhNHDdp8vNbQkHN8zMxSvm/ZWdpg==", "requires": { - "tas-client": "0.0.762" + "tas-client": "0.0.875" } }, "vscode-test": { diff --git a/package.json b/package.json index 72c84e3afd..42d55e5a2e 100644 --- a/package.json +++ b/package.json @@ -2662,7 +2662,7 @@ "vscode-azureextensionui": "^0.31.2", "vscode-languageclient": "^6.1.3", "vscode-nls": "^4.1.2", - "vscode-tas-client": "^0.0.757", + "vscode-tas-client": "^0.0.864", "xml2js": "^0.4.23" } } diff --git a/src/extension.ts b/src/extension.ts index e89c4372e6..c3be4bef9b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -66,17 +66,6 @@ function initializeExtensionVariables(ctx: vscode.ExtensionContext): void { ext.terminalProvider = new DefaultTerminalProvider(); } - // Activity measurement service internally handles telemetry opt-in - ext.activityMeasurementService = new ActivityMeasurementService(ctx.globalState); - - // Experimentation service internally handles telemetry opt-in - const experimentationTelemetry = new ExperimentationTelemetry(); - ctx.subscriptions.push(registerTelemetryHandler(async (context: IActionContext) => experimentationTelemetry.handleTelemetry(context))); - ext.experimentationService = new ExperimentationServiceAdapter(ctx.globalState, experimentationTelemetry); - - // Survey manager internally handles telemetry opt-in - (new SurveyManager()).activate(); - if (!ext.keytar) { ext.keytar = Keytar.tryCreate(); } @@ -94,6 +83,13 @@ export async function activateInternal(ctx: vscode.ExtensionContext, perfStats: activateContext.telemetry.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000; activateContext.telemetry.properties.dockerInstallationID = await getDockerInstallationID(); + // All of these internally handle telemetry opt-in + ext.activityMeasurementService = new ActivityMeasurementService(ctx.globalState); + const experimentationTelemetry = new ExperimentationTelemetry(); + ctx.subscriptions.push(registerTelemetryHandler(async (context: IActionContext) => experimentationTelemetry.handleTelemetry(context))); + ext.experimentationService = await ExperimentationServiceAdapter.create(ctx.globalState, experimentationTelemetry); + (new SurveyManager()).activate(); + validateOldPublisher(activateContext); ctx.subscriptions.push( diff --git a/src/telemetry/ExperimentationServiceAdapter.ts b/src/telemetry/ExperimentationServiceAdapter.ts index 9307fe60ab..514d9326ce 100644 --- a/src/telemetry/ExperimentationServiceAdapter.ts +++ b/src/telemetry/ExperimentationServiceAdapter.ts @@ -14,33 +14,37 @@ export interface IExperimentationServiceAdapter { } export class ExperimentationServiceAdapter implements IExperimentationServiceAdapter { - private readonly wrappedExperimentationService: IExperimentationService; - - public constructor(globalState: vscode.Memento, reporter: tas.IExperimentationTelemetry) { - if (!ext.telemetryOptIn) { - return; + private wrappedExperimentationService: IExperimentationService; + + private constructor() { } + + public static async create(globalState: vscode.Memento, reporter: tas.IExperimentationTelemetry): Promise { + const result = new ExperimentationServiceAdapter(); + + if (ext.telemetryOptIn) { + try { + const version = extensionVersion.value ?? '1'; + let targetPopulation: tas.TargetPopulation; + + if (ext.runningTests || process.env.DEBUGTELEMETRY || process.env.VSCODE_DOCKER_TEAM === '1') { + targetPopulation = tas.TargetPopulation.Team; + } else if (/alpha/ig.test(version)) { + targetPopulation = tas.TargetPopulation.Insiders; + } else { + targetPopulation = tas.TargetPopulation.Public; + } + + result.wrappedExperimentationService = await tas.getExperimentationServiceAsync( + extensionId, + version, + targetPopulation, + reporter, + globalState, + ); + } catch { } // Best effort } - try { - const version = extensionVersion.value ?? '1'; - let targetPopulation: tas.TargetPopulation; - - if (ext.runningTests || process.env.DEBUGTELEMETRY || process.env.VSCODE_DOCKER_TEAM === '1') { - targetPopulation = tas.TargetPopulation.Team; - } else if (/alpha/ig.test(version)) { - targetPopulation = tas.TargetPopulation.Insiders; - } else { - targetPopulation = tas.TargetPopulation.Public; - } - - this.wrappedExperimentationService = tas.getExperimentationService( - extensionId, - version, - targetPopulation, - reporter, - globalState, - ); - } catch { } // Best effort + return result; } public async isFlightEnabled(flight: string): Promise {