@microsoft/1ds-post-js 3.1.11 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/bundle/{ms.post-3.1.11.gbl.js → ms.post-3.2.0.gbl.js} +1486 -786
  3. package/bundle/ms.post-3.2.0.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.2.0.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.2.0.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.2.0.integrity.json +46 -0
  7. package/bundle/{ms.post-3.1.11.js → ms.post-3.2.0.js} +1486 -786
  8. package/bundle/ms.post-3.2.0.js.map +1 -0
  9. package/bundle/ms.post-3.2.0.min.js +7 -0
  10. package/bundle/ms.post-3.2.0.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +1485 -785
  12. package/bundle/ms.post.gbl.js.map +1 -1
  13. package/bundle/ms.post.gbl.min.js +2 -2
  14. package/bundle/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/ms.post.integrity.json +17 -17
  16. package/bundle/ms.post.js +1485 -785
  17. package/bundle/ms.post.js.map +1 -1
  18. package/bundle/ms.post.min.js +2 -2
  19. package/bundle/ms.post.min.js.map +1 -1
  20. package/dist/ms.post.js +177 -116
  21. package/dist/ms.post.js.map +1 -1
  22. package/dist/ms.post.min.js +2 -2
  23. package/dist/ms.post.min.js.map +1 -1
  24. package/dist-esm/src/BatchNotificationActions.js +1 -1
  25. package/dist-esm/src/ClockSkewManager.js +1 -1
  26. package/dist-esm/src/Constants.js +1 -1
  27. package/dist-esm/src/DataModels.js +1 -1
  28. package/dist-esm/src/EventBatch.js +1 -1
  29. package/dist-esm/src/HttpManager.js +41 -36
  30. package/dist-esm/src/HttpManager.js.map +1 -1
  31. package/dist-esm/src/Index.js +1 -1
  32. package/dist-esm/src/KillSwitch.js +1 -1
  33. package/dist-esm/src/PostChannel.d.ts +0 -4
  34. package/dist-esm/src/PostChannel.js +136 -92
  35. package/dist-esm/src/PostChannel.js.map +1 -1
  36. package/dist-esm/src/RetryPolicy.d.ts +20 -25
  37. package/dist-esm/src/RetryPolicy.js +35 -44
  38. package/dist-esm/src/RetryPolicy.js.map +1 -1
  39. package/dist-esm/src/Serializer.js +1 -1
  40. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  41. package/package.json +2 -2
  42. package/src/HttpManager.ts +43 -47
  43. package/src/PostChannel.ts +162 -114
  44. package/src/RetryPolicy.ts +33 -38
  45. package/bundle/ms.post-3.1.11.gbl.js.map +0 -1
  46. package/bundle/ms.post-3.1.11.gbl.min.js +0 -7
  47. package/bundle/ms.post-3.1.11.gbl.min.js.map +0 -1
  48. package/bundle/ms.post-3.1.11.integrity.json +0 -46
  49. package/bundle/ms.post-3.1.11.js.map +0 -1
  50. package/bundle/ms.post-3.1.11.min.js +0 -7
  51. package/bundle/ms.post-3.1.11.min.js.map +0 -1
package/bundle/ms.post.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 3.1.11
2
+ * 1DS JS SDK POST plugin, 3.2.0
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -62,18 +62,6 @@
62
62
 
63
63
  (getGlobal() || {})["Symbol"];
64
64
  (getGlobal() || {})["Reflect"];
65
- var __objAssignFnImpl = function (t) {
66
- for (var s, i = 1, n = arguments.length; i < n; i++) {
67
- s = arguments[i];
68
- for (var p in s) {
69
- if (ObjProto[strShimHasOwnProperty].call(s, p)) {
70
- t[p] = s[p];
71
- }
72
- }
73
- }
74
- return t;
75
- };
76
- var __assignFn = ObjAssign || __objAssignFnImpl;
77
65
  var extendStaticsFn = function (d, b) {
78
66
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
79
67
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -95,14 +83,356 @@
95
83
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
96
84
  }
97
85
 
98
- var EventsDiscardedReason = {
99
- Unknown: 0,
100
- NonRetryableStatus: 1,
101
- InvalidEvent: 2,
102
- SizeLimitExceeded: 3,
103
- KillSwitch: 4,
86
+ var strEmpty = "";
87
+ var strSetNextPlugin = "setNextPlugin";
88
+ var strIsInitialized = "isInitialized";
89
+ var strTeardown = "teardown";
90
+ var strCore = "core";
91
+ var strUpdate = "update";
92
+ var strDisabled = "disabled";
93
+ var strDoTeardown = "_doTeardown";
94
+
95
+ var cStrStartsWith = "startsWith";
96
+ var strIndexOf = "indexOf";
97
+ var cStrTrim = "trim";
98
+ var strToString = "toString";
99
+ var str__Proto$1 = "__proto__";
100
+ var strConstructor = "constructor";
101
+ var _objDefineProperty$1 = ObjDefineProperty;
102
+ var _objFreeze = ObjClass.freeze;
103
+ var _objKeys = ObjClass.keys;
104
+ var StringProto = String[strShimPrototype];
105
+ var _strTrim = StringProto[cStrTrim];
106
+ var _strStartsWith = StringProto[cStrStartsWith];
107
+ var _isArray = Array.isArray;
108
+ var _objToString = ObjProto[strToString];
109
+ var _fnToString = ObjHasOwnProperty[strToString];
110
+ var _objFunctionString = _fnToString.call(ObjClass);
111
+ var rCamelCase = /-([a-z])/g;
112
+ var rNormalizeInvalid = /([^\w\d_$])/g;
113
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
114
+ var _objGetPrototypeOf$1 = Object["getPrototypeOf"];
115
+ function _getObjProto$1(target) {
116
+ if (target) {
117
+ if (_objGetPrototypeOf$1) {
118
+ return _objGetPrototypeOf$1(target);
119
+ }
120
+ var newProto = target[str__Proto$1] || target[strShimPrototype] || target[strConstructor];
121
+ if (newProto) {
122
+ return newProto;
123
+ }
124
+ }
125
+ return null;
126
+ }
127
+ function isUndefined(value) {
128
+ return value === undefined || typeof value === strShimUndefined;
129
+ }
130
+ function isNullOrUndefined(value) {
131
+ return (value === null || isUndefined(value));
132
+ }
133
+ function hasOwnProperty(obj, prop) {
134
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
135
+ }
136
+ function isObject(value) {
137
+ return !!(value && typeof value === strShimObject);
138
+ }
139
+ function isFunction(value) {
140
+ return !!(value && typeof value === strShimFunction);
141
+ }
142
+ function normalizeJsName(name) {
143
+ var value = name;
144
+ if (value && isString(value)) {
145
+ value = value.replace(rCamelCase, function (_all, letter) {
146
+ return letter.toUpperCase();
147
+ });
148
+ value = value.replace(rNormalizeInvalid, "_");
149
+ value = value.replace(rLeadingNumeric, function (_all, match) {
150
+ return "_" + match;
151
+ });
152
+ }
153
+ return value;
154
+ }
155
+ function objForEachKey(target, callbackfn) {
156
+ if (target) {
157
+ for (var prop in target) {
158
+ if (ObjHasOwnProperty.call(target, prop)) {
159
+ callbackfn.call(target, prop, target[prop]);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ function strStartsWith(value, checkValue) {
165
+ var result = false;
166
+ if (value && checkValue && !(result = value === checkValue)) {
167
+ result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
168
+ }
169
+ return result;
170
+ }
171
+ function _strStartsWithPoly(value, checkValue) {
172
+ var result = false;
173
+ var chkLen = checkValue ? checkValue.length : 0;
174
+ if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
175
+ for (var lp = 0; lp < chkLen; lp++) {
176
+ if (value[lp] !== checkValue[lp]) {
177
+ return false;
178
+ }
179
+ }
180
+ result = true;
181
+ }
182
+ return result;
183
+ }
184
+ function strContains(value, search) {
185
+ if (value && search) {
186
+ return value.indexOf(search) !== -1;
187
+ }
188
+ return false;
189
+ }
190
+ var isArray = _isArray || _isArrayPoly;
191
+ function _isArrayPoly(obj) {
192
+ return !!(obj && _objToString.call(obj) === "[object Array]");
193
+ }
194
+ function isString(value) {
195
+ return typeof value === "string";
196
+ }
197
+ function isNumber(value) {
198
+ return typeof value === "number";
199
+ }
200
+ function isBoolean(value) {
201
+ return typeof value === "boolean";
202
+ }
203
+ function isPlainObject(value) {
204
+ var result = false;
205
+ if (value && typeof value === "object") {
206
+ var proto = _objGetPrototypeOf$1 ? _objGetPrototypeOf$1(value) : _getObjProto$1(value);
207
+ if (!proto) {
208
+ result = true;
209
+ }
210
+ else {
211
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
212
+ proto = proto[strConstructor];
213
+ }
214
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
215
+ }
216
+ }
217
+ return result;
218
+ }
219
+ function arrForEach(arr, callbackfn, thisArg) {
220
+ var len = arr.length;
221
+ try {
222
+ for (var idx = 0; idx < len; idx++) {
223
+ if (idx in arr) {
224
+ if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
225
+ break;
226
+ }
227
+ }
228
+ }
229
+ }
230
+ catch (e) {
231
+ }
232
+ }
233
+ function arrIndexOf(arr, searchElement, fromIndex) {
234
+ if (arr) {
235
+ if (arr[strIndexOf]) {
236
+ return arr[strIndexOf](searchElement, fromIndex);
237
+ }
238
+ var len = arr.length;
239
+ var from = fromIndex || 0;
240
+ try {
241
+ for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
242
+ if (lp in arr && arr[lp] === searchElement) {
243
+ return lp;
244
+ }
245
+ }
246
+ }
247
+ catch (e) {
248
+ }
249
+ }
250
+ return -1;
251
+ }
252
+ function strTrim(str) {
253
+ if (str) {
254
+ str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
255
+ }
256
+ return str;
257
+ }
258
+ var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
259
+ var _objKeysDontEnums = [
260
+ "toString",
261
+ "toLocaleString",
262
+ "valueOf",
263
+ "hasOwnProperty",
264
+ "isPrototypeOf",
265
+ "propertyIsEnumerable",
266
+ "constructor"
267
+ ];
268
+ function objKeys(obj) {
269
+ var objType = typeof obj;
270
+ if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
271
+ throwTypeError("objKeys called on non-object");
272
+ }
273
+ if (!_objKeysHasDontEnumBug && _objKeys) {
274
+ return _objKeys(obj);
275
+ }
276
+ var result = [];
277
+ for (var prop in obj) {
278
+ if (obj && ObjHasOwnProperty.call(obj, prop)) {
279
+ result.push(prop);
280
+ }
281
+ }
282
+ if (_objKeysHasDontEnumBug) {
283
+ var dontEnumsLength = _objKeysDontEnums.length;
284
+ for (var lp = 0; lp < dontEnumsLength; lp++) {
285
+ if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
286
+ result.push(_objKeysDontEnums[lp]);
287
+ }
288
+ }
289
+ }
290
+ return result;
291
+ }
292
+ function objDefineAccessors(target, prop, getProp, setProp) {
293
+ if (_objDefineProperty$1) {
294
+ try {
295
+ var descriptor = {
296
+ enumerable: true,
297
+ configurable: true
298
+ };
299
+ if (getProp) {
300
+ descriptor.get = getProp;
301
+ }
302
+ if (setProp) {
303
+ descriptor.set = setProp;
304
+ }
305
+ _objDefineProperty$1(target, prop, descriptor);
306
+ return true;
307
+ }
308
+ catch (e) {
309
+ }
310
+ }
311
+ return false;
312
+ }
313
+ function _doNothing(value) {
314
+ return value;
315
+ }
316
+ function deepFreeze(obj) {
317
+ if (_objFreeze) {
318
+ objForEachKey(obj, function (name, value) {
319
+ if (isArray(value) || isObject(value)) {
320
+ _objFreeze(value);
321
+ }
322
+ });
323
+ }
324
+ return objFreeze(obj);
325
+ }
326
+ var objFreeze = _objFreeze || _doNothing;
327
+ function dateNow() {
328
+ var dt = Date;
329
+ return dt.now ? dt.now() : new dt().getTime();
330
+ }
331
+ function setValue(target, field, value, valChk, srcChk) {
332
+ var theValue = value;
333
+ if (target) {
334
+ theValue = target[field];
335
+ if (theValue !== value && (!srcChk || srcChk(theValue)) && (!valChk || valChk(value))) {
336
+ theValue = value;
337
+ target[field] = theValue;
338
+ }
339
+ }
340
+ return theValue;
341
+ }
342
+ function _createProxyFunction(source, funcName) {
343
+ var srcFunc = null;
344
+ var src = null;
345
+ if (isFunction(source)) {
346
+ srcFunc = source;
347
+ }
348
+ else {
349
+ src = source;
350
+ }
351
+ return function () {
352
+ var originalArguments = arguments;
353
+ if (srcFunc) {
354
+ src = srcFunc();
355
+ }
356
+ if (src) {
357
+ return src[funcName].apply(src, originalArguments);
358
+ }
359
+ };
360
+ }
361
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
362
+ if (target && name && source) {
363
+ if (overwriteTarget !== false || isUndefined(target[name])) {
364
+ target[name] = _createProxyFunction(source, theFunc);
365
+ }
366
+ }
367
+ }
368
+ function optimizeObject(theObject) {
369
+ if (theObject && ObjAssign) {
370
+ theObject = ObjClass(ObjAssign({}, theObject));
371
+ }
372
+ return theObject;
373
+ }
374
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
375
+ var theArgs = arguments;
376
+ var extended = theArgs[0] || {};
377
+ var argLen = theArgs.length;
378
+ var deep = false;
379
+ var idx = 1;
380
+ if (argLen > 0 && isBoolean(extended)) {
381
+ deep = extended;
382
+ extended = theArgs[idx] || {};
383
+ idx++;
384
+ }
385
+ if (!isObject(extended)) {
386
+ extended = {};
387
+ }
388
+ for (; idx < argLen; idx++) {
389
+ var arg = theArgs[idx];
390
+ var isArgArray = isArray(arg);
391
+ var isArgObj = isObject(arg);
392
+ for (var prop in arg) {
393
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
394
+ if (!propOk) {
395
+ continue;
396
+ }
397
+ var newValue = arg[prop];
398
+ var isNewArray = void 0;
399
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
400
+ var clone = extended[prop];
401
+ if (isNewArray) {
402
+ if (!isArray(clone)) {
403
+ clone = [];
404
+ }
405
+ }
406
+ else if (!isPlainObject(clone)) {
407
+ clone = {};
408
+ }
409
+ newValue = objExtend(deep, clone, newValue);
410
+ }
411
+ if (newValue !== undefined) {
412
+ extended[prop] = newValue;
413
+ }
414
+ }
415
+ }
416
+ return extended;
417
+ }
418
+
419
+ function createEnumStyle(values) {
420
+ var enumClass = {};
421
+ objForEachKey(values, function (field, value) {
422
+ enumClass[field] = value;
423
+ enumClass[value] = field;
424
+ });
425
+ return deepFreeze(enumClass);
426
+ }
427
+
428
+ var EventsDiscardedReason = createEnumStyle({
429
+ Unknown: 0 ,
430
+ NonRetryableStatus: 1 ,
431
+ InvalidEvent: 2 ,
432
+ SizeLimitExceeded: 3 ,
433
+ KillSwitch: 4 ,
104
434
  QueueFull: 5
105
- };
435
+ });
106
436
 
