4
4
* See License.AGPL.txt in the project root for license information.
5
5
*/
6
6
7
- import { newAlwaysReturningDefaultValueClient } from "@gitpod/gitpod-protocol/lib/experiments/always-default" ;
8
7
import * as configcat from "configcat-js" ;
9
8
import { ConfigCatClient } from "@gitpod/gitpod-protocol/lib/experiments/configcat" ;
10
9
import { Client } from "@gitpod/gitpod-protocol/lib/experiments/types" ;
@@ -18,40 +17,17 @@ export function getExperimentsClient(): Client {
18
17
return client ;
19
18
}
20
19
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 ( ) ;
31
21
return client ;
32
22
}
33
23
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
51
26
const client = configcat . createClientWithLazyLoad ( clientKey , {
52
27
logger : configcat . createConsoleLogger ( LogLevel . Error ) ,
53
28
cacheTimeToLiveSeconds : 60 * 3 , // 3 minutes
54
29
requestTimeoutMs : 1500 ,
30
+ baseUrl : `${ window . location . origin } /configcat` ,
55
31
} ) ;
56
32
57
33
return new ConfigCatClient ( client ) ;
0 commit comments