@microsoft/1ds-core-js 3.1.9 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/bundle/{ms.core-3.1.9.gbl.js → ms.core-3.2.0.gbl.js} +2560 -1200
  3. package/bundle/ms.core-3.2.0.gbl.js.map +1 -0
  4. package/bundle/ms.core-3.2.0.gbl.min.js +7 -0
  5. package/bundle/ms.core-3.2.0.gbl.min.js.map +1 -0
  6. package/bundle/ms.core-3.2.0.integrity.json +46 -0
  7. package/bundle/{ms.core-3.1.9.js → ms.core-3.2.0.js} +2560 -1200
  8. package/bundle/ms.core-3.2.0.js.map +1 -0
  9. package/bundle/ms.core-3.2.0.min.js +7 -0
  10. package/bundle/ms.core-3.2.0.min.js.map +1 -0
  11. package/bundle/ms.core.gbl.js +2559 -1199
  12. package/bundle/ms.core.gbl.js.map +1 -1
  13. package/bundle/ms.core.gbl.min.js +2 -2
  14. package/bundle/ms.core.gbl.min.js.map +1 -1
  15. package/bundle/ms.core.integrity.json +17 -17
  16. package/bundle/ms.core.js +2559 -1199
  17. package/bundle/ms.core.js.map +1 -1
  18. package/bundle/ms.core.min.js +2 -2
  19. package/bundle/ms.core.min.js.map +1 -1
  20. package/dist/ms.core.js +97 -56
  21. package/dist/ms.core.js.map +1 -1
  22. package/dist/ms.core.min.js +2 -2
  23. package/dist/ms.core.min.js.map +1 -1
  24. package/dist-esm/src/AppInsightsCore.js +5 -6
  25. package/dist-esm/src/AppInsightsCore.js.map +1 -1
  26. package/dist-esm/src/BaseCore.d.ts +0 -8
  27. package/dist-esm/src/BaseCore.js +4 -5
  28. package/dist-esm/src/BaseCore.js.map +1 -1
  29. package/dist-esm/src/DataModels.js +1 -1
  30. package/dist-esm/src/ESPromise.js +1 -1
  31. package/dist-esm/src/ESPromiseScheduler.js +1 -1
  32. package/dist-esm/src/Enums.d.ts +174 -172
  33. package/dist-esm/src/Enums.js +63 -103
  34. package/dist-esm/src/Enums.js.map +1 -1
  35. package/dist-esm/src/Index.d.ts +4 -3
  36. package/dist-esm/src/Index.js +4 -6
  37. package/dist-esm/src/Index.js.map +1 -1
  38. package/dist-esm/src/Utils.d.ts +6 -5
  39. package/dist-esm/src/Utils.js +21 -14
  40. package/dist-esm/src/Utils.js.map +1 -1
  41. package/dist-esm/src/ValueSanitizer.js +1 -1
  42. package/package.json +4 -4
  43. package/src/AppInsightsCore.ts +6 -6
  44. package/src/BaseCore.ts +6 -6
  45. package/src/Enums.ts +155 -65
  46. package/src/Index.ts +14 -7
  47. package/src/Utils.ts +23 -14
  48. package/bundle/ms.core-3.1.9.gbl.js.map +0 -1
  49. package/bundle/ms.core-3.1.9.gbl.min.js +0 -7
  50. package/bundle/ms.core-3.1.9.gbl.min.js.map +0 -1
  51. package/bundle/ms.core-3.1.9.integrity.json +0 -46
  52. package/bundle/ms.core-3.1.9.js.map +0 -1
  53. package/bundle/ms.core-3.1.9.min.js +0 -7
  54. package/bundle/ms.core-3.1.9.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * 1DS JS SDK Core, 3.1.9
2
+ * 1DS JS SDK Core, 3.2.0
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -21,20 +21,24 @@
21
21
  var ObjDefineProperty = ObjClass["defineProperty"];
22
22
  var ObjHasOwnProperty = ObjProto[strShimHasOwnProperty];
23
23
 
