@microsoft/applicationinsights-channel-js 2.7.5-nightly.2204-03 → 2.7.5-nightly.2204-23

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 (38) hide show
  1. package/browser/applicationinsights-channel-js.integrity.json +9 -9
  2. package/browser/applicationinsights-channel-js.js +438 -1212
  3. package/browser/applicationinsights-channel-js.js.map +1 -1
  4. package/browser/applicationinsights-channel-js.min.js +2 -2
  5. package/browser/applicationinsights-channel-js.min.js.map +1 -1
  6. package/dist/applicationinsights-channel-js.api.json +89 -32
  7. package/dist/applicationinsights-channel-js.api.md +2 -0
  8. package/dist/applicationinsights-channel-js.d.ts +2 -1
  9. package/dist/applicationinsights-channel-js.js +438 -1212
  10. package/dist/applicationinsights-channel-js.js.map +1 -1
  11. package/dist/applicationinsights-channel-js.min.js +2 -2
  12. package/dist/applicationinsights-channel-js.min.js.map +1 -1
  13. package/dist/applicationinsights-channel-js.rollup.d.ts +2 -1
  14. package/dist-esm/EnvelopeCreator.js +2 -2
  15. package/dist-esm/EnvelopeCreator.js.map +1 -1
  16. package/dist-esm/Interfaces.js +1 -1
  17. package/dist-esm/Offline.js +65 -77
  18. package/dist-esm/Offline.js.map +1 -1
  19. package/dist-esm/SendBuffer.js +1 -1
  20. package/dist-esm/Sender.js +62 -72
  21. package/dist-esm/Sender.js.map +1 -1
  22. package/dist-esm/Serializer.js +1 -1
  23. package/dist-esm/TelemetryProcessors/Sample.js +3 -3
  24. package/dist-esm/TelemetryProcessors/Sample.js.map +1 -1
  25. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  26. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  27. package/dist-esm/applicationinsights-channel-js.js +1 -1
  28. package/package.json +5 -5
  29. package/src/EnvelopeCreator.ts +2 -2
  30. package/src/Offline.ts +76 -88
  31. package/src/Sender.ts +90 -83
  32. package/src/Serializer.ts +8 -4
  33. package/src/TelemetryProcessors/Sample.ts +1 -1
  34. package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +1 -3
  35. package/types/Offline.d.ts +11 -8
  36. package/types/Sender.d.ts +1 -0
  37. package/types/TelemetryProcessors/Sample.d.ts +2 -2
  38. package/types/tsdoc-metadata.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-03
2
+ * Application Insights JavaScript SDK - Channel, 2.7.5-nightly.2204-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -75,9 +75,7 @@
75
75
  var __assignFn = ObjAssign || __objAssignFnImpl;
76
76
  var extendStaticsFn = function (d, b) {
77
77
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
78
- ({ __proto__: [] } instanceof Array && function (d, b) {
79
- d.__proto__ = b;
80
- }) ||
78
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
81
79
  function (d, b) {
82
80
  for (var p in b) {
83
81
  if (b[strShimHasOwnProperty](p)) {
@@ -92,14 +90,12 @@
92
90
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
93
91
  }
94
92
  extendStaticsFn(d, b);
95
- function __() {
96
- this.constructor = d;
97
- }
93
+ function __() { this.constructor = d; }
98
94
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
99
95
  }
100
96
 
101
97
  /*!
102
- * Microsoft Dynamic Proto Utility, 1.1.4
98
+ * Microsoft Dynamic Proto Utility, 1.1.5
103
99
  * Copyright (c) Microsoft and contributors. All rights reserved.
104
100
  */
105
101
  var Constructor = 'constructor';
@@ -112,12 +108,13 @@
112
108
  var DynInstChkTag = '_dynInstChk';
113
109
  var DynAllowInstChkTag = DynInstChkTag;
114
110
  var DynProtoDefaultOptions = '_dfOpts';
111
+ var DynProtoPolyProto = "_dynProto";
115
112
  var UnknownValue = '_unknown_';
116
- var str__Proto$1 = "__proto__";
113
+ var str__Proto = "__proto__";
117
114
  var strUseBaseInst = 'useBaseInst';
118
115
  var strSetInstFuncs = 'setInstFuncs';
119
116
  var Obj = Object;
120
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
117
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
121
118
  var _dynamicNames = 0;
122
119
  function _hasOwnProperty(obj, prop) {
123
120
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -128,13 +125,16 @@
128
125
  function _isObjectArrayOrFunctionPrototype(target) {
129
126
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
130
127
  }
131
- function _getObjProto$1(target) {
128
+ function _getObjProto(target) {
132
129
  if (target) {
133
- if (_objGetPrototypeOf$1) {
134
- return _objGetPrototypeOf$1(target);
130
+ if (_objGetPrototypeOf) {
131
+ return _objGetPrototypeOf(target);
135
132
  }
136
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
133
+ var newProto = target[DynProtoPolyProto] || target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
137
134
  if (newProto) {
135
+ if (!target[DynProtoPolyProto]) {
136
+ target[DynProtoPolyProto] = newProto;
137
+ }
138
138
  return newProto;
139
139
  }
140
140
  }
@@ -199,16 +199,16 @@
199
199
  _forEachProp(instFuncs, function (name) {
200
200
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
201
201
  });
202
- var baseProto = _getObjProto$1(classProto);
202
+ var baseProto = _getObjProto(classProto);
203
203
  var visited = [];
204
204
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
205
205
  _forEachProp(baseProto, function (name) {
206
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
206
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
207
207
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
208
208
  }
209
209
  });
210
210
  visited.push(baseProto);
211
- baseProto = _getObjProto$1(baseProto);
211
+ baseProto = _getObjProto(baseProto);
212
212
  }
213
213
  return baseFuncs;
214
214
  }
@@ -222,7 +222,7 @@
222
222
  }
223
223
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
224
224
  var canAddInst = !_hasOwnProperty(target, funcName);
225
- var objProto = _getObjProto$1(target);
225
+ var objProto = _getObjProto(target);
226
226
  var visited = [];
227
227
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
228
228
  var protoFunc = objProto[funcName];
@@ -231,7 +231,7 @@
231
231
  break;
232
232
  }
233
233
  visited.push(objProto);
234
- objProto = _getObjProto$1(objProto);
234
+ objProto = _getObjProto(objProto);
235
235
  }
