Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/18393.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log experiments only after we finish updating active experiments list.
3 changes: 1 addition & 2 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export class ExperimentService implements IExperimentService {
telemetryReporter,
this.globalState,
);

this.logExperiments();
}

public async activate(): Promise<void> {
Expand All @@ -99,6 +97,7 @@ export class ExperimentService implements IExperimentService {
await this.experimentationService.initialFetch;
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_INIT_PERFORMANCE, Date.now() - initStart);
}
this.logExperiments();
}
sendOptInOptOutTelemetry(this._optInto, this._optOutFrom, this.appEnvironment.packageJson);
}
Expand Down
11 changes: 8 additions & 3 deletions src/test/common/experiments/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,21 @@ suite('Experimentation service', () => {
assert.deepEqual(experimentService._optOutFrom, ['Foo - experiment']);
});

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

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

new ExperimentService(instance(workspaceService), instance(appEnvironment), instance(globalMemento));
const exp = new ExperimentService(
instance(workspaceService),
instance(appEnvironment),
instance(globalMemento),
);
await exp.activate();
const output = `${Experiments.inGroup().format('pythonExperiment')}\n`;

assert.strictEqual(outputChannel.output, output);
Expand Down