24
- function getGlobal() {
25
- if (typeof globalThis !== strShimUndefined && globalThis) {
26
- return globalThis;
27
- }
28
- if (typeof self !== strShimUndefined && self) {
29
- return self;
30
- }
31
- if (typeof window !== strShimUndefined && window) {
32
- return window;
33
- }
34
- if (typeof global !== strShimUndefined && global) {
35
- return global;
24
+ var _cachedGlobal = null;
25
+ function getGlobal(useCached) {
26
+ if (useCached === void 0) { useCached = true; }
27
+ if (!_cachedGlobal || !useCached) {
28
+ if (typeof globalThis !== strShimUndefined && globalThis) {
29
+ _cachedGlobal = globalThis;
30
+ }
31
+ if (typeof self !== strShimUndefined && self) {
32
+ _cachedGlobal = self;
33
+ }
34
+ if (typeof window !== strShimUndefined && window) {
35
+ _cachedGlobal = window;
36
+ }
37
+ if (typeof global !== strShimUndefined && global) {
38
+ _cachedGlobal = global;
39
+ }
36
40
  }
37
- return null;
41
+ return _cachedGlobal;
38
42
  }
39
43
  function throwTypeError(message) {
40
44
  throw new TypeError(message);
@@ -49,7 +53,7 @@
49
53
  }
50
54
  var type = typeof obj;
51
55
  if (type !== strShimObject && type !== strShimFunction) {
52
- throwTypeError('Object prototype may only be an Object:' + obj);
56
+ throwTypeError("Object prototype may only be an Object:" + obj);
53
57
  }
54
58
  function tmpFunc() { }
55
59
  tmpFunc[strShimPrototype] = obj;
@@ -99,577 +103,303 @@
99
103
 
100
104
  var MinChannelPriorty = 100;
101
105
 
102
- var EventsDiscardedReason = {
103
- Unknown: 0,
104
- NonRetryableStatus: 1,
105
- InvalidEvent: 2,
106
- SizeLimitExceeded: 3,
107
- KillSwitch: 4,
108
- QueueFull: 5
109
- };
106
+ var strEmpty = "";
107
+ var strProcessTelemetry = "processTelemetry";
108
+ var strPriority = "priority";
109
+ var strSetNextPlugin = "setNextPlugin";
110
+ var strIsInitialized = "isInitialized";
111
+ var strTeardown = "teardown";
112
+ var strCore = "core";
113
+ var strUpdate = "update";
114
+ var strDisabled = "disabled";
115
+ var strDoTeardown = "_doTeardown";
116
+ var strProcessNext = "processNext";
117
+ var strResume = "resume";
118
+ var strPause = "pause";
119
+ var strNotificationListener = "NotificationListener";
120
+ var strAddNotificationListener = "add" + strNotificationListener;
121
+ var strRemoveNotificationListener = "remove" + strNotificationListener;
122
+ var strEventsSent = "eventsSent";
123
+ var strEventsDiscarded = "eventsDiscarded";
124
+ var strEventsSendRequest = "eventsSendRequest";
125
+ var strPerfEvent = "perfEvent";
110
126
 
111
- /*!
112
- * Microsoft Dynamic Proto Utility, 1.1.4
113
- * Copyright (c) Microsoft and contributors. All rights reserved.
114
- */
115
- var Constructor = 'constructor';
116
- var Prototype = 'prototype';
117
- var strFunction = 'function';
118
- var DynInstFuncTable = '_dynInstFuncs';
119
- var DynProxyTag = '_isDynProxy';
120
- var DynClassName = '_dynClass';
121
- var DynClassNamePrefix = '_dynCls$';
122
- var DynInstChkTag = '_dynInstChk';
123
- var DynAllowInstChkTag = DynInstChkTag;
124
- var DynProtoDefaultOptions = '_dfOpts';
125
- var UnknownValue = '_unknown_';
126
- var str__Proto = "__proto__";
127
- var strUseBaseInst = 'useBaseInst';
128
- var strSetInstFuncs = 'setInstFuncs';
129
- var Obj = Object;
130
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
131
- var _dynamicNames = 0;
132
- function _hasOwnProperty(obj, prop) {
133
- return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
134
- }
135
- function _isObjectOrArrayPrototype(target) {
136
- return target && (target === Obj[Prototype] || target === Array[Prototype]);
137
- }
138
- function _isObjectArrayOrFunctionPrototype(target) {
139
- return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
140
- }
141
- function _getObjProto(target) {
127
+ var strToISOString = "toISOString";
128
+ var cStrEndsWith = "endsWith";
129
+ var cStrStartsWith = "startsWith";
130
+ var strIndexOf = "indexOf";
131
+ var strMap = "map";
132
+ var strReduce = "reduce";
133
+ var cStrTrim = "trim";
134
+ var strToString = "toString";
135
+ var str__Proto$1 = "__proto__";
136
+ var strConstructor = "constructor";
137
+ var _objDefineProperty$1 = ObjDefineProperty;
138
+ var _objFreeze = ObjClass.freeze;
139
+ var _objSeal = ObjClass.seal;
140
+ var _objKeys = ObjClass.keys;
141
+ var StringProto = String[strShimPrototype];
142
+ var _strTrim = StringProto[cStrTrim];
143
+ var _strEndsWith = StringProto[cStrEndsWith];
144
+ var _strStartsWith = StringProto[cStrStartsWith];
145
+ var DateProto = Date[strShimPrototype];
146
+ var _dataToISOString = DateProto[strToISOString];
147
+ var _isArray = Array.isArray;
148
+ var _objToString = ObjProto[strToString];
149
+ var _fnToString = ObjHasOwnProperty[strToString];
150
+ var _objFunctionString = _fnToString.call(ObjClass);
151
+ var rCamelCase = /-([a-z])/g;
152
+ var rNormalizeInvalid = /([^\w\d_$])/g;
153
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
154
+ var _objGetPrototypeOf$1 = Object["getPrototypeOf"];
155
+ function _getObjProto$1(target) {
142
156
  if (target) {
143
- if (_objGetPrototypeOf) {
144
- return _objGetPrototypeOf(target);
157
+ if (_objGetPrototypeOf$1) {
158
+ return _objGetPrototypeOf$1(target);
145
159
  }
146
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
160
+ var newProto = target[str__Proto$1] || target[strShimPrototype] || target[strConstructor];
147
161
  if (newProto) {
148
162
  return newProto;
149
163
  }
150
164
  }
151
165
  return null;
152
166
  }
153
- function _forEachProp(target, func) {
154
- var props = [];
155
- var getOwnProps = Obj["getOwnPropertyNames"];
156
- if (getOwnProps) {
157
- props = getOwnProps(target);
167
+ function isTypeof(value, theType) {
168
+ return typeof value === theType;
169
+ }
170
+ function isUndefined(value) {
171
+ return value === undefined || typeof value === strShimUndefined;
172
+ }
173
+ function isNullOrUndefined(value) {
174
+ return (value === null || isUndefined(value));
175
+ }
176
+ function isNotNullOrUndefined(value) {
177
+ return !isNullOrUndefined(value);
178
+ }
179
+ function hasOwnProperty(obj, prop) {
180
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
181
+ }
182
+ function isObject(value) {
183
+ return !!(value && typeof value === strShimObject);
184
+ }
185
+ function isFunction(value) {
186
+ return !!(value && typeof value === strShimFunction);
187
+ }
188
+ function normalizeJsName(name) {
189
+ var value = name;
190
+ if (value && isString(value)) {
191
+ value = value.replace(rCamelCase, function (_all, letter) {
192
+ return letter.toUpperCase();
193
+ });
194
+ value = value.replace(rNormalizeInvalid, "_");
195
+ value = value.replace(rLeadingNumeric, function (_all, match) {
196
+ return "_" + match;
197
+ });
158
198
  }
159
- else {
160
- for (var name_1 in target) {
161
- if (typeof name_1 === "string" && _hasOwnProperty(target, name_1)) {
162
- props.push(name_1);
199
+ return value;
200
+ }
201
+ function objForEachKey(target, callbackfn) {
202
+ if (target) {
203
+ for (var prop in target) {
204
+ if (ObjHasOwnProperty.call(target, prop)) {
205
+ callbackfn.call(target, prop, target[prop]);
163
206
  }
164
207
  }
165
208
  }
166
- if (props && props.length > 0) {
167
- for (var lp = 0; lp < props.length; lp++) {
168
- func(props[lp]);
169
- }
209
+ }
210
+ function strEndsWith(value, search) {
211
+ var result = false;
212
+ if (value && search && !(result = value === search)) {
213
+ result = _strEndsWith ? value[cStrEndsWith](search) : _strEndsWithPoly(value, search);
170
214
  }
215
+ return result;
171
216
  }
172
- function _isDynamicCandidate(target, funcName, skipOwn) {
173
- return (funcName !== Constructor && typeof target[funcName] === strFunction && (skipOwn || _hasOwnProperty(target, funcName)));
217
+ function _strEndsWithPoly(value, search) {
218
+ var result = false;
219
+ var searchLen = search ? search.length : 0;
220
+ var valLen = value ? value.length : 0;
221
+ if (searchLen && valLen && valLen >= searchLen && !(result = value === search)) {
222
+ var pos = valLen - 1;
223
+ for (var lp = searchLen - 1; lp >= 0; lp--) {
224
+ if (value[pos] != search[lp]) {
225
+ return false;
226
+ }
227
+ pos--;
228
+ }
229
+ result = true;
230
+ }
231
+ return result;
174
232
  }
175
- function _throwTypeError(message) {
176
- throw new TypeError("DynamicProto: " + message);
233
+ function strStartsWith(value, checkValue) {
234
+ var result = false;
235
+ if (value && checkValue && !(result = value === checkValue)) {
236
+ result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
237
+ }
238
+ return result;
177
239
  }
178
- function _getInstanceFuncs(thisTarget) {
179
- var instFuncs = {};
180
- _forEachProp(thisTarget, function (name) {
181
- if (!instFuncs[name] && _isDynamicCandidate(thisTarget, name, false)) {
182
- instFuncs[name] = thisTarget[name];
240
+ function _strStartsWithPoly(value, checkValue) {
241
+ var result = false;
242
+ var chkLen = checkValue ? checkValue.length : 0;
243
+ if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
244
+ for (var lp = 0; lp < chkLen; lp++) {
245
+ if (value[lp] !== checkValue[lp]) {
246
+ return false;
247
+ }
183
248
  }
184
- });
185
- return instFuncs;
249
+ result = true;
250
+ }
251
+ return result;
186
252
  }
187
- function _hasVisited(values, value) {
188
- for (var lp = values.length - 1; lp >= 0; lp--) {
189
- if (values[lp] === value) {
190
- return true;
191
- }
253
+ function strContains(value, search) {
254
+ if (value && search) {
255
+ return value.indexOf(search) !== -1;
192
256
  }
193
257
  return false;
194
258
  }
195
- function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
196
- function _instFuncProxy(target, funcHost, funcName) {
197
- var theFunc = funcHost[funcName];
198
- if (theFunc[DynProxyTag] && useBaseInst) {
199
- var instFuncTable = target[DynInstFuncTable] || {};
200
- if (instFuncTable[DynAllowInstChkTag] !== false) {
201
- theFunc = (instFuncTable[funcHost[DynClassName]] || {})[funcName] || theFunc;
259
+ function isDate(obj) {
260
+ return !!(obj && _objToString.call(obj) === "[object Date]");
261
+ }
262
+ var isArray = _isArray || _isArrayPoly;
263
+ function _isArrayPoly(obj) {
264
+ return !!(obj && _objToString.call(obj) === "[object Array]");
265
+ }
266
+ function isError(obj) {
267
+ return !!(obj && _objToString.call(obj) === "[object Error]");
268
+ }
269
+ function isString(value) {
270
+ return typeof value === "string";
271
+ }
272
+ function isNumber(value) {
273
+ return typeof value === "number";
274
+ }
275
+ function isBoolean(value) {
276
+ return typeof value === "boolean";
277
+ }
278
+ function isPlainObject(value) {
279
+ var result = false;
280
+ if (value && typeof value === "object") {
281
+ var proto = _objGetPrototypeOf$1 ? _objGetPrototypeOf$1(value) : _getObjProto$1(value);
282
+ if (!proto) {
283
+ result = true;
284
+ }
285
+ else {
286
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
287
+ proto = proto[strConstructor];
202
288
  }
289
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
203
290
  }
204
- return function () {
205
- return theFunc.apply(target, arguments);
206
- };
207
291
  }
208
- var baseFuncs = {};
209
- _forEachProp(instFuncs, function (name) {
210
- baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
211
- });
212
- var baseProto = _getObjProto(classProto);
213
- var visited = [];
214
- while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
215
- _forEachProp(baseProto, function (name) {
216
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
217
- baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
292
+ return result;
293
+ }
294
+ function toISOString(date) {
295
+ if (date) {
296
+ return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
297
+ }
298
+ }
299
+ function _toISOStringPoly(date) {
300
+ if (date && date.getUTCFullYear) {
301
+ var pad = function (num) {
302
+ var r = String(num);
303
+ if (r.length === 1) {
304
+ r = "0" + r;
218
305
  }
219
- });
220
- visited.push(baseProto);
221
- baseProto = _getObjProto(baseProto);
306
+ return r;
307
+ };
308
+ return date.getUTCFullYear()
309
+ + "-" + pad(date.getUTCMonth() + 1)
310
+ + "-" + pad(date.getUTCDate())
311
+ + "T" + pad(date.getUTCHours())
312
+ + ":" + pad(date.getUTCMinutes())
313
+ + ":" + pad(date.getUTCSeconds())
314
+ + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
315
+ + "Z";
222
316
  }
223
- return baseFuncs;
224
317
  }
225
- function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
226
- var instFunc = null;
227
- if (target && _hasOwnProperty(proto, DynClassName)) {
228
- var instFuncTable = target[DynInstFuncTable] || {};
229
- instFunc = (instFuncTable[proto[DynClassName]] || {})[funcName];
230
- if (!instFunc) {
231
- _throwTypeError("Missing [" + funcName + "] " + strFunction);
232
- }
233
- if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
234
- var canAddInst = !_hasOwnProperty(target, funcName);
235
- var objProto = _getObjProto(target);
236
- var visited = [];
237
- while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
238
- var protoFunc = objProto[funcName];
239
- if (protoFunc) {
240
- canAddInst = (protoFunc === currentDynProtoProxy);
318
+ function arrForEach(arr, callbackfn, thisArg) {
319
+ var len = arr.length;
320
+ try {
321
+ for (var idx = 0; idx < len; idx++) {
322
+ if (idx in arr) {
323
+ if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
241
324
  break;
242
325
  }
243
- visited.push(objProto);
244
- objProto = _getObjProto(objProto);
245
- }
246
- try {
247
- if (canAddInst) {
248
- target[funcName] = instFunc;
249
- }
250
- instFunc[DynInstChkTag] = 1;
251
- }
252
- catch (e) {
253
- instFuncTable[DynAllowInstChkTag] = false;
254
326
  }
255
327
  }
256
328
  }
257
- return instFunc;
258
- }
259
- function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
260
- var protoFunc = proto[funcName];
261
- if (protoFunc === currentDynProtoProxy) {
262
- protoFunc = _getObjProto(proto)[funcName];
263
- }
264
- if (typeof protoFunc !== strFunction) {
265
- _throwTypeError("[" + funcName + "] is not a " + strFunction);
329
+ catch (e) {
266
330
  }
267
- return protoFunc;
268
331
  }
269
- function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
270
- function _createDynamicPrototype(proto, funcName) {
271
- var dynProtoProxy = function () {
272
- var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
273
- return instFunc.apply(this, arguments);
274
- };
275
- dynProtoProxy[DynProxyTag] = 1;
276
- return dynProtoProxy;
277
- }
278
- if (!_isObjectOrArrayPrototype(proto)) {
279
- var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
280
- var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
281
- if (instFuncTable[DynAllowInstChkTag] !== false) {
282
- instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
332
+ function arrIndexOf(arr, searchElement, fromIndex) {
333
+ if (arr) {
334
+ if (arr[strIndexOf]) {
335
+ return arr[strIndexOf](searchElement, fromIndex);
283
336
  }
284
- _forEachProp(target, function (name) {
285
- if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
286
- instFuncs_1[name] = target[name];
287
- delete target[name];
288
- if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
289
- proto[name] = _createDynamicPrototype(proto, name);
337
+ var len = arr.length;
338
+ var from = fromIndex || 0;
339
+ try {
340
+ for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
341
+ if (lp in arr && arr[lp] === searchElement) {
342
+ return lp;
290
343
  }
291
344
  }
292
- });
345
+ }
346
+ catch (e) {
347
+ }
293
348
  }
349
+ return -1;
294
350
  }
295
- function _checkPrototype(classProto, thisTarget) {
296
- if (_objGetPrototypeOf) {
297
- var visited = [];
298
- var thisProto = _getObjProto(thisTarget);
299
- while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
300
- if (thisProto === classProto) {
301
- return true;
302
- }
303
- visited.push(thisProto);
304
- thisProto = _getObjProto(thisProto);
305
- }
306
- }
307
- return false;
308
- }
309
- function _getObjName(target, unknownValue) {
310
- if (_hasOwnProperty(target, Prototype)) {
311
- return target.name || unknownValue || UnknownValue;
312
- }
313
- return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
314
- }
315
- function dynamicProto(theClass, target, delegateFunc, options) {
316
- if (!_hasOwnProperty(theClass, Prototype)) {
317
- _throwTypeError("theClass is an invalid class definition.");
318
- }
319
- var classProto = theClass[Prototype];
320
- if (!_checkPrototype(classProto, target)) {
321
- _throwTypeError("[" + _getObjName(theClass) + "] is not in class hierarchy of [" + _getObjName(target) + "]");
322
- }
323
- var className = null;
324
- if (_hasOwnProperty(classProto, DynClassName)) {
325
- className = classProto[DynClassName];
326
- }
327
- else {
328
- className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _dynamicNames;
329
- _dynamicNames++;
330
- classProto[DynClassName] = className;
331
- }
332
- var perfOptions = dynamicProto[DynProtoDefaultOptions];
333
- var useBaseInst = !!perfOptions[strUseBaseInst];
334
- if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
335
- useBaseInst = !!options[strUseBaseInst];
336
- }
337
- var instFuncs = _getInstanceFuncs(target);
338
- var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
339
- delegateFunc(target, baseFuncs);
340
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
341
- if (setInstanceFunc && options) {
342
- setInstanceFunc = !!options[strSetInstFuncs];
343
- }
344
- _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
345
- }
346
- var perfDefaults = {
347
- setInstFuncs: true,
348
- useBaseInst: true
349
- };
350
- dynamicProto[DynProtoDefaultOptions] = perfDefaults;
351
-
352
- exports.LoggingSeverity = void 0;
353
- (function (LoggingSeverity) {
354
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
355
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
356
- })(exports.LoggingSeverity || (exports.LoggingSeverity = {}));
357
- var _InternalMessageId = {
358
- BrowserDoesNotSupportLocalStorage: 0,
359
- BrowserCannotReadLocalStorage: 1,
360
- BrowserCannotReadSessionStorage: 2,
361
- BrowserCannotWriteLocalStorage: 3,
362
- BrowserCannotWriteSessionStorage: 4,
363
- BrowserFailedRemovalFromLocalStorage: 5,
364
- BrowserFailedRemovalFromSessionStorage: 6,
365
- CannotSendEmptyTelemetry: 7,
366
- ClientPerformanceMathError: 8,
367
- ErrorParsingAISessionCookie: 9,
368
- ErrorPVCalc: 10,
369
- ExceptionWhileLoggingError: 11,
370
- FailedAddingTelemetryToBuffer: 12,
371
- FailedMonitorAjaxAbort: 13,
372
- FailedMonitorAjaxDur: 14,
373
- FailedMonitorAjaxOpen: 15,
374
- FailedMonitorAjaxRSC: 16,
375
- FailedMonitorAjaxSend: 17,
376
- FailedMonitorAjaxGetCorrelationHeader: 18,
377
- FailedToAddHandlerForOnBeforeUnload: 19,
378
- FailedToSendQueuedTelemetry: 20,
379
- FailedToReportDataLoss: 21,
380
- FlushFailed: 22,
381
- MessageLimitPerPVExceeded: 23,
382
- MissingRequiredFieldSpecification: 24,
383
- NavigationTimingNotSupported: 25,
384
- OnError: 26,
385
- SessionRenewalDateIsZero: 27,
386
- SenderNotInitialized: 28,
387
- StartTrackEventFailed: 29,
388
- StopTrackEventFailed: 30,
389
- StartTrackFailed: 31,
390
- StopTrackFailed: 32,
391
- TelemetrySampledAndNotSent: 33,
392
- TrackEventFailed: 34,
393
- TrackExceptionFailed: 35,
394
- TrackMetricFailed: 36,
395
- TrackPVFailed: 37,
396
- TrackPVFailedCalc: 38,
397
- TrackTraceFailed: 39,
398
- TransmissionFailed: 40,
399
- FailedToSetStorageBuffer: 41,
400
- FailedToRestoreStorageBuffer: 42,
401
- InvalidBackendResponse: 43,
402
- FailedToFixDepricatedValues: 44,
403
- InvalidDurationValue: 45,
404
- TelemetryEnvelopeInvalid: 46,
405
- CreateEnvelopeError: 47,
406
- CannotSerializeObject: 48,
407
- CannotSerializeObjectNonSerializable: 49,
408
- CircularReferenceDetected: 50,
409
- ClearAuthContextFailed: 51,
410
- ExceptionTruncated: 52,
411
- IllegalCharsInName: 53,
412
- ItemNotInArray: 54,
413
- MaxAjaxPerPVExceeded: 55,
414
- MessageTruncated: 56,
415
- NameTooLong: 57,
416
- SampleRateOutOfRange: 58,
417
- SetAuthContextFailed: 59,
418
- SetAuthContextFailedAccountName: 60,
419
- StringValueTooLong: 61,
420
- StartCalledMoreThanOnce: 62,
421
- StopCalledWithoutStart: 63,
422
- TelemetryInitializerFailed: 64,
423
- TrackArgumentsNotSpecified: 65,
424
- UrlTooLong: 66,
425
- SessionStorageBufferFull: 67,
426
- CannotAccessCookie: 68,
427
- IdTooLong: 69,
428
- InvalidEvent: 70,
429
- FailedMonitorAjaxSetRequestHeader: 71,
430
- SendBrowserInfoOnUserInit: 72,
431
- PluginException: 73,
432
- NotificationException: 74,
433
- SnippetScriptLoadFailure: 99,
434
- InvalidInstrumentationKey: 100,
435
- CannotParseAiBlobValue: 101,
436
- InvalidContentBlob: 102,
437
- TrackPageActionEventFailed: 103,
438
- FailedAddingCustomDefinedRequestContext: 104,
439
- InMemoryStorageBufferFull: 105
440
- };
441
-
442
- var strOnPrefix = "on";
443
- var strAttachEvent = "attachEvent";
444
- var strAddEventHelper = "addEventListener";
445
- var strDetachEvent = "detachEvent";
446
- var strRemoveEventListener = "removeEventListener";
447
- var _objDefineProperty = ObjDefineProperty;
448
- function objToString(obj) {
449
- return ObjProto.toString.call(obj);
450
- }
451
- function isTypeof(value, theType) {
452
- return typeof value === theType;
453
- }
454
- function isUndefined(value) {
455
- return value === undefined || typeof value === strShimUndefined;
456
- }
457
- function isNullOrUndefined(value) {
458
- return (value === null || isUndefined(value));
459
- }
460
- function isNotNullOrUndefined(value) {
461
- return !isNullOrUndefined(value);
462
- }
463
- function hasOwnProperty(obj, prop) {
464
- return obj && ObjHasOwnProperty.call(obj, prop);
465
- }
466
- function isObject(value) {
467
- return typeof value === strShimObject;
468
- }
469
- function isFunction(value) {
470
- return typeof value === strShimFunction;
471
- }
472
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
473
- if (useCapture === void 0) { useCapture = false; }
474
- var result = false;
475
- if (!isNullOrUndefined(obj)) {
476
- try {
477
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
478
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
479
- result = true;
480
- }
481
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
482
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
483
- result = true;
484
- }
485
- }
486
- catch (e) {
351
+ function arrMap(arr, callbackfn, thisArg) {
352
+ var results;
353
+ if (arr) {
354
+ if (arr[strMap]) {
355
+ return arr[strMap](callbackfn, thisArg);
487
356
  }
488
- }
489
- return result;
490
- }
491
- function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
492
- if (useCapture === void 0) { useCapture = false; }
493
- if (!isNullOrUndefined(obj)) {
357
+ var len = arr.length;
358
+ var _this = thisArg || arr;
359
+ results = new Array(len);
494
360
  try {
495
- if (!isNullOrUndefined(obj[strRemoveEventListener])) {
496
- obj[strRemoveEventListener](eventNameWithoutOn, handlerRef, useCapture);
497
- }
498
- else if (!isNullOrUndefined(obj[strDetachEvent])) {
499
- obj[strDetachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
361
+ for (var lp = 0; lp < len; lp++) {
362
+ if (lp in arr) {
363
+ results[lp] = callbackfn.call(_this, arr[lp], arr);
364
+ }
500
365
  }
501
366
  }
502
367
  catch (e) {
503
368
  }
504
369
  }
370
+ return results;
505
371
  }
506
- function normalizeJsName(name) {
507
- var value = name;
508
- var match = /([^\w\d_$])/g;
509
- if (match.test(name)) {
510
- value = name.replace(match, "_");
511
- }
512
- return value;
513
- }
514
- function objForEachKey(target, callbackfn) {
515
- if (target) {
516
- for (var prop in target) {
517
- if (ObjHasOwnProperty.call(target, prop)) {
518
- callbackfn.call(target, prop, target[prop]);
519
- }
520
- }
521
- }
522
- }
523
- function strEndsWith(value, search) {
524
- if (value && search) {
525
- var searchLen = search.length;
526
- var valLen = value.length;
527
- if (value === search) {
528
- return true;
529
- }
530
- else if (valLen >= searchLen) {
531
- var pos = valLen - 1;
532
- for (var lp = searchLen - 1; lp >= 0; lp--) {
533
- if (value[pos] != search[lp]) {
534
- return false;
535
- }
536
- pos--;
537
- }
538
- return true;
539
- }
540
- }
541
- return false;
542
- }
543
- function strStartsWith(value, checkValue) {
544
- var result = false;
545
- if (value && checkValue) {
546
- var chkLen = checkValue.length;
547
- if (value === checkValue) {
548
- return true;
549
- }
550
- else if (value.length >= chkLen) {
551
- for (var lp = 0; lp < chkLen; lp++) {
552
- if (value[lp] !== checkValue[lp]) {
553
- return false;
554
- }
555
- }
556
- result = true;
372
+ function arrReduce(arr, callbackfn, initialValue) {
373
+ var value;
374
+ if (arr) {
375
+ if (arr[strReduce]) {
376
+ return arr[strReduce](callbackfn, initialValue);
557
377
  }
558
- }
559
- return result;
560
- }
561
- function strContains(value, search) {
562
- if (value && search) {
563
- return value.indexOf(search) !== -1;
564
- }
565
- return false;
566
- }
567
- function isDate(obj) {
568
- return objToString(obj) === "[object Date]";
569
- }
570
- function isArray(obj) {
571
- return objToString(obj) === "[object Array]";
572
- }
573
- function isError(obj) {
574
- return objToString(obj) === "[object Error]";
575
- }
576
- function isString(value) {
577
- return typeof value === "string";
578
- }
579
- function isNumber(value) {
580
- return typeof value === "number";
581
- }
582
- function isBoolean(value) {
583
- return typeof value === "boolean";
584
- }
585
- function toISOString(date) {
586
- if (isDate(date)) {
587
- var pad = function (num) {
588
- var r = String(num);
589
- if (r.length === 1) {
590
- r = "0" + r;
591
- }
592
- return r;
593
- };
594
- return date.getUTCFullYear()
595
- + "-" + pad(date.getUTCMonth() + 1)
596
- + "-" + pad(date.getUTCDate())
597
- + "T" + pad(date.getUTCHours())
598
- + ":" + pad(date.getUTCMinutes())
599
- + ":" + pad(date.getUTCSeconds())
600
- + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
601
- + "Z";
602
- }
603
- }
604
- function arrForEach(arr, callbackfn, thisArg) {
605
- var len = arr.length;
606
- try {
607
- for (var idx = 0; idx < len; idx++) {
608
- if (idx in arr) {
609
- if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
610
- break;
611
- }
612
- }
378
+ var len = arr.length;
379
+ var lp = 0;
380
+ if (arguments.length >= 3) {
381
+ value = arguments[2];
613
382
  }
614
- }
615
- catch (e) {
616
- }
617
- }
618
- function arrIndexOf(arr, searchElement, fromIndex) {
619
- var len = arr.length;
620
- var from = fromIndex || 0;
621
- try {
622
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
623
- if (lp in arr && arr[lp] === searchElement) {
624
- return lp;
383
+ else {
384
+ while (lp < len && !(lp in arr)) {
385
+ lp++;
625
386
  }
387
+ value = arr[lp++];
626
388
  }
627
- }
628
- catch (e) {
629
- }
630
- return -1;
631
- }
632
- function arrMap(arr, callbackfn, thisArg) {
633
- var len = arr.length;
634
- var _this = thisArg || arr;
635
- var results = new Array(len);
636
- try {
637
- for (var lp = 0; lp < len; lp++) {
389
+ while (lp < len) {
638
390
  if (lp in arr) {
639
- results[lp] = callbackfn.call(_this, arr[lp], arr);
391
+ value = callbackfn(value, arr[lp], lp, arr);
640
392
  }
641
- }
642
- }
643
- catch (e) {
644
- }
645
- return results;
646
- }
647
- function arrReduce(arr, callbackfn, initialValue) {
648
- var len = arr.length;
649
- var lp = 0;
650
- var value;
651
- if (arguments.length >= 3) {
652
- value = arguments[2];
653
- }
654
- else {
655
- while (lp < len && !(lp in arr)) {
656
393
  lp++;
657
394
  }
658
- value = arr[lp++];
659
- }
660
- while (lp < len) {
661
- if (lp in arr) {
662
- value = callbackfn(value, arr[lp], lp, arr);
663
- }
664
- lp++;
665
395
  }
666
396
  return value;
667
397
  }
668
398
  function strTrim(str) {
669
- if (typeof str !== "string") {
670
- return str;
399
+ if (str) {
400
+ str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
671
401
  }
672
- return str.replace(/^\s+|\s+$/g, "");
402
+ return str;
673
403
  }
674
404
  var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
675
405
  var _objKeysDontEnums = [
@@ -686,6 +416,9 @@
686
416
  if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
687
417
  throwTypeError("objKeys called on non-object");
688
418
  }
419
+ if (!_objKeysHasDontEnumBug && _objKeys) {
420
+ return _objKeys(obj);
421
+ }
689
422
  var result = [];
690
423
  for (var prop in obj) {
691
424
  if (obj && ObjHasOwnProperty.call(obj, prop)) {
@@ -703,7 +436,7 @@
703
436
  return result;
704
437
  }
705
438
  function objDefineAccessors(target, prop, getProp, setProp) {
706
- if (_objDefineProperty) {
439
+ if (_objDefineProperty$1) {
707
440
  try {
708
441
  var descriptor = {
709
442
  enumerable: true,
@@ -715,7 +448,7 @@
715
448
  if (setProp) {
716
449
  descriptor.set = setProp;
717
450
  }
718
- _objDefineProperty(target, prop, descriptor);
451
+ _objDefineProperty$1(target, prop, descriptor);
719
452
  return true;
720
453
  }
721
454
  catch (e) {
@@ -723,18 +456,30 @@
723
456
  }
724
457
  return false;
725
458
  }
459
+ function _doNothing(value) {
460
+ return value;
461
+ }
462
+ function deepFreeze(obj) {
463
+ if (_objFreeze) {
464
+ objForEachKey(obj, function (name, value) {
465
+ if (isArray(value) || isObject(value)) {
466
+ _objFreeze(value);
467
+ }
468
+ });
469
+ }
470
+ return objFreeze(obj);
471
+ }
472
+ var objFreeze = _objFreeze || _doNothing;
473
+ var objSeal = _objSeal || _doNothing;
726
474
  function dateNow() {
727
475
  var dt = Date;
728
- if (dt.now) {
729
- return dt.now();
730
- }
731
- return new dt().getTime();
476
+ return dt.now ? dt.now() : new dt().getTime();
732
477
  }
733
478
  function getExceptionName(object) {
734
479
  if (isError(object)) {
735
480
  return object.name;
736
481
  }
737
- return "";
482
+ return strEmpty;
738
483
  }
739
484
  function setValue(target, field, value, valChk, srcChk) {
740
485
  var theValue = value;
@@ -770,19 +515,33 @@
770
515
  function throwError(message) {
771
516
  throw new Error(message);
772
517
  }
518
+ function _createProxyFunction(source, funcName) {
519
+ var srcFunc = null;
520
+ var src = null;
521
+ if (isFunction(source)) {
522
+ srcFunc = source;
523
+ }
524
+ else {
525
+ src = source;
526
+ }
527
+ return function () {
528
+ var originalArguments = arguments;
529
+ if (srcFunc) {
530
+ src = srcFunc();
531
+ }
532
+ if (src) {
533
+ return src[funcName].apply(src, originalArguments);
534
+ }
535
+ };
536
+ }
773
537
  function proxyAssign(target, source, chkSet) {
774
- if (target && source && target !== source && isObject(target) && isObject(source)) {
538
+ if (target && source && isObject(target) && isObject(source)) {
775
539
  var _loop_1 = function (field) {
776
540
  if (isString(field)) {
777
541
  var value = source[field];
778
542
  if (isFunction(value)) {
779
543
  if (!chkSet || chkSet(field, true, source, target)) {
780
- target[field] = (function (funcName) {
781
- return function () {
782
- var originalArguments = arguments;
783
- return source[funcName].apply(source, originalArguments);
784
- };
785
- })(field);
544
+ target[field] = _createProxyFunction(source, field);
786
545
  }
787
546
  }
788
547
  else if (!chkSet || chkSet(field, false, source, target)) {
@@ -805,15 +564,336 @@
805
564
  }
806
565
  return target;
807
566
  }
567
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
568
+ if (target && name && source) {
569
+ if (overwriteTarget !== false || isUndefined(target[name])) {
570
+ target[name] = _createProxyFunction(source, theFunc);
571
+ }
572
+ }
573
+ }
574
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
575
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
576
+ arrForEach(functionsToProxy, function (theFuncName) {
577
+ if (isString(theFuncName)) {
578
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
579
+ }
580
+ });
581
+ }
582
+ return target;
583
+ }
808
584
  function optimizeObject(theObject) {
809
- if (theObject) {
810
- theObject = ObjClass(ObjAssign ? ObjAssign({}, theObject) : theObject);
585
+ if (theObject && ObjAssign) {
586
+ theObject = ObjClass(ObjAssign({}, theObject));
811
587
  }
812
588
  return theObject;
813
589
  }
590
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
591
+ var theArgs = arguments;
592
+ var extended = theArgs[0] || {};
593
+ var argLen = theArgs.length;
594
+ var deep = false;
595
+ var idx = 1;
596
+ if (argLen > 0 && isBoolean(extended)) {
597
+ deep = extended;
598
+ extended = theArgs[idx] || {};
599
+ idx++;
600
+ }
601
+ if (!isObject(extended)) {
602
+ extended = {};
603
+ }
604
+ for (; idx < argLen; idx++) {
605
+ var arg = theArgs[idx];
606
+ var isArgArray = isArray(arg);
607
+ var isArgObj = isObject(arg);
608
+ for (var prop in arg) {
609
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
610
+ if (!propOk) {
611
+ continue;
612
+ }
613
+ var newValue = arg[prop];
614
+ var isNewArray = void 0;
615
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
616
+ var clone = extended[prop];
617
+ if (isNewArray) {
618
+ if (!isArray(clone)) {
619
+ clone = [];
620
+ }
621
+ }
622
+ else if (!isPlainObject(clone)) {
623
+ clone = {};
624
+ }
625
+ newValue = objExtend(deep, clone, newValue);
626
+ }
627
+ if (newValue !== undefined) {
628
+ extended[prop] = newValue;
629
+ }
630
+ }
631
+ }
632
+ return extended;
633
+ }
814
634
 
815
- var strWindow = "window";
635
+ function createEnumStyle(values) {
636
+ var enumClass = {};
637
+ objForEachKey(values, function (field, value) {
638
+ enumClass[field] = value;
639
+ enumClass[value] = field;
640
+ });
641
+ return deepFreeze(enumClass);
642
+ }
643
+
644
+ var EventsDiscardedReason = createEnumStyle({
645
+ Unknown: 0 ,
646
+ NonRetryableStatus: 1 ,
647
+ InvalidEvent: 2 ,
648
+ SizeLimitExceeded: 3 ,
649
+ KillSwitch: 4 ,
650
+ QueueFull: 5
651
+ });
652
+
653
+ /*!
654
+ * Microsoft Dynamic Proto Utility, 1.1.4
655
+ * Copyright (c) Microsoft and contributors. All rights reserved.
656
+ */
657
+ var Constructor = 'constructor';
658
+ var Prototype = 'prototype';
659
+ var strFunction = 'function';
660
+ var DynInstFuncTable = '_dynInstFuncs';
661
+ var DynProxyTag = '_isDynProxy';
662
+ var DynClassName = '_dynClass';
663
+ var DynClassNamePrefix = '_dynCls$';
664
+ var DynInstChkTag = '_dynInstChk';
665
+ var DynAllowInstChkTag = DynInstChkTag;
666
+ var DynProtoDefaultOptions = '_dfOpts';
667
+ var UnknownValue = '_unknown_';
668
+ var str__Proto = "__proto__";
669
+ var strUseBaseInst = 'useBaseInst';
670
+ var strSetInstFuncs = 'setInstFuncs';
671
+ var Obj = Object;
672
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
673
+ var _dynamicNames = 0;
674
+ function _hasOwnProperty(obj, prop) {
675
+ return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
676
+ }
677
+ function _isObjectOrArrayPrototype(target) {
678
+ return target && (target === Obj[Prototype] || target === Array[Prototype]);
679
+ }
680
+ function _isObjectArrayOrFunctionPrototype(target) {
681
+ return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
682
+ }
683
+ function _getObjProto(target) {
684
+ if (target) {
685
+ if (_objGetPrototypeOf) {
686
+ return _objGetPrototypeOf(target);
687
+ }
688
+ var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
689
+ if (newProto) {
690
+ return newProto;
691
+ }
692
+ }
693
+ return null;
694
+ }
695
+ function _forEachProp(target, func) {
696
+ var props = [];
697
+ var getOwnProps = Obj["getOwnPropertyNames"];
698
+ if (getOwnProps) {
699
+ props = getOwnProps(target);
700
+ }
701
+ else {
702
+ for (var name_1 in target) {
703
+ if (typeof name_1 === "string" && _hasOwnProperty(target, name_1)) {
704
+ props.push(name_1);
705
+ }
706
+ }
707
+ }
708
+ if (props && props.length > 0) {
709
+ for (var lp = 0; lp < props.length; lp++) {
710
+ func(props[lp]);
711
+ }
712
+ }
713
+ }
714
+ function _isDynamicCandidate(target, funcName, skipOwn) {
715
+ return (funcName !== Constructor && typeof target[funcName] === strFunction && (skipOwn || _hasOwnProperty(target, funcName)));
716
+ }
717
+ function _throwTypeError(message) {
718
+ throw new TypeError("DynamicProto: " + message);
719
+ }
720
+ function _getInstanceFuncs(thisTarget) {
721
+ var instFuncs = {};
722
+ _forEachProp(thisTarget, function (name) {
723
+ if (!instFuncs[name] && _isDynamicCandidate(thisTarget, name, false)) {
724
+ instFuncs[name] = thisTarget[name];
725
+ }
726
+ });
727
+ return instFuncs;
728
+ }
729
+ function _hasVisited(values, value) {
730
+ for (var lp = values.length - 1; lp >= 0; lp--) {
731
+ if (values[lp] === value) {
732
+ return true;
733
+ }
734
+ }
735
+ return false;
736
+ }
737
+ function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
738
+ function _instFuncProxy(target, funcHost, funcName) {
739
+ var theFunc = funcHost[funcName];
740
+ if (theFunc[DynProxyTag] && useBaseInst) {
741
+ var instFuncTable = target[DynInstFuncTable] || {};
742
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
743
+ theFunc = (instFuncTable[funcHost[DynClassName]] || {})[funcName] || theFunc;
744
+ }
745
+ }
746
+ return function () {
747
+ return theFunc.apply(target, arguments);
748
+ };
749
+ }
750
+ var baseFuncs = {};
751
+ _forEachProp(instFuncs, function (name) {
752
+ baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
753
+ });
754
+ var baseProto = _getObjProto(classProto);
755
+ var visited = [];
756
+ while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
757
+ _forEachProp(baseProto, function (name) {
758
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
759
+ baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
760
+ }
761
+ });
762
+ visited.push(baseProto);
763
+ baseProto = _getObjProto(baseProto);
764
+ }
765
+ return baseFuncs;
766
+ }
767
+ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
768
+ var instFunc = null;
769
+ if (target && _hasOwnProperty(proto, DynClassName)) {
770
+ var instFuncTable = target[DynInstFuncTable] || {};
771
+ instFunc = (instFuncTable[proto[DynClassName]] || {})[funcName];
772
+ if (!instFunc) {
773
+ _throwTypeError("Missing [" + funcName + "] " + strFunction);
774
+ }
775
+ if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
776
+ var canAddInst = !_hasOwnProperty(target, funcName);
777
+ var objProto = _getObjProto(target);
778
+ var visited = [];
779
+ while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
780
+ var protoFunc = objProto[funcName];
781
+ if (protoFunc) {
782
+ canAddInst = (protoFunc === currentDynProtoProxy);
783
+ break;
784
+ }
785
+ visited.push(objProto);
786
+ objProto = _getObjProto(objProto);
787
+ }
788
+ try {
789
+ if (canAddInst) {
790
+ target[funcName] = instFunc;
791
+ }
792
+ instFunc[DynInstChkTag] = 1;
793
+ }
794
+ catch (e) {
795
+ instFuncTable[DynAllowInstChkTag] = false;
796
+ }
797
+ }
798
+ }
799
+ return instFunc;
800
+ }
801
+ function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
802
+ var protoFunc = proto[funcName];
803
+ if (protoFunc === currentDynProtoProxy) {
804
+ protoFunc = _getObjProto(proto)[funcName];
805
+ }
806
+ if (typeof protoFunc !== strFunction) {
807
+ _throwTypeError("[" + funcName + "] is not a " + strFunction);
808
+ }
809
+ return protoFunc;
810
+ }
811
+ function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
812
+ function _createDynamicPrototype(proto, funcName) {
813
+ var dynProtoProxy = function () {
814
+ var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
815
+ return instFunc.apply(this, arguments);
816
+ };
817
+ dynProtoProxy[DynProxyTag] = 1;
818
+ return dynProtoProxy;
819
+ }
820
+ if (!_isObjectOrArrayPrototype(proto)) {
821
+ var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
822
+ var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
823
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
824
+ instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
825
+ }
826
+ _forEachProp(target, function (name) {
827
+ if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
828
+ instFuncs_1[name] = target[name];
829
+ delete target[name];
830
+ if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
831
+ proto[name] = _createDynamicPrototype(proto, name);
832
+ }
833
+ }
834
+ });
835
+ }
836
+ }
837
+ function _checkPrototype(classProto, thisTarget) {
838
+ if (_objGetPrototypeOf) {
839
+ var visited = [];
840
+ var thisProto = _getObjProto(thisTarget);
841
+ while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
842
+ if (thisProto === classProto) {
843
+ return true;
844
+ }
845
+ visited.push(thisProto);
846
+ thisProto = _getObjProto(thisProto);
847
+ }
848
+ }
849
+ return false;
850
+ }
851
+ function _getObjName(target, unknownValue) {
852
+ if (_hasOwnProperty(target, Prototype)) {
853
+ return target.name || unknownValue || UnknownValue;
854
+ }
855
+ return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
856
+ }
857
+ function dynamicProto(theClass, target, delegateFunc, options) {
858
+ if (!_hasOwnProperty(theClass, Prototype)) {
859
+ _throwTypeError("theClass is an invalid class definition.");
860
+ }
861
+ var classProto = theClass[Prototype];
862
+ if (!_checkPrototype(classProto, target)) {
863
+ _throwTypeError("[" + _getObjName(theClass) + "] is not in class hierarchy of [" + _getObjName(target) + "]");
864
+ }
865
+ var className = null;
866
+ if (_hasOwnProperty(classProto, DynClassName)) {
867
+ className = classProto[DynClassName];
868
+ }
869
+ else {
870
+ className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _dynamicNames;
871
+ _dynamicNames++;
872
+ classProto[DynClassName] = className;
873
+ }
874
+ var perfOptions = dynamicProto[DynProtoDefaultOptions];
875
+ var useBaseInst = !!perfOptions[strUseBaseInst];
876
+ if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
877
+ useBaseInst = !!options[strUseBaseInst];
878
+ }
879
+ var instFuncs = _getInstanceFuncs(target);
880
+ var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
881
+ delegateFunc(target, baseFuncs);
882
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
883
+ if (setInstanceFunc && options) {
884
+ setInstanceFunc = !!options[strSetInstFuncs];
885
+ }
886
+ _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
887
+ }
888
+ var perfDefaults = {
889
+ setInstFuncs: true,
890
+ useBaseInst: true
891
+ };
892
+ dynamicProto[DynProtoDefaultOptions] = perfDefaults;
893
+
894
+ var strWindow = "window";
816
895
  var strDocument = "document";
896
+ var strDocumentMode = "documentMode";
817
897
  var strNavigator = "navigator";
818
898
  var strHistory = "history";
819
899
  var strLocation = "location";
@@ -825,6 +905,7 @@
825
905
  var strReactNative = "ReactNative";
826
906
  var strMsie = "msie";
827
907
  var strTrident = "trident/";
908
+ var strXMLHttpRequest = "XMLHttpRequest";
828
909
  var _isTrident = null;
829
910
  var _navUserAgentCheck = null;
830
911
  var _enableMocks = false;
@@ -951,7 +1032,7 @@
951
1032
  var nav = getNavigator();
952
1033
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
953
1034
  _navUserAgentCheck = nav.userAgent;
954
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
1035
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
955
1036
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
956
1037
  }
957
1038
  return _isTrident;
@@ -960,11 +1041,12 @@
960
1041
  if (userAgentStr === void 0) { userAgentStr = null; }
961
1042
  if (!userAgentStr) {
962
1043
  var navigator_1 = getNavigator() || {};
963
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
1044
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty).toLowerCase() : strEmpty;
964
1045
  }
965
- var ua = (userAgentStr || "").toLowerCase();
1046
+ var ua = (userAgentStr || strEmpty).toLowerCase();
966
1047
  if (strContains(ua, strMsie)) {
967
- return parseInt(ua.split(strMsie)[1]);
1048
+ var doc = getDocument() || {};
1049
+ return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
968
1050
  }
969
1051
  else if (strContains(ua, strTrident)) {
970
1052
  var tridentVer = parseInt(ua.split(strTrident)[1]);
@@ -976,7 +1058,7 @@
976
1058
  }
977
1059
  function dumpObj(object) {
978
1060
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
979
- var propertyValueDump = "";
1061
+ var propertyValueDump = strEmpty;
980
1062
  if (objectTypeDump === "[object Error]") {
981
1063
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
982
1064
  }
@@ -994,8 +1076,7 @@
994
1076
  function isFetchSupported(withKeepAlive) {
995
1077
  var isSupported = false;
996
1078
  try {
997
- var fetchApi = getGlobalInst("fetch");
998
- isSupported = !!fetchApi;
1079
+ isSupported = !!getGlobalInst("fetch");
999
1080
  var request = getGlobalInst("Request");
1000
1081
  if (isSupported && withKeepAlive && request) {
1001
1082
  isSupported = _hasProperty(request, "keepalive");
@@ -1007,9 +1088,9 @@
1007
1088
  }
1008
1089
  function useXDomainRequest() {
1009
1090
  if (_useXDomainRequest === null) {
1010
- _useXDomainRequest = (typeof XDomainRequest !== undefined);
1091
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1011
1092
  if (_useXDomainRequest && isXhrSupported()) {
1012
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
1093
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
1013
1094
  }
1014
1095
  }
1015
1096
  return _useXDomainRequest;
@@ -1017,7 +1098,7 @@
1017
1098
  function isXhrSupported() {
1018
1099
  var isSupported = false;
1019
1100
  try {
1020
- var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
1101
+ var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
1021
1102
  isSupported = !!xmlHttpRequest;
1022
1103
  }
1023
1104
  catch (e) {
@@ -1025,16 +1106,55 @@
1025
1106
  return isSupported;
1026
1107
  }
1027
1108
 
1028
- var AiNonUserActionablePrefix = "AI (Internal): ";
1029
- var AiUserActionablePrefix = "AI: ";
1030
- var AIInternalMessagePrefix = "AITR_";
1031
- var strErrorToConsole = "errorToConsole";
1032
- var strWarnToConsole = "warnToConsole";
1033
- function _sanitizeDiagnosticText(text) {
1034
- if (text) {
1035
- return "\"" + text.replace(/\"/g, "") + "\"";
1036
- }
1037
- return "";
1109
+ var listenerFuncs = ["eventsSent", "eventsDiscarded", "eventsSendRequest", "perfEvent"];
1110
+ var _aiNamespace = null;
1111
+ var _debugListener;
1112
+ function _listenerProxyFunc(name, config) {
1113
+ return function () {
1114
+ var args = arguments;
1115
+ var dbgExt = getDebugExt(config);
1116
+ if (dbgExt) {
1117
+ var listener = dbgExt.listener;
1118
+ if (listener && listener[name]) {
1119
+ listener[name].apply(listener, args);
1120
+ }
1121
+ }
1122
+ };
1123
+ }
1124
+ function _getExtensionNamespace() {
1125
+ var target = getGlobalInst("Microsoft");
1126
+ if (target) {
1127
+ _aiNamespace = target["ApplicationInsights"];
1128
+ }
1129
+ return _aiNamespace;
1130
+ }
1131
+ function getDebugExt(config) {
1132
+ var ns = _aiNamespace;
1133
+ if (!ns && config.disableDbgExt !== true) {
1134
+ ns = _aiNamespace || _getExtensionNamespace();
1135
+ }
1136
+ return ns ? ns["ChromeDbgExt"] : null;
1137
+ }
1138
+ function getDebugListener(config) {
1139
+ if (!_debugListener) {
1140
+ _debugListener = {};
1141
+ for (var lp = 0; lp < listenerFuncs.length; lp++) {
1142
+ _debugListener[listenerFuncs[lp]] = _listenerProxyFunc(listenerFuncs[lp], config);
1143
+ }
1144
+ }
1145
+ return _debugListener;
1146
+ }
1147
+
1148
+ var AiNonUserActionablePrefix = "AI (Internal): ";
1149
+ var AiUserActionablePrefix = "AI: ";
1150
+ var AIInternalMessagePrefix = "AITR_";
1151
+ var strErrorToConsole = "errorToConsole";
1152
+ var strWarnToConsole = "warnToConsole";
1153
+ function _sanitizeDiagnosticText(text) {
1154
+ if (text) {
1155
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
1156
+ }
1157
+ return strEmpty;
1038
1158
  }
1039
1159
  function _logToConsole(func, message) {
1040
1160
  var theConsole = getConsole();
@@ -1056,12 +1176,12 @@
1056
1176
  _self.message =
1057
1177
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1058
1178
  msgId;
1059
- var strProps = "";
1179
+ var strProps = strEmpty;
1060
1180
  if (hasJSON()) {
1061
1181
  strProps = getJSON().stringify(properties);
1062
1182
  }
1063
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
1064
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
1183
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
1184
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
1065
1185
  _self.message += diagnosticText;
1066
1186
  }
1067
1187
  _InternalLogMessage.dataType = "MessageData";
@@ -1091,7 +1211,7 @@
1091
1211
  throw message;
1092
1212
  }
1093
1213
  else {
1094
- var logFunc = severity === exports.LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
1214
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1095
1215
  if (!isUndefined(message.message)) {
1096
1216
  var logLevel = _self.consoleLoggingLevel();
1097
1217
  if (isUserAct) {
@@ -1108,13 +1228,18 @@
1108
1228
  }
1109
1229
  _self.logInternalMessage(severity, message);
1110
1230
  }
1231
+ else {
1232
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1233
+ }
1111
1234
  }
1112
1235
  };
1113
1236
  _self.warnToConsole = function (message) {
1114
1237
  _logToConsole("warn", message);
1238
+ _debugExtMsg("warning", message);
1115
1239
  };
1116
1240
  _self.errorToConsole = function (message) {
1117
1241
  _logToConsole("error", message);
1242
+ _debugExtMsg("error", message);
1118
1243
  };
1119
1244
  _self.resetInternalMessageCount = function () {
1120
1245
  _messageCount = 0;
@@ -1136,12 +1261,18 @@
1136
1261
  if (severity <= _self.telemetryLoggingLevel()) {
1137
1262
  _self.queue.push(message);
1138
1263
  _messageCount++;
1264
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1139
1265
  }
1140
1266
  if (_messageCount === _self.maxInternalMessageLimit()) {
1141
1267
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1142
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1268
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1143
1269
  _self.queue.push(throttleMessage);
1144
- _self.warnToConsole(throttleLimitMessage);
1270
+ if (severity === 1 ) {
1271
+ _self.errorToConsole(throttleLimitMessage);
1272
+ }
1273
+ else {
1274
+ _self.warnToConsole(throttleLimitMessage);
1275
+ }
1145
1276
  }
1146
1277
  }
1147
1278
  };
@@ -1155,10 +1286,26 @@
1155
1286
  function _areInternalMessagesThrottled() {
1156
1287
  return _messageCount >= _self.maxInternalMessageLimit();
1157
1288
  }
1289
+ function _debugExtMsg(name, data) {
1290
+ var dbgExt = getDebugExt(config);
1291
+ if (dbgExt && dbgExt.diagLog) {
1292
+ dbgExt.diagLog(name, data);
1293
+ }
1294
+ }
1158
1295
  });
1159
1296
  }
1160
1297
  return DiagnosticLogger;
1161
1298
  }());
1299
+ function _getLogger(logger) {
1300
+ return (logger || new DiagnosticLogger());
1301
+ }
1302
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1303
+ if (isUserAct === void 0) { isUserAct = false; }
1304
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1305
+ }
1306
+ function _warnToConsole(logger, message) {
1307
+ _getLogger(logger).warnToConsole(message);
1308
+ }
1162
1309
 
1163
1310
  var strExecutionContextKey = "ctx";
1164
1311
  var _defaultPerfManager = null;
@@ -1304,271 +1451,186 @@
1304
1451
  return _defaultPerfManager;
1305
1452
  }
1306
1453
 
1307
- var TelemetryPluginChain = /** @class */ (function () {
1308
- function TelemetryPluginChain(plugin, defItemCtx) {
1309
- var _self = this;
1310
- var _nextProxy = null;
1311
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1312
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1313
- _self._hasRun = false;
1314
- _self.getPlugin = function () {
1315
- return plugin;
1316
- };
1317
- _self.getNext = function () {
1318
- return _nextProxy;
1319
- };
1320
- _self.setNext = function (nextPlugin) {
1321
- _nextProxy = nextPlugin;
1322
- };
1323
- _self.processTelemetry = function (env, itemCtx) {
1324
- if (!itemCtx) {
1325
- itemCtx = defItemCtx;
1326
- }
1327
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1328
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1329
- if (plugin && _hasProcessTelemetry) {
1330
- _self._hasRun = true;
1331
- try {
1332
- itemCtx.setNext(_nextProxy);
1333
- if (_hasSetNext) {
1334
- plugin.setNextPlugin(_nextProxy);
1335
- }
1336
- _nextProxy && (_nextProxy._hasRun = false);
1337
- plugin.processTelemetry(env, itemCtx);
1338
- }
1339
- catch (error) {
1340
- var hasRun = _nextProxy && _nextProxy._hasRun;
1341
- if (!_nextProxy || !hasRun) {
1342
- itemCtx.diagLog().throwInternal(exports.LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1343
- }
1344
- if (_nextProxy && !hasRun) {
1345
- _nextProxy.processTelemetry(env, itemCtx);
1346
- }
1347
- }
1348
- }
1349
- else if (_nextProxy) {
1350
- _self._hasRun = true;
1351
- _nextProxy.processTelemetry(env, itemCtx);
1352
- }
1353
- }, function () { return ({ item: env }); }, !(env.sync));
1354
- };
1454
+ var UInt32Mask = 0x100000000;
1455
+ var MaxUInt32 = 0xffffffff;
1456
+ var _mwcSeeded = false;
1457
+ var _mwcW = 123456789;
1458
+ var _mwcZ = 987654321;
1459
+ function _mwcSeed(seedValue) {
1460
+ if (seedValue < 0) {
1461
+ seedValue >>>= 0;
1355
1462
  }
1356
- return TelemetryPluginChain;
1357
- }());
1358
-
1359
- function _createProxyChain(plugins, itemCtx) {
1360
- var proxies = [];
1361
- if (plugins && plugins.length > 0) {
1362
- var lastProxy = null;
1363
- for (var idx = 0; idx < plugins.length; idx++) {
1364
- var thePlugin = plugins[idx];
1365
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1366
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1367
- proxies.push(newProxy);
1368
- if (lastProxy) {
1369
- lastProxy.setNext(newProxy);
1370
- }
1371
- lastProxy = newProxy;
1372
- }
1373
- }
1463
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1464
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1465
+ _mwcSeeded = true;
1466
+ }
1467
+ function _autoSeedMwc() {
1468
+ try {
1469
+ var now = dateNow() & 0x7fffffff;
1470
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1471
+ }
1472
+ catch (e) {
1374
1473
  }
1375
- return proxies.length > 0 ? proxies[0] : null;
1376
1474
  }
1377
- function _copyProxyChain(proxy, itemCtx, startAt) {
1378
- var plugins = [];
1379
- var add = startAt ? false : true;
1380
- if (proxy) {
1381
- while (proxy) {
1382
- var thePlugin = proxy.getPlugin();
1383
- if (add || thePlugin === startAt) {
1384
- add = true;
1385
- plugins.push(thePlugin);
1386
- }
1387
- proxy = proxy.getNext();
1475
+ function randomValue(maxValue) {
1476
+ if (maxValue > 0) {
1477
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1478
+ }
1479
+ return 0;
1480
+ }
1481
+ function random32(signed) {
1482
+ var value = 0;
1483
+ var c = getCrypto() || getMsCrypto();
1484
+ if (c && c.getRandomValues) {
1485
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1486
+ }
1487
+ if (value === 0 && isIE()) {
1488
+ if (!_mwcSeeded) {
1489
+ _autoSeedMwc();
1388
1490
  }
1491
+ value = mwcRandom32() & MaxUInt32;
1389
1492
  }
1390
- if (!add) {
1391
- plugins.push(startAt);
1493
+ if (value === 0) {
1494
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1495
+ }
1496
+ if (!signed) {
1497
+ value >>>= 0;
1392
1498
  }
1393
- return _createProxyChain(plugins, itemCtx);
1499
+ return value;
1394
1500
  }
1395
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1396
- var plugins = srcPlugins;
1397
- var add = false;
1398
- if (startAt && srcPlugins) {
1399
- plugins = [];
1400
- arrForEach(srcPlugins, function (thePlugin) {
1401
- if (add || thePlugin === startAt) {
1402
- add = true;
1403
- plugins.push(thePlugin);
1404
- }
1405
- });
1501
+ function mwcRandomSeed(value) {
1502
+ if (!value) {
1503
+ _autoSeedMwc();
1504
+ }
1505
+ else {
1506
+ _mwcSeed(value);
1507
+ }
1508
+ }
1509
+ function mwcRandom32(signed) {
1510
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1511
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1512
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1513
+ if (!signed) {
1514
+ value >>>= 0;
1406
1515
  }
1407
- if (startAt && !add) {
1408
- if (!plugins) {
1409
- plugins = [];
1516
+ return value;
1517
+ }
1518
+ function newId(maxLength) {
1519
+ if (maxLength === void 0) { maxLength = 22; }
1520
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1521
+ var number = random32() >>> 0;
1522
+ var chars = 0;
1523
+ var result = strEmpty;
1524
+ while (result.length < maxLength) {
1525
+ chars++;
1526
+ result += base64chars.charAt(number & 0x3F);
1527
+ number >>>= 6;
1528
+ if (chars === 5) {
1529
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1530
+ chars = 0;
1410
1531
  }
1411
- plugins.push(startAt);
1412
1532
  }
1413
- return _createProxyChain(plugins, itemCtx);
1533
+ return result;
1414
1534
  }
1415
- var ProcessTelemetryContext = /** @class */ (function () {
1416
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1417
- var _self = this;
1418
- var _nextProxy = null;
1419
- if (startAt !== null) {
1420
- if (plugins && isFunction(plugins.getPlugin)) {
1421
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1422
- }
1423
- else {
1424
- if (startAt) {
1425
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1426
- }
1427
- else if (isUndefined(startAt)) {
1428
- _nextProxy = _createProxyChain(plugins, _self);
1429
- }
1430
- }
1535
+
1536
+ var _objDefineProperty = ObjDefineProperty;
1537
+ var version = "2.8.0";
1538
+ var instanceName = "." + newId(6);
1539
+ var _dataUid = 0;
1540
+ function _createAccessor(target, prop, value) {
1541
+ if (_objDefineProperty) {
1542
+ try {
1543
+ _objDefineProperty(target, prop, {
1544
+ value: value,
1545
+ enumerable: false,
1546
+ configurable: true
1547
+ });
1548
+ return true;
1431
1549
  }
1432
- _self.core = function () {
1433
- return core;
1434
- };
1435
- _self.diagLog = function () {
1436
- return safeGetLogger(core, config);
1437
- };
1438
- _self.getCfg = function () {
1439
- return config;
1440
- };
1441
- _self.getExtCfg = function (identifier, defaultValue) {
1442
- if (defaultValue === void 0) { defaultValue = {}; }
1443
- var theConfig;
1444
- if (config) {
1445
- var extConfig = config.extensionConfig;
1446
- if (extConfig && identifier) {
1447
- theConfig = extConfig[identifier];
1550
+ catch (e) {
1551
+ }
1552
+ }
1553
+ return false;
1554
+ }
1555
+ function _canAcceptData(target) {
1556
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1557
+ }
1558
+ function _getCache(data, target) {
1559
+ var theCache = target[data.id];
1560
+ if (!theCache) {
1561
+ theCache = {};
1562
+ try {
1563
+ if (_canAcceptData(target)) {
1564
+ if (!_createAccessor(target, data.id, theCache)) {
1565
+ target[data.id] = theCache;
1448
1566
  }
1449
1567
  }
1450
- return (theConfig ? theConfig : defaultValue);
1451
- };
1452
- _self.getConfig = function (identifier, field, defaultValue) {
1453
- if (defaultValue === void 0) { defaultValue = false; }
1454
- var theValue;
1455
- var extConfig = _self.getExtCfg(identifier, null);
1456
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1457
- theValue = extConfig[field];
1458
- }
1459
- else if (config && !isNullOrUndefined(config[field])) {
1460
- theValue = config[field];
1461
- }
1462
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1463
- };
1464
- _self.hasNext = function () {
1465
- return _nextProxy != null;
1466
- };
1467
- _self.getNext = function () {
1468
- return _nextProxy;
1469
- };
1470
- _self.setNext = function (nextPlugin) {
1471
- _nextProxy = nextPlugin;
1472
- };
1473
- _self.processNext = function (env) {
1474
- var nextPlugin = _nextProxy;
1475
- if (nextPlugin) {
1476
- _nextProxy = nextPlugin.getNext();
1477
- nextPlugin.processTelemetry(env, _self);
1478
- }
1479
- };
1480
- _self.createNew = function (plugins, startAt) {
1481
- if (plugins === void 0) { plugins = null; }
1482
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1483
- };
1568
+ }
1569
+ catch (e) {
1570
+ }
1484
1571
  }
1485
- return ProcessTelemetryContext;
1486
- }());
1487
-
1488
- var strIKey = "iKey";
1489
- var strExtensionConfig = "extensionConfig";
1490
-
1491
- var strGetPlugin = "getPlugin";
1492
- var BaseTelemetryPlugin = /** @class */ (function () {
1493
- function BaseTelemetryPlugin() {
1494
- var _self = this;
1495
- var _isinitialized = false;
1496
- var _rootCtx = null;
1497
- var _nextPlugin = null;
1498
- _self.core = null;
1499
- _self.diagLog = function (itemCtx) {
1500
- return _self._getTelCtx(itemCtx).diagLog();
1501
- };
1502
- _self.isInitialized = function () {
1503
- return _isinitialized;
1504
- };
1505
- _self.setInitialized = function (isInitialized) {
1506
- _isinitialized = isInitialized;
1507
- };
1508
- _self.setNextPlugin = function (next) {
1509
- _nextPlugin = next;
1510
- };
1511
- _self.processNext = function (env, itemCtx) {
1512
- if (itemCtx) {
1513
- itemCtx.processNext(env);
1514
- }
1515
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1516
- _nextPlugin.processTelemetry(env, null);
1572
+ return theCache;
1573
+ }
1574
+ function createUniqueNamespace(name, includeVersion) {
1575
+ if (includeVersion === void 0) { includeVersion = false; }
1576
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1577
+ }
1578
+ function createElmNodeData(name) {
1579
+ var data = {
1580
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1581
+ accept: function (target) {
1582
+ return _canAcceptData(target);
1583
+ },
1584
+ get: function (target, name, defValue, addDefault) {
1585
+ var theCache = target[data.id];
1586
+ if (!theCache) {
1587
+ if (addDefault) {
1588
+ theCache = _getCache(data, target);
1589
+ theCache[normalizeJsName(name)] = defValue;
1590
+ }
1591
+ return defValue;
1517
1592
  }
1518
- };
1519
- _self._getTelCtx = function (currentCtx) {
1520
- if (currentCtx === void 0) { currentCtx = null; }
1521
- var itemCtx = currentCtx;
1522
- if (!itemCtx) {
1523
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1524
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1525
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1593
+ return theCache[normalizeJsName(name)];
1594
+ },
1595
+ kill: function (target, name) {
1596
+ if (target && target[name]) {
1597
+ try {
1598
+ delete target[name];
1526
1599
  }
1527
- else {
1528
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1600
+ catch (e) {
1529
1601
  }
1530
1602
  }
1531
- return itemCtx;
1532
- };
1533
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1534
- if (config) {
1535
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1536
- }
1537
- if (!pluginChain && core) {
1538
- pluginChain = core.getProcessTelContext().getNext();
1539
- }
1540
- var nextPlugin = _nextPlugin;
1541
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1542
- nextPlugin = _nextPlugin[strGetPlugin]();
1543
- }
1544
- _self.core = core;
1545
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1546
- _isinitialized = true;
1547
- };
1548
- }
1549
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1550
- this._baseTelInit(config, core, extensions, pluginChain);
1603
+ }
1551
1604
  };
1552
- return BaseTelemetryPlugin;
1553
- }());
1605
+ return data;
1606
+ }
1554
1607
 
1555
- var processTelemetry = "processTelemetry";
1556
- var priority = "priority";
1557
- var setNextPlugin = "setNextPlugin";
1558
- var isInitialized = "isInitialized";
1608
+ var pluginStateData = createElmNodeData("plugin");
1609
+ function _getPluginState(plugin) {
1610
+ return pluginStateData.get(plugin, "state", {}, true);
1611
+ }
1559
1612
  function initializePlugins(processContext, extensions) {
1560
1613
  var initPlugins = [];
1561
1614
  var lastPlugin = null;
1562
1615
  var proxy = processContext.getNext();
1616
+ var pluginState;
1563
1617
  while (proxy) {
1564
1618
  var thePlugin = proxy.getPlugin();
1565
1619
  if (thePlugin) {
1566
1620
  if (lastPlugin &&
1567
- isFunction(lastPlugin[setNextPlugin]) &&
1568
- isFunction(thePlugin[processTelemetry])) {
1569
- lastPlugin[setNextPlugin](thePlugin);
1621
+ isFunction(lastPlugin[strSetNextPlugin]) &&
1622
+ isFunction(thePlugin[strProcessTelemetry])) {
1623
+ lastPlugin[strSetNextPlugin](thePlugin);
1570
1624
  }
1571
- if (!isFunction(thePlugin[isInitialized]) || !thePlugin[isInitialized]()) {
1625
+ var isInitialized = false;
1626
+ if (isFunction(thePlugin[strIsInitialized])) {
1627
+ isInitialized = thePlugin[strIsInitialized]();
1628
+ }
1629
+ else {
1630
+ pluginState = _getPluginState(thePlugin);
1631
+ isInitialized = pluginState[strIsInitialized];
1632
+ }
1633
+ if (!isInitialized) {
1572
1634
  initPlugins.push(thePlugin);
1573
1635
  }
1574
1636
  lastPlugin = thePlugin;
@@ -1576,15 +1638,22 @@
1576
1638
  }
1577
1639
  }
1578
1640
  arrForEach(initPlugins, function (thePlugin) {
1579
- thePlugin.initialize(processContext.getCfg(), processContext.core(), extensions, processContext.getNext());
1641
+ var core = processContext.core();
1642
+ thePlugin.initialize(processContext.getCfg(), core, extensions, processContext.getNext());
1643
+ pluginState = _getPluginState(thePlugin);
1644
+ if (!thePlugin[strCore] && !pluginState[strCore]) {
1645
+ pluginState[strCore] = core;
1646
+ }
1647
+ pluginState[strIsInitialized] = true;
1648
+ delete pluginState[strTeardown];
1580
1649
  });
1581
1650
  }
1582
1651
  function sortPlugins(plugins) {
1583
1652
  return plugins.sort(function (extA, extB) {
1584
1653
  var result = 0;
1585
- var bHasProcess = isFunction(extB[processTelemetry]);
1586
- if (isFunction(extA[processTelemetry])) {
1587
- result = bHasProcess ? extA[priority] - extB[priority] : 1;
1654
+ var bHasProcess = isFunction(extB[strProcessTelemetry]);
1655
+ if (isFunction(extA[strProcessTelemetry])) {
1656
+ result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
1588
1657
  }
1589
1658
  else if (bHasProcess) {
1590
1659
  result = -1;
@@ -1593,80 +1662,361 @@
1593
1662
  });
1594
1663
  }
1595
1664
 
1596
- var ChannelControllerPriority = 500;
1597
- var ChannelValidationMessage = "Channel has invalid priority";
1598
- var ChannelController = /** @class */ (function (_super) {
1599
- __extendsFn(ChannelController, _super);
1600
- function ChannelController() {
1601
- var _this = _super.call(this) || this;
1602
- _this.identifier = "ChannelControllerPlugin";
1603
- _this.priority = ChannelControllerPriority;
1604
- var _channelQueue;
1605
- dynamicProto(ChannelController, _this, function (_self, _base) {
1606
- _self.setNextPlugin = function (next) {
1607
- };
1608
- _self.processTelemetry = function (item, itemCtx) {
1609
- if (_channelQueue) {
1610
- arrForEach(_channelQueue, function (queues) {
1611
- if (queues.length > 0) {
1612
- var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
1613
- chainCtx.processNext(item);
1614
- }
1615
- });
1616
- }
1617
- };
1618
- _self.getChannelControls = function () {
1619
- return _channelQueue;
1620
- };
1621
- _self.initialize = function (config, core, extensions) {
1622
- if (_self.isInitialized()) {
1623
- return;
1624
- }
1625
- _base.initialize(config, core, extensions);
1626
- _createChannelQueues((config || {}).channels, extensions);
1627
- arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
1628
- };
1629
- });
1630
- function _checkQueuePriority(queue) {
1631
- arrForEach(queue, function (queueItem) {
1632
- if (queueItem.priority < ChannelControllerPriority) {
1633
- throwError(ChannelValidationMessage + queueItem.identifier);
1634
- }
1665
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1666
+ var strHasRunFlags = "_hasRun";
1667
+ var strGetTelCtx = "_getTelCtx";
1668
+ var _chainId = 0;
1669
+ function _getNextProxyStart(proxy, core, startAt) {
1670
+ while (proxy) {
1671
+ if (proxy.getPlugin() === startAt) {
1672
+ return proxy;
1673
+ }
1674
+ proxy = proxy.getNext();
1675
+ }
1676
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
1677
+ }
1678
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1679
+ var _nextProxy = null;
1680
+ var _onComplete = [];
1681
+ if (startAt !== null) {
1682
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1683
+ }
1684
+ var context = {
1685
+ _next: _moveNext,
1686
+ ctx: {
1687
+ core: function () {
1688
+ return core;
1689
+ },
1690
+ diagLog: function () {
1691
+ return safeGetLogger(core, config);
1692
+ },
1693
+ getCfg: function () {
1694
+ return config;
1695
+ },
1696
+ getExtCfg: _getExtCfg,
1697
+ getConfig: _getConfig,
1698
+ hasNext: function () {
1699
+ return !!_nextProxy;
1700
+ },
1701
+ getNext: function () {
1702
+ return _nextProxy;
1703
+ },
1704
+ setNext: function (nextPlugin) {
1705
+ _nextProxy = nextPlugin;
1706
+ },
1707
+ iterate: _iterateChain,
1708
+ onComplete: _addOnComplete
1709
+ }
1710
+ };
1711
+ function _addOnComplete(onComplete, that) {
1712
+ var args = [];
1713
+ for (var _i = 2; _i < arguments.length; _i++) {
1714
+ args[_i - 2] = arguments[_i];
1715
+ }
1716
+ if (onComplete) {
1717
+ _onComplete.push({
1718
+ func: onComplete,
1719
+ self: !isUndefined(that) ? that : context.ctx,
1720
+ args: args
1635
1721
  });
1636
1722
  }
1637
- function _addChannelQueue(queue) {
1638
- if (queue && queue.length > 0) {
1639
- queue = queue.sort(function (a, b) {
1640
- return a.priority - b.priority;
1723
+ }
1724
+ function _moveNext() {
1725
+ var nextProxy = _nextProxy;
1726
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1727
+ if (!nextProxy) {
1728
+ var onComplete = _onComplete;
1729
+ if (onComplete && onComplete.length > 0) {
1730
+ arrForEach(onComplete, function (completeDetails) {
1731
+ try {
1732
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1733
+ }
1734
+ catch (e) {
1735
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1736
+ }
1641
1737
  });
1642
- _checkQueuePriority(queue);
1643
- _channelQueue.push(queue);
1738
+ _onComplete = [];
1644
1739
  }
1645
1740
  }
1646
- function _createChannelQueues(channels, extensions) {
1647
- _channelQueue = [];
1648
- if (channels) {
1649
- arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
1741
+ return nextProxy;
1742
+ }
1743
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1744
+ if (defaultValue === void 0) { defaultValue = {}; }
1745
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1746
+ var theConfig;
1747
+ if (config) {
1748
+ var extConfig = config.extensionConfig;
1749
+ if (extConfig && identifier) {
1750
+ theConfig = extConfig[identifier];
1650
1751
  }
1651
- if (extensions) {
1652
- var extensionQueue_1 = [];
1653
- arrForEach(extensions, function (plugin) {
1654
- if (plugin.priority > ChannelControllerPriority) {
1655
- extensionQueue_1.push(plugin);
1656
- }
1657
- });
1658
- _addChannelQueue(extensionQueue_1);
1752
+ }
1753
+ if (!theConfig) {
1754
+ theConfig = defaultValue;
1755
+ }
1756
+ else if (isObject(defaultValue)) {
1757
+ if (mergeDefault !== 0 ) {
1758
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1759
+ if (config && mergeDefault === 2 ) {
1760
+ objForEachKey(defaultValue, function (field) {
1761
+ if (isNullOrUndefined(newConfig_1[field])) {
1762
+ var cfgValue = config[field];
1763
+ if (!isNullOrUndefined(cfgValue)) {
1764
+ newConfig_1[field] = cfgValue;
1765
+ }
1766
+ }
1767
+ });
1768
+ }
1769
+ theConfig = newConfig_1;
1770
+ }
1771
+ }
1772
+ return theConfig;
1773
+ }
1774
+ function _getConfig(identifier, field, defaultValue) {
1775
+ if (defaultValue === void 0) { defaultValue = false; }
1776
+ var theValue;
1777
+ var extConfig = _getExtCfg(identifier, null);
1778
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1779
+ theValue = extConfig[field];
1780
+ }
1781
+ else if (config && !isNullOrUndefined(config[field])) {
1782
+ theValue = config[field];
1783
+ }
1784
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1785
+ }
1786
+ function _iterateChain(cb) {
1787
+ var nextPlugin;
1788
+ while (!!(nextPlugin = context._next())) {
1789
+ var plugin = nextPlugin.getPlugin();
1790
+ if (plugin) {
1791
+ cb(plugin);
1659
1792
  }
1660
1793
  }
1661
- return _this;
1662
1794
  }
1663
- ChannelController._staticInit = (function () {
1664
- var proto = ChannelController.prototype;
1665
- objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
1666
- objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
1667
- })();
1668
- return ChannelController;
1669
- }(BaseTelemetryPlugin));
1795
+ return context;
1796
+ }
1797
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1798
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1799
+ var context = internalContext.ctx;
1800
+ function _processNext(env) {
1801
+ var nextPlugin = internalContext._next();
1802
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1803
+ return !nextPlugin;
1804
+ }
1805
+ function _createNew(plugins, startAt) {
1806
+ if (plugins === void 0) { plugins = null; }
1807
+ if (isArray(plugins)) {
1808
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1809
+ }
1810
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1811
+ }
1812
+ context.processNext = _processNext;
1813
+ context.createNew = _createNew;
1814
+ return context;
1815
+ }
1816
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
1817
+ var config = core.config || {};
1818
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1819
+ var context = internalContext.ctx;
1820
+ function _processNext(unloadState) {
1821
+ var nextPlugin = internalContext._next();
1822
+ nextPlugin && nextPlugin.unload(context, unloadState);
1823
+ return !nextPlugin;
1824
+ }
1825
+ function _createNew(plugins, startAt) {
1826
+ if (plugins === void 0) { plugins = null; }
1827
+ if (isArray(plugins)) {
1828
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1829
+ }
1830
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
1831
+ }
1832
+ context.processNext = _processNext;
1833
+ context.createNew = _createNew;
1834
+ return context;
1835
+ }
1836
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
1837
+ var config = core.config || {};
1838
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1839
+ var context = internalContext.ctx;
1840
+ function _processNext(updateState) {
1841
+ return context.iterate(function (plugin) {
1842
+ if (isFunction(plugin.update)) {
1843
+ plugin.update(context, updateState);
1844
+ }
1845
+ });
1846
+ }
1847
+ function _createNew(plugins, startAt) {
1848
+ if (plugins === void 0) { plugins = null; }
1849
+ if (isArray(plugins)) {
1850
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1851
+ }
1852
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
1853
+ }
1854
+ context.processNext = _processNext;
1855
+ context.createNew = _createNew;
1856
+ return context;
1857
+ }
1858
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1859
+ var firstProxy = null;
1860
+ var add = startAt ? false : true;
1861
+ if (isArray(plugins) && plugins.length > 0) {
1862
+ var lastProxy_1 = null;
1863
+ arrForEach(plugins, function (thePlugin) {
1864
+ if (!add && startAt === thePlugin) {
1865
+ add = true;
1866
+ }
1867
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1868
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1869
+ if (!firstProxy) {
1870
+ firstProxy = newProxy;
1871
+ }
1872
+ if (lastProxy_1) {
1873
+ lastProxy_1._setNext(newProxy);
1874
+ }
1875
+ lastProxy_1 = newProxy;
1876
+ }
1877
+ });
1878
+ }
1879
+ if (startAt && !firstProxy) {
1880
+ return createTelemetryProxyChain([startAt], config, core);
1881
+ }
1882
+ return firstProxy;
1883
+ }
1884
+ function createTelemetryPluginProxy(plugin, config, core) {
1885
+ var nextProxy = null;
1886
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1887
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1888
+ var chainId;
1889
+ if (plugin) {
1890
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1891
+ }
1892
+ else {
1893
+ chainId = "Unknown-0-" + _chainId++;
1894
+ }
1895
+ var proxyChain = {
1896
+ getPlugin: function () {
1897
+ return plugin;
1898
+ },
1899
+ getNext: function () {
1900
+ return nextProxy;
1901
+ },
1902
+ processTelemetry: _processTelemetry,
1903
+ unload: _unloadPlugin,
1904
+ update: _updatePlugin,
1905
+ _id: chainId,
1906
+ _setNext: function (nextPlugin) {
1907
+ nextProxy = nextPlugin;
1908
+ }
1909
+ };
1910
+ function _getTelCtx() {
1911
+ var itemCtx;
1912
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1913
+ itemCtx = plugin[strGetTelCtx]();
1914
+ }
1915
+ if (!itemCtx) {
1916
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1917
+ }
1918
+ return itemCtx;
1919
+ }
1920
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1921
+ var hasRun = false;
1922
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1923
+ var hasRunContext = itemCtx[strHasRunFlags];
1924
+ if (!hasRunContext) {
1925
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1926
+ }
1927
+ itemCtx.setNext(nextProxy);
1928
+ if (plugin) {
1929
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1930
+ hasRunContext[chainId] = true;
1931
+ try {
1932
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1933
+ if (nextId) {
1934
+ hasRunContext[nextId] = false;
1935
+ }
1936
+ hasRun = processPluginFn(itemCtx);
1937
+ }
1938
+ catch (error) {
1939
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1940
+ if (hasNextRun) {
1941
+ hasRun = true;
1942
+ }
1943
+ if (!nextProxy || !hasNextRun) {
1944
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1945
+ }
1946
+ }
1947
+ }, details, isAsync);
1948
+ }
1949
+ return hasRun;
1950
+ }
1951
+ function _processTelemetry(env, itemCtx) {
1952
+ itemCtx = itemCtx || _getTelCtx();
1953
+ function _callProcessTelemetry(itemCtx) {
1954
+ if (!plugin || !hasProcessTelemetry) {
1955
+ return false;
1956
+ }
1957
+ var pluginState = _getPluginState(plugin);
1958
+ if (pluginState.teardown || pluginState[strDisabled]) {
1959
+ return false;
1960
+ }
1961
+ if (hasSetNext) {
1962
+ plugin.setNextPlugin(nextProxy);
1963
+ }
1964
+ plugin.processTelemetry(env, itemCtx);
1965
+ return true;
1966
+ }
1967
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1968
+ itemCtx.processNext(env);
1969
+ }
1970
+ }
1971
+ function _unloadPlugin(unloadCtx, unloadState) {
1972
+ function _callTeardown() {
1973
+ var hasRun = false;
1974
+ if (plugin) {
1975
+ var pluginState = _getPluginState(plugin);
1976
+ var pluginCore = plugin[strCore] || pluginState.core;
1977
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1978
+ pluginState[strCore] = null;
1979
+ pluginState[strTeardown] = true;
1980
+ pluginState[strIsInitialized] = false;
1981
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1982
+ hasRun = true;
1983
+ }
1984
+ }
1985
+ }
1986
+ return hasRun;
1987
+ }
1988
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1989
+ unloadCtx.processNext(unloadState);
1990
+ }
1991
+ }
1992
+ function _updatePlugin(updateCtx, updateState) {
1993
+ function _callUpdate() {
1994
+ var hasRun = false;
1995
+ if (plugin) {
1996
+ var pluginState = _getPluginState(plugin);
1997
+ var pluginCore = plugin[strCore] || pluginState.core;
1998
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1999
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
2000
+ hasRun = true;
2001
+ }
2002
+ }
2003
+ }
2004
+ return hasRun;
2005
+ }
2006
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2007
+ updateCtx.processNext(updateState);
2008
+ }
2009
+ }
2010
+ return objFreeze(proxyChain);
2011
+ }
2012
+ var ProcessTelemetryContext = /** @class */ (function () {
2013
+ function ProcessTelemetryContext(pluginChain, config, core, startAt) {
2014
+ var _self = this;
2015
+ var context = createProcessTelemetryContext(pluginChain, config, core, startAt);
2016
+ proxyFunctions(_self, context, objKeys(context));
2017
+ }
2018
+ return ProcessTelemetryContext;
2019
+ }());
1670
2020
 
1671
2021
  var strToGMTString = "toGMTString";
1672
2022
  var strToUTCString = "toUTCString";
@@ -1676,7 +2026,6 @@
1676
2026
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1677
2027
  var strDisableCookiesUsage = "disableCookiesUsage";
1678
2028
  var strConfigCookieMgr = "_ckMgr";
1679
- var strEmpty = "";
1680
2029
  var _supportsCookies = null;
1681
2030
  var _allowUaSameSite = null;
1682
2031
  var _parsedCookieValue = null;
@@ -1835,7 +2184,7 @@
1835
2184
  _supportsCookies = doc[strCookie] !== undefined;
1836
2185
  }
1837
2186
  catch (e) {
1838
- logger && logger.throwInternal(exports.LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2187
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1839
2188
  }
1840
2189
  }
1841
2190
  return _supportsCookies;
@@ -1914,26 +2263,524 @@
1914
2263
  return false;
1915
2264
  }
1916
2265
 
1917
- var validationError = "Extensions must provide callback to initialize";
2266
+ var strIKey = "iKey";
2267
+ var strExtensionConfig = "extensionConfig";
2268
+
2269
+ var ChannelControllerPriority = 500;
2270
+ var ChannelValidationMessage = "Channel has invalid priority - ";
2271
+ function _addChannelQueue(channelQueue, queue, config, core) {
2272
+ if (queue && isArray(queue) && queue.length > 0) {
2273
+ queue = queue.sort(function (a, b) {
2274
+ return a.priority - b.priority;
2275
+ });
2276
+ arrForEach(queue, function (queueItem) {
2277
+ if (queueItem.priority < ChannelControllerPriority) {
2278
+ throwError(ChannelValidationMessage + queueItem.identifier);
2279
+ }
2280
+ });
2281
+ channelQueue.push({
2282
+ queue: objFreeze(queue),
2283
+ chain: createTelemetryProxyChain(queue, config, core)
2284
+ });
2285
+ }
2286
+ }
2287
+ function createChannelControllerPlugin(channelQueue, core) {
2288
+ var _a;
2289
+ function _getTelCtx() {
2290
+ return createProcessTelemetryContext(null, core.config, core, null);
2291
+ }
2292
+ function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
2293
+ var waiting = theChannels ? (theChannels.length + 1) : 1;
2294
+ function _runChainOnComplete() {
2295
+ waiting--;
2296
+ if (waiting === 0) {
2297
+ onComplete && onComplete();
2298
+ onComplete = null;
2299
+ }
2300
+ }
2301
+ if (waiting > 0) {
2302
+ arrForEach(theChannels, function (channels) {
2303
+ if (channels && channels.queue.length > 0) {
2304
+ var channelChain = channels.chain;
2305
+ var chainCtx = itemCtx.createNew(channelChain);
2306
+ chainCtx.onComplete(_runChainOnComplete);
2307
+ processFn(chainCtx);
2308
+ }
2309
+ else {
2310
+ waiting--;
2311
+ }
2312
+ });
2313
+ }
2314
+ _runChainOnComplete();
2315
+ }
2316
+ function _doUpdate(updateCtx, updateState) {
2317
+ var theUpdateState = updateState || {
2318
+ reason: 0
2319
+ };
2320
+ _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
2321
+ chainCtx[strProcessNext](theUpdateState);
2322
+ }, function () {
2323
+ updateCtx[strProcessNext](theUpdateState);
2324
+ });
2325
+ return true;
2326
+ }
2327
+ function _doTeardown(unloadCtx, unloadState) {
2328
+ var theUnloadState = unloadState || {
2329
+ reason: 0 ,
2330
+ isAsync: false
2331
+ };
2332
+ _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
2333
+ chainCtx[strProcessNext](theUnloadState);
2334
+ }, function () {
2335
+ unloadCtx[strProcessNext](theUnloadState);
2336
+ isInitialized = false;
2337
+ });
2338
+ return true;
2339
+ }
2340
+ function _getChannel(pluginIdentifier) {
2341
+ var thePlugin = null;
2342
+ if (channelQueue && channelQueue.length > 0) {
2343
+ arrForEach(channelQueue, function (channels) {
2344
+ if (channels && channels.queue.length > 0) {
2345
+ arrForEach(channels.queue, function (ext) {
2346
+ if (ext.identifier === pluginIdentifier) {
2347
+ thePlugin = ext;
2348
+ return -1;
2349
+ }
2350
+ });
2351
+ if (thePlugin) {
2352
+ return -1;
2353
+ }
2354
+ }
2355
+ });
2356
+ }
2357
+ return thePlugin;
2358
+ }
2359
+ var isInitialized = false;
2360
+ var channelController = (_a = {
2361
+ identifier: "ChannelControllerPlugin",
2362
+ priority: ChannelControllerPriority,
2363
+ initialize: function (config, core, extensions, pluginChain) {
2364
+ isInitialized = true;
2365
+ arrForEach(channelQueue, function (channels) {
2366
+ if (channels && channels.queue.length > 0) {
2367
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2368
+ }
2369
+ });
2370
+ },
2371
+ isInitialized: function () {
2372
+ return isInitialized;
2373
+ },
2374
+ processTelemetry: function (item, itemCtx) {
2375
+ _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
2376
+ chainCtx[strProcessNext](item);
2377
+ }, function () {
2378
+ itemCtx[strProcessNext](item);
2379
+ });
2380
+ },
2381
+ update: _doUpdate
2382
+ },
2383
+ _a[strPause] = function () {
2384
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2385
+ chainCtx.iterate(function (plugin) {
2386
+ plugin[strPause] && plugin[strPause]();
2387
+ });
2388
+ }, null);
2389
+ },
2390
+ _a[strResume] = function () {
2391
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2392
+ chainCtx.iterate(function (plugin) {
2393
+ plugin[strResume] && plugin[strResume]();
2394
+ });
2395
+ }, null);
2396
+ },
2397
+ _a[strTeardown] = _doTeardown,
2398
+ _a.getChannel = _getChannel,
2399
+ _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
2400
+ var waiting = 1;
2401
+ var doneIterating = false;
2402
+ var cbTimer = null;
2403
+ cbTimeout = cbTimeout || 5000;
2404
+ function doCallback() {
2405
+ waiting--;
2406
+ if (doneIterating && waiting === 0) {
2407
+ if (cbTimer) {
2408
+ clearTimeout(cbTimer);
2409
+ cbTimer = null;
2410
+ }
2411
+ callBack && callBack(doneIterating);
2412
+ callBack = null;
2413
+ }
2414
+ }
2415
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2416
+ chainCtx.iterate(function (plugin) {
2417
+ if (plugin.flush) {
2418
+ waiting++;
2419
+ var handled_1 = false;
2420
+ if (!plugin.flush(isAsync, function () {
2421
+ handled_1 = true;
2422
+ doCallback();
2423
+ }, sendReason)) {
2424
+ if (!handled_1) {
2425
+ if (isAsync && cbTimer == null) {
2426
+ cbTimer = setTimeout(function () {
2427
+ cbTimer = null;
2428
+ doCallback();
2429
+ }, cbTimeout);
2430
+ }
2431
+ else {
2432
+ doCallback();
2433
+ }
2434
+ }
2435
+ }
2436
+ }
2437
+ });
2438
+ }, function () {
2439
+ doneIterating = true;
2440
+ doCallback();
2441
+ });
2442
+ return true;
2443
+ },
2444
+ _a._setQueue = function (queue) {
2445
+ channelQueue = queue;
2446
+ },
2447
+ _a);
2448
+ return channelController;
2449
+ }
2450
+ function createChannelQueues(channels, extensions, config, core) {
2451
+ var channelQueue = [];
2452
+ if (channels) {
2453
+ arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
2454
+ }
2455
+ if (extensions) {
2456
+ var extensionQueue_1 = [];
2457
+ arrForEach(extensions, function (plugin) {
2458
+ if (plugin.priority > ChannelControllerPriority) {
2459
+ extensionQueue_1.push(plugin);
2460
+ }
2461
+ });
2462
+ _addChannelQueue(channelQueue, extensionQueue_1, config, core);
2463
+ }
2464
+ return channelQueue;
2465
+ }
2466
+
2467
+ function createUnloadHandlerContainer() {
2468
+ var handlers = [];
2469
+ function _addHandler(handler) {
2470
+ if (handler) {
2471
+ handlers.push(handler);
2472
+ }
2473
+ }
2474
+ function _runHandlers(unloadCtx, unloadState) {
2475
+ arrForEach(handlers, function (handler) {
2476
+ try {
2477
+ handler(unloadCtx, unloadState);
2478
+ }
2479
+ catch (e) {
2480
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
2481
+ }
2482
+ });
2483
+ handlers = [];
2484
+ }
2485
+ return {
2486
+ add: _addHandler,
2487
+ run: _runHandlers
2488
+ };
2489
+ }
2490
+
2491
+ var strGetPlugin = "getPlugin";
2492
+ var BaseTelemetryPlugin = /** @class */ (function () {
2493
+ function BaseTelemetryPlugin() {
2494
+ var _self = this;
2495
+ var _isinitialized;
2496
+ var _rootCtx;
2497
+ var _nextPlugin;
2498
+ var _unloadHandlerContainer;
2499
+ var _hooks;
2500
+ _initDefaults();
2501
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
2502
+ _self.initialize = function (config, core, extensions, pluginChain) {
2503
+ _setDefaults(config, core, pluginChain);
2504
+ _isinitialized = true;
2505
+ };
2506
+ _self.teardown = function (unloadCtx, unloadState) {
2507
+ var core = _self.core;
2508
+ if (!core || (unloadCtx && core !== unloadCtx.core())) {
2509
+ return;
2510
+ }
2511
+ var result;
2512
+ var unloadDone = false;
2513
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2514
+ var theUnloadState = unloadState || {
2515
+ reason: 0 ,
2516
+ isAsync: false
2517
+ };
2518
+ function _unloadCallback() {
2519
+ if (!unloadDone) {
2520
+ unloadDone = true;
2521
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
2522
+ arrForEach(_hooks, function (fn) {
2523
+ fn.rm();
2524
+ });
2525
+ _hooks = [];
2526
+ if (result === true) {
2527
+ theUnloadCtx.processNext(theUnloadState);
2528
+ }
2529
+ _initDefaults();
2530
+ }
2531
+ }
2532
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2533
+ _unloadCallback();
2534
+ }
2535
+ else {
2536
+ result = true;
2537
+ }
2538
+ return result;
2539
+ };
2540
+ _self.update = function (updateCtx, updateState) {
2541
+ var core = _self.core;
2542
+ if (!core || (updateCtx && core !== updateCtx.core())) {
2543
+ return;
2544
+ }
2545
+ var result;
2546
+ var updateDone = false;
2547
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2548
+ var theUpdateState = updateState || {
2549
+ reason: 0
2550
+ };
2551
+ function _updateCallback() {
2552
+ if (!updateDone) {
2553
+ updateDone = true;
2554
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
2555
+ }
2556
+ }
2557
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
2558
+ _updateCallback();
2559
+ }
2560
+ else {
2561
+ result = true;
2562
+ }
2563
+ return result;
2564
+ };
2565
+ _self._addHook = function (hooks) {
2566
+ if (hooks) {
2567
+ if (isArray(hooks)) {
2568
+ _hooks = _hooks.concat(hooks);
2569
+ }
2570
+ else {
2571
+ _hooks.push(hooks);
2572
+ }
2573
+ }
2574
+ };
2575
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2576
+ });
2577
+ _self.diagLog = function (itemCtx) {
2578
+ return _getTelCtx(itemCtx).diagLog();
2579
+ };
2580
+ _self[strIsInitialized] = function () {
2581
+ return _isinitialized;
2582
+ };
2583
+ _self.setInitialized = function (isInitialized) {
2584
+ _isinitialized = isInitialized;
2585
+ };
2586
+ _self[strSetNextPlugin] = function (next) {
2587
+ _nextPlugin = next;
2588
+ };
2589
+ _self.processNext = function (env, itemCtx) {
2590
+ if (itemCtx) {
2591
+ itemCtx.processNext(env);
2592
+ }
2593
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2594
+ _nextPlugin.processTelemetry(env, null);
2595
+ }
2596
+ };
2597
+ _self._getTelCtx = _getTelCtx;
2598
+ function _getTelCtx(currentCtx) {
2599
+ if (currentCtx === void 0) { currentCtx = null; }
2600
+ var itemCtx = currentCtx;
2601
+ if (!itemCtx) {
2602
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2603
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2604
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2605
+ }
2606
+ else {
2607
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2608
+ }
2609
+ }
2610
+ return itemCtx;
2611
+ }
2612
+ function _setDefaults(config, core, pluginChain) {
2613
+ if (config) {
2614
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2615
+ }
2616
+ if (!pluginChain && core) {
2617
+ pluginChain = core.getProcessTelContext().getNext();
2618
+ }
2619
+ var nextPlugin = _nextPlugin;
2620
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2621
+ nextPlugin = _nextPlugin[strGetPlugin]();
2622
+ }
2623
+ _self.core = core;
2624
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2625
+ }
2626
+ function _initDefaults() {
2627
+ _isinitialized = false;
2628
+ _self.core = null;
2629
+ _rootCtx = null;
2630
+ _nextPlugin = null;
2631
+ _hooks = [];
2632
+ _unloadHandlerContainer = createUnloadHandlerContainer();
2633
+ }
2634
+ }
2635
+ return BaseTelemetryPlugin;
2636
+ }());
2637
+
2638
+ var TelemetryInitializerPlugin = /** @class */ (function (_super) {
2639
+ __extendsFn(TelemetryInitializerPlugin, _super);
2640
+ function TelemetryInitializerPlugin() {
2641
+ var _this = _super.call(this) || this;
2642
+ _this.identifier = "TelemetryInitializerPlugin";
2643
+ _this.priority = 199;
2644
+ var _id;
2645
+ var _initializers;
2646
+ _initDefaults();
2647
+ dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
2648
+ _self.addTelemetryInitializer = function (telemetryInitializer) {
2649
+ var theInitializer = {
2650
+ id: _id++,
2651
+ fn: telemetryInitializer
2652
+ };
2653
+ _initializers.push(theInitializer);
2654
+ var handler = {
2655
+ remove: function () {
2656
+ arrForEach(_initializers, function (initializer, idx) {
2657
+ if (initializer.id === theInitializer.id) {
2658
+ _initializers.splice(idx, 1);
2659
+ return -1;
2660
+ }
2661
+ });
2662
+ }
2663
+ };
2664
+ return handler;
2665
+ };
2666
+ _self.processTelemetry = function (item, itemCtx) {
2667
+ var doNotSendItem = false;
2668
+ var telemetryInitializersCount = _initializers.length;
2669
+ for (var i = 0; i < telemetryInitializersCount; ++i) {
2670
+ var telemetryInitializer = _initializers[i];
2671
+ if (telemetryInitializer) {
2672
+ try {
2673
+ if (telemetryInitializer.fn.apply(null, [item]) === false) {
2674
+ doNotSendItem = true;
2675
+ break;
2676
+ }
2677
+ }
2678
+ catch (e) {
2679
+ _throwInternal(itemCtx.diagLog(), 1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2680
+ }
2681
+ }
2682
+ }
2683
+ if (!doNotSendItem) {
2684
+ _self.processNext(item, itemCtx);
2685
+ }
2686
+ };
2687
+ _self[strDoTeardown] = function () {
2688
+ _initDefaults();
2689
+ };
2690
+ });
2691
+ function _initDefaults() {
2692
+ _id = 0;
2693
+ _initializers = [];
2694
+ }
2695
+ return _this;
2696
+ }
2697
+ return TelemetryInitializerPlugin;
2698
+ }(BaseTelemetryPlugin));
2699
+
2700
+ var strValidationError = "Plugins must provide initialize method";
1918
2701
  var strNotificationManager = "_notificationManager";