236
236
  try {
237
237
  if (canAddInst) {
@@ -249,7 +249,7 @@
249
249
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
250
250
  var protoFunc = proto[funcName];
251
251
  if (protoFunc === currentDynProtoProxy) {
252
- protoFunc = _getObjProto$1(proto)[funcName];
252
+ protoFunc = _getObjProto(proto)[funcName];
253
253
  }
254
254
  if (typeof protoFunc !== strFunction) {
255
255
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -283,18 +283,19 @@
283
283
  }
284
284
  }
285
285
  function _checkPrototype(classProto, thisTarget) {
286
- if (_objGetPrototypeOf$1) {
286
+ if (_objGetPrototypeOf) {
287
287
  var visited = [];
288
- var thisProto = _getObjProto$1(thisTarget);
288
+ var thisProto = _getObjProto(thisTarget);
289
289
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
290
290
  if (thisProto === classProto) {
291
291
  return true;
292
292
  }
293
293
  visited.push(thisProto);
294
- thisProto = _getObjProto$1(thisProto);
294
+ thisProto = _getObjProto(thisProto);
295
295
  }
296
+ return false;
296
297
  }
297
- return false;
298
+ return true;
298
299
  }
299
300
  function _getObjName(target, unknownValue) {
300
301
  if (_hasOwnProperty(target, Prototype)) {
@@ -327,7 +328,7 @@
327
328
  var instFuncs = _getInstanceFuncs(target);
328
329
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
329
330
  delegateFunc(target, baseFuncs);
330
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
331
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
331
332
  if (setInstanceFunc && options) {
332
333
  setInstanceFunc = !!options[strSetInstFuncs];
333
334
  }
@@ -339,24 +340,105 @@
339
340
  };
340
341
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
341
342
 
342
- var strEmpty$1 = "";
343
- var strSetNextPlugin = "setNextPlugin";
344
- var strIsInitialized = "isInitialized";
345
- var strTeardown = "teardown";
346
- var strCore = "core";
347
- var strUpdate = "update";
348
- var strDisabled = "disabled";
349
- var strDoTeardown = "_doTeardown";
343
+ var LoggingSeverity;
344
+ (function (LoggingSeverity) {
345
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
346
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
347
+ })(LoggingSeverity || (LoggingSeverity = {}));
348
+ var _InternalMessageId = {
349
+ BrowserDoesNotSupportLocalStorage: 0,
350
+ BrowserCannotReadLocalStorage: 1,
351
+ BrowserCannotReadSessionStorage: 2,
352
+ BrowserCannotWriteLocalStorage: 3,
353
+ BrowserCannotWriteSessionStorage: 4,
354
+ BrowserFailedRemovalFromLocalStorage: 5,
355
+ BrowserFailedRemovalFromSessionStorage: 6,
356
+ CannotSendEmptyTelemetry: 7,
357
+ ClientPerformanceMathError: 8,
358
+ ErrorParsingAISessionCookie: 9,
359
+ ErrorPVCalc: 10,
360
+ ExceptionWhileLoggingError: 11,
361
+ FailedAddingTelemetryToBuffer: 12,
362
+ FailedMonitorAjaxAbort: 13,
363
+ FailedMonitorAjaxDur: 14,
364
+ FailedMonitorAjaxOpen: 15,
365
+ FailedMonitorAjaxRSC: 16,
366
+ FailedMonitorAjaxSend: 17,
367
+ FailedMonitorAjaxGetCorrelationHeader: 18,
368
+ FailedToAddHandlerForOnBeforeUnload: 19,
369
+ FailedToSendQueuedTelemetry: 20,
370
+ FailedToReportDataLoss: 21,
371
+ FlushFailed: 22,
372
+ MessageLimitPerPVExceeded: 23,
373
+ MissingRequiredFieldSpecification: 24,
374
+ NavigationTimingNotSupported: 25,
375
+ OnError: 26,
376
+ SessionRenewalDateIsZero: 27,
377
+ SenderNotInitialized: 28,
378
+ StartTrackEventFailed: 29,
379
+ StopTrackEventFailed: 30,
380
+ StartTrackFailed: 31,
381
+ StopTrackFailed: 32,
382
+ TelemetrySampledAndNotSent: 33,
383
+ TrackEventFailed: 34,
384
+ TrackExceptionFailed: 35,
385
+ TrackMetricFailed: 36,
386
+ TrackPVFailed: 37,
387
+ TrackPVFailedCalc: 38,
388
+ TrackTraceFailed: 39,
389
+ TransmissionFailed: 40,
390
+ FailedToSetStorageBuffer: 41,
391
+ FailedToRestoreStorageBuffer: 42,
392
+ InvalidBackendResponse: 43,
393
+ FailedToFixDepricatedValues: 44,
394
+ InvalidDurationValue: 45,
395
+ TelemetryEnvelopeInvalid: 46,
396
+ CreateEnvelopeError: 47,
397
+ CannotSerializeObject: 48,
398
+ CannotSerializeObjectNonSerializable: 49,
399
+ CircularReferenceDetected: 50,
400
+ ClearAuthContextFailed: 51,
401
+ ExceptionTruncated: 52,
402
+ IllegalCharsInName: 53,
403
+ ItemNotInArray: 54,
404
+ MaxAjaxPerPVExceeded: 55,
405
+ MessageTruncated: 56,
406
+ NameTooLong: 57,
407
+ SampleRateOutOfRange: 58,
408
+ SetAuthContextFailed: 59,
409
+ SetAuthContextFailedAccountName: 60,
410
+ StringValueTooLong: 61,
411
+ StartCalledMoreThanOnce: 62,
412
+ StopCalledWithoutStart: 63,
413
+ TelemetryInitializerFailed: 64,
414
+ TrackArgumentsNotSpecified: 65,
415
+ UrlTooLong: 66,
416
+ SessionStorageBufferFull: 67,
417
+ CannotAccessCookie: 68,
418
+ IdTooLong: 69,
419
+ InvalidEvent: 70,
420
+ FailedMonitorAjaxSetRequestHeader: 71,
421
+ SendBrowserInfoOnUserInit: 72,
422
+ PluginException: 73,
423
+ NotificationException: 74,
424
+ SnippetScriptLoadFailure: 99,
425
+ InvalidInstrumentationKey: 100,
426
+ CannotParseAiBlobValue: 101,
427
+ InvalidContentBlob: 102,
428
+ TrackPageActionEventFailed: 103,
429
+ FailedAddingCustomDefinedRequestContext: 104,
430
+ InMemoryStorageBufferFull: 105
431
+ };
350
432
 
433
+ var strOnPrefix = "on";
434
+ var strAttachEvent = "attachEvent";
435
+ var strAddEventHelper = "addEventListener";
351
436
  var strToISOString = "toISOString";
352
437
  var strIndexOf = "indexOf";
353
438
  var strMap = "map";
354
439
  var cStrTrim = "trim";
355
440
  var strToString = "toString";
356
- var str__Proto = "__proto__";
357
- var strConstructor = "constructor";
358
- var _objDefineProperty$1 = ObjDefineProperty;
359
- var _objFreeze = ObjClass.freeze;
441
+ var _objDefineProperty = ObjDefineProperty;
360
442
  var _objKeys = ObjClass.keys;
361
443
  var StringProto = String[strShimPrototype];
362
444
  var _strTrim = StringProto[cStrTrim];
@@ -365,23 +447,7 @@
365
447
  var _isArray = Array.isArray;
366
448
  var _objToString = ObjProto[strToString];
367
449
  var _fnToString = ObjHasOwnProperty[strToString];
368
- var _objFunctionString = _fnToString.call(ObjClass);
369
- var rCamelCase = /-([a-z])/g;
370
- var rNormalizeInvalid = /([^\w\d_$])/g;
371
- var rLeadingNumeric = /^(\d+[\w\d_$])/;
372
- var _objGetPrototypeOf = Object["getPrototypeOf"];
373
- function _getObjProto(target) {
374
- if (target) {
375
- if (_objGetPrototypeOf) {
376
- return _objGetPrototypeOf(target);
377
- }
378
- var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
379
- if (newProto) {
380
- return newProto;
381
- }
382
- }
383
- return null;
384
- }
450
+ _fnToString.call(ObjClass);
385
451
  function isUndefined(value) {
386
452
  return value === undefined || typeof value === strShimUndefined;
387
453
  }
@@ -394,18 +460,24 @@
394
460
  function isFunction(value) {
395
461
  return !!(value && typeof value === strShimFunction);
396
462
  }
397
- function normalizeJsName(name) {
398
- var value = name;
399
- if (value && isString(value)) {
400
- value = value.replace(rCamelCase, function (_all, letter) {
401
- return letter.toUpperCase();
402
- });
403
- value = value.replace(rNormalizeInvalid, "_");
404
- value = value.replace(rLeadingNumeric, function (_all, match) {
405
- return "_" + match;
406
- });
463
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
464
+ if (useCapture === void 0) { useCapture = false; }
465
+ var result = false;
466
+ if (!isNullOrUndefined(obj)) {
467
+ try {
468
+ if (!isNullOrUndefined(obj[strAddEventHelper])) {
469
+ obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
470
+ result = true;
471
+ }
472
+ else if (!isNullOrUndefined(obj[strAttachEvent])) {
473
+ obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
474
+ result = true;
475
+ }
476
+ }
477
+ catch (e) {
478
+ }
407
479
  }
408
- return value;
480
+ return result;
409
481
  }
410
482
  function objForEachKey(target, callbackfn) {
411
483
  if (target) {
@@ -435,25 +507,6 @@
435
507
  function isNumber(value) {
436
508
  return typeof value === "number";
437
509
  }
438
- function isBoolean(value) {
439
- return typeof value === "boolean";
440
- }
441
- function isPlainObject(value) {
442
- var result = false;
443
- if (value && typeof value === "object") {
444
- var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
445
- if (!proto) {
446
- result = true;
447
- }
448
- else {
449
- if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
450
- proto = proto[strConstructor];
451
- }
452
- result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
453
- }
454
- }
455
- return result;
456
- }
457
510
  function toISOString(date) {
458
511
  if (date) {
459
512
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -573,7 +626,7 @@
573
626
  return result;
574
627
  }
575
628
  function objDefineAccessors(target, prop, getProp, setProp) {
576
- if (_objDefineProperty$1) {
629
+ if (_objDefineProperty) {
577
630
  try {
578
631
  var descriptor = {
579
632
  enumerable: true,
@@ -585,7 +638,7 @@
585
638
  if (setProp) {
586
639
  descriptor.set = setProp;
587
640
  }
588
- _objDefineProperty$1(target, prop, descriptor);
641
+ _objDefineProperty(target, prop, descriptor);
589
642
  return true;
590
643
  }
591
644
  catch (e) {
@@ -593,10 +646,6 @@
593
646
  }
594
647
  return false;
595
648
  }
596
- function _doNothing(value) {
597
- return value;
598
- }
599
- var objFreeze = _objFreeze || _doNothing;
600
649
  function dateNow() {
601
650
  var dt = Date;
602
651
  return dt.now ? dt.now() : new dt().getTime();
@@ -605,7 +654,7 @@
605
654
  if (isError(object)) {
606
655
  return object.name;
607
656
  }
608
- return strEmpty$1;
657
+ return "";
609
658
  }
610
659
  function setValue(target, field, value, valChk, srcChk) {
611
660
  var theValue = value;
@@ -624,33 +673,6 @@
624
673
  function throwError(message) {
625
674
  throw new Error(message);
626
675
  }
627
- function _createProxyFunction(source, funcName) {
628
- var srcFunc = null;
629
- var src = null;
630
- if (isFunction(source)) {
631
- srcFunc = source;
632
- }
633
- else {
634
- src = source;
635
- }
636
- return function () {
637
- var originalArguments = arguments;
638
- if (srcFunc) {
639
- src = srcFunc();
640
- }
641
- if (src) {
642
- return src[funcName].apply(src, originalArguments);
643
- }
644
- };
645
- }
646
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
647
- if (overwriteTarget === void 0) { overwriteTarget = true; }
648
- if (target && name && source) {
649
- if (overwriteTarget || isUndefined(target[name])) {
650
- target[name] = _createProxyFunction(source, theFunc);
651
- }
652
- }
653
- }
654
676
  function createClassFromInterface(defaults) {
655
677
  return /** @class */ (function () {
656
678
  function class_1() {
@@ -664,67 +686,12 @@
664
686
  return class_1;
665
687
  }());
666
688
  }
667
- function createEnumStyle(values) {
668
- var enumClass = {};
669
- objForEachKey(values, function (field, value) {
670
- enumClass[field] = value;
671
- if (!isUndefined(enumClass[value])) {
672
- throwError("[" + value + "] exists for " + field);
673
- }
674
- enumClass[value] = field;
675
- });
676
- return objFreeze(enumClass);
677
- }
678
689
  function optimizeObject(theObject) {
679
690
  if (theObject && ObjAssign) {
680
691
  theObject = ObjClass(ObjAssign({}, theObject));
681
692
  }
682
693
  return theObject;
683
694
  }
684
- function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
685
- var theArgs = arguments;
686
- var extended = theArgs[0] || {};
687
- var argLen = theArgs.length;
688
- var deep = false;
689
- var idx = 1;
690
- if (argLen > 0 && isBoolean(extended)) {
691
- deep = extended;
692
- extended = theArgs[idx] || {};
693
- idx++;
694
- }
695
- if (!isObject(extended)) {
696
- extended = {};
697
- }
698
- for (; idx < argLen; idx++) {
699
- var arg = theArgs[idx];
700
- var isArgArray = isArray(arg);
701
- var isArgObj = isObject(arg);
702
- for (var prop in arg) {
703
- var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
704
- if (!propOk) {
705
- continue;
706
- }
707
- var newValue = arg[prop];
708
- var isNewArray = void 0;
709
- if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
710
- var clone = extended[prop];
711
- if (isNewArray) {
712
- if (!isArray(clone)) {
713
- clone = [];
714
- }
715
- }
716
- else if (!isPlainObject(clone)) {
717
- clone = {};
718
- }
719
- newValue = objExtend(deep, clone, newValue);
720
- }
721
- if (newValue !== undefined) {
722
- extended[prop] = newValue;
723
- }
724
- }
725
- }
726
- return extended;
727
- }
728
695
 
729
696
  var strWindow = "window";
730
697
  var strDocument = "document";
@@ -732,13 +699,8 @@
732
699
  var strNavigator = "navigator";
733
700
  var strConsole = "console";
734
701
  var strJSON = "JSON";
735
- var strCrypto = "crypto";
736
- var strMsCrypto = "msCrypto";
737
702
  var strMsie = "msie";
738
703
  var strTrident = "trident/";
739
- var strXMLHttpRequest = "XMLHttpRequest";
740
- var _isTrident = null;
741
- var _navUserAgentCheck = null;
742
704
  var _useXDomainRequest = null;
743
705
  var _beaconsSupported = null;
744
706
  function _hasProperty(theClass, property) {
@@ -818,28 +780,13 @@
818
780
  }
819
781
  return null;
820
782
  }
821
- function getCrypto() {
822
- return getGlobalInst(strCrypto);
823
- }
824
- function getMsCrypto() {
825
- return getGlobalInst(strMsCrypto);
826
- }
827
- function isIE() {
828
- var nav = getNavigator();
829
- if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
830
- _navUserAgentCheck = nav.userAgent;
831
- var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
832
- _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
833
- }
834
- return _isTrident;
835
- }
836
783
  function getIEVersion(userAgentStr) {
837
784
  if (userAgentStr === void 0) { userAgentStr = null; }
838
785
  if (!userAgentStr) {
839
786
  var navigator_1 = getNavigator() || {};
840
- userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
787
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
841
788
  }
842
- var ua = (userAgentStr || strEmpty$1).toLowerCase();
789
+ var ua = (userAgentStr || "").toLowerCase();
843
790
  if (strContains(ua, strMsie)) {
844
791
  var doc = getDocument() || {};
845
792
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -854,7 +801,7 @@
854
801
  }
855
802
  function dumpObj(object) {
856
803
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
857
- var propertyValueDump = strEmpty$1;
804
+ var propertyValueDump = "";
858
805
  if (objectTypeDump === "[object Error]") {
859
806
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
860
807
  }
@@ -872,7 +819,8 @@
872
819
  function isFetchSupported(withKeepAlive) {
873
820
  var isSupported = false;
874
821
  try {
875
- isSupported = !!getGlobalInst("fetch");
822
+ var fetchApi = getGlobalInst("fetch");
823
+ isSupported = !!fetchApi;
876
824
  var request = getGlobalInst("Request");
877
825
  if (isSupported && withKeepAlive && request) {
878
826
  isSupported = _hasProperty(request, "keepalive");
@@ -884,9 +832,9 @@
884
832
  }
885
833
  function useXDomainRequest() {
886
834
  if (_useXDomainRequest === null) {
887
- _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
835
+ _useXDomainRequest = (typeof XDomainRequest !== "undefined");
888
836
  if (_useXDomainRequest && isXhrSupported()) {
889
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
837
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
890
838
  }
891
839
  }
892
840
  return _useXDomainRequest;
@@ -894,7 +842,7 @@
894
842
  function isXhrSupported() {
895
843
  var isSupported = false;
896
844
  try {
897
- var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
845
+ var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
898
846
  isSupported = !!xmlHttpRequest;
899
847
  }
900
848
  catch (e) {
@@ -925,9 +873,9 @@
925
873
  var strWarnToConsole = "warnToConsole";
926
874
  function _sanitizeDiagnosticText(text) {
927
875
  if (text) {
928
- return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
876
+ return "\"" + text.replace(/\"/g, "") + "\"";
929
877
  }
930
- return strEmpty$1;
878
+ return "";
931
879
  }
932
880
  function _logToConsole(func, message) {
933
881
  var theConsole = getConsole();
@@ -949,12 +897,12 @@
949
897
  _self.message =
950
898
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
951
899
  msgId;
952
- var strProps = strEmpty$1;
900
+ var strProps = "";
953
901
  if (hasJSON()) {
954
902
  strProps = getJSON().stringify(properties);
955
903
  }
956
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
957
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
904
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
905
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
958
906
  _self.message += diagnosticText;
959
907
  }
960
908
  _InternalLogMessage.dataType = "MessageData";
@@ -981,10 +929,10 @@
981
929
  if (isUserAct === void 0) { isUserAct = false; }
982
930
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
983
931
  if (_self.enableDebugExceptions()) {
984
- throw message;
932
+ throw dumpObj(message);
985
933
  }
986
934
  else {
987
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
935
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
988
936
  if (!isUndefined(message.message)) {
989
937
  var logLevel = _self.consoleLoggingLevel();
990
938
  if (isUserAct) {
@@ -1002,7 +950,7 @@
1002
950
  _self.logInternalMessage(severity, message);
1003
951
  }
1004
952
  else {
1005
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
953
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1006
954
  }
1007
955
  }
1008
956
  };
@@ -1034,13 +982,13 @@
1034
982
  if (severity <= _self.telemetryLoggingLevel()) {
1035
983
  _self.queue.push(message);
1036
984
  _messageCount++;
1037
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
985
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1038
986
  }
1039
987
  if (_messageCount === _self.maxInternalMessageLimit()) {
1040
988
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1041
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
989
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1042
990
  _self.queue.push(throttleMessage);
1043
- if (severity === 1 ) {
991
+ if (severity === LoggingSeverity.CRITICAL) {
1044
992
  _self.errorToConsole(throttleLimitMessage);
1045
993
  }
1046
994
  else {
@@ -1069,10 +1017,6 @@
1069
1017
  }
1070
1018
  return DiagnosticLogger;
1071
1019
  }());
1072
- function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1073
- if (isUserAct === void 0) { isUserAct = false; }
1074
- (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1075
- }
1076
1020
 
1077
1021
  var strExecutionContextKey = "ctx";
1078
1022
  var PerfEvent = /** @class */ (function () {
@@ -1186,616 +1130,207 @@
1186
1130
  return func();
1187
1131
  }
1188
1132
 
1189
- var UInt32Mask = 0x100000000;
1190
- var MaxUInt32 = 0xffffffff;
1191
- var _mwcSeeded = false;
1192
- var _mwcW = 123456789;
1193
- var _mwcZ = 987654321;
1194
- function _mwcSeed(seedValue) {
1195
- if (seedValue < 0) {
1196
- seedValue >>>= 0;
1197
- }
1198
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1199
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1200
- _mwcSeeded = true;
1201
- }
1202
- function _autoSeedMwc() {
1203
- try {
1204
- var now = dateNow() & 0x7fffffff;
1205
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1206
- }
1207
- catch (e) {
1208
- }
1209
- }
1210
- function random32(signed) {
1211
- var value = 0;
1212
- var c = getCrypto() || getMsCrypto();
1213
- if (c && c.getRandomValues) {
1214
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1215
- }
1216
- if (value === 0 && isIE()) {
1217
- if (!_mwcSeeded) {
1218
- _autoSeedMwc();
1219
- }
1220
- value = mwcRandom32() & MaxUInt32;
1221
- }
1222
- if (value === 0) {
1223
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1224
- }
1225
- if (!signed) {
1226
- value >>>= 0;
1227
- }
1228
- return value;
1229
- }
1230
- function mwcRandom32(signed) {
1231
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1232
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1233
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1234
- if (!signed) {
1235
- value >>>= 0;
1236
- }
1237
- return value;
1238
- }
1239
- function newId(maxLength) {
1240
- if (maxLength === void 0) { maxLength = 22; }
1241
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1242
- var number = random32() >>> 0;
1243
- var chars = 0;
1244
- var result = strEmpty$1;
1245
- while (result.length < maxLength) {
1246
- chars++;
1247
- result += base64chars.charAt(number & 0x3F);
1248
- number >>>= 6;
1249
- if (chars === 5) {
1250
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1251
- chars = 0;
1252
- }
1253
- }
1254
- return result;
1255
- }
1256
-
1257
- var _objDefineProperty = ObjDefineProperty;
1258
- var version = "2.7.5-nightly.2204-03";
1259
- var instanceName = "." + newId(6);
1260
- var _dataUid = 0;
1261
- function _createAccessor(target, prop, value) {
1262
- if (_objDefineProperty) {
1263
- try {
1264
- _objDefineProperty(target, prop, {
1265
- value: value,
1266
- enumerable: false,
1267
- configurable: true
1268
- });
1269
- return true;
1270
- }
1271
- catch (e) {
1272
- }
1273
- }
1274
- return false;
1275
- }
1276
- function _canAcceptData(target) {
1277
- return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1278
- }
1279
- function _getCache(data, target) {
1280
- var theCache = target[data.id];
1281
- if (!theCache) {
1282
- theCache = {};
1283
- try {
1284
- if (_canAcceptData(target)) {
1285
- if (!_createAccessor(target, data.id, theCache)) {
1286
- target[data.id] = theCache;
1287
- }
1288
- }
1289
- }
1290
- catch (e) {
1291
- }
1292
- }
1293
- return theCache;
1294
- }
1295
- function createUniqueNamespace(name, includeVersion) {
1296
- if (includeVersion === void 0) { includeVersion = false; }
1297
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1298
- }
1299
- function createElmNodeData(name) {
1300
- var data = {
1301
- id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1302
- accept: function (target) {
1303
- return _canAcceptData(target);
1304
- },
1305
- get: function (target, name, defValue, addDefault) {
1306
- var theCache = target[data.id];
1307
- if (!theCache) {
1308
- if (addDefault) {
1309
- theCache = _getCache(data, target);
1310
- theCache[normalizeJsName(name)] = defValue;
1311
- }
1312
- return defValue;
1313
- }
1314
- return theCache[normalizeJsName(name)];
1315
- },
1316
- kill: function (target, name) {
1317
- if (target && target[name]) {
1318
- try {
1319
- delete target[name];
1320
- }
1321
- catch (e) {
1322
- }
1133
+ var TelemetryPluginChain = /** @class */ (function () {
1134
+ function TelemetryPluginChain(plugin, defItemCtx) {
1135
+ var _self = this;
1136
+ var _nextProxy = null;
1137
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1138
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
1139
+ _self._hasRun = false;
1140
+ _self.getPlugin = function () {
1141
+ return plugin;
1142
+ };
1143
+ _self.getNext = function () {
1144
+ return _nextProxy;
1145
+ };
1146
+ _self.setNext = function (nextPlugin) {
1147
+ _nextProxy = nextPlugin;
1148
+ };
1149
+ _self.processTelemetry = function (env, itemCtx) {
1150
+ if (!itemCtx) {
1151
+ itemCtx = defItemCtx;
1323
1152
  }
1324
- }
1325
- };
1326
- return data;
1327
- }
1328
-
1329
- var pluginStateData = createElmNodeData("plugin");
1330
- function _getPluginState(plugin) {
1331
- return pluginStateData.get(plugin, "state", {}, true);
1332
- }
1333
-
1334
- var strTelemetryPluginChain = "TelemetryPluginChain";
1335
- var strHasRunFlags = "_hasRun";
1336
- var strGetTelCtx = "_getTelCtx";
1337
- var _chainId = 0;
1338
- function _getNextProxyStart(proxy, config, core, startAt) {
1339
- while (proxy) {
1340
- if (proxy.getPlugin() === startAt) {
1341
- return proxy;
1342
- }
1343
- proxy = proxy.getNext();
1344
- }
1345
- return createTelemetryProxyChain([startAt], config, core);
1346
- }
1347
- function _createInternalContext(telemetryChain, config, core, startAt) {
1348
- var _nextProxy = null;
1349
- var _onComplete = [];
1350
- if (startAt !== null) {
1351
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1352
- }
1353
- var context = {
1354
- _next: _moveNext,
1355
- ctx: {
1356
- core: function () {
1357
- return core;
1358
- },
1359
- diagLog: function () {
1360
- return safeGetLogger(core, config);
1361
- },
1362
- getCfg: function () {
1363
- return config;
1364
- },
1365
- getExtCfg: _getExtCfg,
1366
- getConfig: _getConfig,
1367
- hasNext: function () {
1368
- return !!_nextProxy;
1369
- },
1370
- getNext: function () {
1371
- return _nextProxy;
1372
- },
1373
- setNext: function (nextPlugin) {
1374
- _nextProxy = nextPlugin;
1375
- },
1376
- iterate: _iterateChain,
1377
- onComplete: _addOnComplete
1378
- }
1379
- };
1380
- function _addOnComplete(onComplete, that) {
1381
- var args = [];
1382
- for (var _i = 2; _i < arguments.length; _i++) {
1383
- args[_i - 2] = arguments[_i];
1384
- }
1385
- if (onComplete) {
1386
- _onComplete.push({
1387
- func: onComplete,
1388
- self: !isUndefined(that) ? that : context.ctx,
1389
- args: args
1390
- });
1391
- }
1392
- }
1393
- function _moveNext() {
1394
- var nextProxy = _nextProxy;
1395
- _nextProxy = nextProxy ? nextProxy.getNext() : null;
1396
- if (!nextProxy) {
1397
- var onComplete = _onComplete;
1398
- if (onComplete && onComplete.length > 0) {
1399
- arrForEach(onComplete, function (completeDetails) {
1153
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1154
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1155
+ if (plugin && _hasProcessTelemetry) {
1156
+ _self._hasRun = true;
1400
1157
  try {
1401
- completeDetails.func.call(completeDetails.self, completeDetails.args);
1402
- }
1403
- catch (e) {
1404
- _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1158
+ itemCtx.setNext(_nextProxy);
1159
+ if (_hasSetNext) {
1160
+ plugin.setNextPlugin(_nextProxy);
1161
+ }
1162
+ _nextProxy && (_nextProxy._hasRun = false);
1163
+ plugin.processTelemetry(env, itemCtx);
1405
1164
  }
1406
- });
1407
- _onComplete = [];
1408
- }
1409
- }
1410
- return nextProxy;
1411
- }
1412
- function _getExtCfg(identifier, defaultValue, mergeDefault) {
1413
- if (defaultValue === void 0) { defaultValue = {}; }
1414
- if (mergeDefault === void 0) { mergeDefault = 0 ; }
1415
- var theConfig;
1416
- if (config) {
1417
- var extConfig = config.extensionConfig;
1418
- if (extConfig && identifier) {
1419
- theConfig = extConfig[identifier];
1420
- }
1421
- }
1422
- if (!theConfig) {
1423
- theConfig = defaultValue;
1424
- }
1425
- else if (isObject(defaultValue)) {
1426
- if (mergeDefault !== 0 ) {
1427
- var newConfig_1 = objExtend(true, defaultValue, theConfig);
1428
- if (config && mergeDefault === 2 ) {
1429
- objForEachKey(defaultValue, function (field) {
1430
- if (isNullOrUndefined(newConfig_1[field])) {
1431
- var cfgValue = config[field];
1432
- if (!isNullOrUndefined(cfgValue)) {
1433
- newConfig_1[field] = cfgValue;
1434
- }
1165
+ catch (error) {
1166
+ var hasRun = _nextProxy && _nextProxy._hasRun;
1167
+ if (!_nextProxy || !hasRun) {
1168
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1435
1169
  }
1436
- });
1170
+ if (_nextProxy && !hasRun) {
1171
+ _nextProxy.processTelemetry(env, itemCtx);
1172
+ }
1173
+ }
1437
1174
  }
1438
- }
1439
- }
1440
- return theConfig;
1441
- }
1442
- function _getConfig(identifier, field, defaultValue) {
1443
- if (defaultValue === void 0) { defaultValue = false; }
1444
- var theValue;
1445
- var extConfig = _getExtCfg(identifier, null);
1446
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1447
- theValue = extConfig[field];
1448
- }
1449
- else if (config && !isNullOrUndefined(config[field])) {
1450
- theValue = config[field];
1451
- }
1452
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1453
- }
1454
- function _iterateChain(cb) {
1455
- var nextPlugin;
1456
- while (!!(nextPlugin = context._next())) {
1457
- var plugin = nextPlugin.getPlugin();
1458
- if (plugin) {
1459
- cb(plugin);
1175
+ else if (_nextProxy) {
1176
+ _self._hasRun = true;
1177
+ _nextProxy.processTelemetry(env, itemCtx);
1178
+ }
1179
+ }, function () { return ({ item: env }); }, !(env.sync));
1180
+ };
1181
+ }
1182
+ return TelemetryPluginChain;
1183
+ }());
1184
+
1185
+ function _createProxyChain(plugins, itemCtx) {
1186
+ var proxies = [];
1187
+ if (plugins && plugins.length > 0) {
1188
+ var lastProxy = null;
1189
+ for (var idx = 0; idx < plugins.length; idx++) {
1190
+ var thePlugin = plugins[idx];
1191
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1192
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1193
+ proxies.push(newProxy);
1194
+ if (lastProxy) {
1195
+ lastProxy.setNext(newProxy);
1196
+ }
1197
+ lastProxy = newProxy;
1460
1198
  }
1461
1199
  }
1462
1200
  }
1463
- return context;
1201
+ return proxies.length > 0 ? proxies[0] : null;
1464
1202
  }
1465
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1466
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1467
- var context = internalContext.ctx;
1468
- function _processNext(env) {
1469
- var nextPlugin = internalContext._next();
1470
- nextPlugin && nextPlugin.processTelemetry(env, context);
1471
- return !nextPlugin;
1472
- }
1473
- function _createNew(plugins, startAt) {
1474
- if (plugins === void 0) { plugins = null; }
1475
- if (isArray(plugins)) {
1476
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1203
+ function _copyProxyChain(proxy, itemCtx, startAt) {
1204
+ var plugins = [];
1205
+ var add = startAt ? false : true;
1206
+ if (proxy) {
1207
+ while (proxy) {
1208
+ var thePlugin = proxy.getPlugin();
1209
+ if (add || thePlugin === startAt) {
1210
+ add = true;
1211
+ plugins.push(thePlugin);
1212
+ }
1213
+ proxy = proxy.getNext();
1477
1214
  }
1478
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1479
1215
  }
1480
- context.processNext = _processNext;
1481
- context.createNew = _createNew;
1482
- return context;
1483
- }
1484
- function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1485
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1486
- var context = internalContext.ctx;
1487
- function _processNext(unloadState) {
1488
- var nextPlugin = internalContext._next();
1489
- nextPlugin && nextPlugin.unload(context, unloadState);
1490
- return !nextPlugin;
1491
- }
1492
- function _createNew(plugins, startAt) {
1493
- if (plugins === void 0) { plugins = null; }
1494
- if (isArray(plugins)) {
1495
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1496
- }
1497
- return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1216
+ if (!add) {
1217
+ plugins.push(startAt);
1498
1218
  }
1499
- context.processNext = _processNext;
1500
- context.createNew = _createNew;
1501
- return context;
1219
+ return _createProxyChain(plugins, itemCtx);
1502
1220
  }
1503
- function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1504
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1505
- var context = internalContext.ctx;
1506
- function _processNext(updateState) {
1507
- return context.iterate(function (plugin) {
1508
- if (isFunction(plugin[strUpdate])) {
1509
- plugin[strUpdate](context, updateState);
1221
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1222
+ var plugins = srcPlugins;
1223
+ var add = false;
1224
+ if (startAt && srcPlugins) {
1225
+ plugins = [];
1226
+ arrForEach(srcPlugins, function (thePlugin) {
1227
+ if (add || thePlugin === startAt) {
1228
+ add = true;
1229
+ plugins.push(thePlugin);
1510
1230
  }
1511
1231
  });
1512
1232
  }
1513
- function _createNew(plugins, startAt) {
1514
- if (plugins === void 0) { plugins = null; }
1515
- if (isArray(plugins)) {
1516
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1233
+ if (startAt && !add) {
1234
+ if (!plugins) {
1235
+ plugins = [];
1517
1236
  }
1518
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1237
+ plugins.push(startAt);
1519
1238
  }
1520
- context.processNext = _processNext;
1521
- context.createNew = _createNew;
1522
- return context;
1239
+ return _createProxyChain(plugins, itemCtx);
1523
1240
  }
1524
- function createTelemetryProxyChain(plugins, config, core, startAt) {
1525
- var firstProxy = null;
1526
- var add = startAt ? false : true;
1527
- if (isArray(plugins) && plugins.length > 0) {
1528
- var lastProxy_1 = null;
1529
- arrForEach(plugins, function (thePlugin) {
1530
- if (!add && startAt === thePlugin) {
1531
- add = true;
1241
+ var ProcessTelemetryContext = /** @class */ (function () {
1242
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1243
+ var _self = this;
1244
+ var _nextProxy = null;
1245
+ if (startAt !== null) {
1246
+ if (plugins && isFunction(plugins.getPlugin)) {
1247
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1532
1248
  }
1533
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1534
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1535
- if (!firstProxy) {
1536
- firstProxy = newProxy;
1249
+ else {
1250
+ if (startAt) {
1251
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1537
1252
  }
1538
- if (lastProxy_1) {
1539
- lastProxy_1._setNext(newProxy);
1253
+ else if (isUndefined(startAt)) {
1254
+ _nextProxy = _createProxyChain(plugins, _self);
1540
1255
  }
1541
- lastProxy_1 = newProxy;
1542
1256
  }
1543
- });
1544
- }
1545
- if (startAt && !firstProxy) {
1546
- return createTelemetryProxyChain([startAt], config, core);
1547
- }
1548
- return firstProxy;
1549
- }
1550
- function createTelemetryPluginProxy(plugin, config, core) {
1551
- var nextProxy = null;
1552
- var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1553
- var hasSetNext = isFunction(plugin.setNextPlugin);
1554
- var chainId;
1555
- if (plugin) {
1556
- chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1557
- }
1558
- else {
1559
- chainId = "Unknown-0-" + _chainId++;
1560
- }
1561
- var proxyChain = {
1562
- getPlugin: function () {
1563
- return plugin;
1564
- },
1565
- getNext: function () {
1566
- return nextProxy;
1567
- },
1568
- processTelemetry: _processTelemetry,
1569
- unload: _unloadPlugin,
1570
- update: _updatePlugin,
1571
- _id: chainId,
1572
- _setNext: function (nextPlugin) {
1573
- nextProxy = nextPlugin;
1574
- }
1575
- };
1576
- function _getTelCtx() {
1577
- var itemCtx;
1578
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1579
- itemCtx = plugin[strGetTelCtx]();
1580
1257
  }
1581
- if (!itemCtx) {
1582
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1583
- }
1584
- return itemCtx;
1585
- }
1586
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1587
- var hasRun = false;
1588
- var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1589
- var hasRunContext = itemCtx[strHasRunFlags];
1590
- if (!hasRunContext) {
1591
- hasRunContext = itemCtx[strHasRunFlags] = {};
1592
- }
1593
- itemCtx.setNext(nextProxy);
1594
- if (plugin) {
1595
- doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1596
- hasRunContext[chainId] = true;
1597
- try {
1598
- var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1599
- if (nextId) {
1600
- hasRunContext[nextId] = false;
1601
- }
1602
- hasRun = processPluginFn(itemCtx);
1603
- }
1604
- catch (error) {
1605
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1606
- if (hasNextRun) {
1607
- hasRun = true;
1608
- }
1609
- if (!nextProxy || !hasNextRun) {
1610
- _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1611
- }
1258
+ _self.core = function () {
1259
+ return core;
1260
+ };
1261
+ _self.diagLog = function () {
1262
+ return safeGetLogger(core, config);
1263
+ };
1264
+ _self.getCfg = function () {
1265
+ return config;
1266
+ };
1267
+ _self.getExtCfg = function (identifier, defaultValue) {
1268
+ if (defaultValue === void 0) { defaultValue = {}; }
1269
+ var theConfig;
1270
+ if (config) {
1271
+ var extConfig = config.extensionConfig;
1272
+ if (extConfig && identifier) {
1273
+ theConfig = extConfig[identifier];
1612
1274
  }
1613
- }, details, isAsync);
1614
- }
1615
- return hasRun;
1616
- }
1617
- function _processTelemetry(env, itemCtx) {
1618
- itemCtx = itemCtx || _getTelCtx();
1619
- function _callProcessTelemetry(itemCtx) {
1620
- if (!plugin || !hasProcessTelemetry) {
1621
- return false;
1622
1275
  }
1623
- var pluginState = _getPluginState(plugin);
1624
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1625
- return false;
1276
+ return (theConfig ? theConfig : defaultValue);
1277
+ };
1278
+ _self.getConfig = function (identifier, field, defaultValue) {
1279
+ if (defaultValue === void 0) { defaultValue = false; }
1280
+ var theValue;
1281
+ var extConfig = _self.getExtCfg(identifier, null);
1282
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1283
+ theValue = extConfig[field];
1626
1284
  }
1627
- if (hasSetNext) {
1628
- plugin.setNextPlugin(nextProxy);
1285
+ else if (config && !isNullOrUndefined(config[field])) {
1286
+ theValue = config[field];
1629
1287
  }
1630
- plugin.processTelemetry(env, itemCtx);
1631
- return true;
1632
- }
1633
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1634
- itemCtx.processNext(env);
1635
- }
1636
- }
1637
- function _unloadPlugin(unloadCtx, unloadState) {
1638
- function _callTeardown() {
1639
- var hasRun = false;
1640
- if (plugin) {
1641
- var pluginState = _getPluginState(plugin);
1642
- var pluginCore = plugin[strCore] || pluginState.core;
1643
- if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1644
- pluginState[strCore] = null;
1645
- pluginState[strTeardown] = true;
1646
- pluginState[strIsInitialized] = false;
1647
- if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1648
- hasRun = true;
1649
- }
1650
- }
1651
- }
1652
- return hasRun;
1653
- }
1654
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1655
- unloadCtx.processNext(unloadState);
1656
- }
1657
- }
1658
- function _updatePlugin(updateCtx, updateState) {
1659
- function _callUpdate() {
1660
- var hasRun = false;
1661
- if (plugin) {
1662
- var pluginState = _getPluginState(plugin);
1663
- var pluginCore = plugin[strCore] || pluginState.core;
1664
- if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1665
- if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1666
- hasRun = true;
1667
- }
1668
- }
1288
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1289
+ };
1290
+ _self.hasNext = function () {
1291
+ return _nextProxy != null;
1292
+ };
1293
+ _self.getNext = function () {
1294
+ return _nextProxy;
1295
+ };
1296
+ _self.setNext = function (nextPlugin) {
1297
+ _nextProxy = nextPlugin;
1298
+ };
1299
+ _self.processNext = function (env) {
1300
+ var nextPlugin = _nextProxy;
1301
+ if (nextPlugin) {
1302
+ _nextProxy = nextPlugin.getNext();
1303
+ nextPlugin.processTelemetry(env, _self);
1669
1304
  }
1670
- return hasRun;
1671
- }
1672
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1673
- updateCtx.processNext(updateState);
1674
- }
1305
+ };
1306
+ _self.createNew = function (plugins, startAt) {
1307
+ if (plugins === void 0) { plugins = null; }
1308
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1309
+ };
1675
1310
  }
1676
- return objFreeze(proxyChain);
1677
- }
1311
+ return ProcessTelemetryContext;
1312
+ }());
1678
1313
 
1679
1314
  var strExtensionConfig = "extensionConfig";
1680
1315
 
1681
- function createUnloadHandlerContainer() {
1682
- var handlers = [];
1683
- function _addHandler(handler) {
1684
- if (handler) {
1685
- handlers.push(handler);
1686
- }
1687
- }
1688
- function _runHandlers(unloadCtx, unloadState) {
1689
- arrForEach(handlers, function (handler) {
1690
- try {
1691
- handler(unloadCtx, unloadState);
1692
- }
1693
- catch (e) {
1694
- _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1695
- }
1696
- });
1697
- handlers = [];
1698
- }
1699
- return {
1700
- add: _addHandler,
1701
- run: _runHandlers
1702
- };
1703
- }
1704
-
1705
1316
  var strGetPlugin = "getPlugin";
1706
1317
  var BaseTelemetryPlugin = /** @class */ (function () {
1707
1318
  function BaseTelemetryPlugin() {
1708
1319
  var _self = this;
1709
- var _isinitialized;
1710
- var _rootCtx;
1711
- var _nextPlugin;
1712
- var _unloadHandlerContainer;
1713
- var _hooks;
1714
- _initDefaults();
1715
- dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1716
- _self.initialize = function (config, core, extensions, pluginChain) {
1717
- _setDefaults(config, core, pluginChain);
1718
- _isinitialized = true;
1719
- };
1720
- _self.teardown = function (unloadCtx, unloadState) {
1721
- if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1722
- return;
1723
- }
1724
- var result;
1725
- var unloadDone = false;
1726
- var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1727
- var theUnloadState = unloadState || {
1728
- reason: 0 ,
1729
- isAsync: false
1730
- };
1731
- function _unloadCallback() {
1732
- if (!unloadDone) {
1733
- unloadDone = true;
1734
- _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1735
- arrForEach(_hooks, function (fn) {
1736
- fn.rm();
1737
- });
1738
- _hooks = [];
1739
- if (result === true) {
1740
- theUnloadCtx.processNext(theUnloadState);
1741
- }
1742
- _initDefaults();
1743
- }
1744
- }
1745
- if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1746
- _unloadCallback();
1747
- }
1748
- else {
1749
- result = true;
1750
- }
1751
- return result;
1752
- };
1753
- _self.update = function (updateCtx, updateState) {
1754
- if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1755
- return;
1756
- }
1757
- var result;
1758
- var updateDone = false;
1759
- var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1760
- var theUpdateState = updateState || {
1761
- reason: 0
1762
- };
1763
- function _updateCallback() {
1764
- if (!updateDone) {
1765
- updateDone = true;
1766
- _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1767
- }
1768
- }
1769
- if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1770
- _updateCallback();
1771
- }
1772
- else {
1773
- result = true;
1774
- }
1775
- return result;
1776
- };
1777
- _self._addHook = function (hooks) {
1778
- if (hooks) {
1779
- if (isArray(hooks)) {
1780
- _hooks = _hooks.concat(hooks);
1781
- }
1782
- else {
1783
- _hooks.push(hooks);
1784
- }
1785
- }
1786
- };
1787
- proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1788
- });
1320
+ var _isinitialized = false;
1321
+ var _rootCtx = null;
1322
+ var _nextPlugin = null;
1323
+ _self.core = null;
1789
1324
  _self.diagLog = function (itemCtx) {
1790
- return _getTelCtx(itemCtx).diagLog();
1325
+ return _self._getTelCtx(itemCtx).diagLog();
1791
1326
  };
1792
- _self[strIsInitialized] = function () {
1327
+ _self.isInitialized = function () {
1793
1328
  return _isinitialized;
1794
1329
  };
1795
1330
  _self.setInitialized = function (isInitialized) {
1796
1331
  _isinitialized = isInitialized;
1797
1332
  };
1798
- _self[strSetNextPlugin] = function (next) {
1333
+ _self.setNextPlugin = function (next) {
1799
1334
  _nextPlugin = next;
1800
1335
  };
1801
1336
  _self.processNext = function (env, itemCtx) {
@@ -1806,12 +1341,11 @@
1806
1341
  _nextPlugin.processTelemetry(env, null);
1807
1342
  }
1808
1343
  };
1809
- _self._getTelCtx = _getTelCtx;
1810
- function _getTelCtx(currentCtx) {
1344
+ _self._getTelCtx = function (currentCtx) {
1811
1345
  if (currentCtx === void 0) { currentCtx = null; }
1812
1346
  var itemCtx = currentCtx;
1813
1347
  if (!itemCtx) {
1814
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1348
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1815
1349
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1816
1350
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1817
1351
  }
@@ -1820,8 +1354,8 @@
1820
1354
  }
1821
1355
  }
1822
1356
  return itemCtx;
1823
- }
1824
- function _setDefaults(config, core, pluginChain) {
1357
+ };
1358
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1825
1359
  if (config) {
1826
1360
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1827
1361
  }
@@ -1833,280 +1367,16 @@
1833
1367
  nextPlugin = _nextPlugin[strGetPlugin]();
1834
1368
  }
1835
1369
  _self.core = core;
1836
- _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1837
- }
1838
- function _initDefaults() {
1839
- _isinitialized = false;
1840
- _self.core = null;
1841
- _rootCtx = null;
1842
- _nextPlugin = null;
1843
- _hooks = [];
1844
- _unloadHandlerContainer = createUnloadHandlerContainer();
1845
- }
1370
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1371
+ _isinitialized = true;
1372
+ };
1846
1373
  }
1374
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1375
+ this._baseTelInit(config, core, extensions, pluginChain);
1376
+ };
1847
1377
  return BaseTelemetryPlugin;
1848
1378
  }());
1849
1379
 
1850
- var strOnPrefix = "on";
1851
- var strAttachEvent = "attachEvent";
1852
- var strAddEventHelper = "addEventListener";
1853
- var strDetachEvent = "detachEvent";
1854
- var strRemoveEventListener = "removeEventListener";
1855
- var strEvents = "events";
1856
- createUniqueNamespace("aiEvtPageHide");
1857
- createUniqueNamespace("aiEvtPageShow");
1858
- var rRemoveEmptyNs = /\.[\.]+/g;
1859
- var rRemoveTrailingEmptyNs = /[\.]+$/;
1860
- var _guid = 1;
1861
- var elmNodeData = createElmNodeData("events");
1862
- var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1863
- function _normalizeNamespace(name) {
1864
- if (name && name.replace) {
1865
- return name.replace(/^\s*\.*|\.*\s*$/g, "");
1866
- }
1867
- return name;
1868
- }
1869
- function _getEvtNamespace(eventName, evtNamespace) {
1870
- if (evtNamespace) {
1871
- var theNamespace_1 = "";
1872
- if (isArray(evtNamespace)) {
1873
- theNamespace_1 = "";
1874
- arrForEach(evtNamespace, function (name) {
1875
- name = _normalizeNamespace(name);
1876
- if (name) {
1877
- if (name[0] !== ".") {
1878
- name = "." + name;
1879
- }
1880
- theNamespace_1 += name;
1881
- }
1882
- });
1883
- }
1884
- else {
1885
- theNamespace_1 = _normalizeNamespace(evtNamespace);
1886
- }
1887
- if (theNamespace_1) {
1888
- if (theNamespace_1[0] !== ".") {
1889
- theNamespace_1 = "." + theNamespace_1;
1890
- }
1891
- eventName = (eventName || "") + theNamespace_1;
1892
- }
1893
- }
1894
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
1895
- return {
1896
- type: parsedEvent[1],
1897
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
1898
- };
1899
- }
1900
- function _getRegisteredEvents(target, evtName, addDefault) {
1901
- if (addDefault === void 0) { addDefault = true; }
1902
- var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1903
- var registeredEvents = aiEvts[evtName];
1904
- if (!registeredEvents) {
1905
- registeredEvents = aiEvts[evtName] = [];
1906
- }
1907
- return registeredEvents;
1908
- }
1909
- function _doDetach(obj, evtName, handlerRef, useCapture) {
1910
- if (obj && evtName && evtName.type) {
1911
- if (obj[strRemoveEventListener]) {
1912
- obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
1913
- }
1914
- else if (obj[strDetachEvent]) {
1915
- obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
1916
- }
1917
- }
1918
- }
1919
- function _doAttach(obj, evtName, handlerRef, useCapture) {
1920
- var result = false;
1921
- if (obj && evtName && evtName.type && handlerRef) {
1922
- if (obj[strAddEventHelper]) {
1923
- obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1924
- result = true;
1925
- }
1926
- else if (obj[strAttachEvent]) {
1927
- obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1928
- result = true;
1929
- }
1930
- }
1931
- return result;
1932
- }
1933
- function _doUnregister(target, events, evtName, unRegFn) {
1934
- var idx = events.length;
1935
- while (idx--) {
1936
- var theEvent = events[idx];
1937
- if (theEvent) {
1938
- if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
1939
- if (!unRegFn || unRegFn(theEvent)) {
1940
- _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
1941
- events.splice(idx, 1);
1942
- }
1943
- }
1944
- }
1945
- }
1946
- }
1947
- function _unregisterEvents(target, evtName, unRegFn) {
1948
- if (evtName.type) {
1949
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1950
- }
1951
- else {
1952
- var eventCache = elmNodeData.get(target, strEvents, {});
1953
- objForEachKey(eventCache, function (evtType, events) {
1954
- _doUnregister(target, events, evtName, unRegFn);
1955
- });
1956
- if (objKeys(eventCache).length === 0) {
1957
- elmNodeData.kill(target, strEvents);
1958
- }
1959
- }
1960
- }
1961
- function mergeEvtNamespace(theNamespace, namespaces) {
1962
- var newNamespaces;
1963
- if (namespaces) {
1964
- if (isArray(namespaces)) {
1965
- newNamespaces = [theNamespace].concat(namespaces);
1966
- }
1967
- else {
1968
- newNamespaces = [theNamespace, namespaces];
1969
- }
1970
- newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1971
- }
1972
- else {
1973
- newNamespaces = theNamespace;
1974
- }
1975
- return newNamespaces;
1976
- }
1977
- function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1978
- if (useCapture === void 0) { useCapture = false; }
1979
- var result = false;
1980
- if (target) {
1981
- try {
1982
- var evtName = _getEvtNamespace(eventName, evtNamespace);
1983
- result = _doAttach(target, evtName, handlerRef, useCapture);
1984
- if (result && elmNodeData.accept(target)) {
1985
- var registeredEvent = {
1986
- guid: _guid++,
1987
- evtName: evtName,
1988
- handler: handlerRef,
1989
- capture: useCapture
1990
- };
1991
- _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1992
- }
1993
- }
1994
- catch (e) {
1995
- }
1996
- }
1997
- return result;
1998
- }
1999
- function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
2000
- if (useCapture === void 0) { useCapture = false; }
2001
- if (target) {
2002
- try {
2003
- var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
2004
- var found_1 = false;
2005
- _unregisterEvents(target, evtName_1, function (regEvent) {
2006
- if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
2007
- found_1 = true;
2008
- return true;
2009
- }
2010
- return false;
2011
- });
2012
- if (!found_1) {
2013
- _doDetach(target, evtName_1, handlerRef, useCapture);
2014
- }
2015
- }
2016
- catch (e) {
2017
- }
2018
- }
2019
- }
2020
-
2021
- var LoggingSeverity = createEnumStyle({
2022
- CRITICAL: 1 ,
2023
- WARNING: 2
2024
- });
2025
- var _InternalMessageId = createEnumStyle({
2026
- BrowserDoesNotSupportLocalStorage: 0 ,
2027
- BrowserCannotReadLocalStorage: 1 ,
2028
- BrowserCannotReadSessionStorage: 2 ,
2029
- BrowserCannotWriteLocalStorage: 3 ,
2030
- BrowserCannotWriteSessionStorage: 4 ,
2031
- BrowserFailedRemovalFromLocalStorage: 5 ,
2032
- BrowserFailedRemovalFromSessionStorage: 6 ,
2033
- CannotSendEmptyTelemetry: 7 ,
2034
- ClientPerformanceMathError: 8 ,
2035
- ErrorParsingAISessionCookie: 9 ,
2036
- ErrorPVCalc: 10 ,
2037
- ExceptionWhileLoggingError: 11 ,
2038
- FailedAddingTelemetryToBuffer: 12 ,
2039
- FailedMonitorAjaxAbort: 13 ,
2040
- FailedMonitorAjaxDur: 14 ,
2041
- FailedMonitorAjaxOpen: 15 ,
2042
- FailedMonitorAjaxRSC: 16 ,
2043
- FailedMonitorAjaxSend: 17 ,
2044
- FailedMonitorAjaxGetCorrelationHeader: 18 ,
2045
- FailedToAddHandlerForOnBeforeUnload: 19 ,
2046
- FailedToSendQueuedTelemetry: 20 ,
2047
- FailedToReportDataLoss: 21 ,
2048
- FlushFailed: 22 ,
2049
- MessageLimitPerPVExceeded: 23 ,
2050
- MissingRequiredFieldSpecification: 24 ,
2051
- NavigationTimingNotSupported: 25 ,
2052
- OnError: 26 ,
2053
- SessionRenewalDateIsZero: 27 ,
2054
- SenderNotInitialized: 28 ,
2055
- StartTrackEventFailed: 29 ,
2056
- StopTrackEventFailed: 30 ,
2057
- StartTrackFailed: 31 ,
2058
- StopTrackFailed: 32 ,
2059
- TelemetrySampledAndNotSent: 33 ,
2060
- TrackEventFailed: 34 ,
2061
- TrackExceptionFailed: 35 ,
2062
- TrackMetricFailed: 36 ,
2063
- TrackPVFailed: 37 ,
2064
- TrackPVFailedCalc: 38 ,
2065
- TrackTraceFailed: 39 ,
2066
- TransmissionFailed: 40 ,
2067
- FailedToSetStorageBuffer: 41 ,
2068
- FailedToRestoreStorageBuffer: 42 ,
2069
- InvalidBackendResponse: 43 ,
2070
- FailedToFixDepricatedValues: 44 ,
2071
- InvalidDurationValue: 45 ,
2072
- TelemetryEnvelopeInvalid: 46 ,
2073
- CreateEnvelopeError: 47 ,
2074
- CannotSerializeObject: 48 ,
2075
- CannotSerializeObjectNonSerializable: 49 ,
2076
- CircularReferenceDetected: 50 ,
2077
- ClearAuthContextFailed: 51 ,
2078
- ExceptionTruncated: 52 ,
2079
- IllegalCharsInName: 53 ,
2080
- ItemNotInArray: 54 ,
2081
- MaxAjaxPerPVExceeded: 55 ,
2082
- MessageTruncated: 56 ,
2083
- NameTooLong: 57 ,
2084
- SampleRateOutOfRange: 58 ,
2085
- SetAuthContextFailed: 59 ,
2086
- SetAuthContextFailedAccountName: 60 ,
2087
- StringValueTooLong: 61 ,
2088
- StartCalledMoreThanOnce: 62 ,
2089
- StopCalledWithoutStart: 63 ,
2090
- TelemetryInitializerFailed: 64 ,
2091
- TrackArgumentsNotSpecified: 65 ,
2092
- UrlTooLong: 66 ,
2093
- SessionStorageBufferFull: 67 ,
2094
- CannotAccessCookie: 68 ,
2095
- IdTooLong: 69 ,
2096
- InvalidEvent: 70 ,
2097
- FailedMonitorAjaxSetRequestHeader: 71 ,
2098
- SendBrowserInfoOnUserInit: 72 ,
2099
- PluginException: 73 ,
2100
- NotificationException: 74 ,
2101
- SnippetScriptLoadFailure: 99 ,
2102
- InvalidInstrumentationKey: 100 ,
2103
- CannotParseAiBlobValue: 101 ,
2104
- InvalidContentBlob: 102 ,
2105
- TrackPageActionEventFailed: 103 ,
2106
- FailedAddingCustomDefinedRequestContext: 104 ,
2107
- InMemoryStorageBufferFull: 105
2108
- });
2109
-
2110
1380
  var RequestHeaders = {
2111
1381
  requestContextHeader: "Request-Context",
2112
1382
  requestContextTargetKey: "appId",
@@ -2139,7 +1409,7 @@
2139
1409
  name = strTrim(name.toString());
2140
1410
  if (name.length > 150 ) {
2141
1411
  nameTrunc = name.substring(0, 150 );
2142
- _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1412
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2143
1413
  }
2144
1414
  }
2145
1415
  return nameTrunc || name;
@@ -2152,7 +1422,7 @@
2152
1422
  value = strTrim(value);
2153
1423
  if (value.toString().length > maxLength) {
2154
1424
  valueTrunc = value.toString().substring(0, maxLength);
2155
- _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1425
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2156
1426
  }
2157
1427
  }
2158
1428
  return valueTrunc || value;
@@ -2165,7 +1435,7 @@
2165
1435
  if (message) {
2166
1436
  if (message.length > 32768 ) {
2167
1437
  messageTrunc = message.substring(0, 32768 );
2168
- _throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1438
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2169
1439
  }
2170
1440
  }
2171
1441
  return messageTrunc || message;
@@ -2176,7 +1446,7 @@
2176
1446
  var value = "" + exception;
2177
1447
  if (value.length > 32768 ) {
2178
1448
  exceptionTrunc = value.substring(0, 32768 );
2179
- _throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1449
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2180
1450
  }
2181
1451
  }
2182
1452
  return exceptionTrunc || exception;
@@ -2190,7 +1460,7 @@
2190
1460
  value = getJSON().stringify(value);
2191
1461
  }
2192
1462
  catch (e) {
2193
- _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1463
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2194
1464
  }
2195
1465
  }
2196
1466
  value = dataSanitizeString(logger, value, 8192 );
@@ -2221,7 +1491,7 @@
2221
1491
  input = strTrim(input);
2222
1492
  if (input.length > maxLength) {
2223
1493
  inputTrunc = input.substring(0, maxLength);
2224
- _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1494
+ logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2225
1495
  }
2226
1496
  }
2227
1497
  return inputTrunc || input;
@@ -2231,22 +1501,21 @@
2231
1501
  return s.substr(s.length - 3);
2232
1502
  }
