-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathenvironment_variables.js
141 lines (128 loc) · 3.55 KB
/
environment_variables.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
function normalizedPrefix (name) {
return name.replace('KADIRA_', 'MONTI_');
}
Kadira._parseEnv = function (env) {
let options = {};
for (let name in env) {
let value = env[name];
let normalizedName = normalizedPrefix(name);
let info = Kadira._parseEnv._options[normalizedName];
if (info && value) {
options[info.name] = info.parser(value);
}
}
return options;
};
Kadira._parseEnv.parseInt = function (str) {
let num = parseInt(str, 10);
if (num || num === 0) {
return num;
}
throw new Error(`Kadira: Match Error: "${num}" is not a number`);
};
Kadira._parseEnv.parseBool = function (str) {
str = str.toLowerCase();
if (str === 'true') {
return true;
}
if (str === 'false') {
return false;
}
throw new Error(`Kadira: Match Error: ${str} is not a boolean`);
};
Kadira._parseEnv.parseUrl = function (str) {
return str;
};
Kadira._parseEnv.parseString = function (str) {
return str;
};
Kadira._parseEnv._options = {
// auth
MONTI_APP_ID: {
name: 'appId',
parser: Kadira._parseEnv.parseString
},
MONTI_APP_SECRET: {
name: 'appSecret',
parser: Kadira._parseEnv.parseString
},
MONTI_OPTIONS_STALLED_TIMEOUT: {
name: 'stalledTimeout',
parser: Kadira._parseEnv.parseInt,
},
// delay to send the initial ping to the kadira engine after page loads
MONTI_OPTIONS_CLIENT_ENGINE_SYNC_DELAY: {
name: 'clientEngineSyncDelay',
parser: Kadira._parseEnv.parseInt,
},
// time between sending errors to the engine
MONTI_OPTIONS_ERROR_DUMP_INTERVAL: {
name: 'errorDumpInterval',
parser: Kadira._parseEnv.parseInt,
},
// no of errors allowed in a given interval
MONTI_OPTIONS_MAX_ERRORS_PER_INTERVAL: {
name: 'maxErrorsPerInterval',
parser: Kadira._parseEnv.parseInt,
},
// a zone.js specific option to collect the full stack trace(which is not much useful)
MONTI_OPTIONS_COLLECT_ALL_STACKS: {
name: 'collectAllStacks',
parser: Kadira._parseEnv.parseBool,
},
// enable error tracking (which is turned on by default)
MONTI_OPTIONS_ENABLE_ERROR_TRACKING: {
name: 'enableErrorTracking',
parser: Kadira._parseEnv.parseBool,
},
MONTI_OPTIONS_DISABLE_CLIENT_ERROR_TRACKING: {
name: 'disableClientErrorTracking',
parser: Kadira._parseEnv.parseBool,
},
// kadira engine endpoint
MONTI_OPTIONS_ENDPOINT: {
name: 'endpoint',
parser: Kadira._parseEnv.parseUrl,
},
// define the hostname of the current running process
MONTI_OPTIONS_HOSTNAME: {
name: 'hostname',
parser: Kadira._parseEnv.parseString,
},
// interval between sending data to the kadira engine from the server
MONTI_OPTIONS_PAYLOAD_TIMEOUT: {
name: 'payloadTimeout',
parser: Kadira._parseEnv.parseInt,
},
// set HTTP/HTTPS proxy
MONTI_OPTIONS_PROXY: {
name: 'proxy',
parser: Kadira._parseEnv.parseUrl,
},
// number of items cached for tracking document size
MONTI_OPTIONS_DOCUMENT_SIZE_CACHE_SIZE: {
name: 'documentSizeCacheSize',
parser: Kadira._parseEnv.parseInt,
},
// enable uploading sourcemaps
MONTI_UPLOAD_SOURCE_MAPS: {
name: 'uploadSourceMaps',
parser: Kadira._parseEnv.parseBool
},
MONTI_RECORD_IP_ADDRESS: {
name: 'recordIPAddress',
parser: Kadira._parseEnv.parseString,
},
MONTI_EVENT_STACK_TRACE: {
name: 'eventStackTrace',
parser: Kadira._parseEnv.parseBool,
},
MONTI_OPTIONS_DISABLE_NTP: {
name: 'disableNtp',
parser: Kadira._parseEnv.parseBool,
},
MONTI_DISABLE_INSTRUMENTATION: {
name: 'disableInstrumentation',
parser: Kadira._parseEnv.parseBool
}
};