107
437
  /*!
108
438
  * Microsoft Dynamic Proto Utility, 1.1.4
@@ -234,414 +564,116 @@
234
564
  var protoFunc = objProto[funcName];
235
565
  if (protoFunc) {
236
566
  canAddInst = (protoFunc === currentDynProtoProxy);
237
- break;
238
- }
239
- visited.push(objProto);
240
- objProto = _getObjProto(objProto);
241
- }
242
- try {
243
- if (canAddInst) {
244
- target[funcName] = instFunc;
245
- }
246
- instFunc[DynInstChkTag] = 1;
247
- }
248
- catch (e) {
249
- instFuncTable[DynAllowInstChkTag] = false;
250
- }
251
- }
252
- }
253
- return instFunc;
254
- }
255
- function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
256
- var protoFunc = proto[funcName];
257
- if (protoFunc === currentDynProtoProxy) {
258
- protoFunc = _getObjProto(proto)[funcName];
259
- }
260
- if (typeof protoFunc !== strFunction) {
261
- _throwTypeError("[" + funcName + "] is not a " + strFunction);
262
- }
263
- return protoFunc;
264
- }
265
- function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
266
- function _createDynamicPrototype(proto, funcName) {
267
- var dynProtoProxy = function () {
268
- var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
269
- return instFunc.apply(this, arguments);
270
- };
271
- dynProtoProxy[DynProxyTag] = 1;
272
- return dynProtoProxy;
273
- }
274
- if (!_isObjectOrArrayPrototype(proto)) {
275
- var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
276
- var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
277
- if (instFuncTable[DynAllowInstChkTag] !== false) {
278
- instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
279
- }
280
- _forEachProp(target, function (name) {
281
- if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
282
- instFuncs_1[name] = target[name];
283
- delete target[name];
284
- if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
285
- proto[name] = _createDynamicPrototype(proto, name);
286
- }
287
- }
288
- });
289
- }
290
- }
291
- function _checkPrototype(classProto, thisTarget) {
292
- if (_objGetPrototypeOf) {
293
- var visited = [];
294
- var thisProto = _getObjProto(thisTarget);
295
- while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
296
- if (thisProto === classProto) {
297
- return true;
298
- }
299
- visited.push(thisProto);
300
- thisProto = _getObjProto(thisProto);
301
- }
302
- }
303
- return false;
304
- }
305
- function _getObjName(target, unknownValue) {
306
- if (_hasOwnProperty(target, Prototype)) {
307
- return target.name || unknownValue || UnknownValue;
308
- }
309
- return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
310
- }
311
- function dynamicProto(theClass, target, delegateFunc, options) {
312
- if (!_hasOwnProperty(theClass, Prototype)) {
313
- _throwTypeError("theClass is an invalid class definition.");
314
- }
315
- var classProto = theClass[Prototype];
316
- if (!_checkPrototype(classProto, target)) {
317
- _throwTypeError("[" + _getObjName(theClass) + "] is not in class hierarchy of [" + _getObjName(target) + "]");
318
- }
319
- var className = null;
320
- if (_hasOwnProperty(classProto, DynClassName)) {
321
- className = classProto[DynClassName];
322
- }
323
- else {
324
- className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _dynamicNames;
325
- _dynamicNames++;
326
- classProto[DynClassName] = className;
327
- }
328
- var perfOptions = dynamicProto[DynProtoDefaultOptions];
329
- var useBaseInst = !!perfOptions[strUseBaseInst];
330
- if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
331
- useBaseInst = !!options[strUseBaseInst];
332
- }
333
- var instFuncs = _getInstanceFuncs(target);
334
- var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
335
- delegateFunc(target, baseFuncs);
336
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
337
- if (setInstanceFunc && options) {
338
- setInstanceFunc = !!options[strSetInstFuncs];
339
- }
340
- _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
341
- }
342
- var perfDefaults = {
343
- setInstFuncs: true,
344
- useBaseInst: true
345
- };
346
- dynamicProto[DynProtoDefaultOptions] = perfDefaults;
347
-
348
- var LoggingSeverity;
349
- (function (LoggingSeverity) {
350
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
351
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
352
- })(LoggingSeverity || (LoggingSeverity = {}));
353
- var _InternalMessageId = {
354
- BrowserDoesNotSupportLocalStorage: 0,
355
- BrowserCannotReadLocalStorage: 1,
356
- BrowserCannotReadSessionStorage: 2,
357
- BrowserCannotWriteLocalStorage: 3,
358
- BrowserCannotWriteSessionStorage: 4,
359
- BrowserFailedRemovalFromLocalStorage: 5,
360
- BrowserFailedRemovalFromSessionStorage: 6,
361
- CannotSendEmptyTelemetry: 7,
362
- ClientPerformanceMathError: 8,
363
- ErrorParsingAISessionCookie: 9,
364
- ErrorPVCalc: 10,
365
- ExceptionWhileLoggingError: 11,
366
- FailedAddingTelemetryToBuffer: 12,
367
- FailedMonitorAjaxAbort: 13,
368
- FailedMonitorAjaxDur: 14,
369
- FailedMonitorAjaxOpen: 15,
370
- FailedMonitorAjaxRSC: 16,
371
- FailedMonitorAjaxSend: 17,
372
- FailedMonitorAjaxGetCorrelationHeader: 18,
373
- FailedToAddHandlerForOnBeforeUnload: 19,
374
- FailedToSendQueuedTelemetry: 20,
375
- FailedToReportDataLoss: 21,
376
- FlushFailed: 22,
377
- MessageLimitPerPVExceeded: 23,
378
- MissingRequiredFieldSpecification: 24,
379
- NavigationTimingNotSupported: 25,
380
- OnError: 26,
381
- SessionRenewalDateIsZero: 27,
382
- SenderNotInitialized: 28,
383
- StartTrackEventFailed: 29,
384
- StopTrackEventFailed: 30,
385
- StartTrackFailed: 31,
386
- StopTrackFailed: 32,
387
- TelemetrySampledAndNotSent: 33,
388
- TrackEventFailed: 34,
389
- TrackExceptionFailed: 35,
390
- TrackMetricFailed: 36,
391
- TrackPVFailed: 37,
392
- TrackPVFailedCalc: 38,
393
- TrackTraceFailed: 39,
394
- TransmissionFailed: 40,
395
- FailedToSetStorageBuffer: 41,
396
- FailedToRestoreStorageBuffer: 42,
397
- InvalidBackendResponse: 43,
398
- FailedToFixDepricatedValues: 44,
399
- InvalidDurationValue: 45,
400
- TelemetryEnvelopeInvalid: 46,
401
- CreateEnvelopeError: 47,
402
- CannotSerializeObject: 48,
403
- CannotSerializeObjectNonSerializable: 49,
404
- CircularReferenceDetected: 50,
405
- ClearAuthContextFailed: 51,
406
- ExceptionTruncated: 52,
407
- IllegalCharsInName: 53,
408
- ItemNotInArray: 54,
409
- MaxAjaxPerPVExceeded: 55,
410
- MessageTruncated: 56,
411
- NameTooLong: 57,
412
- SampleRateOutOfRange: 58,
413
- SetAuthContextFailed: 59,
414
- SetAuthContextFailedAccountName: 60,
415
- StringValueTooLong: 61,
416
- StartCalledMoreThanOnce: 62,
417
- StopCalledWithoutStart: 63,
418
- TelemetryInitializerFailed: 64,
419
- TrackArgumentsNotSpecified: 65,
420
- UrlTooLong: 66,
421
- SessionStorageBufferFull: 67,
422
- CannotAccessCookie: 68,
423
- IdTooLong: 69,
424
- InvalidEvent: 70,
425
- FailedMonitorAjaxSetRequestHeader: 71,
426
- SendBrowserInfoOnUserInit: 72,
427
- PluginException: 73,
428
- NotificationException: 74,
429
- SnippetScriptLoadFailure: 99,
430
- InvalidInstrumentationKey: 100,
431
- CannotParseAiBlobValue: 101,
432
- InvalidContentBlob: 102,
433
- TrackPageActionEventFailed: 103,
434
- FailedAddingCustomDefinedRequestContext: 104,
435
- InMemoryStorageBufferFull: 105
436
- };
437
-
438
- var strOnPrefix = "on";
439
- var strAttachEvent = "attachEvent";
440
- var strAddEventHelper = "addEventListener";
441
- var cStrStartsWith = "startsWith";
442
- var strIndexOf = "indexOf";
443
- var cStrTrim = "trim";
444
- var strToString = "toString";
445
- var _objDefineProperty = ObjDefineProperty;
446
- var _objKeys = ObjClass.keys;
447
- var StringProto = String[strShimPrototype];
448
- var _strTrim = StringProto[cStrTrim];
449
- var _strStartsWith = StringProto[cStrStartsWith];
450
- var _isArray = Array.isArray;
451
- var _objToString = ObjProto[strToString];
452
- var _fnToString = ObjHasOwnProperty[strToString];
453
- _fnToString.call(ObjClass);
454
- function isUndefined(value) {
455
- return value === undefined || typeof value === strShimUndefined;
456
- }
457
- function isNullOrUndefined(value) {
458
- return (value === null || isUndefined(value));
459
- }
460
- function hasOwnProperty(obj, prop) {
461
- return !!(obj && ObjHasOwnProperty.call(obj, prop));
462
- }
463
- function isObject(value) {
464
- return !!(value && typeof value === strShimObject);
465
- }
466
- function isFunction(value) {
467
- return !!(value && typeof value === strShimFunction);
468
- }
469
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
470
- if (useCapture === void 0) { useCapture = false; }
471
- var result = false;
472
- if (!isNullOrUndefined(obj)) {
473
- try {
474
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
475
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
476
- result = true;
477
- }
478
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
479
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
480
- result = true;
481
- }
482
- }
483
- catch (e) {
484
- }
485
- }
486
- return result;
487
- }
488
- function objForEachKey(target, callbackfn) {
489
- if (target) {
490
- for (var prop in target) {
491
- if (ObjHasOwnProperty.call(target, prop)) {
492
- callbackfn.call(target, prop, target[prop]);
493
- }
494
- }
495
- }
496
- }
497
- function strStartsWith(value, checkValue) {
498
- var result = false;
499
- if (value && checkValue && !(result = value === checkValue)) {
500
- result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
501
- }
502
- return result;
503
- }
504
- function _strStartsWithPoly(value, checkValue) {
505
- var result = false;
506
- var chkLen = checkValue ? checkValue.length : 0;
507
- if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
508
- for (var lp = 0; lp < chkLen; lp++) {
509
- if (value[lp] !== checkValue[lp]) {
510
- return false;
511
- }
512
- }
513
- result = true;
514
- }
515
- return result;
516
- }
517
- var isArray = _isArray || _isArrayPoly;
518
- function _isArrayPoly(obj) {
519
- return !!(obj && _objToString.call(obj) === "[object Array]");
520
- }
521
- function isString(value) {
522
- return typeof value === "string";
523
- }
524
- function isNumber(value) {
525
- return typeof value === "number";
526
- }
527
- function isBoolean(value) {
528
- return typeof value === "boolean";
529
- }
530
- function arrForEach(arr, callbackfn, thisArg) {
531
- var len = arr.length;
532
- try {
533
- for (var idx = 0; idx < len; idx++) {
534
- if (idx in arr) {
535
- if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
536
- break;
537
- }
538
- }
539
- }
540
- }
541
- catch (e) {
542
- }
543
- }
544
- function arrIndexOf(arr, searchElement, fromIndex) {
545
- if (arr) {
546
- if (arr[strIndexOf]) {
547
- return arr[strIndexOf](searchElement, fromIndex);
548
- }
549
- var len = arr.length;
550
- var from = fromIndex || 0;
551
- try {
552
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
553
- if (lp in arr && arr[lp] === searchElement) {
554
- return lp;
567
+ break;
555
568
  }
569
+ visited.push(objProto);
570
+ objProto = _getObjProto(objProto);
571
+ }
572
+ try {
573
+ if (canAddInst) {
574
+ target[funcName] = instFunc;
575
+ }
576
+ instFunc[DynInstChkTag] = 1;
577
+ }
578
+ catch (e) {
579
+ instFuncTable[DynAllowInstChkTag] = false;
556
580
  }
557
- }
558
- catch (e) {
559
581
  }
560
582
  }
561
- return -1;
583
+ return instFunc;
562
584
  }
563
- function strTrim(str) {
564
- if (str) {
565
- str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
585
+ function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
586
+ var protoFunc = proto[funcName];
587
+ if (protoFunc === currentDynProtoProxy) {
588
+ protoFunc = _getObjProto(proto)[funcName];
566
589
  }
567
- return str;
568
- }
569
- var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
570
- var _objKeysDontEnums = [
571
- "toString",
572
- "toLocaleString",
573
- "valueOf",
574
- "hasOwnProperty",
575
- "isPrototypeOf",
576
- "propertyIsEnumerable",
577
- "constructor"
578
- ];
579
- function objKeys(obj) {
580
- var objType = typeof obj;
581
- if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
582
- throwTypeError("objKeys called on non-object");
590
+ if (typeof protoFunc !== strFunction) {
591
+ _throwTypeError("[" + funcName + "] is not a " + strFunction);
583
592
  }
584
- if (!_objKeysHasDontEnumBug && _objKeys) {
585
- return _objKeys(obj);
593
+ return protoFunc;
594
+ }
595
+ function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
596
+ function _createDynamicPrototype(proto, funcName) {
597
+ var dynProtoProxy = function () {
598
+ var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
599
+ return instFunc.apply(this, arguments);
600
+ };
601
+ dynProtoProxy[DynProxyTag] = 1;
602
+ return dynProtoProxy;
586
603
  }
587
- var result = [];
588
- for (var prop in obj) {
589
- if (obj && ObjHasOwnProperty.call(obj, prop)) {
590
- result.push(prop);
604
+ if (!_isObjectOrArrayPrototype(proto)) {
605
+ var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
606
+ var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
607
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
608
+ instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
591
609
  }
592
- }
593
- if (_objKeysHasDontEnumBug) {
594
- var dontEnumsLength = _objKeysDontEnums.length;
595
- for (var lp = 0; lp < dontEnumsLength; lp++) {
596
- if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
597
- result.push(_objKeysDontEnums[lp]);
610
+ _forEachProp(target, function (name) {
611
+ if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
612
+ instFuncs_1[name] = target[name];
613
+ delete target[name];
614
+ if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
615
+ proto[name] = _createDynamicPrototype(proto, name);
616
+ }
598
617
  }
599
- }
618
+ });
600
619
  }
601
- return result;
602
620
  }
603
- function objDefineAccessors(target, prop, getProp, setProp) {
604
- if (_objDefineProperty) {
605
- try {
606
- var descriptor = {
607
- enumerable: true,
608
- configurable: true
609
- };
610
- if (getProp) {
611
- descriptor.get = getProp;
612
- }
613
- if (setProp) {
614
- descriptor.set = setProp;
621
+ function _checkPrototype(classProto, thisTarget) {
622
+ if (_objGetPrototypeOf) {
623
+ var visited = [];
624
+ var thisProto = _getObjProto(thisTarget);
625
+ while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
626
+ if (thisProto === classProto) {
627
+ return true;
615
628
  }
616
- _objDefineProperty(target, prop, descriptor);
617
- return true;
618
- }
619
- catch (e) {
629
+ visited.push(thisProto);
630
+ thisProto = _getObjProto(thisProto);
620
631
  }
621
632
  }
622
633
  return false;
623
634
  }
624
- function dateNow() {
625
- var dt = Date;
626
- return dt.now ? dt.now() : new dt().getTime();
627
- }
628
- function setValue(target, field, value, valChk, srcChk) {
629
- var theValue = value;
630
- if (target) {
631
- theValue = target[field];
632
- if (theValue !== value && (!srcChk || srcChk(theValue)) && (!valChk || valChk(value))) {
633
- theValue = value;
634
- target[field] = theValue;
635
- }
635
+ function _getObjName(target, unknownValue) {
636
+ if (_hasOwnProperty(target, Prototype)) {
637
+ return target.name || unknownValue || UnknownValue;
636
638
  }
637
- return theValue;
639
+ return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
638
640
  }
639
- function optimizeObject(theObject) {
640
- if (theObject && ObjAssign) {
641
- theObject = ObjClass(ObjAssign({}, theObject));
641
+ function dynamicProto(theClass, target, delegateFunc, options) {
642
+ if (!_hasOwnProperty(theClass, Prototype)) {
643
+ _throwTypeError("theClass is an invalid class definition.");
642
644
  }
643
- return theObject;
645
+ var classProto = theClass[Prototype];
646
+ if (!_checkPrototype(classProto, target)) {
647
+ _throwTypeError("[" + _getObjName(theClass) + "] is not in class hierarchy of [" + _getObjName(target) + "]");
648
+ }
649
+ var className = null;
650
+ if (_hasOwnProperty(classProto, DynClassName)) {
651
+ className = classProto[DynClassName];
652
+ }
653
+ else {
654
+ className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _dynamicNames;
655
+ _dynamicNames++;
656
+ classProto[DynClassName] = className;
657
+ }
658
+ var perfOptions = dynamicProto[DynProtoDefaultOptions];
659
+ var useBaseInst = !!perfOptions[strUseBaseInst];
660
+ if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
661
+ useBaseInst = !!options[strUseBaseInst];
662
+ }
663
+ var instFuncs = _getInstanceFuncs(target);
664
+ var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
665
+ delegateFunc(target, baseFuncs);
666
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
667
+ if (setInstanceFunc && options) {
668
+ setInstanceFunc = !!options[strSetInstFuncs];
669
+ }
670
+ _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
644
671
  }
672
+ var perfDefaults = {
673
+ setInstFuncs: true,
674
+ useBaseInst: true
675
+ };
676
+ dynamicProto[DynProtoDefaultOptions] = perfDefaults;
645
677
 
646
678
  var strWindow = "window";
647
679
  var strDocument = "document";
@@ -650,7 +682,14 @@
650
682
  var strConsole = "console";
651
683
  var strPerformance = "performance";
652
684
  var strJSON = "JSON";
685
+ var strCrypto = "crypto";
686
+ var strMsCrypto = "msCrypto";
653
687
  var strReactNative = "ReactNative";
688
+ var strMsie = "msie";
689
+ var strTrident = "trident/";
690
+ var strXMLHttpRequest = "XMLHttpRequest";
691
+ var _isTrident = null;
692
+ var _navUserAgentCheck = null;
654
693
  var _enableMocks = false;
655
694
  var _useXDomainRequest = null;
656
695
  var _beaconsSupported = null;
@@ -746,6 +785,12 @@
746
785
  }
747
786
  return null;
748
787
  }
788
+ function getCrypto() {
789
+ return getGlobalInst(strCrypto);
790
+ }
791
+ function getMsCrypto() {
792
+ return getGlobalInst(strMsCrypto);
793
+ }
749
794
  function isReactNative() {
750
795
  var nav = getNavigator();
751
796
  if (nav && nav.product) {
@@ -753,9 +798,18 @@
753
798
  }
754
799
  return false;
755
800
  }
801
+ function isIE() {
802
+ var nav = getNavigator();
803
+ if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
804
+ _navUserAgentCheck = nav.userAgent;
805
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
806
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
807
+ }
808
+ return _isTrident;
809
+ }
756
810
  function dumpObj(object) {
757
811
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
758
- var propertyValueDump = "";
812
+ var propertyValueDump = strEmpty;
759
813
  if (objectTypeDump === "[object Error]") {
760
814
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
761
815
  }
@@ -773,8 +827,7 @@
773
827
  function isFetchSupported(withKeepAlive) {
774
828
  var isSupported = false;
775
829
  try {
776
- var fetchApi = getGlobalInst("fetch");
777
- isSupported = !!fetchApi;
830
+ isSupported = !!getGlobalInst("fetch");
778
831
  var request = getGlobalInst("Request");
779
832
  if (isSupported && withKeepAlive && request) {
780
833
  isSupported = _hasProperty(request, "keepalive");
@@ -786,9 +839,9 @@
786
839
  }
787
840
  function useXDomainRequest() {
788
841
  if (_useXDomainRequest === null) {
789
- _useXDomainRequest = (typeof XDomainRequest !== "undefined");
842
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
790
843
  if (_useXDomainRequest && isXhrSupported()) {
791
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
844
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
792
845
  }
793
846
  }
794
847
  return _useXDomainRequest;
@@ -796,7 +849,7 @@
796
849
  function isXhrSupported() {
797
850
  var isSupported = false;
798
851
  try {
799
- var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
852
+ var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
800
853
  isSupported = !!xmlHttpRequest;
801
854
  }
802
855
  catch (e) {
@@ -827,9 +880,9 @@
827
880
  var strWarnToConsole = "warnToConsole";
828
881
  function _sanitizeDiagnosticText(text) {
829
882
  if (text) {
830
- return "\"" + text.replace(/\"/g, "") + "\"";
883
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
831
884
  }
832
- return "";
885
+ return strEmpty;
833
886
  }
834
887
  function _logToConsole(func, message) {
835
888
  var theConsole = getConsole();
@@ -851,12 +904,12 @@
851
904
  _self.message =
852
905
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
853
906
  msgId;
854
- var strProps = "";
907
+ var strProps = strEmpty;
855
908
  if (hasJSON()) {
856
909
  strProps = getJSON().stringify(properties);
857
910
  }
858
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
859
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
911
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
912
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
860
913
  _self.message += diagnosticText;
861
914
  }
862
915
  _InternalLogMessage.dataType = "MessageData";
@@ -886,7 +939,7 @@
886
939
  throw message;
887
940
  }
888
941
  else {
889
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
942
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
890
943
  if (!isUndefined(message.message)) {
891
944
  var logLevel = _self.consoleLoggingLevel();
892
945
  if (isUserAct) {
@@ -904,7 +957,7 @@
904
957
  _self.logInternalMessage(severity, message);
905
958
  }
906
959
  else {
907
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
960
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
908
961
  }
909
962
  }
910
963
  };
@@ -936,13 +989,13 @@
936
989
  if (severity <= _self.telemetryLoggingLevel()) {
937
990
  _self.queue.push(message);
938
991
  _messageCount++;
939
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
992
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
940
993
  }
941
994
  if (_messageCount === _self.maxInternalMessageLimit()) {
942
995
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
943
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
996
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
944
997
  _self.queue.push(throttleMessage);
945
- if (severity === LoggingSeverity.CRITICAL) {
998
+ if (severity === 1 ) {
946
999
  _self.errorToConsole(throttleLimitMessage);
947
1000
  }
948
1001
  else {
@@ -971,6 +1024,10 @@
971
1024
  }
972
1025
  return DiagnosticLogger;
973
1026
  }());
1027
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1028
+ if (isUserAct === void 0) { isUserAct = false; }
1029
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1030
+ }
974
1031
 
975
1032
  var strExecutionContextKey = "ctx";
976
1033
  var PerfEvent = /** @class */ (function () {
@@ -1084,207 +1141,621 @@
1084
1141
  return func();
1085
1142
  }
1086
1143
 
1087
- var TelemetryPluginChain = /** @class */ (function () {
1088
- function TelemetryPluginChain(plugin, defItemCtx) {
1089
- var _self = this;
1090
- var _nextProxy = null;
1091
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1092
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1093
- _self._hasRun = false;
1094
- _self.getPlugin = function () {
1095
- return plugin;
1096
- };
1097
- _self.getNext = function () {
1098
- return _nextProxy;
1099
- };
1100
- _self.setNext = function (nextPlugin) {
1101
- _nextProxy = nextPlugin;
1102
- };
1103
- _self.processTelemetry = function (env, itemCtx) {
1104
- if (!itemCtx) {
1105
- itemCtx = defItemCtx;
1144
+ var UInt32Mask = 0x100000000;
1145
+ var MaxUInt32 = 0xffffffff;
1146
+ var _mwcSeeded = false;
1147
+ var _mwcW = 123456789;
1148
+ var _mwcZ = 987654321;
1149
+ function _mwcSeed(seedValue) {
1150
+ if (seedValue < 0) {
1151
+ seedValue >>>= 0;
1152
+ }
1153
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1154
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1155
+ _mwcSeeded = true;
1156
+ }
1157
+ function _autoSeedMwc() {
1158
+ try {
1159
+ var now = dateNow() & 0x7fffffff;
1160
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1161
+ }
1162
+ catch (e) {
1163
+ }
1164
+ }
1165
+ function random32(signed) {
1166
+ var value = 0;
1167
+ var c = getCrypto() || getMsCrypto();
1168
+ if (c && c.getRandomValues) {
1169
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1170
+ }
1171
+ if (value === 0 && isIE()) {
1172
+ if (!_mwcSeeded) {
1173
+ _autoSeedMwc();
1174
+ }
1175
+ value = mwcRandom32() & MaxUInt32;
1176
+ }
1177
+ if (value === 0) {
1178
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1179
+ }
1180
+ if (!signed) {
1181
+ value >>>= 0;
1182
+ }
1183
+ return value;
1184
+ }
1185
+ function mwcRandom32(signed) {
1186
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1187
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1188
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1189
+ if (!signed) {
1190
+ value >>>= 0;
1191
+ }
1192
+ return value;
1193
+ }
1194
+ function newId(maxLength) {
1195
+ if (maxLength === void 0) { maxLength = 22; }
1196
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1197
+ var number = random32() >>> 0;
1198
+ var chars = 0;
1199
+ var result = strEmpty;
1200
+ while (result.length < maxLength) {
1201
+ chars++;
1202
+ result += base64chars.charAt(number & 0x3F);
1203
+ number >>>= 6;
1204
+ if (chars === 5) {
1205
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1206
+ chars = 0;
1207
+ }
1208
+ }
1209
+ return result;
1210
+ }
1211
+
1212
+ var _objDefineProperty = ObjDefineProperty;
1213
+ var version = "2.8.0";
1214
+ var instanceName = "." + newId(6);
1215
+ var _dataUid = 0;
1216
+ function _createAccessor(target, prop, value) {
1217
+ if (_objDefineProperty) {
1218
+ try {
1219
+ _objDefineProperty(target, prop, {
1220
+ value: value,
1221
+ enumerable: false,
1222
+ configurable: true
1223
+ });
1224
+ return true;
1225
+ }
1226
+ catch (e) {
1227
+ }
1228
+ }
1229
+ return false;
1230
+ }
1231
+ function _canAcceptData(target) {
1232
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1233
+ }
1234
+ function _getCache(data, target) {
1235
+ var theCache = target[data.id];
1236
+ if (!theCache) {
1237
+ theCache = {};
1238
+ try {
1239
+ if (_canAcceptData(target)) {
1240
+ if (!_createAccessor(target, data.id, theCache)) {
1241
+ target[data.id] = theCache;
1242
+ }
1243
+ }
1244
+ }
1245
+ catch (e) {
1246
+ }
1247
+ }
1248
+ return theCache;
1249
+ }
1250
+ function createUniqueNamespace(name, includeVersion) {
1251
+ if (includeVersion === void 0) { includeVersion = false; }
1252
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1253
+ }
1254
+ function createElmNodeData(name) {
1255
+ var data = {
1256
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1257
+ accept: function (target) {
1258
+ return _canAcceptData(target);
1259
+ },
1260
+ get: function (target, name, defValue, addDefault) {
1261
+ var theCache = target[data.id];
1262
+ if (!theCache) {
1263
+ if (addDefault) {
1264
+ theCache = _getCache(data, target);
1265
+ theCache[normalizeJsName(name)] = defValue;
1266
+ }
1267
+ return defValue;
1268
+ }
1269
+ return theCache[normalizeJsName(name)];
1270
+ },
1271
+ kill: function (target, name) {
1272
+ if (target && target[name]) {
1273
+ try {
1274
+ delete target[name];
1275
+ }
1276
+ catch (e) {
1277
+ }
1106
1278
  }
1107
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1108
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1109
- if (plugin && _hasProcessTelemetry) {
1110
- _self._hasRun = true;
1279
+ }
1280
+ };
1281
+ return data;
1282
+ }
1283
+
1284
+ var pluginStateData = createElmNodeData("plugin");
1285
+ function _getPluginState(plugin) {
1286
+ return pluginStateData.get(plugin, "state", {}, true);
1287
+ }
1288
+
1289
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1290
+ var strHasRunFlags = "_hasRun";
1291
+ var strGetTelCtx = "_getTelCtx";
1292
+ var _chainId = 0;
1293
+ function _getNextProxyStart(proxy, core, startAt) {
1294
+ while (proxy) {
1295
+ if (proxy.getPlugin() === startAt) {
1296
+ return proxy;
1297
+ }
1298
+ proxy = proxy.getNext();
1299
+ }
1300
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
1301
+ }
1302
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1303
+ var _nextProxy = null;
1304
+ var _onComplete = [];
1305
+ if (startAt !== null) {
1306
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1307
+ }
1308
+ var context = {
1309
+ _next: _moveNext,
1310
+ ctx: {
1311
+ core: function () {
1312
+ return core;
1313
+ },
1314
+ diagLog: function () {
1315
+ return safeGetLogger(core, config);
1316
+ },
1317
+ getCfg: function () {
1318
+ return config;
1319
+ },
1320
+ getExtCfg: _getExtCfg,
1321
+ getConfig: _getConfig,
1322
+ hasNext: function () {
1323
+ return !!_nextProxy;
1324
+ },
1325
+ getNext: function () {
1326
+ return _nextProxy;
1327
+ },
1328
+ setNext: function (nextPlugin) {
1329
+ _nextProxy = nextPlugin;
1330
+ },
1331
+ iterate: _iterateChain,
1332
+ onComplete: _addOnComplete
1333
+ }
1334
+ };
1335
+ function _addOnComplete(onComplete, that) {
1336
+ var args = [];
1337
+ for (var _i = 2; _i < arguments.length; _i++) {
1338
+ args[_i - 2] = arguments[_i];
1339
+ }
1340
+ if (onComplete) {
1341
+ _onComplete.push({
1342
+ func: onComplete,
1343
+ self: !isUndefined(that) ? that : context.ctx,
1344
+ args: args
1345
+ });
1346
+ }
1347
+ }
1348
+ function _moveNext() {
1349
+ var nextProxy = _nextProxy;
1350
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1351
+ if (!nextProxy) {
1352
+ var onComplete = _onComplete;
1353
+ if (onComplete && onComplete.length > 0) {
1354
+ arrForEach(onComplete, function (completeDetails) {
1111
1355
  try {
1112
- itemCtx.setNext(_nextProxy);
1113
- if (_hasSetNext) {
1114
- plugin.setNextPlugin(_nextProxy);
1115
- }
1116
- _nextProxy && (_nextProxy._hasRun = false);
1117
- plugin.processTelemetry(env, itemCtx);
1356
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1118
1357
  }
1119
- catch (error) {
1120
- var hasRun = _nextProxy && _nextProxy._hasRun;
1121
- if (!_nextProxy || !hasRun) {
1122
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1123
- }
1124
- if (_nextProxy && !hasRun) {
1125
- _nextProxy.processTelemetry(env, itemCtx);
1126
- }
1358
+ catch (e) {
1359
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1127
1360
  }
1361
+ });
1362
+ _onComplete = [];
1363
+ }
1364
+ }
1365
+ return nextProxy;
1366
+ }
1367
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1368
+ if (defaultValue === void 0) { defaultValue = {}; }
1369
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1370
+ var theConfig;
1371
+ if (config) {
1372
+ var extConfig = config.extensionConfig;
1373
+ if (extConfig && identifier) {
1374
+ theConfig = extConfig[identifier];
1375
+ }
1376
+ }
1377
+ if (!theConfig) {
1378
+ theConfig = defaultValue;
1379
+ }
1380
+ else if (isObject(defaultValue)) {
1381
+ if (mergeDefault !== 0 ) {
1382
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1383
+ if (config && mergeDefault === 2 ) {
1384
+ objForEachKey(defaultValue, function (field) {
1385
+ if (isNullOrUndefined(newConfig_1[field])) {
1386
+ var cfgValue = config[field];
1387
+ if (!isNullOrUndefined(cfgValue)) {
1388
+ newConfig_1[field] = cfgValue;
1389
+ }
1390
+ }
1391
+ });
1128
1392
  }
1129
- else if (_nextProxy) {
1130
- _self._hasRun = true;
1131
- _nextProxy.processTelemetry(env, itemCtx);
1132
- }
1133
- }, function () { return ({ item: env }); }, !(env.sync));
1134
- };
1393
+ theConfig = newConfig_1;
1394
+ }
1395
+ }
1396
+ return theConfig;
1397
+ }
1398
+ function _getConfig(identifier, field, defaultValue) {
1399
+ if (defaultValue === void 0) { defaultValue = false; }
1400
+ var theValue;
1401
+ var extConfig = _getExtCfg(identifier, null);
1402
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1403
+ theValue = extConfig[field];
1404
+ }
1405
+ else if (config && !isNullOrUndefined(config[field])) {
1406
+ theValue = config[field];
1407
+ }
1408
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1135
1409
  }
1136
- return TelemetryPluginChain;
1137
- }());
1138
-
1139
- function _createProxyChain(plugins, itemCtx) {
1140
- var proxies = [];
1141
- if (plugins && plugins.length > 0) {
1142
- var lastProxy = null;
1143
- for (var idx = 0; idx < plugins.length; idx++) {
1144
- var thePlugin = plugins[idx];
1145
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1146
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1147
- proxies.push(newProxy);
1148
- if (lastProxy) {
1149
- lastProxy.setNext(newProxy);
1150
- }
1151
- lastProxy = newProxy;
1410
+ function _iterateChain(cb) {
1411
+ var nextPlugin;
1412
+ while (!!(nextPlugin = context._next())) {
1413
+ var plugin = nextPlugin.getPlugin();
1414
+ if (plugin) {
1415
+ cb(plugin);
1152
1416
  }
1153
1417
  }
1154
1418
  }
1155
- return proxies.length > 0 ? proxies[0] : null;
1419
+ return context;
1156
1420
  }
1157
- function _copyProxyChain(proxy, itemCtx, startAt) {
1158
- var plugins = [];
1159
- var add = startAt ? false : true;
1160
- if (proxy) {
1161
- while (proxy) {
1162
- var thePlugin = proxy.getPlugin();
1163
- if (add || thePlugin === startAt) {
1164
- add = true;
1165
- plugins.push(thePlugin);
1166
- }
1167
- proxy = proxy.getNext();
1421
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1422
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1423
+ var context = internalContext.ctx;
1424
+ function _processNext(env) {
1425
+ var nextPlugin = internalContext._next();
1426
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1427
+ return !nextPlugin;
1428
+ }
1429
+ function _createNew(plugins, startAt) {
1430
+ if (plugins === void 0) { plugins = null; }
1431
+ if (isArray(plugins)) {
1432
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1168
1433
  }
1434
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1435
+ }
1436
+ context.processNext = _processNext;
1437
+ context.createNew = _createNew;
1438
+ return context;
1439
+ }
1440
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
1441
+ var config = core.config || {};
1442
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1443
+ var context = internalContext.ctx;
1444
+ function _processNext(unloadState) {
1445
+ var nextPlugin = internalContext._next();
1446
+ nextPlugin && nextPlugin.unload(context, unloadState);
1447
+ return !nextPlugin;
1169
1448
  }
1170
- if (!add) {
1171
- plugins.push(startAt);
1449
+ function _createNew(plugins, startAt) {
1450
+ if (plugins === void 0) { plugins = null; }
1451
+ if (isArray(plugins)) {
1452
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1453
+ }
1454
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
1172
1455
  }
1173
- return _createProxyChain(plugins, itemCtx);
1456
+ context.processNext = _processNext;
1457
+ context.createNew = _createNew;
1458
+ return context;
1174
1459
  }
1175
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1176
- var plugins = srcPlugins;
1177
- var add = false;
1178
- if (startAt && srcPlugins) {
1179
- plugins = [];
1180
- arrForEach(srcPlugins, function (thePlugin) {
1181
- if (add || thePlugin === startAt) {
1182
- add = true;
1183
- plugins.push(thePlugin);
1460
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
1461
+ var config = core.config || {};
1462
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1463
+ var context = internalContext.ctx;
1464
+ function _processNext(updateState) {
1465
+ return context.iterate(function (plugin) {
1466
+ if (isFunction(plugin.update)) {
1467
+ plugin.update(context, updateState);
1184
1468
  }
1185
1469
  });
1186
1470
  }
1187
- if (startAt && !add) {
1188
- if (!plugins) {
1189
- plugins = [];
1471
+ function _createNew(plugins, startAt) {
1472
+ if (plugins === void 0) { plugins = null; }
1473
+ if (isArray(plugins)) {
1474
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1190
1475
  }
1191
- plugins.push(startAt);
1476
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
1192
1477
  }
1193
- return _createProxyChain(plugins, itemCtx);
1478
+ context.processNext = _processNext;
1479
+ context.createNew = _createNew;
1480
+ return context;
1194
1481
  }
1195
- var ProcessTelemetryContext = /** @class */ (function () {
1196
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1197
- var _self = this;
1198
- var _nextProxy = null;
1199
- if (startAt !== null) {
1200
- if (plugins && isFunction(plugins.getPlugin)) {
1201
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1482
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1483
+ var firstProxy = null;
1484
+ var add = startAt ? false : true;
1485
+ if (isArray(plugins) && plugins.length > 0) {
1486
+ var lastProxy_1 = null;
1487
+ arrForEach(plugins, function (thePlugin) {
1488
+ if (!add && startAt === thePlugin) {
1489
+ add = true;
1202
1490
  }
1203
- else {
1204
- if (startAt) {
1205
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1491
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1492
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1493
+ if (!firstProxy) {
1494
+ firstProxy = newProxy;
1206
1495
  }
1207
- else if (isUndefined(startAt)) {
1208
- _nextProxy = _createProxyChain(plugins, _self);
1496
+ if (lastProxy_1) {
1497
+ lastProxy_1._setNext(newProxy);
1209
1498
  }
1499
+ lastProxy_1 = newProxy;
1210
1500
  }
1501
+ });
1502
+ }
1503
+ if (startAt && !firstProxy) {
1504
+ return createTelemetryProxyChain([startAt], config, core);
1505
+ }
1506
+ return firstProxy;
1507
+ }
1508
+ function createTelemetryPluginProxy(plugin, config, core) {
1509
+ var nextProxy = null;
1510
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1511
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1512
+ var chainId;
1513
+ if (plugin) {
1514
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1515
+ }
1516
+ else {
1517
+ chainId = "Unknown-0-" + _chainId++;
1518
+ }
1519
+ var proxyChain = {
1520
+ getPlugin: function () {
1521
+ return plugin;
1522
+ },
1523
+ getNext: function () {
1524
+ return nextProxy;
1525
+ },
1526
+ processTelemetry: _processTelemetry,
1527
+ unload: _unloadPlugin,
1528
+ update: _updatePlugin,
1529
+ _id: chainId,
1530
+ _setNext: function (nextPlugin) {
1531
+ nextProxy = nextPlugin;
1211
1532
  }
1212
- _self.core = function () {
1213
- return core;
1214
- };
1215
- _self.diagLog = function () {
1216
- return safeGetLogger(core, config);
1217
- };
1218
- _self.getCfg = function () {
1219
- return config;
1220
- };
1221
- _self.getExtCfg = function (identifier, defaultValue) {
1222
- if (defaultValue === void 0) { defaultValue = {}; }
1223
- var theConfig;
1224
- if (config) {
1225
- var extConfig = config.extensionConfig;
1226
- if (extConfig && identifier) {
1227
- theConfig = extConfig[identifier];
1533
+ };
1534
+ function _getTelCtx() {
1535
+ var itemCtx;
1536
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1537
+ itemCtx = plugin[strGetTelCtx]();
1538
+ }
1539
+ if (!itemCtx) {
1540
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1541
+ }
1542
+ return itemCtx;
1543
+ }
1544
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1545
+ var hasRun = false;
1546
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1547
+ var hasRunContext = itemCtx[strHasRunFlags];
1548
+ if (!hasRunContext) {
1549
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1550
+ }
1551
+ itemCtx.setNext(nextProxy);
1552
+ if (plugin) {
1553
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1554
+ hasRunContext[chainId] = true;
1555
+ try {
1556
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1557
+ if (nextId) {
1558
+ hasRunContext[nextId] = false;
1559
+ }
1560
+ hasRun = processPluginFn(itemCtx);
1561
+ }
1562
+ catch (error) {
1563
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1564
+ if (hasNextRun) {
1565
+ hasRun = true;
1566
+ }
1567
+ if (!nextProxy || !hasNextRun) {
1568
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1569
+ }
1228
1570
  }
1571
+ }, details, isAsync);
1572
+ }
1573
+ return hasRun;
1574
+ }
1575
+ function _processTelemetry(env, itemCtx) {
1576
+ itemCtx = itemCtx || _getTelCtx();
1577
+ function _callProcessTelemetry(itemCtx) {
1578
+ if (!plugin || !hasProcessTelemetry) {
1579
+ return false;
1229
1580
  }
1230
- return (theConfig ? theConfig : defaultValue);
1231
- };
1232
- _self.getConfig = function (identifier, field, defaultValue) {
1233
- if (defaultValue === void 0) { defaultValue = false; }
1234
- var theValue;
1235
- var extConfig = _self.getExtCfg(identifier, null);
1236
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1237
- theValue = extConfig[field];
1581
+ var pluginState = _getPluginState(plugin);
1582
+ if (pluginState.teardown || pluginState[strDisabled]) {
1583
+ return false;
1238
1584
  }
1239
- else if (config && !isNullOrUndefined(config[field])) {
1240
- theValue = config[field];
1585
+ if (hasSetNext) {
1586
+ plugin.setNextPlugin(nextProxy);
1241
1587
  }
1242
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1243
- };
1244
- _self.hasNext = function () {
1245
- return _nextProxy != null;
1246
- };
1247
- _self.getNext = function () {
1248
- return _nextProxy;
1249
- };
1250
- _self.setNext = function (nextPlugin) {
1251
- _nextProxy = nextPlugin;
1252
- };
1253
- _self.processNext = function (env) {
1254
- var nextPlugin = _nextProxy;
1255
- if (nextPlugin) {
1256
- _nextProxy = nextPlugin.getNext();
1257
- nextPlugin.processTelemetry(env, _self);
1588
+ plugin.processTelemetry(env, itemCtx);
1589
+ return true;
1590
+ }
1591
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1592
+ itemCtx.processNext(env);
1593
+ }
1594
+ }
1595
+ function _unloadPlugin(unloadCtx, unloadState) {
1596
+ function _callTeardown() {
1597
+ var hasRun = false;
1598
+ if (plugin) {
1599
+ var pluginState = _getPluginState(plugin);
1600
+ var pluginCore = plugin[strCore] || pluginState.core;
1601
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1602
+ pluginState[strCore] = null;
1603
+ pluginState[strTeardown] = true;
1604
+ pluginState[strIsInitialized] = false;
1605
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1606
+ hasRun = true;
1607
+ }
1608
+ }
1258
1609
  }
1259
- };
1260
- _self.createNew = function (plugins, startAt) {
1261
- if (plugins === void 0) { plugins = null; }
1262
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1263
- };
1610
+ return hasRun;
1611
+ }
1612
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1613
+ unloadCtx.processNext(unloadState);
1614
+ }
1264
1615
  }
1265
- return ProcessTelemetryContext;
1266
- }());
1616
+ function _updatePlugin(updateCtx, updateState) {
1617
+ function _callUpdate() {
1618
+ var hasRun = false;
1619
+ if (plugin) {
1620
+ var pluginState = _getPluginState(plugin);
1621
+ var pluginCore = plugin[strCore] || pluginState.core;
1622
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1623
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1624
+ hasRun = true;
1625
+ }
1626
+ }
1627
+ }
1628
+ return hasRun;
1629
+ }
1630
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1631
+ updateCtx.processNext(updateState);
1632
+ }
1633
+ }
1634
+ return objFreeze(proxyChain);
1635
+ }
1267
1636
 
1268
1637
  var strExtensionConfig = "extensionConfig";
1269
1638
 
1639
+ function createUnloadHandlerContainer() {
1640
+ var handlers = [];
1641
+ function _addHandler(handler) {
1642
+ if (handler) {
1643
+ handlers.push(handler);
1644
+ }
1645
+ }
1646
+ function _runHandlers(unloadCtx, unloadState) {
1647
+ arrForEach(handlers, function (handler) {
1648
+ try {
1649
+ handler(unloadCtx, unloadState);
1650
+ }
1651
+ catch (e) {
1652
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1653
+ }
1654
+ });
1655
+ handlers = [];
1656
+ }
1657
+ return {
1658
+ add: _addHandler,
1659
+ run: _runHandlers
1660
+ };
1661
+ }
1662
+
1270
1663
  var strGetPlugin = "getPlugin";
1271
1664
  var BaseTelemetryPlugin = /** @class */ (function () {
1272
1665
  function BaseTelemetryPlugin() {
1273
1666
  var _self = this;
1274
- var _isinitialized = false;
1275
- var _rootCtx = null;
1276
- var _nextPlugin = null;
1277
- _self.core = null;
1667
+ var _isinitialized;
1668
+ var _rootCtx;
1669
+ var _nextPlugin;
1670
+ var _unloadHandlerContainer;
1671
+ var _hooks;
1672
+ _initDefaults();
1673
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1674
+ _self.initialize = function (config, core, extensions, pluginChain) {
1675
+ _setDefaults(config, core, pluginChain);
1676
+ _isinitialized = true;
1677
+ };
1678
+ _self.teardown = function (unloadCtx, unloadState) {
1679
+ var core = _self.core;
1680
+ if (!core || (unloadCtx && core !== unloadCtx.core())) {
1681
+ return;
1682
+ }
1683
+ var result;
1684
+ var unloadDone = false;
1685
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1686
+ var theUnloadState = unloadState || {
1687
+ reason: 0 ,
1688
+ isAsync: false
1689
+ };
1690
+ function _unloadCallback() {
1691
+ if (!unloadDone) {
1692
+ unloadDone = true;
1693
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1694
+ arrForEach(_hooks, function (fn) {
1695
+ fn.rm();
1696
+ });
1697
+ _hooks = [];
1698
+ if (result === true) {
1699
+ theUnloadCtx.processNext(theUnloadState);
1700
+ }
1701
+ _initDefaults();
1702
+ }
1703
+ }
1704
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1705
+ _unloadCallback();
1706
+ }
1707
+ else {
1708
+ result = true;
1709
+ }
1710
+ return result;
1711
+ };
1712
+ _self.update = function (updateCtx, updateState) {
1713
+ var core = _self.core;
1714
+ if (!core || (updateCtx && core !== updateCtx.core())) {
1715
+ return;
1716
+ }
1717
+ var result;
1718
+ var updateDone = false;
1719
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1720
+ var theUpdateState = updateState || {
1721
+ reason: 0
1722
+ };
1723
+ function _updateCallback() {
1724
+ if (!updateDone) {
1725
+ updateDone = true;
1726
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1727
+ }
1728
+ }
1729
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1730
+ _updateCallback();
1731
+ }
1732
+ else {
1733
+ result = true;
1734
+ }
1735
+ return result;
1736
+ };
1737
+ _self._addHook = function (hooks) {
1738
+ if (hooks) {
1739
+ if (isArray(hooks)) {
1740
+ _hooks = _hooks.concat(hooks);
1741
+ }
1742
+ else {
1743
+ _hooks.push(hooks);
1744
+ }
1745
+ }
1746
+ };
1747
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1748
+ });
1278
1749
  _self.diagLog = function (itemCtx) {
1279
- return _self._getTelCtx(itemCtx).diagLog();
1750
+ return _getTelCtx(itemCtx).diagLog();
1280
1751
  };
1281
- _self.isInitialized = function () {
1752
+ _self[strIsInitialized] = function () {
1282
1753
  return _isinitialized;
1283
1754
  };
1284
1755
  _self.setInitialized = function (isInitialized) {
1285
1756
  _isinitialized = isInitialized;
1286
1757
  };
1287
- _self.setNextPlugin = function (next) {
1758
+ _self[strSetNextPlugin] = function (next) {
1288
1759
  _nextPlugin = next;
1289
1760
  };
1290
1761
  _self.processNext = function (env, itemCtx) {
@@ -1295,11 +1766,12 @@
1295
1766
  _nextPlugin.processTelemetry(env, null);
1296
1767
  }
1297
1768
  };
1298
- _self._getTelCtx = function (currentCtx) {
1769
+ _self._getTelCtx = _getTelCtx;
1770
+ function _getTelCtx(currentCtx) {
1299
1771
  if (currentCtx === void 0) { currentCtx = null; }
1300
1772
  var itemCtx = currentCtx;
1301
1773
  if (!itemCtx) {
1302
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1774
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1303
1775
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1304
1776
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1305
1777
  }
@@ -1308,8 +1780,8 @@
1308
1780
  }
1309
1781
  }
1310
1782
  return itemCtx;
1311
- };
1312
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1783
+ }
1784
+ function _setDefaults(config, core, pluginChain) {
1313
1785
  if (config) {
1314
1786
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1315
1787
  }
@@ -1321,93 +1793,300 @@
1321
1793
  nextPlugin = _nextPlugin[strGetPlugin]();
1322
1794
  }
1323
1795
  _self.core = core;
1324
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1325
- _isinitialized = true;
1326
- };
1796
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1797
+ }
1798
+ function _initDefaults() {
1799
+ _isinitialized = false;
1800
+ _self.core = null;
1801
+ _rootCtx = null;
1802
+ _nextPlugin = null;
1803
+ _hooks = [];
1804
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1805
+ }
1327
1806
  }
1328
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1329
- this._baseTelInit(config, core, extensions, pluginChain);
1330
- };
1331
1807
  return BaseTelemetryPlugin;