2233
1503
 
2234
- var strEmpty = "";
2235
1504
  function msToTimeSpan(totalms) {
2236
1505
  if (isNaN(totalms) || totalms < 0) {
2237
1506
  totalms = 0;
2238
1507
  }
2239
1508
  totalms = Math.round(totalms);
2240
- var ms = strEmpty + totalms % 1000;
2241
- var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2242
- var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2243
- var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
1509
+ var ms = "" + totalms % 1000;
1510
+ var sec = "" + Math.floor(totalms / 1000) % 60;
1511
+ var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1512
+ var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2244
1513
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2245
1514
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2246
1515
  sec = sec.length < 2 ? "0" + sec : sec;
2247
1516
  min = min.length < 2 ? "0" + min : min;
2248
1517
  hour = hour.length < 2 ? "0" + hour : hour;
2249
- return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1518
+ return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2250
1519
  }
2251
1520
 
2252
1521
  var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
@@ -2255,15 +1524,17 @@
2255
1524
  var HttpMethod = "http.method";
2256
1525
  var strNotSpecified = "not_specified";
2257
1526
 
2258
- var StorageType = createEnumStyle({
2259
- LocalStorage: 0 ,
2260
- SessionStorage: 1
2261
- });
2262
- createEnumStyle({
2263
- AI: 0 ,
2264
- AI_AND_W3C: 1 ,
2265
- W3C: 2
2266
- });
1527
+ var StorageType;
1528
+ (function (StorageType) {
1529
+ StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1530
+ StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1531
+ })(StorageType || (StorageType = {}));
1532
+ var DistributedTracingModes;
1533
+ (function (DistributedTracingModes) {
1534
+ DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1535
+ DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1536
+ DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1537
+ })(DistributedTracingModes || (DistributedTracingModes = {}));
2267
1538
 
