Skip to content

Commit ae0ad03

Browse files
committed
[experiments] ensure to check all teams
Before it would check only first team and then exit with whatever value if configured for all cases. Now it will continue to check next team if value is the same as default.
1 parent 266edb3 commit ae0ad03

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
],
1717
"outFiles": [
1818
"${workspaceRoot}/gitpod-web/out/**/*.js",
19+
"${workspaceRoot}/gitpod-shared/out/**/*.js",
1920
]
2021
},
2122
{

gitpod-shared/src/experiments.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,35 @@ export class ExperimentalSettings {
3838
});
3939
}
4040

41-
async get<T>(key: EXPERIMENTAL_SETTINGS): Promise<T | undefined> {
41+
async get<T>(key: EXPERIMENTAL_SETTINGS, defaultValue: T): Promise<T> {
4242
const config = vscode.workspace.getConfiguration(experimentsSection);
4343
const values = config.inspect<T>(key.substring((experimentsSection + '.').length));
4444
if (!values) {
4545
this.logger.error(`Cannot get invalid experimental setting '${key}'`);
46-
return undefined;
46+
return defaultValue;
4747
}
4848
if (values.globalValue !== undefined) {
4949
// User setting have priority over configcat so return early
5050
return values.globalValue;
5151
}
52-
const experimentValue = await this.getExperimentValue<T>(key);
53-
return experimentValue ?? values.defaultValue;
52+
return this.getExperimentValue<T>(key, defaultValue);
5453
}
5554

56-
private async getExperimentValue<T>(key: string): Promise<T | undefined> {
55+
private async getExperimentValue<T>(key: string, defaultValue: T): Promise<T> {
5756
const configcatKey = key.replace(/\./g, '_'); // '.' are not allowed in configcat
58-
const unresolved = '__unressssolved__'
59-
6057
const user = await this.pendingOwner;
6158
const email = User.getPrimaryEmail(user);
6259
const teams = await this.pendingTeams;
6360
if (teams.length) {
6461
for (const team of teams) {
65-
const value = (await this.configcatClient.getValueAsync(configcatKey, unresolved, this.getConfigcatUser(user.id, email, team.id)));
66-
if (value != unresolved) {
62+
const value = (await this.configcatClient.getValueAsync(configcatKey, defaultValue, this.getConfigcatUser(user.id, email, team.id)));
63+
if (value != defaultValue) {
6764
return value as T;
6865
}
6966
}
70-
} else {
71-
const value = (await this.configcatClient.getValueAsync(configcatKey, unresolved, this.getConfigcatUser(user.id, email, undefined)));
72-
if (value != unresolved) {
73-
return value as T;
74-
}
67+
return defaultValue;
7568
}
76-
return undefined;
69+
return this.configcatClient.getValueAsync(configcatKey, defaultValue, this.getConfigcatUser(user.id, email, undefined));
7770
}
7871

7972
private getConfigcatUser(userId: string, email: string | undefined, teamId: string | undefined): configcatcommon.User {

gitpod-shared/src/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class ValidateService extends vscode.Disposable {
123123
}
124124

125125
private async initialize(): Promise<void> {
126-
if (!(await this.context.experiments.get<boolean>('gitpod.experiments.rebuildHints'))) {
126+
if (!(await this.context.experiments.get<boolean>('gitpod.experiments.rebuildHints', false))) {
127127
return;
128128
}
129129

0 commit comments

Comments
 (0)