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