2268
1539
  var _canUseSessionStorage = undefined;
2269
1540
  function _getVerifiedStorageObject(storageType) {
@@ -2290,8 +1561,8 @@
2290
1561
  }
2291
1562
  return null;
2292
1563
  }
2293
- function utlCanUseSessionStorage(reset) {
2294
- if (reset || _canUseSessionStorage === undefined) {
1564
+ function utlCanUseSessionStorage() {
1565
+ if (_canUseSessionStorage === undefined) {
2295
1566
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
2296
1567
  }
2297
1568
  return _canUseSessionStorage;
@@ -2304,7 +1575,7 @@
2304
1575
  }
2305
1576
  catch (e) {
2306
1577
  _canUseSessionStorage = false;
2307
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1578
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2308
1579
  }
2309
1580
  }
2310
1581
  return null;
@@ -2318,7 +1589,7 @@
2318
1589
  }
2319
1590
  catch (e) {
2320
1591
  _canUseSessionStorage = false;
2321
- _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1592
+ logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2322
1593
  }
2323
1594
  }
2324
1595
  return false;
@@ -2383,7 +1654,7 @@
2383
1654
  "https://dc-int.services.visualstudio.com/v2/track"
2384
1655
  ];
2385
1656
  function isInternalApplicationInsightsEndpoint(endpointUrl) {
2386
- return _internalEndpoints.indexOf(endpointUrl.toLowerCase()) !== -1;
1657
+ return arrIndexOf(_internalEndpoints, endpointUrl.toLowerCase()) !== -1;
2387
1658
  }