2702
+ var strSdkUnloadingError = "SDK is still unloading...";
2703
+ var strSdkNotInitialized = "SDK is not initialized";
2704
+ var defaultInitConfig = {
2705
+ loggingLevelConsole: 1
2706
+ };
1919
2707
  function _createPerfManager(core, notificationMgr) {
1920
2708
  return new PerfManager(notificationMgr);
1921
2709
  }
2710
+ function _validateExtensions(logger, channelPriority, allExtensions) {
2711
+ var coreExtensions = [];
2712
+ var extPriorities = {};
2713
+ arrForEach(allExtensions, function (ext) {
2714
+ if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2715
+ throwError(strValidationError);
2716
+ }
2717
+ var extPriority = ext.priority;
2718
+ var identifier = ext.identifier;
2719
+ if (ext && extPriority) {
2720
+ if (!isNullOrUndefined(extPriorities[extPriority])) {
2721
+ _warnToConsole(logger, "Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2722
+ }
2723
+ else {
2724
+ extPriorities[extPriority] = identifier;
2725
+ }
2726
+ }
2727
+ if (!extPriority || extPriority < channelPriority) {
2728
+ coreExtensions.push(ext);
2729
+ }
2730
+ });
2731
+ return {
2732
+ all: allExtensions,
2733
+ core: coreExtensions
2734
+ };
2735
+ }
2736
+ function _isPluginPresent(thePlugin, plugins) {
2737
+ var exists = false;
2738
+ arrForEach(plugins, function (plugin) {
2739
+ if (plugin === thePlugin) {
2740
+ exists = true;
2741
+ return -1;
2742
+ }
2743
+ });
2744
+ return exists;
2745
+ }
2746
+ function _createDummyNotificationManager() {
2747
+ var _a;
2748
+ return objCreateFn((_a = {},
2749
+ _a[strAddNotificationListener] = function (listener) { },
2750
+ _a[strRemoveNotificationListener] = function (listener) { },
2751
+ _a[strEventsSent] = function (events) { },
2752
+ _a[strEventsDiscarded] = function (events, reason) { },
2753
+ _a[strEventsSendRequest] = function (sendReason, isAsync) { },
2754
+ _a));
2755
+ }
1922
2756
  var BaseCore$2 = /** @class */ (function () {
1923
2757
  function BaseCore() {
1924
- var _isInitialized = false;
2758
+ var _isInitialized;
1925
2759
  var _eventQueue;
1926
- var _channelController;
1927
2760
  var _notificationManager;
1928
2761
  var _perfManager;
2762
+ var _cfgPerfManager;
1929
2763
  var _cookieManager;
2764
+ var _pluginChain;
2765
+ var _configExtensions;
2766
+ var _coreExtensions;
2767
+ var _channelControl;
2768
+ var _channelConfig;
2769
+ var _channelQueue;
2770
+ var _isUnloading;
2771
+ var _telemetryInitializerPlugin;
2772
+ var _internalLogsEventName;
2773
+ var _evtNamespace;
2774
+ var _unloadHandlers;
2775
+ var _debugListener;
2776
+ var _internalLogPoller = 0;
1930
2777
  dynamicProto(BaseCore, this, function (_self) {
1931
- _self._extensions = new Array();
1932
- _channelController = new ChannelController();
1933
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: exports.LoggingSeverity.CRITICAL });
1934
- _eventQueue = [];
2778
+ _initDefaults();
1935
2779
  _self.isInitialized = function () { return _isInitialized; };
1936
2780
  _self.initialize = function (config, extensions, logger, notificationManager) {
2781
+ if (_isUnloading) {
2782
+ throwError(strSdkUnloadingError);
2783
+ }
1937
2784
  if (_self.isInitialized()) {
1938
2785
  throwError("Core should not be initialized more than once");
1939
2786
  }
@@ -1943,182 +2790,460 @@
1943
2790
  _notificationManager = notificationManager;
1944
2791
  _self[strNotificationManager] = notificationManager;
1945
2792
  _self.config = config || {};
1946
- if (_self.config.enablePerfMgr) {
1947
- setValue(_self.config, "createPerfMgr", _createPerfManager);
1948
- }
2793
+ _initDebugListener(config);
2794
+ _initPerfManager(config);
1949
2795
  config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
1950
- var extConfig = getSetValue(config, strExtensionConfig);
1951
- extConfig.NotificationManager = notificationManager;
2796
+ _initExtConfig(config);
1952
2797
  if (logger) {
1953
2798
  _self.logger = logger;
1954
2799
  }
1955
- var allExtensions = [];
1956
- allExtensions.push.apply(allExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
1957
- allExtensions = sortPlugins(allExtensions);
1958
- var coreExtensions = [];
1959
- var extPriorities = {};
1960
- arrForEach(allExtensions, function (ext) {
1961
- if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
1962
- throwError(validationError);
1963
- }
1964
- var extPriority = ext.priority;
1965
- var identifier = ext.identifier;
1966
- if (ext && extPriority) {
1967
- if (!isNullOrUndefined(extPriorities[extPriority])) {
1968
- logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
1969
- }
1970
- else {
1971
- extPriorities[extPriority] = identifier;
1972
- }
1973
- }
1974
- if (!extPriority || extPriority < _channelController.priority) {
1975
- coreExtensions.push(ext);
1976
- }
1977
- });
1978
- allExtensions.push(_channelController);
1979
- coreExtensions.push(_channelController);
1980
- allExtensions = sortPlugins(allExtensions);
1981
- _self._extensions = allExtensions;
1982
- initializePlugins(new ProcessTelemetryContext([_channelController], config, _self), allExtensions);
1983
- initializePlugins(new ProcessTelemetryContext(coreExtensions, config, _self), allExtensions);
1984
- _self._extensions = coreExtensions;
1985
- if (_self.getTransmissionControls().length === 0) {
2800
+ _configExtensions = [];
2801
+ _configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2802
+ _channelConfig = (config || {}).channels;
2803
+ _initPluginChain(config, null);
2804
+ if (!_channelQueue || _channelQueue.length === 0) {
1986
2805
  throwError("No channels available");
1987
2806
  }
1988
2807
  _isInitialized = true;
1989
2808
  _self.releaseQueue();
1990
2809
  };
1991
2810
  _self.getTransmissionControls = function () {
1992
- return _channelController.getChannelControls();
2811
+ var controls = [];
2812
+ if (_channelQueue) {
2813
+ arrForEach(_channelQueue, function (channels) {
2814
+ controls.push(channels.queue);
2815
+ });
2816
+ }
2817
+ return objFreeze(controls);
1993
2818
  };
1994
2819
  _self.track = function (telemetryItem) {
1995
2820
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
1996
2821
  setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
1997
2822
  setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
1998
- if (_self.isInitialized()) {
1999
- _self.getProcessTelContext().processNext(telemetryItem);
2823
+ if (!_isUnloading && _self.isInitialized()) {
2824
+ _createTelCtx().processNext(telemetryItem);
2000
2825
  }
2001
2826
  else {
2002
2827
  _eventQueue.push(telemetryItem);
2003
2828
  }
2004
2829
  };
2005
- _self.getProcessTelContext = function () {
2006
- var extensions = _self._extensions;
2007
- var thePlugins = extensions;
2008
- if (!extensions || extensions.length === 0) {
2009
- thePlugins = [_channelController];
2010
- }
2011
- return new ProcessTelemetryContext(thePlugins, _self.config, _self);
2012
- };
2830
+ _self.getProcessTelContext = _createTelCtx;
2013
2831
  _self.getNotifyMgr = function () {
2014
2832
  if (!_notificationManager) {
2015
- _notificationManager = objCreateFn({
2016
- addNotificationListener: function (listener) { },
2017
- removeNotificationListener: function (listener) { },
2018
- eventsSent: function (events) { },
2019
- eventsDiscarded: function (events, reason) { },
2020
- eventsSendRequest: function (sendReason, isAsync) { }
2021
- });
2833
+ _notificationManager = _createDummyNotificationManager();
2022
2834
  _self[strNotificationManager] = _notificationManager;
2023
2835
  }
2024
2836
  return _notificationManager;
2025
2837
  };
2838
+ _self[strAddNotificationListener] = function (listener) {
2839
+ if (_notificationManager) {
2840
+ _notificationManager[strAddNotificationListener](listener);
2841
+ }
2842
+ };
2843
+ _self[strRemoveNotificationListener] = function (listener) {
2844
+ if (_notificationManager) {
2845
+ _notificationManager[strRemoveNotificationListener](listener);
2846
+ }
2847
+ };
2026
2848
  _self.getCookieMgr = function () {
2027
2849
  if (!_cookieManager) {
2028
2850
  _cookieManager = createCookieMgr(_self.config, _self.logger);
2029
2851
  }
2030
- return _cookieManager;
2031
- };
2032
- _self.setCookieMgr = function (cookieMgr) {
2033
- _cookieManager = cookieMgr;
2034
- };
2035
- _self.getPerfMgr = function () {
2036
- if (!_perfManager) {
2037
- if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2038
- _perfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2039
- }
2852
+ return _cookieManager;
2853
+ };
2854
+ _self.setCookieMgr = function (cookieMgr) {
2855
+ _cookieManager = cookieMgr;
2856
+ };
2857
+ _self.getPerfMgr = function () {
2858
+ if (!_perfManager && !_cfgPerfManager) {
2859
+ if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2860
+ _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2861
+ }
2862
+ }
2863
+ return _perfManager || _cfgPerfManager || getGblPerfMgr();
2864
+ };
2865
+ _self.setPerfMgr = function (perfMgr) {
2866
+ _perfManager = perfMgr;
2867
+ };
2868
+ _self.eventCnt = function () {
2869
+ return _eventQueue.length;
2870
+ };
2871
+ _self.releaseQueue = function () {
2872
+ if (_isInitialized && _eventQueue.length > 0) {
2873
+ var eventQueue = _eventQueue;
2874
+ _eventQueue = [];
2875
+ arrForEach(eventQueue, function (event) {
2876
+ _createTelCtx().processNext(event);
2877
+ });
2878
+ }
2879
+ };
2880
+ _self.pollInternalLogs = function (eventName) {
2881
+ _internalLogsEventName = eventName || null;
2882
+ var interval = _self.config.diagnosticLogInterval;
2883
+ if (!interval || !(interval > 0)) {
2884
+ interval = 10000;
2885
+ }
2886
+ if (_internalLogPoller) {
2887
+ clearInterval(_internalLogPoller);
2888
+ }
2889
+ _internalLogPoller = setInterval(function () {
2890
+ _flushInternalLogs();
2891
+ }, interval);
2892
+ return _internalLogPoller;
2893
+ };
2894
+ _self.stopPollingInternalLogs = function () {
2895
+ if (_internalLogPoller) {
2896
+ clearInterval(_internalLogPoller);
2897
+ _internalLogPoller = 0;
2898
+ _flushInternalLogs();
2899
+ }
2900
+ };
2901
+ proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2902
+ _self.unload = function (isAsync, unloadComplete, cbTimeout) {
2903
+ if (isAsync === void 0) { isAsync = true; }
2904
+ if (!_isInitialized) {
2905
+ throwError(strSdkNotInitialized);
2906
+ }
2907
+ if (_isUnloading) {
2908
+ throwError(strSdkUnloadingError);
2909
+ }
2910
+ var unloadState = {
2911
+ reason: 50 ,
2912
+ isAsync: isAsync,
2913
+ flushComplete: false
2914
+ };
2915
+ var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self);
2916
+ processUnloadCtx.onComplete(function () {
2917
+ _initDefaults();
2918
+ unloadComplete && unloadComplete(unloadState);
2919
+ }, _self);
2920
+ function _doUnload(flushComplete) {
2921
+ unloadState.flushComplete = flushComplete;
2922
+ _isUnloading = true;
2923
+ _unloadHandlers.run(processUnloadCtx, unloadState);
2924
+ _self.stopPollingInternalLogs();
2925
+ processUnloadCtx.processNext(unloadState);
2926
+ }
2927
+ if (!_flushChannels(isAsync, _doUnload, 6 , cbTimeout)) {
2928
+ _doUnload(false);
2929
+ }
2930
+ };
2931
+ _self.getPlugin = _getPlugin;
2932
+ _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {
2933
+ if (!plugin) {
2934
+ addCb && addCb(false);
2935
+ _logOrThrowError(strValidationError);
2936
+ return;
2937
+ }
2938
+ var existingPlugin = _getPlugin(plugin.identifier);
2939
+ if (existingPlugin && !replaceExisting) {
2940
+ addCb && addCb(false);
2941
+ _logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
2942
+ return;
2943
+ }
2944
+ var updateState = {
2945
+ reason: 16
2946
+ };
2947
+ function _addPlugin(removed) {
2948
+ _configExtensions.push(plugin);
2949
+ updateState.added = [plugin];
2950
+ _initPluginChain(_self.config, updateState);
2951
+ addCb && addCb(true);
2952
+ }
2953
+ if (existingPlugin) {
2954
+ var removedPlugins_1 = [existingPlugin.plugin];
2955
+ var unloadState = {
2956
+ reason: 2 ,
2957
+ isAsync: !!isAsync
2958
+ };
2959
+ _removePlugins(removedPlugins_1, unloadState, function (removed) {
2960
+ if (!removed) {
2961
+ addCb && addCb(false);
2962
+ }
2963
+ else {
2964
+ updateState.removed = removedPlugins_1;
2965
+ updateState.reason |= 32 ;
2966
+ _addPlugin();
2967
+ }
2968
+ });
2969
+ }
2970
+ else {
2971
+ _addPlugin();
2972
+ }
2973
+ };
2974
+ _self.evtNamespace = function () {
2975
+ return _evtNamespace;
2976
+ };
2977
+ _self.flush = _flushChannels;
2978
+ proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
2979
+ function _initDefaults() {
2980
+ _isInitialized = false;
2981
+ _self.config = objExtend(true, {}, defaultInitConfig);
2982
+ _self.logger = new DiagnosticLogger(_self.config);
2983
+ _self._extensions = [];
2984
+ _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
2985
+ _eventQueue = [];
2986
+ _notificationManager = null;
2987
+ _perfManager = null;
2988
+ _cfgPerfManager = null;
2989
+ _cookieManager = null;
2990
+ _pluginChain = null;
2991
+ _coreExtensions = null;
2992
+ _configExtensions = [];
2993
+ _channelControl = null;
2994
+ _channelConfig = null;
2995
+ _channelQueue = null;
2996
+ _isUnloading = false;
2997
+ _internalLogsEventName = null;
2998
+ _evtNamespace = createUniqueNamespace("AIBaseCore", true);
2999
+ _unloadHandlers = createUnloadHandlerContainer();
3000
+ }
3001
+ function _createTelCtx() {
3002
+ return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
3003
+ }
3004
+ function _initPluginChain(config, updateState) {
3005
+ var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
3006
+ _coreExtensions = theExtensions.core;
3007
+ _pluginChain = null;
3008
+ var allExtensions = theExtensions.all;
3009
+ _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
3010
+ if (_channelControl) {
3011
+ var idx = allExtensions.indexOf(_channelControl);
3012
+ if (idx !== -1) {
3013
+ allExtensions.splice(idx, 1);
3014
+ }
3015
+ idx = _coreExtensions.indexOf(_channelControl);
3016
+ if (idx !== -1) {
3017
+ _coreExtensions.splice(idx, 1);
3018
+ }
3019
+ _channelControl._setQueue(_channelQueue);
3020
+ }
3021
+ else {
3022
+ _channelControl = createChannelControllerPlugin(_channelQueue, _self);
3023
+ }
3024
+ allExtensions.push(_channelControl);
3025
+ _coreExtensions.push(_channelControl);
3026
+ _self._extensions = sortPlugins(allExtensions);
3027
+ _channelControl.initialize(config, _self, allExtensions);
3028
+ initializePlugins(_createTelCtx(), allExtensions);
3029
+ _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
3030
+ if (updateState) {
3031
+ _doUpdate(updateState);
3032
+ }
3033
+ }
3034
+ function _getPlugin(pluginIdentifier) {
3035
+ var theExt = null;
3036
+ var thePlugin = null;
3037
+ arrForEach(_self._extensions, function (ext) {
3038
+ if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
3039
+ thePlugin = ext;
3040
+ return -1;
3041
+ }
3042
+ });
3043
+ if (!thePlugin && _channelControl) {
3044
+ thePlugin = _channelControl.getChannel(pluginIdentifier);
3045
+ }
3046
+ if (thePlugin) {
3047
+ theExt = {
3048
+ plugin: thePlugin,
3049
+ setEnabled: function (enabled) {
3050
+ _getPluginState(thePlugin)[strDisabled] = !enabled;
3051
+ },
3052
+ isEnabled: function () {
3053
+ var pluginState = _getPluginState(thePlugin);
3054
+ return !pluginState[strTeardown] && !pluginState[strDisabled];
3055
+ },
3056
+ remove: function (isAsync, removeCb) {
3057
+ if (isAsync === void 0) { isAsync = true; }
3058
+ var pluginsToRemove = [thePlugin];
3059
+ var unloadState = {
3060
+ reason: 1 ,
3061
+ isAsync: isAsync
3062
+ };
3063
+ _removePlugins(pluginsToRemove, unloadState, function (removed) {
3064
+ if (removed) {
3065
+ _initPluginChain(_self.config, {
3066
+ reason: 32 ,
3067
+ removed: pluginsToRemove
3068
+ });
3069
+ }
3070
+ removeCb && removeCb(removed);
3071
+ });
3072
+ }
3073
+ };
3074
+ }
3075
+ return theExt;
3076
+ }
3077
+ function _getPluginChain() {
3078
+ if (!_pluginChain) {
3079
+ var extensions = (_coreExtensions || []).slice();
3080
+ if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {
3081
+ extensions.push(_telemetryInitializerPlugin);
3082
+ }
3083
+ _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
3084
+ }
3085
+ return _pluginChain;
3086
+ }
3087
+ function _removePlugins(thePlugins, unloadState, removeComplete) {
3088
+ if (thePlugins && thePlugins.length > 0) {
3089
+ var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
3090
+ var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
3091
+ unloadCtx.onComplete(function () {
3092
+ var removed = false;
3093
+ var newConfigExtensions = [];
3094
+ arrForEach(_configExtensions, function (plugin, idx) {
3095
+ if (!_isPluginPresent(plugin, thePlugins)) {
3096
+ newConfigExtensions.push(plugin);
3097
+ }
3098
+ else {
3099
+ removed = true;
3100
+ }
3101
+ });
3102
+ _configExtensions = newConfigExtensions;
3103
+ var newChannelConfig = [];
3104
+ if (_channelConfig) {
3105
+ arrForEach(_channelConfig, function (queue, idx) {
3106
+ var newQueue = [];
3107
+ arrForEach(queue, function (channel) {
3108
+ if (!_isPluginPresent(channel, thePlugins)) {
3109
+ newQueue.push(channel);
3110
+ }
3111
+ else {
3112
+ removed = true;
3113
+ }
3114
+ });
3115
+ newChannelConfig.push(newQueue);
3116
+ });
3117
+ _channelConfig = newChannelConfig;
3118
+ }
3119
+ removeComplete && removeComplete(removed);
3120
+ });
3121
+ unloadCtx.processNext(unloadState);
3122
+ }
3123
+ else {
3124
+ removeComplete(false);
3125
+ }
3126
+ }
3127
+ function _flushInternalLogs() {
3128
+ var queue = _self.logger ? _self.logger.queue : [];
3129
+ if (queue) {
3130
+ arrForEach(queue, function (logMessage) {
3131
+ var item = {
3132
+ name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
3133
+ iKey: _self.config.instrumentationKey,
3134
+ time: toISOString(new Date()),
3135
+ baseType: _InternalLogMessage.dataType,
3136
+ baseData: { message: logMessage.message }
3137
+ };
3138
+ _self.track(item);
3139
+ });
3140
+ queue.length = 0;
3141
+ }
3142
+ }
3143
+ function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
3144
+ if (_channelControl) {
3145
+ return _channelControl.flush(isAsync, callBack, sendReason || 6 , cbTimeout);
3146
+ }
3147
+ callBack && callBack(false);
3148
+ return true;
3149
+ }
3150
+ function _initDebugListener(config) {
3151
+ if (config.disableDbgExt === true && _debugListener) {
3152
+ _notificationManager[strRemoveNotificationListener](_debugListener);
3153
+ _debugListener = null;
3154
+ }
3155
+ if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
3156
+ _debugListener = getDebugListener(config);
3157
+ _notificationManager[strAddNotificationListener](_debugListener);
3158
+ }
3159
+ }
3160
+ function _initPerfManager(config) {
3161
+ if (!config.enablePerfMgr && _cfgPerfManager) {
3162
+ _cfgPerfManager = null;
3163
+ }
3164
+ if (config.enablePerfMgr) {
3165
+ setValue(_self.config, "createPerfMgr", _createPerfManager);
3166
+ }
3167
+ }
3168
+ function _initExtConfig(config) {
3169
+ var extConfig = getSetValue(config, strExtensionConfig);
3170
+ extConfig.NotificationManager = _notificationManager;
3171
+ }
3172
+ function _doUpdate(updateState) {
3173
+ var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self);
3174
+ if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
3175
+ updateCtx.processNext(updateState);
2040
3176
  }
