Skip to content

Commit ebaf8fe

Browse files
author
Kartik Raj
authored
Fix experiment telemetry related to optInto/optOutFrom settings (microsoft#22241)
cc/ @luabud
1 parent 10b98d3 commit ebaf8fe

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/client/common/experiments/service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ function sendOptInOptOutTelemetry(optedIn: string[], optedOut: string[], package
257257
const sanitizedOptedIn = optedIn.filter((exp) => optedInEnumValues.includes(exp));
258258
const sanitizedOptedOut = optedOut.filter((exp) => optedOutEnumValues.includes(exp));
259259

260+
JSON.stringify(sanitizedOptedIn.sort());
261+
260262
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS, undefined, {
261-
optedInto: sanitizedOptedIn,
262-
optedOutFrom: sanitizedOptedOut,
263+
optedInto: JSON.stringify(sanitizedOptedIn.sort()),
264+
optedOutFrom: JSON.stringify(sanitizedOptedOut.sort()),
263265
});
264266
}

src/client/telemetry/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,14 +1405,14 @@ export interface IEventNamePropertyMapping {
14051405
[EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS]: {
14061406
/**
14071407
* List of valid experiments in the python.experiments.optInto setting
1408-
* @type {string[]}
1408+
* @type {string}
14091409
*/
1410-
optedInto: string[];
1410+
optedInto: string;
14111411
/**
14121412
* List of valid experiments in the python.experiments.optOutFrom setting
1413-
* @type {string[]}
1413+
* @type {string}
14141414
*/
1415-
optedOutFrom: string[];
1415+
optedOutFrom: string;
14161416
};
14171417
/**
14181418
* Telemetry event sent when LS is started for workspace (workspace folder in case of multi-root)

src/test/common/experiments/service.unit.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,10 @@ suite('Experimentation service', () => {
491491
await experimentService.activate();
492492

493493
const { properties } = telemetryEvents[1];
494-
assert.deepStrictEqual(properties, { optedInto: ['foo'], optedOutFrom: ['bar'] });
494+
assert.deepStrictEqual(properties, {
495+
optedInto: JSON.stringify(['foo']),
496+
optedOutFrom: JSON.stringify(['bar']),
497+
});
495498
});
496499

497500
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', () => {
523526
await experimentService.activate();
524527

525528
const { properties } = telemetryEvents[1];
526-
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
529+
assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' });
527530
});
528531

529532
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', () => {
555558
await experimentService.activate();
556559

557560
const { properties } = telemetryEvents[0];
558-
assert.deepStrictEqual(properties, { optedInto: ['All'], optedOutFrom: ['All'] });
561+
assert.deepStrictEqual(properties, {
562+
optedInto: JSON.stringify(['All']),
563+
optedOutFrom: JSON.stringify(['All']),
564+
});
559565
});
560566

561567
// This is an unlikely scenario.
@@ -577,7 +583,7 @@ suite('Experimentation service', () => {
577583
await experimentService.activate();
578584

579585
const { properties } = telemetryEvents[1];
580-
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
586+
assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' });
581587
});
582588

583589
// This is also an unlikely scenario.
@@ -608,7 +614,7 @@ suite('Experimentation service', () => {
608614
await experimentService.activate();
609615

610616
const { properties } = telemetryEvents[1];
611-
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
617+
assert.deepStrictEqual(properties, { optedInto: '[]', optedOutFrom: '[]' });
612618
});
613619
});
614620
});

0 commit comments

Comments
 (0)