From ebaf8fe0d587cfbc190bd89ad4d584c35ff57bd1 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 17 Oct 2023 13:29:27 -0700 Subject: [PATCH] Fix experiment telemetry related to optInto/optOutFrom settings (#22241) cc/ @luabud --- src/client/common/experiments/service.ts | 6 ++++-- src/client/telemetry/index.ts | 8 ++++---- src/test/common/experiments/service.unit.test.ts | 16 +++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/client/common/experiments/service.ts b/src/client/common/experiments/service.ts index 270f91512809..3d85b99a26ff 100644 --- a/src/client/common/experiments/service.ts +++ b/src/client/common/experiments/service.ts @@ -257,8 +257,10 @@ function sendOptInOptOutTelemetry(optedIn: string[], optedOut: string[], package const sanitizedOptedIn = optedIn.filter((exp) => optedInEnumValues.includes(exp)); const sanitizedOptedOut = optedOut.filter((exp) => optedOutEnumValues.includes(exp)); + JSON.stringify(sanitizedOptedIn.sort()); + sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS, undefined, { - optedInto: sanitizedOptedIn, - optedOutFrom: sanitizedOptedOut, + optedInto: JSON.stringify(sanitizedOptedIn.sort()), + optedOutFrom: JSON.stringify(sanitizedOptedOut.sort()), }); } diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index f69da6046254..ba65c4d1913f 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1405,14 +1405,14 @@ export interface IEventNamePropertyMapping { [EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS]: { /** * List of valid experiments in the python.experiments.optInto setting - * @type {string[]} + * @type {string} */ - optedInto: string[]; + optedInto: string; /** * List of valid experiments in the python.experiments.optOutFrom setting - * @type {string[]} + * @type {string} */ - optedOutFrom: string[]; + optedOutFrom: string; }; /** * Telemetry event sent when LS is started for workspace (workspace folder in case of multi-root) diff --git a/src/test/common/experiments/service.unit.test.ts b/src/test/common/experiments/service.unit.test.ts index 1d96f2e0bd70..ab05db6da5a1 100644 --- a/src/test/common/experiments/service.unit.test.ts +++ b/src/test/common/experiments/service.unit.test.ts @@ -491,7 +491,10 @@ suite('Experimentation service', () => { await experimentService.activate(); const { properties } = telemetryEvents[1]; - assert.deepStrictEqual(properties, { optedInto: ['foo'], optedOutFrom: ['bar'] }); + assert.deepStrictEqual(properties, { + optedInto: JSON.stringify(['foo']), + optedOutFrom: JSON.stringify(['bar']), + }); }); test('Set telemetry properties to empty arrays if no experiments have been opted into or out from', async () => { @@ -523,7 +526,7 @@ suite('Experimentation service', () => { await experimentService.activate(); const { properties } = telemetryEvents[1]; - assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] }); + assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' }); }); test('If the entered value for a setting contains "All", do not expand it to be a list of all experiments, and pass it as-is', async () => { @@ -555,7 +558,10 @@ suite('Experimentation service', () => { await experimentService.activate(); const { properties } = telemetryEvents[0]; - assert.deepStrictEqual(properties, { optedInto: ['All'], optedOutFrom: ['All'] }); + assert.deepStrictEqual(properties, { + optedInto: JSON.stringify(['All']), + optedOutFrom: JSON.stringify(['All']), + }); }); // This is an unlikely scenario. @@ -577,7 +583,7 @@ suite('Experimentation service', () => { await experimentService.activate(); const { properties } = telemetryEvents[1]; - assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] }); + assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' }); }); // This is also an unlikely scenario. @@ -608,7 +614,7 @@ suite('Experimentation service', () => { await experimentService.activate(); const { properties } = telemetryEvents[1]; - assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] }); + assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' }); }); }); });