1332
1808
  }());
1333
1809
 
1810
+ var strOnPrefix = "on";
1811
+ var strAttachEvent = "attachEvent";
1812
+ var strAddEventHelper = "addEventListener";
1813
+ var strDetachEvent = "detachEvent";
1814
+ var strRemoveEventListener = "removeEventListener";
1815
+ var strEvents = "events";
1334
1816
  var strVisibilityChangeEvt = "visibilitychange";
1335
1817
  var strPageHide = "pagehide";
1336
1818
  var strPageShow = "pageshow";
1337
- function addEventHandler(eventName, callback) {
1819
+ var strUnload = "unload";
1820
+ var strBeforeUnload = "beforeunload";
1821
+ var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
1822
+ var strPageShowNamespace = createUniqueNamespace("aiEvtPageShow");
1823
+ var rRemoveEmptyNs = /\.[\.]+/g;
1824
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
1825
+ var _guid = 1;
1826
+ var elmNodeData = createElmNodeData("events");
1827
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1828
+ function _normalizeNamespace(name) {
1829
+ if (name && name.replace) {
1830
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1831
+ }
1832
+ return name;
1833
+ }
1834
+ function _getEvtNamespace(eventName, evtNamespace) {
1835
+ if (evtNamespace) {
1836
+ var theNamespace_1 = "";
1837
+ if (isArray(evtNamespace)) {
1838
+ theNamespace_1 = "";
1839
+ arrForEach(evtNamespace, function (name) {
1840
+ name = _normalizeNamespace(name);
1841
+ if (name) {
1842
+ if (name[0] !== ".") {
1843
+ name = "." + name;
1844
+ }
1845
+ theNamespace_1 += name;
1846
+ }
1847
+ });
1848
+ }
1849
+ else {
1850
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
1851
+ }
1852
+ if (theNamespace_1) {
1853
+ if (theNamespace_1[0] !== ".") {
1854
+ theNamespace_1 = "." + theNamespace_1;
1855
+ }
1856
+ eventName = (eventName || "") + theNamespace_1;
1857
+ }
1858
+ }
1859
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
1860
+ return {
1861
+ type: parsedEvent[1],
1862
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
1863
+ };
1864
+ }
1865
+ function _getRegisteredEvents(target, evtName, addDefault) {
1866
+ if (addDefault === void 0) { addDefault = true; }
1867
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1868
+ var registeredEvents = aiEvts[evtName];
1869
+ if (!registeredEvents) {
1870
+ registeredEvents = aiEvts[evtName] = [];
1871
+ }
1872
+ return registeredEvents;
1873
+ }
1874
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
1875
+ if (obj && evtName && evtName.type) {
1876
+ if (obj[strRemoveEventListener]) {
1877
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
1878
+ }
1879
+ else if (obj[strDetachEvent]) {
1880
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
1881
+ }
1882
+ }
1883
+ }
1884
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
1885
+ var result = false;
1886
+ if (obj && evtName && evtName.type && handlerRef) {
1887
+ if (obj[strAddEventHelper]) {
1888
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1889
+ result = true;
1890
+ }
1891
+ else if (obj[strAttachEvent]) {
1892
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1893
+ result = true;
1894
+ }
1895
+ }
1896
+ return result;
1897
+ }
1898
+ function _doUnregister(target, events, evtName, unRegFn) {
1899
+ var idx = events.length;
1900
+ while (idx--) {
1901
+ var theEvent = events[idx];
1902
+ if (theEvent) {
1903
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
1904
+ if (!unRegFn || unRegFn(theEvent)) {
1905
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
1906
+ events.splice(idx, 1);
1907
+ }
1908
+ }
1909
+ }
1910
+ }
1911
+ }
1912
+ function _unregisterEvents(target, evtName, unRegFn) {
1913
+ if (evtName.type) {
1914
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1915
+ }
1916
+ else {
1917
+ var eventCache = elmNodeData.get(target, strEvents, {});
1918
+ objForEachKey(eventCache, function (evtType, events) {
1919
+ _doUnregister(target, events, evtName, unRegFn);
1920
+ });
1921
+ if (objKeys(eventCache).length === 0) {
1922
+ elmNodeData.kill(target, strEvents);
1923
+ }
1924
+ }
1925
+ }
1926
+ function mergeEvtNamespace(theNamespace, namespaces) {
1927
+ var newNamespaces;
1928
+ if (namespaces) {
1929
+ if (isArray(namespaces)) {
1930
+ newNamespaces = [theNamespace].concat(namespaces);
1931
+ }
1932
+ else {
1933
+ newNamespaces = [theNamespace, namespaces];
1934
+ }
1935
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1936
+ }
1937
+ else {
1938
+ newNamespaces = theNamespace;
1939
+ }
1940
+ return newNamespaces;
1941
+ }
1942
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1943
+ if (useCapture === void 0) { useCapture = false; }
1944
+ var result = false;
1945
+ if (target) {
1946
+ try {
1947
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
1948
+ result = _doAttach(target, evtName, handlerRef, useCapture);
1949
+ if (result && elmNodeData.accept(target)) {
1950
+ var registeredEvent = {
1951
+ guid: _guid++,
1952
+ evtName: evtName,
1953
+ handler: handlerRef,
1954
+ capture: useCapture
1955
+ };
1956
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1957
+ }
1958
+ }
1959
+ catch (e) {
1960
+ }
1961
+ }
1962
+ return result;
1963
+ }
1964
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
1965
+ if (useCapture === void 0) { useCapture = false; }
1966
+ if (target) {
1967
+ try {
1968
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
1969
+ var found_1 = false;
1970
+ _unregisterEvents(target, evtName_1, function (regEvent) {
1971
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
1972
+ found_1 = true;
1973
+ return true;
1974
+ }
1975
+ return false;
1976
+ });
1977
+ if (!found_1) {
1978
+ _doDetach(target, evtName_1, handlerRef, useCapture);
1979
+ }
1980
+ }
1981
+ catch (e) {
1982
+ }
1983
+ }
1984
+ }
1985
+ function addEventHandler(eventName, callback, evtNamespace) {
1338
1986
  var result = false;
1339
1987
  var w = getWindow();
1340
1988
  if (w) {
1341
- result = attachEvent(w, eventName, callback);
1342
- result = attachEvent(w["body"], eventName, callback) || result;
1989
+ result = eventOn(w, eventName, callback, evtNamespace);
1990
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1343
1991
  }
1344
1992
  var doc = getDocument();
1345
1993
  if (doc) {
1346
- result = attachEvent(doc, eventName, callback) || result;
1994
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1347
1995
  }
1348
1996
  return result;
1349
1997
  }