2388
1659
  function AjaxHelperParseDependencyPath(logger, absoluteUrl, method, commandName) {
2389
1660
  var target, name = commandName, data = commandName;
@@ -3595,7 +2866,7 @@
3595
2866
  }
3596
2867
  }
3597
2868
  var EnvelopeCreator = {
3598
- Version: "2.7.5-nightly.2204-03"
2869
+ Version: "2.7.5-nightly.2204-23"
3599
2870
  };
3600
2871
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
3601
2872
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -3890,81 +3161,65 @@
3890
3161
  return Serializer;
3891
3162
  }());
3892
3163
 
3893
- function _disableEvents(target, evtNamespace) {
3894
- eventOff(target, null, null, evtNamespace);
3895
- }
3896
- function createOfflineListener(parentEvtNamespace) {
3897
- var _document = getDocument();
3898
- var _navigator = getNavigator();
3899
- var _isListening = false;
3900
- var _onlineStatus = true;
3901
- var _evtNamespace = mergeEvtNamespace(createUniqueNamespace("OfflineListener"), parentEvtNamespace);
3902
- try {
3903
- if (_enableEvents(getWindow())) {
3904
- _isListening = true;
3905
- }
3906
- if (_document) {
3907
- var target = _document.body || _document;
3908
- if (target.ononline) {
3909
- if (_enableEvents(target)) {
3910
- _isListening = true;
3164
+ var OfflineListener = /** @class */ (function () {
3165
+ function OfflineListener() {
3166
+ var _window = getWindow();
3167
+ var _document = getDocument();
3168
+ var isListening = false;
3169
+ var _onlineStatus = true;
3170
+ dynamicProto(OfflineListener, this, function (_self) {
3171
+ try {
3172
+ if (_window) {
3173
+ if (attachEvent(_window, "online", _setOnline)) {
3174
+ attachEvent(_window, "offline", _setOffline);
3175
+ isListening = true;
3176
+ }
3177
+ }
3178
+ if (_document) {
3179
+ var target = _document.body || _document;
3180
+ if (!isUndefined(target.ononline)) {
3181
+ target.ononline = _setOnline;
3182
+ target.onoffline = _setOffline;
3183
+ isListening = true;
3184
+ }
3185
+ }
3186
+ if (isListening) {
3187
+ var _navigator = getNavigator();
3188
+ if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3189
+ _onlineStatus = _navigator.onLine;
3190
+ }
3911
3191
  }
3912
3192
  }
3913
- }
3914
- if (_isListening) {
3915
- if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3916
- _onlineStatus = _navigator.onLine;
3917
- }
3918
- }
3919
- }
3920
- catch (e) {
3921
- _isListening = false;
3922
- }
3923
- function _enableEvents(target) {
3924
- var enabled = false;
3925
- if (target) {
3926
- enabled = eventOn(target, "online", _setOnline, _evtNamespace);
3927
- if (enabled) {
3928
- eventOn(target, "offline", _setOffline, _evtNamespace);
3193
+ catch (e) {
3194
+ isListening = false;
3929
3195
  }
3930
- }
3931
- return enabled;
3932
- }
3933
- function _setOnline() {
3934
- _onlineStatus = true;
3935
- }
3936
- function _setOffline() {
3937
- _onlineStatus = false;
3938
- }
3939
- function _isOnline() {
3940
- var result = true;
3941
- if (_isListening) {
3942
- result = _onlineStatus;
3943
- }
3944
- else if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3945
- result = _navigator.onLine;
3946
- }
3947
- return result;
3948
- }
3949
- function _unload() {
3950
- var win = getWindow();
3951
- if (win && _isListening) {
3952
- _disableEvents(win, _evtNamespace);
3953
- if (_document) {
3954
- var target = _document.body || _document;
3955
- if (!isUndefined(target.ononline)) {
3956
- _disableEvents(target, _evtNamespace);
3196
+ _self.isListening = isListening;
3197
+ _self.isOnline = function () {
3198
+ var result = true;
3199
+ var _navigator = getNavigator();
3200
+ if (isListening) {
3201
+ result = _onlineStatus;
3202
+ }
3203
+ else if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3204
+ result = _navigator.onLine;
3957
3205
  }
3206
+ return result;
3207
+ };
3208
+ _self.isOffline = function () {
3209
+ return !_self.isOnline();
3210
+ };
3211
+ function _setOnline() {
3212
+ _onlineStatus = true;
3958
3213
  }
3959
- _isListening = false;
3960
- }
3214
+ function _setOffline() {
3215
+ _onlineStatus = false;
3216
+ }
3217
+ });
3961
3218
  }
3962
- return {
3963
- isOnline: _isOnline,
3964
- isListening: function () { return _isListening; },
3965
- unload: _unload
3966
- };
3967
- }
3219
+ OfflineListener.Offline = new OfflineListener;
3220
+ return OfflineListener;
3221
+ }());
3222
+ var Offline = OfflineListener.Offline;
3968
3223
 
3969
3224
  var MIN_INPUT_LENGTH = 8;
3970
3225
  var HashCodeScoreGenerator = /** @class */ (function () {
@@ -4092,22 +3347,22 @@
4092
3347
  var _this = _super.call(this) || this;
4093
3348
  _this.priority = 1001;
4094
3349
  _this.identifier = BreezeChannelIdentifier;
4095
- _this._senderConfig = _getDefaultAppInsightsChannelConfig();
4096
3350
  var _consecutiveErrors;
4097
3351
  var _retryAt;
4098
3352
  var _lastSend;
4099
- var _paused;
3353
+ var _paused = false;
4100
3354
  var _timeoutHandle;
4101
3355
  var _serializer;
4102
3356
  var _stamp_specific_redirects;
4103
- var _headers;
3357
+ var _headers = {};
4104
3358
  var _syncFetchPayload = 0;
4105
3359
  var _fallbackSender;
4106
3360
  var _syncUnloadSender;
4107
- var _offlineListener;
4108
- var _evtNamespace;
3361
+ _this._senderConfig = _getDefaultAppInsightsChannelConfig();
4109
3362
  dynamicProto(Sender, _this, function (_self, _base) {
4110
- _initDefaults();
3363
+ function _notImplemented() {
3364
+ throwError("Method not implemented.");
3365
+ }
4111
3366
  _self.pause = function () {
4112
3367
  _clearScheduledTimer();
4113
3368
  _paused = true;
@@ -4122,15 +3377,14 @@
4122
3377
  _setupTimer();
4123
3378
  }
4124
3379
  };
4125
- _self.flush = function (isAsync, callBack, sendReason) {
4126
- if (isAsync === void 0) { isAsync = true; }
3380
+ _self.flush = function () {
4127
3381
  if (!_paused) {
4128
3382
  _clearScheduledTimer();
4129
3383
  try {
4130
- _self.triggerSend(isAsync, null, sendReason || 1 );
3384
+ _self.triggerSend(true, null, 1 );
4131
3385
  }
4132
3386
  catch (e) {
4133
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3387
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4134
3388
  }
4135
3389
  }
4136
3390
  };
@@ -4141,7 +3395,7 @@
4141
3395
  _self.triggerSend(true, _doUnloadSend, 2 );
4142
3396
  }
4143
3397
  catch (e) {
4144
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.FailedToSendQueuedTelemetry, "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3398
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.FailedToSendQueuedTelemetry, "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4145
3399
  }
4146
3400
  }
4147
3401
  else {
@@ -4149,13 +3403,11 @@
4149
3403
  }
4150
3404
  }
4151
3405
  };
3406
+ _self.teardown = _notImplemented;
4152
3407
  _self.addHeader = function (name, value) {
4153
3408
  _headers[name] = value;
4154
3409
  };
4155
3410
  _self.initialize = function (config, core, extensions, pluginChain) {
4156
- if (_self.isInitialized()) {
4157
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender is already initialized");
4158
- }
4159
3411
  _base.initialize(config, core, extensions, pluginChain);
4160
3412
  var ctx = _self._getTelCtx();
4161
3413
  var identifier = _self.identifier;
@@ -4166,8 +3418,6 @@
4166
3418
  _self._sender = null;
4167
3419
  _stamp_specific_redirects = 0;
4168
3420
  var diagLog = _self.diagLog();
4169
- _evtNamespace = mergeEvtNamespace(createUniqueNamespace("Sender"), core.evtNamespace && core.evtNamespace());
4170
- _offlineListener = createOfflineListener(_evtNamespace);
4171
3421
  var defaultConfig = _getDefaultAppInsightsChannelConfig();
4172
3422
  objForEachKey(defaultConfig, function (field, value) {
4173
3423
  _self._senderConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };
@@ -4176,7 +3426,7 @@
4176
3426
  ? new SessionStorageSendBuffer(diagLog, _self._senderConfig) : new ArraySendBuffer(diagLog, _self._senderConfig);
4177
3427
  _self._sample = new Sample(_self._senderConfig.samplingPercentage(), diagLog);
4178
3428
  if (!_validateInstrumentationKey(config)) {
4179
- _throwInternal(diagLog, LoggingSeverity.CRITICAL, _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key " + config.instrumentationKey);
3429
+ diagLog.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key " + config.instrumentationKey);
4180
3430
  }
4181
3431
  if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders().length > 0) {
4182
3432
  arrForEach(_self._senderConfig.customHeaders(), function (customHeader) {
@@ -4222,22 +3472,22 @@
4222
3472
  return;
4223
3473
  }
4224
3474
  if (!telemetryItem) {
4225
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
3475
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
4226
3476
  return;
4227
3477
  }
4228
3478
  if (telemetryItem.baseData && !telemetryItem.baseType) {
4229
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
3479
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
4230
3480
  return;
4231
3481
  }
4232
3482
  if (!telemetryItem.baseType) {
4233
3483
  telemetryItem.baseType = "EventData";
4234
3484
  }
4235
3485
  if (!_self._sender) {
4236
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
3486
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
4237
3487
  return;
4238
3488
  }
4239
3489
  if (!_isSampledIn(telemetryItem)) {
4240
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
3490
+ itemCtx.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
4241
3491
  return;
4242
3492
  }
4243
3493
  else {
@@ -4247,7 +3497,7 @@
4247
3497
  var defaultEnvelopeIkey = telemetryItem.iKey || _self._senderConfig.instrumentationKey();
4248
3498
  var aiEnvelope_1 = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, itemCtx.diagLog(), convertUndefined);
4249
3499
  if (!aiEnvelope_1) {
4250
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
3500
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
4251
3501
  return;
4252
3502
  }
4253
3503
  var doNotSendItem_1 = false;
@@ -4260,7 +3510,7 @@
4260
3510
  }
4261
3511
  }
4262
3512
  catch (e) {
4263
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3513
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
4264
3514
  }
4265
3515
  });
4266
3516
  delete telemetryItem.tags[ProcessLegacy];
@@ -4278,7 +3528,7 @@
4278
3528
  _setupTimer();
4279
3529
  }
4280
3530
  catch (e) {
4281
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.FailedAddingTelemetryToBuffer, "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
3531
+ itemCtx.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.FailedAddingTelemetryToBuffer, "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
4282
3532
  }
4283
3533
  _self.processNext(telemetryItem, itemCtx);
4284
3534
  };
