-
Notifications
You must be signed in to change notification settings - Fork 20
/
env.ts
50 lines (43 loc) · 1.64 KB
/
env.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {applyUrlOverrides, getValue, renderOverridesIndicator} from './overrides';
// Load overrides
applyUrlOverrides();
renderOverridesIndicator();
// Obtain dynamic variables from server
export const provided = (window as any)._env_;
// Build-time variables
export const build: BuildTimeEnvironment = {
sentryKey: getValue('REACT_APP_SENTRY_DSN', process.env.REACT_APP_SENTRY_DSN),
gtmKey: getValue('REACT_APP_GTM_ID', process.env.REACT_APP_GTM_ID),
version: getValue('REACT_APP_VERSION', process.env.REACT_APP_VERSION) || 'dev',
};
// Dynamic variables
export const dynamic: DynamicEnvironment = {
apiUrl: getValue('REACT_APP_API_SERVER_ENDPOINT', provided?.REACT_APP_API_SERVER_ENDPOINT),
basename: getValue('REACT_APP_ROOT_ROUTE', provided?.REACT_APP_ROOT_ROUTE),
bannersRotationTime: parseInt(
getValue('REACT_APP_BANNERS_ROTATION_TIME', provided?.REACT_APP_BANNERS_ROTATION_TIME) || 7 * 24 * 3600 * 1000,
10
),
disableTelemetry: getValue('REACT_APP_DISABLE_TELEMETRY', provided?.REACT_APP_DISABLE_TELEMETRY) === 'true',
crdOperatorRevision: getValue('REACT_APP_CRD_OPERATOR_REVISION', provided?.REACT_APP_CRD_OPERATOR_REVISION) || 'main',
debugTelemetry:
getValue('REACT_APP_DEBUG_TELEMETRY', provided?.REACT_APP_DEBUG_TELEMETRY) === 'true' ||
process.env.NODE_ENV !== 'production',
};
export interface BuildTimeEnvironment {
sentryKey?: string;
gtmKey?: string;
version: string;
}
export interface DynamicEnvironment {
apiUrl: string;
basename: string;
bannersRotationTime: number;
disableTelemetry: boolean;
crdOperatorRevision: string;
debugTelemetry: boolean;
}
export default {
...dynamic,
...build,
};