Skip to content

Commit 82997ef

Browse files
authored
[dashboard] Use proxy endpoint to fetch feature flags (#16819)
* [dashboard] Use proxy endpoint to fetch feature flags * retest * fix * Fix * Fix
1 parent f260c31 commit 82997ef

File tree

1 file changed

+4
-28
lines changed
  • components/dashboard/src/experiments

1 file changed

+4
-28
lines changed

components/dashboard/src/experiments/client.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { newAlwaysReturningDefaultValueClient } from "@gitpod/gitpod-protocol/lib/experiments/always-default";
87
import * as configcat from "configcat-js";
98
import { ConfigCatClient } from "@gitpod/gitpod-protocol/lib/experiments/configcat";
109
import { Client } from "@gitpod/gitpod-protocol/lib/experiments/types";
@@ -18,40 +17,17 @@ export function getExperimentsClient(): Client {
1817
return client;
1918
}
2019

21-
const host = window.location.hostname;
22-
if (host === "gitpod.io") {
23-
client = newProductionConfigCatClient();
24-
} else if (host === "gitpod-staging.com" || host.endsWith("gitpod-dev.com") || host.endsWith("gitpod-io-dev.com")) {
25-
client = newNonProductionConfigCatClient();
26-
} else {
27-
// We're gonna use a client which always returns the default value.
28-
client = newAlwaysReturningDefaultValueClient();
29-
}
30-
20+
client = newProxyConfigCatClient();
3121
return client;
3222
}
3323

34-
// newProductionConfigCatClient constructs a new ConfigCat client with production configuration.
35-
function newProductionConfigCatClient(): Client {
36-
// clientKey is an identifier of our ConfigCat application. It is not a secret.
37-
const clientKey = "WBLaCPtkjkqKHlHedziE9g/TwAe6YyftEGPnGxVRXd0Ig";
38-
const client = configcat.createClientWithLazyLoad(clientKey, {
39-
logger: configcat.createConsoleLogger(LogLevel.Error),
40-
cacheTimeToLiveSeconds: 60 * 3, // 3 minutes
41-
requestTimeoutMs: 1500,
42-
});
43-
44-
return new ConfigCatClient(client);
45-
}
46-
47-
// newNonProductionConfigCatClient constructs a new ConfigCat client with non-production configuration.
48-
function newNonProductionConfigCatClient(): Client {
49-
// clientKey is an identifier of our ConfigCat application. It is not a secret.
50-
const clientKey = "WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw";
24+
function newProxyConfigCatClient(): Client {
25+
const clientKey = "gitpod"; // the client key is populated by the proxy
5126
const client = configcat.createClientWithLazyLoad(clientKey, {
5227
logger: configcat.createConsoleLogger(LogLevel.Error),
5328
cacheTimeToLiveSeconds: 60 * 3, // 3 minutes
5429
requestTimeoutMs: 1500,
30+
baseUrl: `${window.location.origin}/configcat`,
5531
});
5632

5733
return new ConfigCatClient(client);

0 commit comments

Comments
 (0)