1350
- function addEventListeners(events, listener, excludeEvents) {
1998
+ function removeEventHandler(eventName, callback, evtNamespace) {
1999
+ var w = getWindow();
2000
+ if (w) {
2001
+ eventOff(w, eventName, callback, evtNamespace);
2002
+ eventOff(w["body"], eventName, callback, evtNamespace);
2003
+ }
2004
+ var doc = getDocument();
2005
+ if (doc) {
2006
+ eventOff(doc, eventName, callback, evtNamespace);
2007
+ }
2008
+ }
2009
+ function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
1351
2010
  var added = false;
1352
- if (listener && events && isArray(events)) {
1353
- var excluded_1 = [];
2011
+ if (listener && events && events.length > 0) {
1354
2012
  arrForEach(events, function (name) {
1355
- if (isString(name)) {
2013
+ if (name) {
1356
2014
  if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
1357
- added = addEventHandler(name, listener) || added;
1358
- }
1359
- else {
1360
- excluded_1.push(name);
2015
+ added = addEventHandler(name, listener, evtNamespace) || added;
1361
2016
  }
1362
2017
  }
1363
2018
  });
1364
- if (!added && excluded_1.length > 0) {
1365
- added = addEventListeners(excluded_1, listener);
2019
+ }
2020
+ return added;
2021
+ }
2022
+ function addEventListeners(events, listener, excludeEvents, evtNamespace) {
2023
+ var added = false;
2024
+ if (listener && events && isArray(events)) {
2025
+ added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
2026
+ if (!added && excludeEvents && excludeEvents.length > 0) {
2027
+ added = _addEventListeners(events, listener, null, evtNamespace);
1366
2028
  }
1367
2029
  }
1368
2030
  return added;
1369
2031
  }
1370
- function addPageUnloadEventListener(listener, excludeEvents) {
1371
- return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
2032
+ function removeEventListeners(events, listener, evtNamespace) {
2033
+ if (events && isArray(events)) {
2034
+ arrForEach(events, function (name) {
2035
+ if (name) {
2036
+ removeEventHandler(name, listener, evtNamespace);
2037
+ }
2038
+ });
2039
+ }
2040
+ }
2041
+ function addPageUnloadEventListener(listener, excludeEvents, evtNamespace) {
2042
+ return addEventListeners([strBeforeUnload, strUnload, strPageHide], listener, excludeEvents, evtNamespace);
2043
+ }
2044
+ function removePageUnloadEventListener(listener, evtNamespace) {
2045
+ removeEventListeners([strBeforeUnload, strUnload, strPageHide], listener, evtNamespace);
1372
2046
  }
1373
- function addPageHideEventListener(listener, excludeEvents) {
2047
+ function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
1374
2048
  function _handlePageVisibility(evt) {
1375
2049
  var doc = getDocument();
1376
2050
  if (listener && doc && doc.visibilityState === "hidden") {
1377
2051
  listener(evt);
1378
2052
  }
1379
2053
  }
1380
- var pageUnloadAdded = false;
1381
- if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
1382
- pageUnloadAdded = addEventHandler(strPageHide, listener);
1383
- }
2054
+ var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
2055
+ var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
1384
2056
  if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
1385
- pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
2057
+ pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
1386
2058
  }
1387
2059
  if (!pageUnloadAdded && excludeEvents) {
1388
- pageUnloadAdded = addPageHideEventListener(listener);
2060
+ pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
1389
2061
  }
1390
2062
  return pageUnloadAdded;
1391
2063
  }
1392
- function addPageShowEventListener(listener, excludeEvents) {
2064
+ function removePageHideEventListener(listener, evtNamespace) {
2065
+ var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
2066
+ removeEventListeners([strPageHide], listener, newNamespaces);
2067
+ removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
2068
+ }
2069
+ function addPageShowEventListener(listener, excludeEvents, evtNamespace) {
1393
2070
  function _handlePageVisibility(evt) {
1394
2071
  var doc = getDocument();
1395
2072
  if (listener && doc && doc.visibilityState === "visible") {
1396
2073
  listener(evt);
1397
2074
  }
1398
2075
  }
1399
- var pageShowAdded = false;
1400
- if (!excludeEvents || arrIndexOf(excludeEvents, strPageShow) === -1) {
1401
- pageShowAdded = addEventHandler(strPageShow, listener);
1402
- }
1403
- if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
1404
- pageShowAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageShowAdded;
1405
- }
2076
+ var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
2077
+ var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
2078
+ pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
1406
2079
  if (!pageShowAdded && excludeEvents) {
1407
- pageShowAdded = addPageShowEventListener(listener);
2080
+ pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
1408
2081
  }
1409
2082
  return pageShowAdded;
1410
2083
  }
2084
+ function removePageShowEventListener(listener, evtNamespace) {
2085
+ var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
2086
+ removeEventListeners([strPageShow], listener, newNamespaces);
2087
+ removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
2088
+ }
2089
+
1411
2090
  function perfNow() {
1412
2091
  var perf = getPerformance();
1413
2092
  if (perf && perf.now) {
@@ -1416,57 +2095,20 @@
1416
2095
  return dateNow();
1417
2096
  }
1418
2097
 
1419
- var ValueKind = {
1420
- NotSet: 0,
1421
- Pii_DistinguishedName: 1,
1422
- Pii_GenericData: 2,
1423
- Pii_IPV4Address: 3,
1424
- Pii_IPv6Address: 4,
1425
- Pii_MailSubject: 5,
1426
- Pii_PhoneNumber: 6,
1427
- Pii_QueryString: 7,
1428
- Pii_SipAddress: 8,
1429
- Pii_SmtpAddress: 9,
1430
- Pii_Identity: 10,
1431
- Pii_Uri: 11,
1432
- Pii_Fqdn: 12,
1433
- Pii_IPV4AddressLegacy: 13,
1434
- CustomerContent_GenericContent: 32
1435
- };
1436
- var EventLatency = {
1437
- Normal: 1 ,
1438
- CostDeferred: 2 ,
1439
- RealTime: 3 ,
1440
- Immediate: 4
1441
- };
1442
- var EventPropertyType = {
1443
- Unspecified: 0,
1444
- String: 1,
1445
- Int32: 2,
1446
- UInt32: 3,
1447
- Int64: 4,
1448
- UInt64: 5,
1449
- Double: 6,
1450
- Bool: 7,
1451
- Guid: 8,
1452
- DateTime: 9
1453
- };
1454
- 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 });
1455
-
1456
2098
  var _a$1;
