Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Insiders target population as VS Code Insiders for ExP #24412

Merged
merged 2 commits into from
Nov 13, 2024
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
16 changes: 3 additions & 13 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { inject, injectable } from 'inversify';
import { l10n } from 'vscode';
import { getExperimentationService, IExperimentationService } from 'vscode-tas-client';
import { getExperimentationService, IExperimentationService, TargetPopulation } from 'vscode-tas-client';
import { traceLog } from '../../logging';
import { sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
Expand All @@ -17,16 +17,6 @@ import { ExperimentationTelemetry } from './telemetry';
const EXP_MEMENTO_KEY = 'VSCode.ABExp.FeatureData';
const EXP_CONFIG_ID = 'vscode';

/**
* We're defining a custom TargetPopulation specific for the Python extension.
* This is done so the exp framework is able to differentiate between
* VS Code insiders/public users and Python extension insiders (pre-release)/public users.
*/
export enum TargetPopulation {
Insiders = 'python-insider',
Public = 'python-public',
}

@injectable()
export class ExperimentService implements IExperimentService {
/**
Expand Down Expand Up @@ -73,8 +63,8 @@ export class ExperimentService implements IExperimentService {
}

let targetPopulation: TargetPopulation;

if (this.appEnvironment.extensionChannel === 'insiders') {
// if running in VS Code Insiders, use the Insiders target population
if (this.appEnvironment.channel === 'insiders') {
targetPopulation = TargetPopulation.Insiders;
} else {
targetPopulation = TargetPopulation.Public;
Expand Down
9 changes: 5 additions & 4 deletions src/test/common/experiments/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import { Disposable } from 'vscode-jsonrpc';
// sinon can not create a stub if we just point to the exported module
import * as tasClient from 'vscode-tas-client/vscode-tas-client/VSCodeTasClient';
import * as expService from 'vscode-tas-client';
import { TargetPopulation } from 'vscode-tas-client';
import { ApplicationEnvironment } from '../../../client/common/application/applicationEnvironment';
import { IApplicationEnvironment, IWorkspaceService } from '../../../client/common/application/types';
import { WorkspaceService } from '../../../client/common/application/workspace';
import { Channel } from '../../../client/common/constants';
import { ExperimentService, TargetPopulation } from '../../../client/common/experiments/service';
import { ExperimentService } from '../../../client/common/experiments/service';
import { PersistentState } from '../../../client/common/persistentState';
import { IPersistentStateFactory } from '../../../client/common/types';
import { registerLogger } from '../../../client/logging';
Expand Down Expand Up @@ -74,13 +75,13 @@ suite('Experimentation service', () => {
}

function configureApplicationEnvironment(channel: Channel, version: string, contributes?: Record<string, unknown>) {
when(appEnvironment.extensionChannel).thenReturn(channel);
when(appEnvironment.channel).thenReturn(channel);
when(appEnvironment.extensionName).thenReturn(PVSC_EXTENSION_ID_FOR_TESTS);
when(appEnvironment.packageJson).thenReturn({ version, contributes });
}

suite('Initialization', () => {
test('Users with a release version of the extension should be in the Public target population', () => {
test('Users with VS Code stable version should be in the Public target population', () => {
const getExperimentationServiceStub = sinon.stub(tasClient, 'getExperimentationService');
configureSettings(true, [], []);
configureApplicationEnvironment('stable', extensionVersion);
Expand All @@ -99,7 +100,7 @@ suite('Experimentation service', () => {
);
});

test('Users with an Insiders version of the extension should be the Insiders target population', () => {
test('Users with VS Code Insiders version should be the Insiders target population', () => {
const getExperimentationServiceStub = sinon.stub(tasClient, 'getExperimentationService');

configureSettings(true, [], []);
Expand Down
Loading