@microsoft/1ds-core-js 3.1.10 → 3.2.1

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