1457
- var Version = '3.1.11';
2099
+ var Version = '3.2.0';
1458
2100
  var FullVersionString = "1DS-Web-JS-" + Version;
1459
2101
  var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1460
2102
  var strWithCredentials = "withCredentials";
1461
2103
  var strTimeout = "timeout";
1462
2104
  var _fieldTypeEventPropMap = (_a$1 = {},
1463
- _a$1[0 ] = EventPropertyType.Unspecified,
1464
- _a$1[2 ] = EventPropertyType.Double,
1465
- _a$1[1 ] = EventPropertyType.String,
1466
- _a$1[3 ] = EventPropertyType.Bool,
1467
- _a$1[4096 | 2 ] = EventPropertyType.Double,
1468
- _a$1[4096 | 1 ] = EventPropertyType.String,
1469
- _a$1[4096 | 3 ] = EventPropertyType.Bool,
2105
+ _a$1[0 ] = 0 ,
2106
+ _a$1[2 ] = 6 ,
2107
+ _a$1[1 ] = 1 ,
2108
+ _a$1[3 ] = 7 ,
2109
+ _a$1[4096 | 2 ] = 6 ,
2110
+ _a$1[4096 | 1 ] = 1 ,
2111
+ _a$1[4096 | 3 ] = 7 ,
1470
2112
  _a$1);