@@ -4313,18 +3563,13 @@
4313
3563
  catch (e) {
4314
3564
  var ieVer = getIEVersion();
4315
3565
  if (!ieVer || ieVer > 9) {
4316
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
3566
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
4317
3567
  }
4318
3568
  }
4319
3569
  }
4320
3570
  };
4321
- _self._doTeardown = function (unloadCtx, unloadState) {
4322
- _self.onunloadFlush();
4323
- _offlineListener.unload();
4324
- _initDefaults();
4325
- };
4326
3571
  _self._onError = function (payload, message, event) {
4327
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.OnError, "Failed to send telemetry.", { message: message });
3572
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.OnError, "Failed to send telemetry.", { message: message });
4328
3573
  _self._buffer.clearSent(payload);
4329
3574
  };
4330
3575
  _self._onPartialSuccess = function (payload, results) {
@@ -4349,7 +3594,7 @@
4349
3594
  }
4350
3595
  if (retry.length > 0) {
4351
3596
  _resendPayload(retry);
4352
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, "Partial success. " +
3597
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, "Partial success. " +
4353
3598
  "Delivered: " + payload.length + ", Failed: " + failed.length +
4354
3599
  ". Will retry to send " + retry.length + " our of " + results.itemsReceived + " items");
4355
3600
  }
