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