1471
2113
  Boolean(getDocument());
1472
2114
  var isWindowObjectAvailable = Boolean(getWindow());
@@ -1533,7 +2175,7 @@
1533
2175
  if (encodedTypeValue !== -1 && propType !== -1) {
1534
2176
  encodedTypeValue |= propType;
1535
2177
  }
1536
- else if (propType === EventPropertyType.Double) {
2178
+ else if (propType === 6 ) {
1537
2179
  encodedTypeValue = propType;
1538
2180
  }
1539
2181
  }
@@ -1579,7 +2221,7 @@
1579
2221
  }
1580
2222
  var getTime = perfNow;
1581
2223
  function isValueKind(value) {
1582
- if (value === ValueKind.NotSet || ((value > ValueKind.NotSet && value <= ValueKind.Pii_IPV4AddressLegacy) || value === ValueKind.CustomerContent_GenericContent)) {
2224
+ if (value === 0 || ((value > 0 && value <= 13 ) || value === 32 )) {
1583
2225
  return true;
1584
2226
  }
1585
2227
  return false;
@@ -1682,6 +2324,7 @@
1682
2324
  var strUploadTime = "upload-time";
1683
2325
  var strApiKey = "apikey";
1684
2326
  var strMsaDeviceTicket = "AuthMsaDeviceTicket";
2327
+ var strAuthXToken = "AuthXToken";
1685
2328
  var strNoResponseBody = "NoResponseBody";
1686
2329
  var strMsfpc = "msfpc";
1687
2330
 
@@ -1994,25 +2637,19 @@
1994
2637
  var RandomizationUpperThreshold = 1.2;
1995
2638
  var BaseBackoff = 3000;
1996
2639
  var MaxBackoff = 600000;
1997
- var RetryPolicy = /** @class */ (function () {
1998
- function RetryPolicy() {
1999
- }
2000
- RetryPolicy.shouldRetryForStatus = function (httpStatusCode) {
2001
- return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
2002
- || (httpStatusCode == 501)
2003
- || (httpStatusCode == 505));
2004
- };
2005
- RetryPolicy.getMillisToBackoffForRetry = function (retriesSoFar) {
2006
- var waitDuration = 0;
2007
- var minBackoff = BaseBackoff * RandomizationLowerThreshold;
2008
- var maxBackoff = BaseBackoff * RandomizationUpperThreshold;
2009
- var randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
2010
- waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
2011
- return Math.min(waitDuration, MaxBackoff);
2012
- };
2013
- return RetryPolicy;
2014
- }());
2015
- var RetryPolicy$1 = RetryPolicy;
2640
+ function retryPolicyShouldRetryForStatus(httpStatusCode) {
2641
+ return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
2642
+ || (httpStatusCode == 501)
2643
+ || (httpStatusCode == 505));
2644
+ }
2645
+ function retryPolicyGetMillisToBackoffForRetry(retriesSoFar) {
2646
+ var waitDuration = 0;
2647
+ var minBackoff = BaseBackoff * RandomizationLowerThreshold;
2648
+ var maxBackoff = BaseBackoff * RandomizationUpperThreshold;
2649
+ var randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
2650
+ waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
2651
+ return Math.min(waitDuration, MaxBackoff);
2652
+ }
2016
2653
 