@@ -4394,18 +3639,18 @@
4394
3639
  }
4395
3640
  if (!_self._senderConfig.isRetryDisabled() && _isRetriable(status)) {
4396
3641
  _resendPayload(payload);
4397
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
3642
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
4398
3643
  "Response code " + status + ". Will retry to send " + payload.length + " items.");
4399
3644
  }
4400
3645
  else {
4401
3646
  _self._onError(payload, errorMessage);
4402
3647
  }
4403
3648
  }
4404
- else if (_offlineListener && !_offlineListener.isOnline()) {
3649
+ else if (Offline.isOffline()) {
4405
3650
  if (!_self._senderConfig.isRetryDisabled()) {
4406
3651
  var offlineBackOffMultiplier = 10;
4407
3652
  _resendPayload(payload, offlineBackOffMultiplier);
4408
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". Offline - Response Code: ".concat(status, ". Offline status: ").concat(!_offlineListener.isOnline(), ". Will retry to send ").concat(payload.length, " items."));
3653
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". Offline - Response Code: ".concat(status, ". Offline status: ").concat(Offline.isOffline(), ". Will retry to send ").concat(payload.length, " items."));
4409
3654
  }
4410
3655
  }
4411
3656
  else {
@@ -4472,8 +3717,8 @@
4472
3717
  }
