Skip to content

Commit 2f7268e

Browse files
authored
Merge pull request #1430 from microsoft/ulugbekna/cand-exp-filter-fcv1
add exp filter for fcv1 copilot token flag
2 parents 7eb8f57 + ee248f6 commit 2f7268e

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/platform/authentication/common/copilotToken.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ export class CopilotToken {
199199
isExpandedClientSideIndexingEnabled(): boolean {
200200
return this._info.blackbird_clientside_indexing === true;
201201
}
202+
203+
isFcv1(): boolean {
204+
return this.tokenMap.get('fcv1') === '1';
205+
}
202206
}
203207

204208
/**

src/platform/telemetry/node/baseExperimentationService.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import { IExperimentationService, TreatmentsChangeEvent } from '../common/nullEx
1717
export class UserInfoStore extends Disposable {
1818
private _internalOrg: string | undefined;
1919
private _sku: string | undefined;
20+
private _isFcv1: boolean | undefined;
2021

2122
private _onDidChangeUserInfo = this._register(new Emitter<void>());
2223
readonly onDidChangeUserInfo = this._onDidChangeUserInfo.event;
2324

2425
static INTERNAL_ORG_STORAGE_KEY = 'exp.github.copilot.internalOrg';
2526
static SKU_STORAGE_KEY = 'exp.github.copilot.sku';
26-
27+
static IS_FCV1_STORAGE_KEY = 'exp.github.copilot.isFcv1';
2728
constructor(private readonly context: IVSCodeExtensionContext, copilotTokenStore: ICopilotTokenStore) {
2829
super();
2930

@@ -38,15 +39,16 @@ export class UserInfoStore extends Disposable {
3839
};
3940

4041
copilotTokenStore.onDidStoreUpdate(() => {
41-
this.updateUserInfo(getInternalOrg(), copilotTokenStore.copilotToken?.sku);
42+
this.updateUserInfo(getInternalOrg(), copilotTokenStore.copilotToken?.sku, copilotTokenStore.copilotToken?.isFcv1());
4243
});
4344

4445
if (copilotTokenStore.copilotToken) {
45-
this.updateUserInfo(getInternalOrg(), copilotTokenStore.copilotToken.sku);
46+
this.updateUserInfo(getInternalOrg(), copilotTokenStore.copilotToken.sku, copilotTokenStore.copilotToken.isFcv1());
4647
} else {
4748
const cachedInternalValue = this.context.globalState.get<string>(UserInfoStore.INTERNAL_ORG_STORAGE_KEY);
4849
const cachedSkuValue = this.context.globalState.get<string>(UserInfoStore.SKU_STORAGE_KEY);
49-
this.updateUserInfo(cachedInternalValue, cachedSkuValue);
50+
const cachedIsFcv1Value = this.context.globalState.get<boolean>(UserInfoStore.IS_FCV1_STORAGE_KEY);
51+
this.updateUserInfo(cachedInternalValue, cachedSkuValue, cachedIsFcv1Value);
5052
}
5153
}
5254
}
@@ -59,17 +61,22 @@ export class UserInfoStore extends Disposable {
5961
return this._sku;
6062
}
6163

62-
private updateUserInfo(internalOrg?: string, sku?: string): void {
63-
if (this._internalOrg === internalOrg && this._sku === sku) {
64+
get isFcv1(): boolean | undefined {
65+
return this._isFcv1;
66+
}
67+
68+
private updateUserInfo(internalOrg?: string, sku?: string, isFcv1?: boolean): void {
69+
if (this._internalOrg === internalOrg && this._sku === sku && this._isFcv1 === isFcv1) {
6470
// no change
6571
return;
6672
}
6773

6874
this._internalOrg = internalOrg;
6975
this._sku = sku;
70-
76+
this._isFcv1 = isFcv1;
7177
this.context.globalState.update(UserInfoStore.INTERNAL_ORG_STORAGE_KEY, this._internalOrg);
7278
this.context.globalState.update(UserInfoStore.SKU_STORAGE_KEY, this._sku);
79+
this.context.globalState.update(UserInfoStore.IS_FCV1_STORAGE_KEY, this._isFcv1);
7380

7481
this._onDidChangeUserInfo.fire();
7582
}
@@ -186,4 +193,4 @@ function equalMap(map1: Map<string, string>, map2: Map<string, string>): boolean
186193
}
187194

188195
return true;
189-
}
196+
}

src/platform/telemetry/vscode-node/microsoftExperimentationService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ class GithubAccountFilterProvider implements IExperimentationFilterProvider {
127127
constructor(private _userInfoStore: UserInfoStore, private _logService: ILogService) { }
128128

129129
getFilters(): Map<string, any> {
130-
this._logService.trace(`[GithubAccountFilterProvider]::getFilters SKU: ${this._userInfoStore.sku}, Internal Org: ${this._userInfoStore.internalOrg}`);
130+
this._logService.trace(`[GithubAccountFilterProvider]::getFilters SKU: ${this._userInfoStore.sku}, Internal Org: ${this._userInfoStore.internalOrg}, IsFcv1: ${this._userInfoStore.isFcv1}`);
131131
const filters = new Map<string, any>();
132132
filters.set('X-GitHub-Copilot-SKU', this._userInfoStore.sku);
133133
filters.set('X-Microsoft-Internal-Org', this._userInfoStore.internalOrg);
134+
filters.set('X-GitHub-Copilot-IsFcv1', this._userInfoStore.isFcv1);
134135
return filters;
135136
}
136137

@@ -174,7 +175,7 @@ export class MicrosoftExperimentationService extends BaseExperimentationService
174175
new CopilotExtensionsFilterProvider(logService),
175176
// The callback is called in super ctor. At that time, self/this is not initialized yet (but also, no filter could have been possibly set).
176177
new CopilotCompletionsFilterProvider(() => self?.getCompletionsFilters() ?? new Map(), logService),
177-
new DevDeviceIdFilterProvider(vscode.env.devDeviceId)
178+
new DevDeviceIdFilterProvider(vscode.env.devDeviceId),
178179
);
179180
};
180181

0 commit comments

Comments
 (0)