2017
2654
  var SecToMsMultiplier = 1000;
2018
2655
  var KillSwitch = /** @class */ (function () {
@@ -2117,11 +2754,19 @@
2117
2754
  _a);
2118
2755
  var _collectorQsHeaders = {};
2119
2756
  var _collectorHeaderToQs = {};
2120
- function _addCollectorHeaderQsMapping(qsName, headerName) {
2757
+ function _addCollectorHeaderQsMapping(qsName, headerName, allowQs) {
2121
2758
  _collectorQsHeaders[qsName] = headerName;
2122
- _collectorHeaderToQs[headerName] = qsName;
2759
+ if (allowQs !== false) {
2760
+ _collectorHeaderToQs[headerName] = qsName;
2761
+ }
2123
2762
  }
2124
- _addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket);
2763
+ _addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket, false);
2764
+ _addCollectorHeaderQsMapping(strClientVersion, strClientVersion);
2765
+ _addCollectorHeaderQsMapping(strClientId, "Client-Id");
2766
+ _addCollectorHeaderQsMapping(strApiKey, strApiKey);
2767
+ _addCollectorHeaderQsMapping(strTimeDeltaToApply, strTimeDeltaToApply);
2768
+ _addCollectorHeaderQsMapping(strUploadTime, strUploadTime);
2769
+ _addCollectorHeaderQsMapping(strAuthXToken, strAuthXToken);
2125
2770
  function _getResponseText(xhr) {
2126
2771
  try {
2127
2772
  return xhr.responseText;
@@ -2190,7 +2835,7 @@
2190
2835
  channelConfig = {};
2191
2836
  }
2192
2837
  _urlString = endpointUrl + _urlString;
2193
- _useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : false;
2838
+ _useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : true;
2194
2839
  _core = core;
2195
2840
  _cookieMgr = core.getCookieMgr();
2196
2841
  _enableEventTimings = !_core.config.disableEventTimings;
@@ -2416,7 +3061,7 @@
2416
3061
  oncomplete(status, headers, response);
2417
3062
  }
2418
3063
  catch (e) {
2419
- _postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.SendPostOnCompleteFailure, dumpObj(e));
3064
+ _throwInternal(_postManager.diagLog(), 2 , 518 , dumpObj(e));
2420
3065
  }
2421
3066
  }
2422
3067
  function _beaconSendPost(payload, oncomplete, sync) {
@@ -2451,7 +3096,7 @@
2451
3096
  }
2452
3097
  }
2453
3098
  catch (ex) {
2454
- _postManager.diagLog().warnToConsole("Failed to send telemetry using sendBeacon API. Ex:" + ex);
3099
+ _postManager.diagLog().warnToConsole("Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
2455
3100
  status = 0;
2456
3101
  }
2457
3102
  finally {
@@ -2615,7 +3260,7 @@
2615
3260
  }, function () { return ({ batches: _createDebugBatches(orgBatches_1), retryCount: retryCount, isTeardown: isTeardown, isSynchronous: isSynchronous_1, sendReason: sendReason, useSendBeacon: _isBeaconPayload(sendType), sendType: sendType }); }, !isSynchronous_1);
2616
3261
  }
2617
3262
  catch (ex) {
2618
- _postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
3263
+ _throwInternal(_postManager.diagLog(), 2 , 48 , "Unexpected Exception sending batch: " + dumpObj(ex));
2619
3264
  }
2620
3265
  }
2621
3266
  function _buildRequestDetails(thePayload, useHeaders) {
@@ -2624,8 +3269,21 @@
2624
3269
  hdrs: {},
2625
3270
  useHdrs: false
2626
3271
  };
2627
- requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
2628
- requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
3272
+ if (!useHeaders) {
3273
+ objForEachKey(_headers, function (name, value) {
3274
+ if (_collectorHeaderToQs[name]) {
3275
+ _addRequestDetails(requestDetails, _collectorHeaderToQs[name], value, false);
3276
+ }
3277
+ else {
3278
+ requestDetails.hdrs[name] = value;
3279
+ requestDetails.useHdrs = true;
3280
+ }
3281
+ });
3282
+ }
3283
+ else {
3284
+ requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
3285
+ requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
3286
+ }
2629
3287
  _addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
2630
3288
  _addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
2631
3289
  var apiQsKeys = "";
@@ -2811,7 +3469,7 @@
2811
3469
  reason = 200 ;
2812
3470
  return;
2813
3471
  }
2814
- if (!RetryPolicy$1.shouldRetryForStatus(status) || thePayload.numEvents <= 0) {
3472
+ if (!retryPolicyShouldRetryForStatus(status) || thePayload.numEvents <= 0) {
2815
3473
  shouldRetry = false;
2816
3474
  }
2817
3475
  reason = 9000 + (status % 1000);
@@ -2827,7 +3485,7 @@
2827
3485
  _outstandingRequests--;
2828
3486
  }
2829
3487
  _sendBatches(thePayload.batches, retryCount_1 + 1, thePayload.isTeardown, _isUnloading ? 2 : thePayload.sendType, 5 );
2830
- }, _isUnloading, RetryPolicy$1.getMillisToBackoffForRetry(retryCount_1));
3488
+ }, _isUnloading, retryPolicyGetMillisToBackoffForRetry(retryCount_1));
2831
3489
  }
2832
3490
  else {
2833
3491
  backOffTrans = true;
@@ -2923,7 +3581,7 @@
2923
3581
  responseHandlers[i](responseText);
2924
3582
  }
2925
3583
  catch (e) {
2926
- _postManager.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.PostResponseHandler, "Response handler failed: " + e);
3584
+ _throwInternal(_postManager.diagLog(), 1 , 519 , "Response handler failed: " + e);
2927
3585
  }
2928
3586
  }
2929
3587
  if (responseText) {
@@ -2947,7 +3605,7 @@
2947
3605
  theAction_1.call(actions, theBatches, batchReason, isSyncRequest_1, sendType);
2948
3606
  }
2949
3607
  catch (e) {
2950
- _postManager.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.NotificationException, "send request notification failed: " + e);
3608
+ _throwInternal(_postManager.diagLog(), 1 , 74 , "send request notification failed: " + e);
2951
3609
  }
2952
3610
  }, sendSync || isSyncRequest_1, 0);
2953
3611
  }, function () { return ({ batches: _createDebugBatches(theBatches), reason: batchReason, isSync: isSyncRequest_1, sendSync: sendSync, sendType: sendType }); }, !isSyncRequest_1);
@@ -2988,13 +3646,14 @@
2988
3646
  var strOverrideInstrumentationKey = "overrideInstrumentationKey";
2989
3647
  var strMaxEventRetryAttempts = "maxEventRetryAttempts";
2990
3648
  var strMaxUnloadEventRetryAttempts = "maxUnloadEventRetryAttempts";
3649
+ var strAddUnloadCb = "addUnloadCb";
2991
3650
  var PostChannel = /** @class */ (function (_super) {
2992
3651
  __extendsFn(PostChannel, _super);
2993
3652
  function PostChannel() {
2994
3653
  var _this = _super.call(this) || this;
2995
3654
  _this.identifier = "PostChannel";
2996
3655
  _this.priority = 1011;
2997
- _this.version = '3.1.11';
3656
+ _this.version = '3.2.0';
2998
3657
  var _config;
2999
3658
  var _isTeardownCalled = false;
3000
3659
  var _flushCallbackQueue = [];
@@ -3022,18 +3681,9 @@
3022
3681
  var _disableXhrSync = false;
3023
3682
  var _maxEventSendAttempts = MaxSendAttempts;
3024
3683
  var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
3684
+ var _evtNamespace;
3025
3685
  dynamicProto(PostChannel, _this, function (_self, _base) {
3026
- _initializeProfiles();
3027
- _clearQueues();
3028
- _setAutoLimits();
3029
- _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
3030
- requeue: _requeueEvents,
3031
- send: _sendingEvent,
3032
- sent: _eventsSentEvent,
3033
- drop: _eventsDropped,
3034
- rspFail: _eventsResponseFail,
3035
- oth: _otherEvent
3036
- });
3686
+ _initDefaults();
3037
3687
  _self["_getDbgPlgTargets"] = function () {
3038
3688
  return [_httpManager];
3039
3689
  };
@@ -3041,47 +3691,53 @@
3041
3691
  doPerf(core, function () { return "PostChannel:initialize"; }, function () {
3042
3692
  var extendedCore = core;
3043
3693
  _base.initialize(coreConfig, core, extensions);
3044
- _self.setInitialized(false);
3045
- var ctx = _self._getTelCtx();
3046
- coreConfig.extensionConfig[_self.identifier] = coreConfig.extensionConfig[_self.identifier] || {};
3047
- _config = ctx.getExtCfg(_self.identifier);
3048
- _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
3049
- _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
3050
- _optimizeObject = !_config.disableOptimizeObj && isChromium();
3051
- _hookWParam(extendedCore);
3052
- if (_config.eventsLimitInMem > 0) {
3053
- _queueSizeLimit = _config.eventsLimitInMem;
3054
- }
3055
- if (_config.immediateEventLimit > 0) {
3056
- _immediateQueueSizeLimit = _config.immediateEventLimit;
3057
- }
3058
- if (_config.autoFlushEventsLimit > 0) {
3059
- _autoFlushEventsLimit = _config.autoFlushEventsLimit;
3060
- }
3061
- _disableXhrSync = _config.disableXhrSync;
3062
- if (isNumber(_config[strMaxEventRetryAttempts])) {
3063
- _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
3064
- }
3065
- if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
3066
- _maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
3067
- }
3068
- _setAutoLimits();
3069
- if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
3070
- _xhrOverride = _config.httpXHROverride;
3071
- }
3072
- if (isValueAssigned(coreConfig.anonCookieName)) {
3073
- _httpManager.addQueryStringParameter("anoncknm", coreConfig.anonCookieName);
3074
- }
3075
- _httpManager.sendHook = _config.payloadPreprocessor;
3076
- _httpManager.sendListener = _config.payloadListener;
3077
- var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
3078
- _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
3079
- _httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
3080
- var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
3081
- addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents);
3082
- addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents);
3083
- addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents);
3084
- _self.setInitialized(true);
3694
+ try {
3695
+ var hasAddUnloadCb = !!core[strAddUnloadCb];
3696
+ _evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self.identifier), core.evtNamespace && core.evtNamespace());
3697
+ var ctx = _self._getTelCtx();
3698
+ coreConfig.extensionConfig[_self.identifier] = coreConfig.extensionConfig[_self.identifier] || {};
3699
+ _config = ctx.getExtCfg(_self.identifier);
3700
+ _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
3701
+ _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
3702
+ _optimizeObject = !_config.disableOptimizeObj && isChromium();
3703
+ _hookWParam(extendedCore);
3704
+ if (_config.eventsLimitInMem > 0) {
3705
+ _queueSizeLimit = _config.eventsLimitInMem;
3706
+ }
3707
+ if (_config.immediateEventLimit > 0) {
3708
+ _immediateQueueSizeLimit = _config.immediateEventLimit;
3709
+ }
3710
+ if (_config.autoFlushEventsLimit > 0) {
3711
+ _autoFlushEventsLimit = _config.autoFlushEventsLimit;
3712
+ }
3713
+ _disableXhrSync = _config.disableXhrSync;
3714
+ if (isNumber(_config[strMaxEventRetryAttempts])) {
3715
+ _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
3716
+ }
3717
+ if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
3718
+ _maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
3719
+ }
3720
+ _setAutoLimits();
3721
+ if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
3722
+ _xhrOverride = _config.httpXHROverride;
3723
+ }
3724
+ if (isValueAssigned(coreConfig.anonCookieName)) {
3725
+ _httpManager.addQueryStringParameter("anoncknm", coreConfig.anonCookieName);
3726
+ }
3727
+ _httpManager.sendHook = _config.payloadPreprocessor;
3728
+ _httpManager.sendListener = _config.payloadListener;
3729
+ var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
3730
+ _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
3731
+ _httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
3732
+ var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
3733
+ addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);
3734
+ addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);
3735
+ addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents, _evtNamespace);
3736
+ }
3737
+ catch (e) {
3738
+ _self.setInitialized(false);
3739
+ throw e;
3740
+ }
3085
3741
  }, function () { return ({ coreConfig: coreConfig, core: core, extensions: extensions }); });
3086
3742
  };
3087
3743
  _self.processTelemetry = function (ev, itemCtx) {
@@ -3110,6 +3766,15 @@
3110
3766
  }
3111
3767
  _self.processNext(event, itemCtx);
3112
3768
  };
