Skip to content

Commit 936e162

Browse files
committed
feat(ab env): check the current url
1 parent aa08489 commit 936e162

File tree

1 file changed

+7
-17
lines changed
  • packages/common/src/config

1 file changed

+7
-17
lines changed

packages/common/src/config/env.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@ const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
88
const LOCAL_SERVER = Boolean(JSON.stringify(process.env.LOCAL_SERVER));
99
const STAGING_API = Boolean(JSON.stringify(process.env.STAGING_API));
1010

11-
const getAbTestingEnv = () => {
12-
const host = () => {
13-
if (process.env.NODE_ENV === 'production') {
14-
const CODESANDBOX_HOST = getHost();
15-
return CODESANDBOX_HOST.split('//')[1];
16-
}
17-
18-
return process.env.DEV_DOMAIN;
19-
};
20-
21-
return `https://ab-testing.${
22-
process.env.NODE_ENV === 'development' || process.env.STAGING
23-
? 'codesandbox.stream'
24-
: host()
25-
}`;
26-
};
27-
export const AB_TESTING_URL = getAbTestingEnv();
11+
const AB_TESTING_URL_STAGING = 'https://ab-testing.codesandbox.stream';
12+
const AB_TESTING_URL_PRODUCTION = 'https://ab-testing.codesandbox.io';
13+
export const AB_TESTING_URL = /codesandbox\.io/.test(
14+
typeof window !== `undefined` ? window?.location?.host : ''
15+
)
16+
? AB_TESTING_URL_PRODUCTION
17+
: AB_TESTING_URL_STAGING;
2818

2919
export const getExperimentUserId = () => {
3020
const KEY_NAME = 'csb-ab-user-id';

0 commit comments

Comments
 (0)