4473
3718
  }
4474
3719
  if (droppedPayload.length > 0) {
4475
- _fallbackSender && _fallbackSender(droppedPayload, true);
4476
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
3720
+ _fallbackSender(droppedPayload, true);
3721
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
4477
3722
  }
4478
3723
  }
4479
3724
  }
@@ -4514,7 +3759,7 @@
4514
3759
  }
4515
3760
  else {
4516
3761
  _fallbackSender && _fallbackSender(payload, true);
4517
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
3762
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
4518
3763
  }
4519
3764
  }
4520
3765
  }
@@ -4605,7 +3850,7 @@
4605
3850
  }
4606
3851
  }
4607
3852
  catch (e) {
4608
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidBackendResponse, "Cannot parse the response. " + getExceptionName(e), {
3853
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidBackendResponse, "Cannot parse the response. " + getExceptionName(e), {
4609
3854
  response: response
4610
3855
  });
4611
3856
  }
@@ -4676,7 +3921,7 @@
4676
3921
  xdr.onerror = function (event) { return _self._onError(payload, _formatErrorMessageXdr(xdr), event); };
4677
3922
  var hostingProtocol = _window && _window.location && _window.location.protocol || "";
4678
3923
  if (_self._senderConfig.endpointUrl().lastIndexOf(hostingProtocol, 0) !== 0) {
4679
- _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
3924
+ _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
4680
3925
  "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
4681
3926
  buffer.clear();
4682
3927
  return;
@@ -4707,7 +3952,7 @@
4707
3952
  manager.eventsSendRequest(sendRequest, isAsync);
4708
3953
  }
4709
3954
  catch (e) {
4710
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.NotificationException, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
3955
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.NotificationException, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
4711
3956
  }
4712
3957
  }
4713
3958
  }
@@ -4720,25 +3965,6 @@
4720
3965
  var regexp = new RegExp(UUID_Regex);
4721
3966
  return regexp.test(config.instrumentationKey);
4722
3967
  }
4723
- function _initDefaults() {
4724
- _self._sender = null;
4725
- _self._buffer = null;
4726
- _self._appId = null;
4727
- _self._sample = null;
4728
- _headers = {};
4729
- _offlineListener = null;
4730
- _consecutiveErrors = 0;
4731
- _retryAt = null;
4732
- _lastSend = null;
4733
- _paused = false;
4734
- _timeoutHandle = null;
4735
- _serializer = null;
4736
- _stamp_specific_redirects = 0;
4737
- _syncFetchPayload = 0;
4738
- _fallbackSender = null;
4739
- _syncUnloadSender = null;
4740
- _evtNamespace = null;
4741
- }
4742
3968
  });
4743
3969
  return _this;
4744
3970
  }