3769
+ _self._doTeardown = function (unloadCtx, unloadState) {
3770
+ _releaseAllQueues(2 , 2 );
3771
+ _isTeardownCalled = true;
3772
+ _httpManager.teardown();
3773
+ removePageUnloadEventListener(null, _evtNamespace);
3774
+ removePageHideEventListener(null, _evtNamespace);
3775
+ removePageShowEventListener(null, _evtNamespace);
3776
+ _initDefaults();
3777
+ };
3113
3778
  function _hookWParam(extendedCore) {
3114
3779
  var existingGetWParamMethod = extendedCore.getWParam;
3115
3780
  extendedCore.getWParam = function () {
@@ -3137,7 +3802,7 @@
3137
3802
  event.sendAttempt = 0;
3138
3803
  }
3139
3804
  if (!event.latency) {
3140
- event.latency = EventLatency.Normal;
3805
+ event.latency = 1 ;
3141
3806
  }
3142
3807
  if (event.ext && event.ext["trace"]) {
3143
3808
  delete (event.ext["trace"]);
@@ -3156,7 +3821,7 @@
3156
3821
  }
3157
3822
  if (event.sync) {
3158
3823
  if (_currentBackoffCount || _paused) {
3159
- event.latency = EventLatency.RealTime;
3824
+ event.latency = 3 ;
3160
3825
  event.sync = false;
3161
3826
  }
3162
3827
  else {
@@ -3172,7 +3837,7 @@
3172
3837
  var evtLatency = event.latency;
3173
3838
  var queueSize = _queueSize;
3174
3839
  var queueLimit = _queueSizeLimit;
3175
- if (evtLatency === EventLatency.Immediate) {
3840
+ if (evtLatency === 4 ) {
3176
3841
  queueSize = _immediateQueueSize;
3177
3842
  queueLimit = _immediateQueueSizeLimit;
3178
3843
  }
@@ -3181,10 +3846,10 @@
3181
3846
  eventDropped = !_addEventToProperQueue(event, append);
3182
3847
  }
3183
3848
  else {
3184
- var dropLatency = EventLatency.Normal;
3849
+ var dropLatency = 1 ;
3185
3850
  var dropNumber = EventsDroppedAtOneTime;
3186
- if (evtLatency === EventLatency.Immediate) {
3187
- dropLatency = EventLatency.Immediate;
3851
+ if (evtLatency === 4 ) {
3852
+ dropLatency = 4 ;
3188
3853
  dropNumber = 1;
3189
3854
  }
3190
3855
  eventDropped = true;
@@ -3202,7 +3867,7 @@
3202
3867
  _setAutoLimits();
3203
3868
  var doFlush = _queueSize > eventLimit;
3204
3869
  if (!doFlush && _autoFlushBatchLimit > 0) {
3205
- for (var latency = EventLatency.Normal; !doFlush && latency <= EventLatency.RealTime; latency++) {
3870
+ for (var latency = 1 ; !doFlush && latency <= 3 ; latency++) {
3206
3871
  var batchQueue = _batchQueues[latency];
3207
3872
  if (batchQueue && batchQueue.batches) {
3208
3873
  arrForEach(batchQueue.batches, function (theBatch) {
@@ -3215,11 +3880,6 @@
3215
3880
  }
3216
3881
  _performAutoFlush(true, doFlush);
3217
3882
  };
3218
- _self.teardown = function () {
3219
- _releaseAllQueues(2 , 2 );
3220
- _isTeardownCalled = true;
3221
- _httpManager.teardown();
3222
- };
3223
3883
  _self.pause = function () {
3224
3884
  _clearScheduledTimer();
3225
3885
  _paused = true;
@@ -3261,7 +3921,7 @@
3261
3921
  _clearScheduledTimer();
3262
3922
  sendReason = sendReason || 1 ;
3263
3923
  if (async) {
3264
- _queueBatches(EventLatency.Normal, 0 , sendReason);
3924
+ _queueBatches(1 , 0 , sendReason);
3265
3925
  _resetQueueCounts();
3266
3926
  if (_flushCallbackTimerId == null) {
3267
3927
  _flushCallbackTimerId = _createTimer(function () {
@@ -3273,7 +3933,7 @@
3273
3933
  }
3274
3934
  }
3275
3935
  else {
3276
- _sendEventsForLatencyAndAbove(EventLatency.Normal, 1 , sendReason);
3936
+ _sendEventsForLatencyAndAbove(1 , 1 , sendReason);
3277
3937
  if (callback !== null && callback !== undefined) {
3278
3938
  callback();
3279
3939
  }
@@ -3308,7 +3968,7 @@
3308
3968
  if (immediateTimeOut >= 0) {
3309
3969
  _immediateTimerId = _createTimer(function () {
3310
3970
  _immediateTimerId = null;
3311
- _sendEventsForLatencyAndAbove(EventLatency.Immediate, 0 , 1 );
3971
+ _sendEventsForLatencyAndAbove(4 , 0 , 1 );
3312
3972
  _scheduleTimer();
3313
3973
  }, immediateTimeOut);
3314
3974
  }
@@ -3318,7 +3978,7 @@
3318
3978
  if (_hasEvents()) {
3319
3979
  _scheduledTimerId = _createTimer(function () {
3320
3980
  _scheduledTimerId = null;
3321
- _sendEventsForLatencyAndAbove(_timerCount === 0 ? EventLatency.RealTime : EventLatency.Normal, 0 , 1 );
3981
+ _sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 : 1 , 0 , 1 );
3322
3982
  _timerCount++;
3323
3983
  _timerCount %= 2;
3324
3984
  _scheduleTimer();
@@ -3343,13 +4003,53 @@
3343
4003
  _scheduleTimer();
3344
4004
  }
3345
4005
  };
4006
+ function _initDefaults() {
4007
+ _config = null;
4008
+ _isTeardownCalled = false;
4009
+ _flushCallbackQueue = [];
4010
+ _flushCallbackTimerId = null;
4011
+ _paused = false;
4012
+ _immediateQueueSize = 0;
4013
+ _immediateQueueSizeLimit = 500;
4014
+ _queueSize = 0;
4015
+ _queueSizeLimit = 10000;
4016
+ _profiles = {};
4017
+ _currentProfile = RT_PROFILE;
4018
+ _scheduledTimerId = null;
4019
+ _immediateTimerId = null;
4020
+ _currentBackoffCount = 0;
4021
+ _timerCount = 0;
4022
+ _xhrOverride = null;
4023
+ _batchQueues = {};
4024
+ _autoFlushEventsLimit = undefined;
4025
+ _autoFlushBatchLimit = 0;
4026
+ _delayedBatchSendLatency = -1;
4027
+ _delayedBatchReason = null;
4028
+ _optimizeObject = true;
4029
+ _isPageUnloadTriggered = false;
4030
+ _disableXhrSync = false;
4031
+ _maxEventSendAttempts = MaxSendAttempts;
4032
+ _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
4033
+ _evtNamespace = null;
4034
+ _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
4035
+ requeue: _requeueEvents,
4036
+ send: _sendingEvent,
4037
+ sent: _eventsSentEvent,
4038
+ drop: _eventsDropped,
4039
+ rspFail: _eventsResponseFail,
4040
+ oth: _otherEvent
4041
+ });
4042
+ _initializeProfiles();
4043
+ _clearQueues();
4044
+ _setAutoLimits();
4045
+ }
3346
4046
  function _createTimer(theTimerFunc, timeOut) {
3347
4047
  if (timeOut === 0 && _currentBackoffCount) {
3348
4048
  timeOut = 1;
3349
4049
  }
3350
4050
  var timerMultiplier = 1000;
3351
4051
  if (_currentBackoffCount) {
3352
- timerMultiplier = RetryPolicy$1.getMillisToBackoffForRetry(_currentBackoffCount - 1);
4052
+ timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);
3353
4053
  }
3354
4054
  return _self._setTimeoutOverride(theTimerFunc, timeOut * timerMultiplier);
3355
4055
  }
@@ -3367,23 +4067,23 @@
3367
4067
  _flushCallbackTimerId = null;
3368
4068
  }
3369
4069
  if (!_paused) {
3370
- _sendEventsForLatencyAndAbove(EventLatency.Normal, sendType, sendReason);
4070
+ _sendEventsForLatencyAndAbove(1 , sendType, sendReason);
3371
4071
  }
3372
4072
  }
3373
4073
  function _clearQueues() {
3374
- _batchQueues[EventLatency.Immediate] = {
4074
+ _batchQueues[4 ] = {
3375
4075
  batches: [],
3376
4076
  iKeyMap: {}
3377
4077
  };
3378
- _batchQueues[EventLatency.RealTime] = {
4078
+ _batchQueues[3 ] = {
3379
4079
  batches: [],
3380
4080
  iKeyMap: {}
3381
4081
  };
3382
- _batchQueues[EventLatency.CostDeferred] = {
4082
+ _batchQueues[2 ] = {
3383
4083
  batches: [],
3384
4084
  iKeyMap: {}
3385
4085
  };
3386
- _batchQueues[EventLatency.Normal] = {
4086
+ _batchQueues[1 ] = {
3387
4087
  batches: [],
3388
4088
  iKeyMap: {}
3389
4089
  };
@@ -3391,7 +4091,7 @@
3391
4091
  function _getEventBatch(iKey, latency, create) {
3392
4092
  var batchQueue = _batchQueues[latency];
3393
4093
  if (!batchQueue) {
3394
- latency = EventLatency.Normal;
4094
+ latency = 1 ;
3395
4095
  batchQueue = _batchQueues[latency];
3396
4096
  }
3397
4097
  var eventBatch = batchQueue.iKeyMap[iKey];
@@ -3419,7 +4119,7 @@
3419
4119
  var latency = event.latency;
3420
4120
  var eventBatch = _getEventBatch(event.iKey, latency, true);
3421
4121
  if (eventBatch.addEvent(event)) {
3422
- if (latency !== EventLatency.Immediate) {
4122
+ if (latency !== 4 ) {
3423
4123
  _queueSize++;
3424
4124
  if (append && event.sendAttempt === 0) {
3425
4125
  _performAutoFlush(!event.sync, _autoFlushBatchLimit > 0 && eventBatch.count() >= _autoFlushBatchLimit);
@@ -3439,7 +4139,7 @@
3439
4139
  var droppedEvents = eventBatch.split(0, dropNumber);
3440
4140
  var droppedCount = droppedEvents.count();
3441
4141
  if (droppedCount > 0) {
3442
- if (currentLatency === EventLatency.Immediate) {
4142
+ if (currentLatency === 4 ) {
3443
4143
  _immediateQueueSize -= droppedCount;
3444
4144
  }
3445
4145
  else {
@@ -3461,7 +4161,7 @@
3461
4161
  var batchQueue = _batchQueues[latency];
3462
4162
  if (batchQueue && batchQueue.batches) {
3463
4163
  arrForEach(batchQueue.batches, function (theBatch) {
3464
- if (latency === EventLatency.Immediate) {
4164
+ if (latency === 4 ) {
3465
4165
  immediateQueue += theBatch.count();
3466
4166
  }
3467
4167
  else {
@@ -3470,7 +4170,7 @@
3470
4170
  });
3471
4171
  }
3472
4172
  };
3473
- for (var latency = EventLatency.Normal; latency <= EventLatency.Immediate; latency++) {
4173
+ for (var latency = 1 ; latency <= 4 ; latency++) {
3474
4174
  _loop_1(latency);
3475
4175
  }
3476
4176
  _queueSize = normalQueue;
@@ -3482,7 +4182,7 @@
3482
4182
  if (!isAsync || _httpManager.canSendRequest()) {
3483
4183
  doPerf(_self.core, function () { return "PostChannel._queueBatches"; }, function () {
3484
4184
  var droppedEvents = [];
3485
- var latencyToProcess = EventLatency.Immediate;
4185
+ var latencyToProcess = 4 ;
3486
4186
  while (latencyToProcess >= latency) {
3487
4187
  var batchQueue = _batchQueues[latencyToProcess];
3488
4188
  if (batchQueue && batchQueue.batches && batchQueue.batches.length > 0) {
@@ -3493,7 +4193,7 @@
3493
4193
  else {
3494
4194
  eventsQueued = eventsQueued || (theBatch && theBatch.count() > 0);
3495
4195
  }
3496
- if (latencyToProcess === EventLatency.Immediate) {
4196
+ if (latencyToProcess === 4 ) {
3497
4197
  _immediateQueueSize -= theBatch.count();
3498
4198
  }
3499
4199
  else {
@@ -3521,7 +4221,7 @@
3521
4221
  return eventsQueued;
3522
4222
  }
3523
4223
  function _flushImpl(callback, sendReason) {
3524
- _sendEventsForLatencyAndAbove(EventLatency.Normal, 0 , sendReason);
4224
+ _sendEventsForLatencyAndAbove(1 , 0 , sendReason);
3525
4225
  _waitForIdleManager(function () {
3526
4226
  if (callback) {
3527
4227
  callback();
@@ -3570,7 +4270,7 @@
3570
4270
  arrForEach(theBatch.events(), function (theEvent) {
3571
4271
  if (theEvent) {
3572
4272
  if (theEvent.sync) {
3573
- theEvent.latency = EventLatency.Immediate;
4273
+ theEvent.latency = 4 ;
3574
4274
  theEvent.sync = false;
3575
4275
  }
3576
4276
  if (theEvent.sendAttempt < maxSendAttempts) {
@@ -3599,7 +4299,7 @@
3599
4299
  notifyFunc.apply(manager, theArgs);
3600
4300
  }
3601
4301
  catch (e) {
3602
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.NotificationException, evtName + " notification failed: " + e);
4302
+ _throwInternal(_self.diagLog(), 1 , 74 , evtName + " notification failed: " + e);
3603
4303
  }
3604
4304
  }
3605
4305
  }