Skip to content

Commit 0d815df

Browse files
author
Kartik Raj
authored
Log experiments after we finish updating active experiments list (#18393)
* Log experiments after we finish updating active experiments list * Fix tests * News entry
1 parent 9d6200f commit 0d815df

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

news/2 Fixes/18393.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Log experiments only after we finish updating active experiments list.

src/client/common/experiments/service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ export class ExperimentService implements IExperimentService {
7575
telemetryReporter,
7676
this.globalState,
7777
);
78-
79-
this.logExperiments();
8078
}
8179

8280
public async activate(): Promise<void> {
@@ -99,6 +97,7 @@ export class ExperimentService implements IExperimentService {
9997
await this.experimentationService.initialFetch;
10098
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_INIT_PERFORMANCE, Date.now() - initStart);
10199
}
100+
this.logExperiments();
102101
}
103102
sendOptInOptOutTelemetry(this._optInto, this._optOutFrom, this.appEnvironment.packageJson);
104103
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,21 @@ suite('Experimentation service', () => {
138138
assert.deepEqual(experimentService._optOutFrom, ['Foo - experiment']);
139139
});
140140

141-
test('Experiment data in Memento storage should be logged if it starts with "python"', () => {
141+
test('Experiment data in Memento storage should be logged if it starts with "python"', async () => {
142142
const experiments = ['ExperimentOne', 'pythonExperiment'];
143143
globalMemento = mock(MockMemento);
144144
configureSettings(true, [], []);
145-
configureApplicationEnvironment('stable', extensionVersion);
145+
configureApplicationEnvironment('stable', extensionVersion, { configuration: { properties: {} } });
146146

147147
// eslint-disable-next-line @typescript-eslint/no-explicit-any
148148
when(globalMemento.get(anything(), anything())).thenReturn({ features: experiments } as any);
149149

150-
new ExperimentService(instance(workspaceService), instance(appEnvironment), instance(globalMemento));
150+
const exp = new ExperimentService(
151+
instance(workspaceService),
152+
instance(appEnvironment),
153+
instance(globalMemento),
154+
);
155+
await exp.activate();
151156
const output = `${Experiments.inGroup().format('pythonExperiment')}\n`;
152157

153158
assert.strictEqual(outputChannel.output, output);

0 commit comments

Comments
 (0)