2041
- return _perfManager || getGblPerfMgr();
2042
- };
2043
- _self.setPerfMgr = function (perfMgr) {
2044
- _perfManager = perfMgr;
2045
- };
2046
- _self.eventCnt = function () {
2047
- return _eventQueue.length;
2048
- };
2049
- _self.releaseQueue = function () {
2050
- if (_eventQueue.length > 0) {
2051
- arrForEach(_eventQueue, function (event) {
2052
- _self.getProcessTelContext().processNext(event);
2053
- });
2054
- _eventQueue = [];
3177
+ }
3178
+ function _logOrThrowError(message) {
3179
+ var logger = _self.logger;
3180
+ if (logger) {
3181
+ _throwInternal(logger, 2 , 73 , message);
2055
3182
  }
2056
- };
3183
+ else {
3184
+ throwError(message);
3185
+ }
3186
+ }
2057
3187
  });
2058
3188
  }
2059
3189
  return BaseCore;
2060
3190
  }());
2061
3191
 
3192
+ function _runListeners(listeners, name, isAsync, callback) {
3193
+ arrForEach(listeners, function (listener) {
3194
+ if (listener && listener[name]) {
3195
+ if (isAsync) {
3196
+ setTimeout(function () { return callback(listener); }, 0);
3197
+ }
3198
+ else {
3199
+ try {
3200
+ callback(listener);
3201
+ }
3202
+ catch (e) {
3203
+ }
3204
+ }
3205
+ }
3206
+ });
3207
+ }
2062
3208
  var NotificationManager = /** @class */ (function () {
2063
3209
  function NotificationManager(config) {
2064
3210
  this.listeners = [];
2065
3211
  var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
2066
3212
  dynamicProto(NotificationManager, this, function (_self) {
2067
- _self.addNotificationListener = function (listener) {
3213
+ _self[strAddNotificationListener] = function (listener) {
2068
3214
  _self.listeners.push(listener);
2069
3215
  };
2070
- _self.removeNotificationListener = function (listener) {
3216
+ _self[strRemoveNotificationListener] = function (listener) {
2071
3217
  var index = arrIndexOf(_self.listeners, listener);
2072
3218
  while (index > -1) {
2073
3219
  _self.listeners.splice(index, 1);
2074
3220
  index = arrIndexOf(_self.listeners, listener);
2075
3221
  }
2076
3222
  };
2077
- _self.eventsSent = function (events) {
2078
- arrForEach(_self.listeners, function (listener) {
2079
- if (listener && listener.eventsSent) {
2080
- setTimeout(function () { return listener.eventsSent(events); }, 0);
2081
- }
3223
+ _self[strEventsSent] = function (events) {
3224
+ _runListeners(_self.listeners, strEventsSent, true, function (listener) {
3225
+ listener[strEventsSent](events);
2082
3226
  });
2083
3227
  };
2084
- _self.eventsDiscarded = function (events, reason) {
2085
- arrForEach(_self.listeners, function (listener) {
2086
- if (listener && listener.eventsDiscarded) {
2087
- setTimeout(function () { return listener.eventsDiscarded(events, reason); }, 0);
2088
- }
3228
+ _self[strEventsDiscarded] = function (events, reason) {
3229
+ _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
3230
+ listener[strEventsDiscarded](events, reason);
2089
3231
  });
2090
3232
  };
2091
- _self.eventsSendRequest = function (sendReason, isAsync) {
2092
- arrForEach(_self.listeners, function (listener) {
2093
- if (listener && listener.eventsSendRequest) {
2094
- if (isAsync) {
2095
- setTimeout(function () { return listener.eventsSendRequest(sendReason, isAsync); }, 0);
2096
- }
2097
- else {
2098
- try {
2099
- listener.eventsSendRequest(sendReason, isAsync);
2100
- }
2101
- catch (e) {
2102
- }
2103
- }
2104
- }
3233
+ _self[strEventsSendRequest] = function (sendReason, isAsync) {
3234
+ _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
3235
+ listener[strEventsSendRequest](sendReason, isAsync);
2105
3236
  });
2106
3237
  };
2107
- _self.perfEvent = function (perfEvent) {
3238
+ _self[strPerfEvent] = function (perfEvent) {
2108
3239
  if (perfEvent) {
2109
3240
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
2110
- arrForEach(_self.listeners, function (listener) {
2111
- if (listener && listener.perfEvent) {
2112
- if (perfEvent.isAsync) {
2113
- setTimeout(function () { return listener.perfEvent(perfEvent); }, 0);
2114
- }
2115
- else {
2116
- try {
2117
- listener.perfEvent(perfEvent);
2118
- }
2119
- catch (e) {
2120
- }
2121
- }
3241
+ _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
3242
+ if (perfEvent.isAsync) {
3243
+ setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
3244
+ }
3245
+ else {
3246
+ listener[strPerfEvent](perfEvent);
2122
3247
  }
2123
3248
  });
2124
3249
  }
@@ -2133,7 +3258,6 @@
2133
3258
  __extendsFn(AppInsightsCore, _super);
2134
3259
  function AppInsightsCore() {
2135
3260
  var _this = _super.call(this) || this;
2136
- var _internalLogPoller = 0;
2137
3261
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
2138
3262
  _self.initialize = function (config, extensions, logger, notificationManager) {
2139
3263
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -2148,58 +3272,16 @@
2148
3272
  _base.track(telemetryItem);
2149
3273
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
2150
3274
  };
2151
- _self.addNotificationListener = function (listener) {
2152
- var manager = _self.getNotifyMgr();
2153
- if (manager) {
2154
- manager.addNotificationListener(listener);
2155
- }
2156
- };
2157
- _self.removeNotificationListener = function (listener) {
2158
- var manager = _self.getNotifyMgr();
2159
- if (manager) {
2160
- manager.removeNotificationListener(listener);
2161
- }
2162
- };
2163
- _self.pollInternalLogs = function (eventName) {
2164
- var interval = _self.config.diagnosticLogInterval;
2165
- if (!interval || !(interval > 0)) {
2166
- interval = 10000;
2167
- }
2168
- if (_internalLogPoller) {
2169
- _self.stopPollingInternalLogs();
2170
- }
2171
- _internalLogPoller = setInterval(function () {
2172
- var queue = _self.logger ? _self.logger.queue : [];
2173
- arrForEach(queue, function (logMessage) {
2174
- var item = {
2175
- name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
2176
- iKey: _self.config.instrumentationKey,
2177
- time: toISOString(new Date()),
2178
- baseType: _InternalLogMessage.dataType,
2179
- baseData: { message: logMessage.message }
2180
- };
2181
- _self.track(item);
2182
- });
2183
- queue.length = 0;
2184
- }, interval);
2185
- return _internalLogPoller;
2186
- };
2187
- _self.stopPollingInternalLogs = function () {
2188
- if (!_internalLogPoller)
2189
- return;
2190
- clearInterval(_internalLogPoller);
2191
- _internalLogPoller = 0;
2192
- };
2193
3275
  function _validateTelemetryItem(telemetryItem) {
2194
3276
  if (isNullOrUndefined(telemetryItem.name)) {
2195
3277
  _notifyInvalidEvent(telemetryItem);
2196
- throw Error("telemetry name required");
3278
+ throwError("telemetry name required");
2197
3279
  }
2198
3280
  }
2199
3281
  function _notifyInvalidEvent(telemetryItem) {
2200
3282
  var manager = _self.getNotifyMgr();
2201
3283
  if (manager) {
2202
- manager.eventsDiscarded([telemetryItem], EventsDiscardedReason.InvalidEvent);
3284
+ manager.eventsDiscarded([telemetryItem], 2 );
2203
3285
  }
2204
3286
  }
2205
3287
  });
@@ -2208,148 +3290,312 @@
2208
3290
  return AppInsightsCore;
2209
3291
  }(BaseCore$2));
2210
3292
 
2211
- var UInt32Mask = 0x100000000;
2212
- var MaxUInt32 = 0xffffffff;
2213
- var _mwcSeeded = false;
2214
- var _mwcW = 123456789;
2215
- var _mwcZ = 987654321;
2216
- function _mwcSeed(seedValue) {
2217
- if (seedValue < 0) {
2218
- seedValue >>>= 0;
3293
+ var strOnPrefix = "on";
3294
+ var strAttachEvent = "attachEvent";
3295
+ var strAddEventHelper = "addEventListener";
3296
+ var strDetachEvent = "detachEvent";
3297
+ var strRemoveEventListener = "removeEventListener";
3298
+ var strEvents = "events";
3299
+ var strVisibilityChangeEvt = "visibilitychange";
3300
+ var strPageHide = "pagehide";
3301
+ var strPageShow = "pageshow";
3302
+ var strUnload = "unload";
3303
+ var strBeforeUnload = "beforeunload";
3304
+ var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
3305
+ var strPageShowNamespace = createUniqueNamespace("aiEvtPageShow");
3306
+ var rRemoveEmptyNs = /\.[\.]+/g;
3307
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
3308
+ var _guid = 1;
3309
+ var elmNodeData = createElmNodeData("events");
3310
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
3311
+ function _normalizeNamespace(name) {
3312
+ if (name && name.replace) {
3313
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
3314
+ }
3315
+ return name;
3316
+ }
3317
+ function _getEvtNamespace(eventName, evtNamespace) {
3318
+ if (evtNamespace) {
3319
+ var theNamespace_1 = "";
3320
+ if (isArray(evtNamespace)) {
3321
+ theNamespace_1 = "";
3322
+ arrForEach(evtNamespace, function (name) {
3323
+ name = _normalizeNamespace(name);
3324
+ if (name) {
3325
+ if (name[0] !== ".") {
3326
+ name = "." + name;
3327
+ }
3328
+ theNamespace_1 += name;
3329
+ }
3330
+ });
3331
+ }
3332
+ else {
3333
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
3334
+ }
3335
+ if (theNamespace_1) {
3336
+ if (theNamespace_1[0] !== ".") {
3337
+ theNamespace_1 = "." + theNamespace_1;
3338
+ }
3339
+ eventName = (eventName || "") + theNamespace_1;
3340
+ }
2219
3341
  }
2220
- _mwcW = (123456789 + seedValue) & MaxUInt32;
2221
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
2222
- _mwcSeeded = true;
3342
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
3343
+ return {
3344
+ type: parsedEvent[1],
3345
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
3346
+ };
2223
3347
  }
2224
- function _autoSeedMwc() {
2225
- try {
2226
- var now = dateNow() & 0x7fffffff;
2227
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2228
- }
2229
- catch (e) {
3348
+ function __getRegisteredEvents(target, eventName, evtNamespace) {
3349
+ var theEvents = [];
3350
+ var eventCache = elmNodeData.get(target, strEvents, {}, false);
3351
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
3352
+ objForEachKey(eventCache, function (evtType, registeredEvents) {
3353
+ arrForEach(registeredEvents, function (value) {
3354
+ if (!evtName.type || evtName.type === value.evtName.type) {
3355
+ if (!evtName.ns || evtName.ns === evtName.ns) {
3356
+ theEvents.push({
3357
+ name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
3358
+ handler: value.handler
3359
+ });
3360
+ }
3361
+ }
3362
+ });
3363
+ });
3364
+ return theEvents;
3365
+ }
3366
+ function _getRegisteredEvents(target, evtName, addDefault) {
3367
+ if (addDefault === void 0) { addDefault = true; }
3368
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
3369
+ var registeredEvents = aiEvts[evtName];
3370
+ if (!registeredEvents) {
3371
+ registeredEvents = aiEvts[evtName] = [];
2230
3372
  }
3373
+ return registeredEvents;
2231
3374
  }
2232
- function randomValue(maxValue) {
2233
- if (maxValue > 0) {
2234
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
3375
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
3376
+ if (obj && evtName && evtName.type) {
3377
+ if (obj[strRemoveEventListener]) {
3378
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
3379
+ }
3380
+ else if (obj[strDetachEvent]) {
3381
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
3382
+ }
2235
3383
  }
2236
- return 0;
2237
3384
  }
2238
- function random32(signed) {
2239
- var value;
2240
- var c = getCrypto() || getMsCrypto();
2241
- if (c && c.getRandomValues) {
2242
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
3385
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
3386
+ var result = false;
3387
+ if (obj && evtName && evtName.type && handlerRef) {
3388
+ if (obj[strAddEventHelper]) {
3389
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
3390
+ result = true;
3391
+ }
3392
+ else if (obj[strAttachEvent]) {
3393
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
3394
+ result = true;
3395
+ }
2243
3396
  }
2244
- else if (isIE()) {
2245
- if (!_mwcSeeded) {
2246
- _autoSeedMwc();
3397
+ return result;
3398
+ }
3399
+ function _doUnregister(target, events, evtName, unRegFn) {
3400
+ var idx = events.length;
3401
+ while (idx--) {
3402
+ var theEvent = events[idx];
3403
+ if (theEvent) {
3404
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
3405
+ if (!unRegFn || unRegFn(theEvent)) {
3406
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
3407
+ events.splice(idx, 1);
3408
+ }
3409
+ }
2247
3410
  }
2248
- value = mwcRandom32() & MaxUInt32;
2249
3411
  }
2250
- else {
2251
- value = Math.floor((UInt32Mask * Math.random()) | 0);
3412
+ }
3413
+ function _unregisterEvents(target, evtName, unRegFn) {
3414
+ if (evtName.type) {
3415
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
2252
3416
  }
2253
- if (!signed) {
2254
- value >>>= 0;
3417
+ else {
3418
+ var eventCache = elmNodeData.get(target, strEvents, {});
3419
+ objForEachKey(eventCache, function (evtType, events) {
3420
+ _doUnregister(target, events, evtName, unRegFn);
3421
+ });
3422
+ if (objKeys(eventCache).length === 0) {
3423
+ elmNodeData.kill(target, strEvents);
3424
+ }
2255
3425
  }
2256
- return value;
2257
3426
  }
2258
- function mwcRandomSeed(value) {
2259
- if (!value) {
2260
- _autoSeedMwc();
3427
+ function mergeEvtNamespace(theNamespace, namespaces) {
3428
+ var newNamespaces;
3429
+ if (namespaces) {
3430
+ if (isArray(namespaces)) {
3431
+ newNamespaces = [theNamespace].concat(namespaces);
3432
+ }
3433
+ else {
3434
+ newNamespaces = [theNamespace, namespaces];
3435
+ }
3436
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
2261
3437
  }
2262
3438
  else {
2263
- _mwcSeed(value);
3439
+ newNamespaces = theNamespace;
2264
3440
  }
3441
+ return newNamespaces;
2265
3442
  }
2266
- function mwcRandom32(signed) {
2267
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
2268
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
2269
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
2270
- if (!signed) {
2271
- value >>>= 0;
3443
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
3444
+ if (useCapture === void 0) { useCapture = false; }
3445
+ var result = false;
3446
+ if (target) {
3447
+ try {
3448
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
3449
+ result = _doAttach(target, evtName, handlerRef, useCapture);
3450
+ if (result && elmNodeData.accept(target)) {
3451
+ var registeredEvent = {
3452
+ guid: _guid++,
3453
+ evtName: evtName,
3454
+ handler: handlerRef,
3455
+ capture: useCapture
3456
+ };
3457
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
3458
+ }
3459
+ }
3460
+ catch (e) {
3461
+ }
2272
3462
  }
2273
- return value;
3463
+ return result;
2274
3464
  }
2275
-
2276
- var strVisibilityChangeEvt = "visibilitychange";
2277
- var strPageHide = "pagehide";
2278
- var strPageShow = "pageshow";
2279
- function addEventHandler(eventName, callback) {
3465
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
3466
+ if (useCapture === void 0) { useCapture = false; }
3467
+ if (target) {
3468
+ try {
3469
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
3470
+ var found_1 = false;
3471
+ _unregisterEvents(target, evtName_1, function (regEvent) {
3472
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
3473
+ found_1 = true;
3474
+ return true;
3475
+ }
3476
+ return false;
3477
+ });
3478
+ if (!found_1) {
3479
+ _doDetach(target, evtName_1, handlerRef, useCapture);
3480
+ }
3481
+ }
3482
+ catch (e) {
3483
+ }
3484
+ }
3485
+ }
3486
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3487
+ if (useCapture === void 0) { useCapture = false; }
3488
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3489
+ }
3490
+ function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3491
+ if (useCapture === void 0) { useCapture = false; }
3492
+ eventOff(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3493
+ }
3494
+ function addEventHandler(eventName, callback, evtNamespace) {
2280
3495
  var result = false;
2281
3496
  var w = getWindow();
2282
3497
  if (w) {
2283
- result = attachEvent(w, eventName, callback);
2284
- result = attachEvent(w["body"], eventName, callback) || result;
3498
+ result = eventOn(w, eventName, callback, evtNamespace);
3499
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2285
3500
  }
2286
3501
  var doc = getDocument();
2287
3502
  if (doc) {
2288
- result = attachEvent(doc, eventName, callback) || result;
3503
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
2289
3504
  }
2290
3505
  return result;
2291
3506
  }
2292
- function addEventListeners(events, listener, excludeEvents) {
3507
+ function removeEventHandler(eventName, callback, evtNamespace) {
3508
+ var w = getWindow();
3509
+ if (w) {
3510
+ eventOff(w, eventName, callback, evtNamespace);
3511
+ eventOff(w["body"], eventName, callback, evtNamespace);
3512
+ }
3513
+ var doc = getDocument();
3514
+ if (doc) {
3515
+ eventOff(doc, eventName, callback, evtNamespace);
3516
+ }
3517
+ }
3518
+ function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
2293
3519
  var added = false;
2294
- if (listener && events && isArray(events)) {
2295
- var excluded_1 = [];
3520
+ if (listener && events && events.length > 0) {
2296
3521
  arrForEach(events, function (name) {
2297
- if (isString(name)) {
3522
+ if (name) {
2298
3523
  if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
2299
- added = addEventHandler(name, listener) || added;
2300
- }
2301
- else {
2302
- excluded_1.push(name);
3524
+ added = addEventHandler(name, listener, evtNamespace) || added;
2303
3525
  }
2304
3526
  }
2305
3527
  });
2306
- if (!added && excluded_1.length > 0) {
2307
- added = addEventListeners(excluded_1, listener);
3528
+ }
3529
+ return added;
3530
+ }
3531
+ function addEventListeners(events, listener, excludeEvents, evtNamespace) {
3532
+ var added = false;
3533
+ if (listener && events && isArray(events)) {
3534
+ added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
3535
+ if (!added && excludeEvents && excludeEvents.length > 0) {
3536
+ added = _addEventListeners(events, listener, null, evtNamespace);
2308
3537
  }
2309
3538
  }
2310
3539
  return added;
2311
3540
  }
2312
- function addPageUnloadEventListener(listener, excludeEvents) {
2313
- return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
3541
+ function removeEventListeners(events, listener, evtNamespace) {
3542
+ if (events && isArray(events)) {
3543
+ arrForEach(events, function (name) {
3544
+ if (name) {
3545
+ removeEventHandler(name, listener, evtNamespace);
3546
+ }
3547
+ });
3548
+ }
3549
+ }
3550
+ function addPageUnloadEventListener(listener, excludeEvents, evtNamespace) {
3551
+ return addEventListeners([strBeforeUnload, strUnload, strPageHide], listener, excludeEvents, evtNamespace);
2314
3552
  }
2315
- function addPageHideEventListener(listener, excludeEvents) {
3553
+ function removePageUnloadEventListener(listener, evtNamespace) {
3554
+ removeEventListeners([strBeforeUnload, strUnload, strPageHide], listener, evtNamespace);
3555
+ }
3556
+ function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
2316
3557
  function _handlePageVisibility(evt) {
2317
3558
  var doc = getDocument();
2318
3559
  if (listener && doc && doc.visibilityState === "hidden") {
2319
3560
  listener(evt);
2320
3561
  }
2321
3562
  }
2322
- var pageUnloadAdded = false;
2323
- if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
2324
- pageUnloadAdded = addEventHandler(strPageHide, listener);
2325
- }
3563
+ var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3564
+ var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
2326
3565
  if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
2327
- pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
3566
+ pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
2328
3567
  }
2329
3568
  if (!pageUnloadAdded && excludeEvents) {
2330
- pageUnloadAdded = addPageHideEventListener(listener);
3569
+ pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
2331
3570
  }
2332
3571
  return pageUnloadAdded;
2333
3572
  }
2334
- function addPageShowEventListener(listener, excludeEvents) {
3573
+ function removePageHideEventListener(listener, evtNamespace) {
3574
+ var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3575
+ removeEventListeners([strPageHide], listener, newNamespaces);
3576
+ removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
3577
+ }
3578
+ function addPageShowEventListener(listener, excludeEvents, evtNamespace) {
2335
3579
  function _handlePageVisibility(evt) {
2336
3580
  var doc = getDocument();
2337
3581
  if (listener && doc && doc.visibilityState === "visible") {
2338
3582
  listener(evt);
2339
3583
  }
2340
3584
  }
2341
- var pageShowAdded = false;
2342
- if (!excludeEvents || arrIndexOf(excludeEvents, strPageShow) === -1) {
2343
- pageShowAdded = addEventHandler(strPageShow, listener);
2344
- }
2345
- if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
2346
- pageShowAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageShowAdded;
2347
- }
3585
+ var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
3586
+ var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
3587
+ pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
2348
3588
  if (!pageShowAdded && excludeEvents) {
2349
- pageShowAdded = addPageShowEventListener(listener);
3589
+ pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
2350
3590
  }
2351
3591
  return pageShowAdded;
2352
3592
  }
3593
+ function removePageShowEventListener(listener, evtNamespace) {
3594
+ var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
3595
+ removeEventListeners([strPageShow], listener, newNamespaces);
3596
+ removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
3597
+ }
3598
+
2353
3599
  function newGuid() {
2354
3600
  function randomHexDigit() {
2355
3601
  return randomValue(15);
@@ -2366,26 +3612,9 @@
2366
3612
  }
2367
3613
  return dateNow();
2368
3614
  }
2369
- function newId(maxLength) {
2370
- if (maxLength === void 0) { maxLength = 22; }
2371
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2372
- var number = random32() >>> 0;
2373
- var chars = 0;
2374
- var result = "";
2375
- while (result.length < maxLength) {
2376
- chars++;
2377
- result += base64chars.charAt(number & 0x3F);
2378
- number >>>= 6;
2379
- if (chars === 5) {
2380
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2381
- chars = 0;
2382
- }
2383
- }
2384
- return result;
2385
- }
2386
3615
  function generateW3CId() {
2387
3616
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2388
- var oct = "", tmp;
3617
+ var oct = strEmpty, tmp;
2389
3618
  for (var a = 0; a < 4; a++) {
2390
3619
  tmp = random32();
2391
3620
  oct +=
@@ -2409,66 +3638,177 @@
2409
3638
  DetachEvent: detachEvent
2410
3639
  };
2411
3640
 
2412
- var ValueKind = {
2413
- NotSet: 0,
2414
- Pii_DistinguishedName: 1,
2415
- Pii_GenericData: 2,
2416
- Pii_IPV4Address: 3,
2417
- Pii_IPv6Address: 4,
2418
- Pii_MailSubject: 5,
2419
- Pii_PhoneNumber: 6,
2420
- Pii_QueryString: 7,
2421
- Pii_SipAddress: 8,
2422
- Pii_SmtpAddress: 9,
2423
- Pii_Identity: 10,
2424
- Pii_Uri: 11,
2425
- Pii_Fqdn: 12,
2426
- Pii_IPV4AddressLegacy: 13,
3641
+ var LoggingSeverity = createEnumStyle({
3642
+ CRITICAL: 1 ,
3643
+ WARNING: 2
3644
+ });
3645
+ var _InternalMessageId = createEnumStyle({
3646
+ BrowserDoesNotSupportLocalStorage: 0 ,
3647
+ BrowserCannotReadLocalStorage: 1 ,
3648
+ BrowserCannotReadSessionStorage: 2 ,
3649
+ BrowserCannotWriteLocalStorage: 3 ,
3650
+ BrowserCannotWriteSessionStorage: 4 ,
3651
+ BrowserFailedRemovalFromLocalStorage: 5 ,
3652
+ BrowserFailedRemovalFromSessionStorage: 6 ,
3653
+ CannotSendEmptyTelemetry: 7 ,
3654
+ ClientPerformanceMathError: 8 ,
3655
+ ErrorParsingAISessionCookie: 9 ,
3656
+ ErrorPVCalc: 10 ,
3657
+ ExceptionWhileLoggingError: 11 ,
3658
+ FailedAddingTelemetryToBuffer: 12 ,
3659
+ FailedMonitorAjaxAbort: 13 ,
3660
+ FailedMonitorAjaxDur: 14 ,
3661
+ FailedMonitorAjaxOpen: 15 ,
3662
+ FailedMonitorAjaxRSC: 16 ,
3663
+ FailedMonitorAjaxSend: 17 ,
3664
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
3665
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
3666
+ FailedToSendQueuedTelemetry: 20 ,
3667
+ FailedToReportDataLoss: 21 ,
3668
+ FlushFailed: 22 ,
3669
+ MessageLimitPerPVExceeded: 23 ,
3670
+ MissingRequiredFieldSpecification: 24 ,
3671
+ NavigationTimingNotSupported: 25 ,
3672
+ OnError: 26 ,
3673
+ SessionRenewalDateIsZero: 27 ,
3674
+ SenderNotInitialized: 28 ,
3675
+ StartTrackEventFailed: 29 ,
3676
+ StopTrackEventFailed: 30 ,
3677
+ StartTrackFailed: 31 ,
3678
+ StopTrackFailed: 32 ,
3679
+ TelemetrySampledAndNotSent: 33 ,
3680
+ TrackEventFailed: 34 ,
3681
+ TrackExceptionFailed: 35 ,
3682
+ TrackMetricFailed: 36 ,
3683
+ TrackPVFailed: 37 ,
3684
+ TrackPVFailedCalc: 38 ,
3685
+ TrackTraceFailed: 39 ,
3686
+ TransmissionFailed: 40 ,
3687
+ FailedToSetStorageBuffer: 41 ,
3688
+ FailedToRestoreStorageBuffer: 42 ,
3689
+ InvalidBackendResponse: 43 ,
3690
+ FailedToFixDepricatedValues: 44 ,
3691
+ InvalidDurationValue: 45 ,
3692
+ TelemetryEnvelopeInvalid: 46 ,
3693
+ CreateEnvelopeError: 47 ,
3694
+ CannotSerializeObject: 48 ,
3695
+ CannotSerializeObjectNonSerializable: 49 ,
3696
+ CircularReferenceDetected: 50 ,
3697
+ ClearAuthContextFailed: 51 ,
3698
+ ExceptionTruncated: 52 ,
3699
+ IllegalCharsInName: 53 ,
3700
+ ItemNotInArray: 54 ,
3701
+ MaxAjaxPerPVExceeded: 55 ,
3702
+ MessageTruncated: 56 ,
3703
+ NameTooLong: 57 ,
3704
+ SampleRateOutOfRange: 58 ,
3705
+ SetAuthContextFailed: 59 ,
3706
+ SetAuthContextFailedAccountName: 60 ,
3707
+ StringValueTooLong: 61 ,
3708
+ StartCalledMoreThanOnce: 62 ,
3709
+ StopCalledWithoutStart: 63 ,
3710
+ TelemetryInitializerFailed: 64 ,
3711
+ TrackArgumentsNotSpecified: 65 ,
3712
+ UrlTooLong: 66 ,
3713
+ SessionStorageBufferFull: 67 ,
3714
+ CannotAccessCookie: 68 ,
3715
+ IdTooLong: 69 ,
3716
+ InvalidEvent: 70 ,
3717
+ FailedMonitorAjaxSetRequestHeader: 71 ,
3718
+ SendBrowserInfoOnUserInit: 72 ,
3719
+ PluginException: 73 ,
3720
+ NotificationException: 74 ,
3721
+ SnippetScriptLoadFailure: 99 ,
3722
+ InvalidInstrumentationKey: 100 ,
3723
+ CannotParseAiBlobValue: 101 ,
3724
+ InvalidContentBlob: 102 ,
3725
+ TrackPageActionEventFailed: 103 ,
3726
+ FailedAddingCustomDefinedRequestContext: 104 ,
3727
+ InMemoryStorageBufferFull: 105
3728
+ });
3729
+
3730
+ var ValueKind = createEnumStyle({
3731
+ NotSet: 0 ,
3732
+ Pii_DistinguishedName: 1 ,
3733
+ Pii_GenericData: 2 ,
3734
+ Pii_IPV4Address: 3 ,
3735
+ Pii_IPv6Address: 4 ,
3736
+ Pii_MailSubject: 5 ,
3737
+ Pii_PhoneNumber: 6 ,
3738
+ Pii_QueryString: 7 ,
3739
+ Pii_SipAddress: 8 ,
3740
+ Pii_SmtpAddress: 9 ,
3741
+ Pii_Identity: 10 ,
3742
+ Pii_Uri: 11 ,
3743
+ Pii_Fqdn: 12 ,
3744
+ Pii_IPV4AddressLegacy: 13 ,
2427
3745
  CustomerContent_GenericContent: 32
2428
- };
2429
- var EventLatency = {
3746
+ });
3747
+ var EventLatency = createEnumStyle({
2430
3748
  Normal: 1 ,
2431
3749
  CostDeferred: 2 ,
2432
3750
  RealTime: 3 ,
2433
3751
  Immediate: 4
2434
- };
2435
- var EventPropertyType = {
2436
- Unspecified: 0,
2437
- String: 1,
2438
- Int32: 2,
2439
- UInt32: 3,
2440
- Int64: 4,
2441
- UInt64: 5,
2442
- Double: 6,
2443
- Bool: 7,
2444
- Guid: 8,
3752
+ });
3753
+ var EventPropertyType = createEnumStyle({
3754
+ Unspecified: 0 ,
3755
+ String: 1 ,
3756
+ Int32: 2 ,
3757
+ UInt32: 3 ,
3758
+ Int64: 4 ,
3759
+ UInt64: 5 ,
3760
+ Double: 6 ,
3761
+ Bool: 7 ,
3762
+ Guid: 8 ,
2445
3763
  DateTime: 9
2446
- };
2447
- var EventPersistence = {
3764
+ });
3765
+ var EventPersistence = createEnumStyle({
2448
3766
  Normal: 1 ,
2449
3767
  Critical: 2
2450
- };
2451
- var TraceLevel = {
2452
- NONE: 0,
2453
- ERROR: 1,
2454
- WARNING: 2,
3768
+ });
3769
+ var TraceLevel = createEnumStyle({
3770
+ NONE: 0 ,
3771
+ ERROR: 1 ,
3772
+ WARNING: 2 ,
2455
3773
  INFORMATION: 3
2456
- };
2457
- var _ExtendedInternalMessageId = __assignFn(__assignFn({}, _InternalMessageId), { AuthHandShakeError: 501, AuthRedirectFail: 502, BrowserCannotReadLocalStorage: 503, BrowserCannotWriteLocalStorage: 504, BrowserDoesNotSupportLocalStorage: 505, CannotParseBiBlobValue: 506, CannotParseDataAttribute: 507, CVPluginNotAvailable: 508, DroppedEvent: 509, ErrorParsingAISessionCookie: 510, ErrorProvidedChannels: 511, FailedToGetCookies: 512, FailedToInitializeCorrelationVector: 513, FailedToInitializeSDK: 514, InvalidContentBlob: 515, InvalidCorrelationValue: 516, SessionRenewalDateIsZero: 517, SendPostOnCompleteFailure: 518, PostResponseHandler: 519, SDKNotInitialized: 520 });
3774
+ });
3775
+ var _ExtendedInternalMessageId = objFreeze(__assignFn(__assignFn({}, _InternalMessageId), createEnumStyle({
3776
+ AuthHandShakeError: 501 ,
3777
+ AuthRedirectFail: 502 ,
3778
+ BrowserCannotReadLocalStorage: 503 ,
3779
+ BrowserCannotWriteLocalStorage: 504 ,
3780
+ BrowserDoesNotSupportLocalStorage: 505 ,
3781
+ CannotParseBiBlobValue: 506 ,
3782
+ CannotParseDataAttribute: 507 ,
3783
+ CVPluginNotAvailable: 508 ,
3784
+ DroppedEvent: 509 ,
3785
+ ErrorParsingAISessionCookie: 510 ,
3786
+ ErrorProvidedChannels: 511 ,
3787
+ FailedToGetCookies: 512 ,
3788
+ FailedToInitializeCorrelationVector: 513 ,
3789
+ FailedToInitializeSDK: 514 ,
3790
+ InvalidContentBlob: 515 ,
3791
+ InvalidCorrelationValue: 516 ,
3792
+ SessionRenewalDateIsZero: 517 ,
3793
+ SendPostOnCompleteFailure: 518 ,
3794
+ PostResponseHandler: 519 ,
3795
+ SDKNotInitialized: 520
3796
+ })));
2458
3797
 
2459
3798
  var _a;
2460
- var Version = '3.1.9';
3799
+ var Version = '3.2.0';
2461
3800
  var FullVersionString = "1DS-Web-JS-" + Version;
2462
3801
  var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
2463
3802
  var strWithCredentials = "withCredentials";
3803
+ var strTimeout = "timeout";
2464
3804
  var _fieldTypeEventPropMap = (_a = {},
2465
- _a[0 ] = EventPropertyType.Unspecified,
2466
- _a[2 ] = EventPropertyType.Double,
2467
- _a[1 ] = EventPropertyType.String,
2468
- _a[3 ] = EventPropertyType.Bool,
2469
- _a[4096 | 2 ] = EventPropertyType.Double,
2470
- _a[4096 | 1 ] = EventPropertyType.String,
2471
- _a[4096 | 3 ] = EventPropertyType.Bool,
3805
+ _a[0 ] = 0 ,
3806
+ _a[2 ] = 6 ,
3807
+ _a[1 ] = 1 ,
3808
+ _a[3 ] = 7 ,
3809
+ _a[4096 | 2 ] = 6 ,
3810
+ _a[4096 | 1 ] = 1 ,
3811
+ _a[4096 | 3 ] = 7 ,
2472
3812
  _a);
2473
3813
  var uInt8ArraySupported = null;
2474
3814
  var isDocumentObjectAvailable = Boolean(getDocument());
@@ -2492,7 +3832,7 @@
2492
3832
  return uInt8ArraySupported;
2493
3833
  }
2494
3834
  function isLatency(value) {
2495
- if (value && isNumber(value) && value >= EventLatency.Normal && value <= EventLatency.Immediate) {
3835
+ if (value && isNumber(value) && value >= 1 && value <= 4 ) {
2496
3836
  return true;
2497
3837
  }
2498
3838
  return false;
@@ -2548,7 +3888,7 @@
2548
3888
  if (encodedTypeValue !== -1 && propType !== -1) {
2549
3889
  encodedTypeValue |= propType;
2550
3890
  }
2551
- else if (propType === EventPropertyType.Double) {
3891
+ else if (propType === 6 ) {
2552
3892
  encodedTypeValue = propType;
2553
3893
  }
2554
3894
  }
@@ -2638,7 +3978,7 @@
2638
3978
  }
2639
3979
  var getTime = perfNow;
2640
3980
  function isValueKind(value) {
2641
- if (value === ValueKind.NotSet || ((value > ValueKind.NotSet && value <= ValueKind.Pii_IPV4AddressLegacy) || value === ValueKind.CustomerContent_GenericContent)) {
3981
+ if (value === 0 || ((value > 0 && value <= 13 ) || value === 32 )) {
2642
3982
  return true;
2643
3983
  }
2644
3984
  return false;
@@ -2784,7 +4124,7 @@
2784
4124
  function isChromium() {
2785
4125
  return !!getGlobalInst("chrome");
2786
4126
  }
2787
- function openXhr(method, urlString, withCredentials, disabled, isSync) {
4127
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
2788
4128
  if (disabled === void 0) { disabled = false; }
2789
4129
  if (isSync === void 0) { isSync = false; }
2790
4130
  function _wrapSetXhrProp(xhr, prop, value) {
@@ -2805,6 +4145,9 @@
2805
4145
  if (withCredentials) {
2806
4146
  _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
2807
4147
  }
4148
+ if (!isSync && timeout) {
4149
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
4150
+ }
2808
4151
  return xhr;
2809
4152
  }
2810
4153
 
@@ -2818,7 +4161,7 @@
2818
4161
  _this.pluginVersionString = "";
2819
4162
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
2820
4163
  if (!_self.logger || !_self.logger.queue) {
2821
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: exports.LoggingSeverity.CRITICAL });
4164
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 });
2822
4165
  }
2823
4166
  _self.initialize = function (config, extensions, logger, notificationManager) {
2824
4167
  doPerf(_self, function () { return "AppInsightsCore.initialize"; }, function () {
@@ -2865,7 +4208,7 @@
2865
4208
  if (message.indexOf("channels") !== -1) {
2866
4209
  message += "\n - Channels must be provided through config.channels only!";
2867
4210
  }
2868
- logger_1.throwInternal(exports.LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.FailedToInitializeSDK, "SDK Initialization Failed - no telemetry will be sent: " + message);
4211
+ logger_1.throwInternal(1 , 514 , "SDK Initialization Failed - no telemetry will be sent: " + message);
2869
4212
  }
2870
4213
  }, function () { return ({ config: config, extensions: extensions, logger: logger, notificationManager: notificationManager }); });
2871
4214
  };
@@ -2876,7 +4219,7 @@
2876
4219
  telemetryItem.timings = telemetryItem.timings || {};
2877
4220
  telemetryItem.timings.trackStart = getTime();
2878
4221
  if (!isLatency(telemetryItem.latency)) {
2879
- telemetryItem.latency = EventLatency.Normal;
4222
+ telemetryItem.latency = 1 ;
2880
4223
  }
2881
4224
  var itemExt = telemetryItem.ext = telemetryItem.ext || {};
2882
4225
  itemExt.sdk = itemExt.sdk || {};
@@ -2919,7 +4262,7 @@
2919
4262
  _base.initialize(config, extensions, logger, notificationManager);
2920
4263
  }
2921
4264
  catch (e) {
2922
- _self.logger.throwInternal(exports.LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.FailedToInitializeSDK, "Initialization Failed: " + dumpObj(e) + "\n - Note: Channels must be provided through config.channels only");
4265
+ _throwInternal(_self.logger, 1 , 514 , "Initialization Failed: " + dumpObj(e) + "\n - Note: Channels must be provided through config.channels only");
2923
4266
  }
2924
4267
  };
2925
4268
  _self.track = function (item) {
@@ -3523,6 +4866,7 @@
3523
4866
  exports.FullVersionString = FullVersionString;
3524
4867
  exports.InternalAppInsightsCore = AppInsightsCore$2;
3525
4868
  exports.InternalBaseCore = BaseCore$2;
4869
+ exports.LoggingSeverity = LoggingSeverity;
3526
4870
  exports.MinChannelPriorty = MinChannelPriorty;
3527
4871
  exports.NotificationManager = NotificationManager;
3528
4872
  exports.PerfEvent = PerfEvent;
@@ -3537,6 +4881,8 @@
3537
4881
  exports._ExtendedInternalMessageId = _ExtendedInternalMessageId;
3538
4882
  exports._InternalLogMessage = _InternalLogMessage;
3539
4883
  exports._InternalMessageId = _InternalMessageId;
4884
+ exports.__getRegisteredEvents = __getRegisteredEvents;
4885
+ exports._throwInternal = _throwInternal;
3540
4886
  exports.addEventHandler = addEventHandler;
3541
4887
  exports.addEventListeners = addEventListeners;
3542
4888
  exports.addPageHideEventListener = addPageHideEventListener;
@@ -3550,7 +4896,11 @@
3550
4896
  exports.attachEvent = attachEvent;
3551
4897
  exports.cookieAvailable = areCookiesSupported;
3552
4898
  exports.createCookieMgr = createCookieMgr;
4899
+ exports.createEnumStyle = createEnumStyle;
3553
4900
  exports.createGuid = createGuid;
4901
+ exports.createProcessTelemetryContext = createProcessTelemetryContext;
4902
+ exports.createUniqueNamespace = createUniqueNamespace;
4903
+ exports.createUnloadHandlerContainer = createUnloadHandlerContainer;
3554
4904
  exports.dateNow = dateNow;
3555
4905
  exports.deleteCookie = deleteCookie;
3556
4906
  exports.detachEvent = detachEvent;
@@ -3558,6 +4908,8 @@
3558
4908
  exports.disallowsSameSiteNone = uaDisallowsSameSiteNone;
3559
4909
  exports.doPerf = doPerf;
3560
4910
  exports.dumpObj = dumpObj;
4911
+ exports.eventOff = eventOff;
4912
+ exports.eventOn = eventOn;
3561
4913
  exports.extend = extend;
3562
4914
  exports.generateW3CId = generateW3CId;
3563
4915
  exports.getCommonSchemaMetaData = getCommonSchemaMetaData;
@@ -3614,19 +4966,29 @@
3614
4966
  exports.isValueKind = isValueKind;
3615
4967
  exports.isWindowObjectAvailable = isWindowObjectAvailable;
3616
4968
  exports.isXhrSupported = isXhrSupported;
4969
+ exports.mergeEvtNamespace = mergeEvtNamespace;
3617
4970
  exports.newGuid = newGuid;
3618
4971
  exports.newId = newId;
3619
4972
  exports.normalizeJsName = normalizeJsName;
3620
4973
  exports.objCreate = objCreateFn;
3621
4974
  exports.objDefineAccessors = objDefineAccessors;
3622
4975
  exports.objForEachKey = objForEachKey;
4976
+ exports.objFreeze = objFreeze;
3623
4977
  exports.objKeys = objKeys;
4978
+ exports.objSeal = objSeal;
3624
4979
  exports.openXhr = openXhr;
3625
4980
  exports.optimizeObject = optimizeObject;
3626
4981
  exports.perfNow = perfNow;
3627
4982
  exports.proxyAssign = proxyAssign;
4983
+ exports.proxyFunctionAs = proxyFunctionAs;
4984
+ exports.proxyFunctions = proxyFunctions;
3628
4985
  exports.random32 = random32;
3629
4986
  exports.randomValue = randomValue;
4987
+ exports.removeEventHandler = removeEventHandler;
4988
+ exports.removeEventListeners = removeEventListeners;
4989
+ exports.removePageHideEventListener = removePageHideEventListener;
4990
+ exports.removePageShowEventListener = removePageShowEventListener;
4991
+ exports.removePageUnloadEventListener = removePageUnloadEventListener;
3630
4992
  exports.safeGetCookieMgr = safeGetCookieMgr;
3631
4993
  exports.safeGetLogger = safeGetLogger;
3632
4994
  exports.sanitizeProperty = sanitizeProperty;
@@ -3636,9 +4998,7 @@
3636
4998
  exports.setValue = setValue;
3637
4999
  exports.strContains = strContains;
3638
5000
  exports.strEndsWith = strEndsWith;
3639
- exports.strExtensionConfig = strExtensionConfig;
3640
5001
  exports.strFunction = strShimFunction;
3641
- exports.strIKey = strIKey;
3642
5002
  exports.strObject = strShimObject;
3643
5003
  exports.strPrototype = strShimPrototype;
3644
5004
  exports.strStartsWith = strStartsWith;
@@ -3651,4 +5011,4 @@
3651
5011
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3652
5012
 
3653
5013
  }));
3654
- //# sourceMappingURL=ms.core-3.1.9.js.map
5014
+ //# sourceMappingURL=ms.core-3.2.0.js.map