@microsoft/applicationinsights-channel-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-04

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 +1363 -719
  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 +56 -58
  7. package/dist/applicationinsights-channel-js.api.md +0 -2
  8. package/dist/applicationinsights-channel-js.d.ts +1 -2
  9. package/dist/applicationinsights-channel-js.js +1363 -719
  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 +1 -2
  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 +77 -65
  18. package/dist-esm/Offline.js.map +1 -1
  19. package/dist-esm/SendBuffer.js +1 -1
  20. package/dist-esm/Sender.js +72 -62
  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 +4 -4
  29. package/src/EnvelopeCreator.ts +2 -2
  30. package/src/Offline.ts +88 -76
  31. package/src/Sender.ts +83 -90
  32. package/src/Serializer.ts +4 -8
  33. package/src/TelemetryProcessors/Sample.ts +1 -1
  34. package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +3 -1
  35. package/types/Offline.d.ts +8 -11
  36. package/types/Sender.d.ts +0 -1
  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.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Channel, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -75,7 +75,9 @@
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) { d.__proto__ = b; }) ||
78
+ ({ __proto__: [] } instanceof Array && function (d, b) {
79
+ d.__proto__ = b;
80
+ }) ||
79
81
  function (d, b) {
80
82
  for (var p in b) {
81
83
  if (b[strShimHasOwnProperty](p)) {
@@ -90,7 +92,9 @@
90
92
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
91
93
  }
92
94
  extendStaticsFn(d, b);
93
- function __() { this.constructor = d; }
95
+ function __() {
96
+ this.constructor = d;
97
+ }
94
98
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
95
99
  }
96
100
 
@@ -109,11 +113,11 @@
109
113
  var DynAllowInstChkTag = DynInstChkTag;
110
114
  var DynProtoDefaultOptions = '_dfOpts';
111
115
  var UnknownValue = '_unknown_';
112
- var str__Proto = "__proto__";
116
+ var str__Proto$1 = "__proto__";
113
117
  var strUseBaseInst = 'useBaseInst';
114
118
  var strSetInstFuncs = 'setInstFuncs';
115
119
  var Obj = Object;
116
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
120
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
117
121
  var _dynamicNames = 0;
118
122
  function _hasOwnProperty(obj, prop) {
119
123
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -124,12 +128,12 @@
124
128
  function _isObjectArrayOrFunctionPrototype(target) {
125
129
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
126
130
  }
127
- function _getObjProto(target) {
131
+ function _getObjProto$1(target) {
128
132
  if (target) {
129
- if (_objGetPrototypeOf) {
130
- return _objGetPrototypeOf(target);
133
+ if (_objGetPrototypeOf$1) {
134
+ return _objGetPrototypeOf$1(target);
131
135
  }
132
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
136
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
133
137
  if (newProto) {
134
138
  return newProto;
135
139
  }
@@ -195,16 +199,16 @@
195
199
  _forEachProp(instFuncs, function (name) {
196
200
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
197
201
  });
198
- var baseProto = _getObjProto(classProto);
202
+ var baseProto = _getObjProto$1(classProto);
199
203
  var visited = [];
200
204
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
201
205
  _forEachProp(baseProto, function (name) {
202
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
206
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
203
207
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
204
208
  }
205
209
  });
206
210
  visited.push(baseProto);
207
- baseProto = _getObjProto(baseProto);
211
+ baseProto = _getObjProto$1(baseProto);
208
212
  }
209
213
  return baseFuncs;
210
214
  }
@@ -218,7 +222,7 @@
218
222
  }
219
223
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
220
224
  var canAddInst = !_hasOwnProperty(target, funcName);
221
- var objProto = _getObjProto(target);
225
+ var objProto = _getObjProto$1(target);
222
226
  var visited = [];
223
227
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
224
228
  var protoFunc = objProto[funcName];
@@ -227,7 +231,7 @@
227
231
  break;
228
232
  }
229
233
  visited.push(objProto);
230
- objProto = _getObjProto(objProto);
234
+ objProto = _getObjProto$1(objProto);
231
235
  }
232
236
  try {
233
237
  if (canAddInst) {
@@ -245,7 +249,7 @@
245
249
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
246
250
  var protoFunc = proto[funcName];
247
251
  if (protoFunc === currentDynProtoProxy) {
248
- protoFunc = _getObjProto(proto)[funcName];
252
+ protoFunc = _getObjProto$1(proto)[funcName];
249
253
  }
250
254
  if (typeof protoFunc !== strFunction) {
251
255
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -279,15 +283,15 @@
279
283
  }
280
284
  }
281
285
  function _checkPrototype(classProto, thisTarget) {
282
- if (_objGetPrototypeOf) {
286
+ if (_objGetPrototypeOf$1) {
283
287
  var visited = [];
284
- var thisProto = _getObjProto(thisTarget);
288
+ var thisProto = _getObjProto$1(thisTarget);
285
289
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
286
290
  if (thisProto === classProto) {
287
291
  return true;
288
292
  }
289
293
  visited.push(thisProto);
290
- thisProto = _getObjProto(thisProto);
294
+ thisProto = _getObjProto$1(thisProto);
291
295
  }
292
296
  }
293
297
  return false;
@@ -323,7 +327,7 @@
323
327
  var instFuncs = _getInstanceFuncs(target);
324
328
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
325
329
  delegateFunc(target, baseFuncs);
326
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
330
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
327
331
  if (setInstanceFunc && options) {
328
332
  setInstanceFunc = !!options[strSetInstFuncs];
329
333
  }
@@ -335,105 +339,24 @@
335
339
  };
336
340
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
337
341
 
338
- var LoggingSeverity;
339
- (function (LoggingSeverity) {
340
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
341
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
342
- })(LoggingSeverity || (LoggingSeverity = {}));
343
- var _InternalMessageId = {
344
- BrowserDoesNotSupportLocalStorage: 0,
345
- BrowserCannotReadLocalStorage: 1,
346
- BrowserCannotReadSessionStorage: 2,
347
- BrowserCannotWriteLocalStorage: 3,
348
- BrowserCannotWriteSessionStorage: 4,
349
- BrowserFailedRemovalFromLocalStorage: 5,
350
- BrowserFailedRemovalFromSessionStorage: 6,
351
- CannotSendEmptyTelemetry: 7,
352
- ClientPerformanceMathError: 8,
353
- ErrorParsingAISessionCookie: 9,
354
- ErrorPVCalc: 10,
355
- ExceptionWhileLoggingError: 11,
356
- FailedAddingTelemetryToBuffer: 12,
357
- FailedMonitorAjaxAbort: 13,
358
- FailedMonitorAjaxDur: 14,
359
- FailedMonitorAjaxOpen: 15,
360
- FailedMonitorAjaxRSC: 16,
361
- FailedMonitorAjaxSend: 17,
362
- FailedMonitorAjaxGetCorrelationHeader: 18,
363
- FailedToAddHandlerForOnBeforeUnload: 19,
364
- FailedToSendQueuedTelemetry: 20,
365
- FailedToReportDataLoss: 21,
366
- FlushFailed: 22,
367
- MessageLimitPerPVExceeded: 23,
368
- MissingRequiredFieldSpecification: 24,
369
- NavigationTimingNotSupported: 25,
370
- OnError: 26,
371
- SessionRenewalDateIsZero: 27,
372
- SenderNotInitialized: 28,
373
- StartTrackEventFailed: 29,
374
- StopTrackEventFailed: 30,
375
- StartTrackFailed: 31,
376
- StopTrackFailed: 32,
377
- TelemetrySampledAndNotSent: 33,
378
- TrackEventFailed: 34,
379
- TrackExceptionFailed: 35,
380
- TrackMetricFailed: 36,
381
- TrackPVFailed: 37,
382
- TrackPVFailedCalc: 38,
383
- TrackTraceFailed: 39,
384
- TransmissionFailed: 40,
385
- FailedToSetStorageBuffer: 41,
386
- FailedToRestoreStorageBuffer: 42,
387
- InvalidBackendResponse: 43,
388
- FailedToFixDepricatedValues: 44,
389
- InvalidDurationValue: 45,
390
- TelemetryEnvelopeInvalid: 46,
391
- CreateEnvelopeError: 47,
392
- CannotSerializeObject: 48,
393
- CannotSerializeObjectNonSerializable: 49,
394
- CircularReferenceDetected: 50,
395
- ClearAuthContextFailed: 51,
396
- ExceptionTruncated: 52,
397
- IllegalCharsInName: 53,
398
- ItemNotInArray: 54,
399
- MaxAjaxPerPVExceeded: 55,
400
- MessageTruncated: 56,
401
- NameTooLong: 57,
402
- SampleRateOutOfRange: 58,
403
- SetAuthContextFailed: 59,
404
- SetAuthContextFailedAccountName: 60,
405
- StringValueTooLong: 61,
406
- StartCalledMoreThanOnce: 62,
407
- StopCalledWithoutStart: 63,
408
- TelemetryInitializerFailed: 64,
409
- TrackArgumentsNotSpecified: 65,
410
- UrlTooLong: 66,
411
- SessionStorageBufferFull: 67,
412
- CannotAccessCookie: 68,
413
- IdTooLong: 69,
414
- InvalidEvent: 70,
415
- FailedMonitorAjaxSetRequestHeader: 71,
416
- SendBrowserInfoOnUserInit: 72,
417
- PluginException: 73,
418
- NotificationException: 74,
419
- SnippetScriptLoadFailure: 99,
420
- InvalidInstrumentationKey: 100,
421
- CannotParseAiBlobValue: 101,
422
- InvalidContentBlob: 102,
423
- TrackPageActionEventFailed: 103,
424
- FailedAddingCustomDefinedRequestContext: 104,
425
- InMemoryStorageBufferFull: 105
426
- };
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";
427
350
 
428
- var strOnPrefix = "on";
429
- var strAttachEvent = "attachEvent";
430
- var strAddEventHelper = "addEventListener";
431
351
  var strToISOString = "toISOString";
432
352
  var strIndexOf = "indexOf";
433
353
  var strMap = "map";
434
354
  var cStrTrim = "trim";
435
355
  var strToString = "toString";
436
- var _objDefineProperty = ObjDefineProperty;
356
+ var str__Proto = "__proto__";
357
+ var strConstructor = "constructor";
358
+ var _objDefineProperty$1 = ObjDefineProperty;
359
+ var _objFreeze = ObjClass.freeze;
437
360
  var _objKeys = ObjClass.keys;
438
361
  var StringProto = String[strShimPrototype];
439
362
  var _strTrim = StringProto[cStrTrim];
@@ -442,7 +365,23 @@
442
365
  var _isArray = Array.isArray;
443
366
  var _objToString = ObjProto[strToString];
444
367
  var _fnToString = ObjHasOwnProperty[strToString];
445
- _fnToString.call(ObjClass);
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
+ }
446
385
  function isUndefined(value) {
447
386
  return value === undefined || typeof value === strShimUndefined;
448
387
  }
@@ -455,24 +394,18 @@
455
394
  function isFunction(value) {
456
395
  return !!(value && typeof value === strShimFunction);
457
396
  }
458
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
459
- if (useCapture === void 0) { useCapture = false; }
460
- var result = false;
461
- if (!isNullOrUndefined(obj)) {
462
- try {
463
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
464
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
465
- result = true;
466
- }
467
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
468
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
469
- result = true;
470
- }
471
- }
472
- catch (e) {
473
- }
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
+ });
474
407
  }
475
- return result;
408
+ return value;
476
409
  }
477
410
  function objForEachKey(target, callbackfn) {
478
411
  if (target) {
@@ -502,6 +435,25 @@
502
435
  function isNumber(value) {
503
436
  return typeof value === "number";
504
437
  }
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
+ }
505
457
  function toISOString(date) {
506
458
  if (date) {
507
459
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -621,7 +573,7 @@
621
573
  return result;
622
574
  }
623
575
  function objDefineAccessors(target, prop, getProp, setProp) {
624
- if (_objDefineProperty) {
576
+ if (_objDefineProperty$1) {
625
577
  try {
626
578
  var descriptor = {
627
579
  enumerable: true,
@@ -633,7 +585,7 @@
633
585
  if (setProp) {
634
586
  descriptor.set = setProp;
635
587
  }
636
- _objDefineProperty(target, prop, descriptor);
588
+ _objDefineProperty$1(target, prop, descriptor);
637
589
  return true;
638
590
  }
639
591
  catch (e) {
@@ -641,6 +593,10 @@
641
593
  }
642
594
  return false;
643
595
  }
596
+ function _doNothing(value) {
597
+ return value;
598
+ }
599
+ var objFreeze = _objFreeze || _doNothing;
644
600
  function dateNow() {
645
601
  var dt = Date;
646
602
  return dt.now ? dt.now() : new dt().getTime();
@@ -649,7 +605,7 @@
649
605
  if (isError(object)) {
650
606
  return object.name;
651
607
  }
652
- return "";
608
+ return strEmpty$1;
653
609
  }
654
610
  function setValue(target, field, value, valChk, srcChk) {
655
611
  var theValue = value;
@@ -668,6 +624,33 @@
668
624
  function throwError(message) {
669
625
  throw new Error(message);
670
626
  }
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
+ }
671
654
  function createClassFromInterface(defaults) {
672
655
  return /** @class */ (function () {
673
656
  function class_1() {
@@ -681,12 +664,67 @@
681
664
  return class_1;
682
665
  }());
683
666
  }
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
+ }
684
678
  function optimizeObject(theObject) {
685
679
  if (theObject && ObjAssign) {
686
680
  theObject = ObjClass(ObjAssign({}, theObject));
687
681
  }
688
682
  return theObject;
689
683
  }
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
+ }
690
728
 
691
729
  var strWindow = "window";
692
730
  var strDocument = "document";
@@ -694,8 +732,13 @@
694
732
  var strNavigator = "navigator";
695
733
  var strConsole = "console";
696
734
  var strJSON = "JSON";
735
+ var strCrypto = "crypto";
736
+ var strMsCrypto = "msCrypto";
697
737
  var strMsie = "msie";
698
738
  var strTrident = "trident/";
739
+ var strXMLHttpRequest = "XMLHttpRequest";
740
+ var _isTrident = null;
741
+ var _navUserAgentCheck = null;
699
742
  var _useXDomainRequest = null;
700
743
  var _beaconsSupported = null;
701
744
  function _hasProperty(theClass, property) {
@@ -775,13 +818,28 @@
775
818
  }
776
819
  return null;
777
820
  }
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
+ }
778
836
  function getIEVersion(userAgentStr) {
779
837
  if (userAgentStr === void 0) { userAgentStr = null; }
780
838
  if (!userAgentStr) {
781
839
  var navigator_1 = getNavigator() || {};
782
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
840
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
783
841
  }
784
- var ua = (userAgentStr || "").toLowerCase();
842
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
785
843
  if (strContains(ua, strMsie)) {
786
844
  var doc = getDocument() || {};
787
845
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -796,7 +854,7 @@
796
854
  }
797
855
  function dumpObj(object) {
798
856
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
799
- var propertyValueDump = "";
857
+ var propertyValueDump = strEmpty$1;
800
858
  if (objectTypeDump === "[object Error]") {
801
859
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
802
860
  }
@@ -814,8 +872,7 @@
814
872
  function isFetchSupported(withKeepAlive) {
815
873
  var isSupported = false;
816
874
  try {
817
- var fetchApi = getGlobalInst("fetch");
818
- isSupported = !!fetchApi;
875
+ isSupported = !!getGlobalInst("fetch");
819
876
  var request = getGlobalInst("Request");
820
877
  if (isSupported && withKeepAlive && request) {
821
878
  isSupported = _hasProperty(request, "keepalive");
@@ -827,9 +884,9 @@
827
884
  }
828
885
  function useXDomainRequest() {
829
886
  if (_useXDomainRequest === null) {
830
- _useXDomainRequest = (typeof XDomainRequest !== "undefined");
887
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
831
888
  if (_useXDomainRequest && isXhrSupported()) {
832
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
889
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
833
890
  }
834
891
  }
835
892
  return _useXDomainRequest;
@@ -837,7 +894,7 @@
837
894
  function isXhrSupported() {
838
895
  var isSupported = false;
839
896
  try {
840
- var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
897
+ var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
841
898
  isSupported = !!xmlHttpRequest;
842
899
  }
843
900
  catch (e) {
@@ -868,9 +925,9 @@
868
925
  var strWarnToConsole = "warnToConsole";
869
926
  function _sanitizeDiagnosticText(text) {
870
927
  if (text) {
871
- return "\"" + text.replace(/\"/g, "") + "\"";
928
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
872
929
  }
873
- return "";
930
+ return strEmpty$1;
874
931
  }
875
932
  function _logToConsole(func, message) {
876
933
  var theConsole = getConsole();
@@ -892,12 +949,12 @@
892
949
  _self.message =
893
950
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
894
951
  msgId;
895
- var strProps = "";
952
+ var strProps = strEmpty$1;
896
953
  if (hasJSON()) {
897
954
  strProps = getJSON().stringify(properties);
898
955
  }
899
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
900
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
956
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
957
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
901
958
  _self.message += diagnosticText;
902
959
  }
903
960
  _InternalLogMessage.dataType = "MessageData";
@@ -927,7 +984,7 @@
927
984
  throw message;
928
985
  }
929
986
  else {
930
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
987
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
931
988
  if (!isUndefined(message.message)) {
932
989
  var logLevel = _self.consoleLoggingLevel();
933
990
  if (isUserAct) {
@@ -945,7 +1002,7 @@
945
1002
  _self.logInternalMessage(severity, message);
946
1003
  }
947
1004
  else {
948
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1005
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
949
1006
  }
950
1007
  }
951
1008
  };
@@ -977,13 +1034,13 @@
977
1034
  if (severity <= _self.telemetryLoggingLevel()) {
978
1035
  _self.queue.push(message);
979
1036
  _messageCount++;
980
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1037
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
981
1038
  }
982
1039
  if (_messageCount === _self.maxInternalMessageLimit()) {
983
1040
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
984
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1041
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
985
1042
  _self.queue.push(throttleMessage);
986
- if (severity === LoggingSeverity.CRITICAL) {
1043
+ if (severity === 1 ) {
987
1044
  _self.errorToConsole(throttleLimitMessage);
988
1045
  }
989
1046
  else {
@@ -1012,6 +1069,10 @@
1012
1069
  }
1013
1070
  return DiagnosticLogger;
1014
1071
  }());
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
+ }
1015
1076
 
1016
1077
  var strExecutionContextKey = "ctx";
1017
1078
  var PerfEvent = /** @class */ (function () {
@@ -1125,207 +1186,616 @@
1125
1186
  return func();
1126
1187
  }
1127
1188
 
1128
- var TelemetryPluginChain = /** @class */ (function () {
1129
- function TelemetryPluginChain(plugin, defItemCtx) {
1130
- var _self = this;
1131
- var _nextProxy = null;
1132
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1133
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1134
- _self._hasRun = false;
1135
- _self.getPlugin = function () {
1136
- return plugin;
1137
- };
1138
- _self.getNext = function () {
1139
- return _nextProxy;
1140
- };
1141
- _self.setNext = function (nextPlugin) {
1142
- _nextProxy = nextPlugin;
1143
- };
1144
- _self.processTelemetry = function (env, itemCtx) {
1145
- if (!itemCtx) {
1146
- itemCtx = defItemCtx;
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.8.0-nightly.2204-04";
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
+ }
1147
1288
  }
1148
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1149
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1150
- if (plugin && _hasProcessTelemetry) {
1151
- _self._hasRun = true;
1152
- try {
1153
- itemCtx.setNext(_nextProxy);
1154
- if (_hasSetNext) {
1155
- plugin.setNextPlugin(_nextProxy);
1156
- }
1157
- _nextProxy && (_nextProxy._hasRun = false);
1158
- plugin.processTelemetry(env, itemCtx);
1159
- }
1160
- catch (error) {
1161
- var hasRun = _nextProxy && _nextProxy._hasRun;
1162
- if (!_nextProxy || !hasRun) {
1163
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1164
- }
1165
- if (_nextProxy && !hasRun) {
1166
- _nextProxy.processTelemetry(env, itemCtx);
1167
- }
1168
- }
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;
1169
1311
  }
1170
- else if (_nextProxy) {
1171
- _self._hasRun = true;
1172
- _nextProxy.processTelemetry(env, itemCtx);
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];
1173
1320
  }
1174
- }, function () { return ({ item: env }); }, !(env.sync));
1175
- };
1176
- }
1177
- return TelemetryPluginChain;
1178
- }());
1179
-
1180
- function _createProxyChain(plugins, itemCtx) {
1181
- var proxies = [];
1182
- if (plugins && plugins.length > 0) {
1183
- var lastProxy = null;
1184
- for (var idx = 0; idx < plugins.length; idx++) {
1185
- var thePlugin = plugins[idx];
1186
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1187
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1188
- proxies.push(newProxy);
1189
- if (lastProxy) {
1190
- lastProxy.setNext(newProxy);
1321
+ catch (e) {
1191
1322
  }
1192
- lastProxy = newProxy;
1193
1323
  }
1194
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();
1195
1344
  }
1196
- return proxies.length > 0 ? proxies[0] : null;
1345
+ return createTelemetryProxyChain([startAt], config, core);
1197
1346
  }
1198
- function _copyProxyChain(proxy, itemCtx, startAt) {
1199
- var plugins = [];
1200
- var add = startAt ? false : true;
1201
- if (proxy) {
1202
- while (proxy) {
1203
- var thePlugin = proxy.getPlugin();
1204
- if (add || thePlugin === startAt) {
1205
- add = true;
1206
- plugins.push(thePlugin);
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) {
1400
+ 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));
1405
+ }
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
+ }
1435
+ }
1436
+ });
1437
+ }
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);
1207
1460
  }
1208
- proxy = proxy.getNext();
1209
1461
  }
1210
1462
  }
1211
- if (!add) {
1212
- plugins.push(startAt);
1463
+ return context;
1464
+ }
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);
1477
+ }
1478
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1213
1479
  }
1214
- return _createProxyChain(plugins, itemCtx);
1480
+ context.processNext = _processNext;
1481
+ context.createNew = _createNew;
1482
+ return context;
1215
1483
  }
1216
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1217
- var plugins = srcPlugins;
1218
- var add = false;
1219
- if (startAt && srcPlugins) {
1220
- plugins = [];
1221
- arrForEach(srcPlugins, function (thePlugin) {
1222
- if (add || thePlugin === startAt) {
1223
- add = true;
1224
- plugins.push(thePlugin);
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);
1498
+ }
1499
+ context.processNext = _processNext;
1500
+ context.createNew = _createNew;
1501
+ return context;
1502
+ }
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);
1225
1510
  }
1226
1511
  });
1227
1512
  }
1228
- if (startAt && !add) {
1229
- if (!plugins) {
1230
- plugins = [];
1513
+ function _createNew(plugins, startAt) {
1514
+ if (plugins === void 0) { plugins = null; }
1515
+ if (isArray(plugins)) {
1516
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1231
1517
  }
1232
- plugins.push(startAt);
1518
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1233
1519
  }
1234
- return _createProxyChain(plugins, itemCtx);
1520
+ context.processNext = _processNext;
1521
+ context.createNew = _createNew;
1522
+ return context;
1235
1523
  }
1236
- var ProcessTelemetryContext = /** @class */ (function () {
1237
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1238
- var _self = this;
1239
- var _nextProxy = null;
1240
- if (startAt !== null) {
1241
- if (plugins && isFunction(plugins.getPlugin)) {
1242
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
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;
1243
1532
  }
1244
- else {
1245
- if (startAt) {
1246
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1533
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1534
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1535
+ if (!firstProxy) {
1536
+ firstProxy = newProxy;
1247
1537
  }
1248
- else if (isUndefined(startAt)) {
1249
- _nextProxy = _createProxyChain(plugins, _self);
1538
+ if (lastProxy_1) {
1539
+ lastProxy_1._setNext(newProxy);
1250
1540
  }
1541
+ lastProxy_1 = newProxy;
1251
1542
  }
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;
1252
1574
  }
1253
- _self.core = function () {
1254
- return core;
1255
- };
1256
- _self.diagLog = function () {
1257
- return safeGetLogger(core, config);
1258
- };
1259
- _self.getCfg = function () {
1260
- return config;
1261
- };
1262
- _self.getExtCfg = function (identifier, defaultValue) {
1263
- if (defaultValue === void 0) { defaultValue = {}; }
1264
- var theConfig;
1265
- if (config) {
1266
- var extConfig = config.extensionConfig;
1267
- if (extConfig && identifier) {
1268
- theConfig = extConfig[identifier];
1575
+ };
1576
+ function _getTelCtx() {
1577
+ var itemCtx;
1578
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1579
+ itemCtx = plugin[strGetTelCtx]();
1580
+ }
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);
1269
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
+ }
1612
+ }
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;
1270
1622
  }
1271
- return (theConfig ? theConfig : defaultValue);
1272
- };
1273
- _self.getConfig = function (identifier, field, defaultValue) {
1274
- if (defaultValue === void 0) { defaultValue = false; }
1275
- var theValue;
1276
- var extConfig = _self.getExtCfg(identifier, null);
1277
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1278
- theValue = extConfig[field];
1623
+ var pluginState = _getPluginState(plugin);
1624
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1625
+ return false;
1279
1626
  }
1280
- else if (config && !isNullOrUndefined(config[field])) {
1281
- theValue = config[field];
1627
+ if (hasSetNext) {
1628
+ plugin.setNextPlugin(nextProxy);
1282
1629
  }
1283
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1284
- };
1285
- _self.hasNext = function () {
1286
- return _nextProxy != null;
1287
- };
1288
- _self.getNext = function () {
1289
- return _nextProxy;
1290
- };
1291
- _self.setNext = function (nextPlugin) {
1292
- _nextProxy = nextPlugin;
1293
- };
1294
- _self.processNext = function (env) {
1295
- var nextPlugin = _nextProxy;
1296
- if (nextPlugin) {
1297
- _nextProxy = nextPlugin.getNext();
1298
- nextPlugin.processTelemetry(env, _self);
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
+ }
1299
1651
  }
1300
- };
1301
- _self.createNew = function (plugins, startAt) {
1302
- if (plugins === void 0) { plugins = null; }
1303
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1304
- };
1652
+ return hasRun;
1653
+ }
1654
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1655
+ unloadCtx.processNext(unloadState);
1656
+ }
1305
1657
  }
1306
- return ProcessTelemetryContext;
1307
- }());
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
+ }
1669
+ }
1670
+ return hasRun;
1671
+ }
1672
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1673
+ updateCtx.processNext(updateState);
1674
+ }
1675
+ }
1676
+ return objFreeze(proxyChain);
1677
+ }
1308
1678
 
1309
1679
  var strExtensionConfig = "extensionConfig";
1310
1680
 
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
+
1311
1705
  var strGetPlugin = "getPlugin";
1312
1706
  var BaseTelemetryPlugin = /** @class */ (function () {
1313
1707
  function BaseTelemetryPlugin() {
1314
1708
  var _self = this;
1315
- var _isinitialized = false;
1316
- var _rootCtx = null;
1317
- var _nextPlugin = null;
1318
- _self.core = null;
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
+ });
1319
1789
  _self.diagLog = function (itemCtx) {
1320
- return _self._getTelCtx(itemCtx).diagLog();
1790
+ return _getTelCtx(itemCtx).diagLog();
1321
1791
  };
1322
- _self.isInitialized = function () {
1792
+ _self[strIsInitialized] = function () {
1323
1793
  return _isinitialized;
1324
1794
  };
1325
1795
  _self.setInitialized = function (isInitialized) {
1326
1796
  _isinitialized = isInitialized;
1327
1797
  };
1328
- _self.setNextPlugin = function (next) {
1798
+ _self[strSetNextPlugin] = function (next) {
1329
1799
  _nextPlugin = next;
1330
1800
  };
1331
1801
  _self.processNext = function (env, itemCtx) {
@@ -1336,11 +1806,12 @@
1336
1806
  _nextPlugin.processTelemetry(env, null);
1337
1807
  }
1338
1808
  };
1339
- _self._getTelCtx = function (currentCtx) {
1809
+ _self._getTelCtx = _getTelCtx;
1810
+ function _getTelCtx(currentCtx) {
1340
1811
  if (currentCtx === void 0) { currentCtx = null; }
1341
1812
  var itemCtx = currentCtx;
1342
1813
  if (!itemCtx) {
1343
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1814
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1344
1815
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1345
1816
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1346
1817
  }
@@ -1349,8 +1820,8 @@
1349
1820
  }
1350
1821
  }
1351
1822
  return itemCtx;
1352
- };
1353
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1823
+ }
1824
+ function _setDefaults(config, core, pluginChain) {
1354
1825
  if (config) {
1355
1826
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1356
1827
  }
@@ -1362,16 +1833,280 @@
1362
1833
  nextPlugin = _nextPlugin[strGetPlugin]();
1363
1834
  }
1364
1835
  _self.core = core;
1365
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1366
- _isinitialized = true;
1367
- };
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
+ }
1368
1846
  }
1369
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1370
- this._baseTelInit(config, core, extensions, pluginChain);
1371
- };
1372
1847
  return BaseTelemetryPlugin;
1373
1848
  }());
1374
1849
 
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
+
1375
2110
  var RequestHeaders = {
1376
2111
  requestContextHeader: "Request-Context",
1377
2112
  requestContextTargetKey: "appId",
@@ -1404,7 +2139,7 @@
1404
2139
  name = strTrim(name.toString());
1405
2140
  if (name.length > 150 ) {
1406
2141
  nameTrunc = name.substring(0, 150 );
1407
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2142
+ _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1408
2143
  }
1409
2144
  }
1410
2145
  return nameTrunc || name;
@@ -1417,7 +2152,7 @@
1417
2152
  value = strTrim(value);
1418
2153
  if (value.toString().length > maxLength) {
1419
2154
  valueTrunc = value.toString().substring(0, maxLength);
1420
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2155
+ _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1421
2156
  }
1422
2157
  }
1423
2158
  return valueTrunc || value;
@@ -1430,7 +2165,7 @@
1430
2165
  if (message) {
1431
2166
  if (message.length > 32768 ) {
1432
2167
  messageTrunc = message.substring(0, 32768 );
1433
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2168
+ _throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
1434
2169
  }
1435
2170
  }
1436
2171
  return messageTrunc || message;
@@ -1441,7 +2176,7 @@
1441
2176
  var value = "" + exception;
1442
2177
  if (value.length > 32768 ) {
1443
2178
  exceptionTrunc = value.substring(0, 32768 );
1444
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2179
+ _throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
1445
2180
  }
1446
2181
  }
1447
2182
  return exceptionTrunc || exception;
@@ -1455,7 +2190,7 @@
1455
2190
  value = getJSON().stringify(value);
1456
2191
  }
1457
2192
  catch (e) {
1458
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2193
+ _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
1459
2194
  }
1460
2195
  }
1461
2196
  value = dataSanitizeString(logger, value, 8192 );
@@ -1486,7 +2221,7 @@
1486
2221
  input = strTrim(input);
1487
2222
  if (input.length > maxLength) {
1488
2223
  inputTrunc = input.substring(0, maxLength);
1489
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2224
+ _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
1490
2225
  }
1491
2226
  }
1492
2227
  return inputTrunc || input;
@@ -1496,21 +2231,22 @@
1496
2231
  return s.substr(s.length - 3);
1497
2232
  }
1498
2233
 
2234
+ var strEmpty = "";
1499
2235
  function msToTimeSpan(totalms) {
1500
2236
  if (isNaN(totalms) || totalms < 0) {
1501
2237
  totalms = 0;
1502
2238
  }
1503
2239
  totalms = Math.round(totalms);
1504
- var ms = "" + totalms % 1000;
1505
- var sec = "" + Math.floor(totalms / 1000) % 60;
1506
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
1507
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
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;
1508
2244
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
1509
2245
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
1510
2246
  sec = sec.length < 2 ? "0" + sec : sec;
1511
2247
  min = min.length < 2 ? "0" + min : min;
1512
2248
  hour = hour.length < 2 ? "0" + hour : hour;
1513
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2249
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
1514
2250
  }
1515
2251
 
1516
2252
  var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
@@ -1519,17 +2255,15 @@
1519
2255
  var HttpMethod = "http.method";
1520
2256
  var strNotSpecified = "not_specified";
1521
2257
 
1522
- var StorageType;
1523
- (function (StorageType) {
1524
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
1525
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
1526
- })(StorageType || (StorageType = {}));
1527
- var DistributedTracingModes;
1528
- (function (DistributedTracingModes) {
1529
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
1530
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
1531
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
1532
- })(DistributedTracingModes || (DistributedTracingModes = {}));
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
+ });
1533
2267
 
1534
2268
  var _canUseSessionStorage = undefined;
1535
2269
  function _getVerifiedStorageObject(storageType) {
@@ -1556,8 +2290,8 @@
1556
2290
  }
1557
2291
  return null;
1558
2292
  }
1559
- function utlCanUseSessionStorage() {
1560
- if (_canUseSessionStorage === undefined) {
2293
+ function utlCanUseSessionStorage(reset) {
2294
+ if (reset || _canUseSessionStorage === undefined) {
1561
2295
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
1562
2296
  }
1563
2297
  return _canUseSessionStorage;
@@ -1570,7 +2304,7 @@
1570
2304
  }
1571
2305
  catch (e) {
1572
2306
  _canUseSessionStorage = false;
1573
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2307
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1574
2308
  }
1575
2309
  }
1576
2310
  return null;
@@ -1584,7 +2318,7 @@
1584
2318
  }
1585
2319
  catch (e) {
1586
2320
  _canUseSessionStorage = false;
1587
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2321
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
1588
2322
  }
1589
2323
  }
1590
2324
  return false;
@@ -1681,37 +2415,17 @@
1681
2415
  };
1682
2416
  }
1683
2417
 
1684
- var Base = /** @class */ (function () {
1685
- function Base() {
1686
- }
1687
- return Base;
1688
- }());
1689
-
1690
- var Data$1 = /** @class */ (function (_super) {
1691
- __extendsFn(Data, _super);
1692
- function Data() {
1693
- return _super.call(this) || this;
1694
- }
1695
- return Data;
1696
- }(Base));
1697
-
1698
- var Envelope$1 = /** @class */ (function () {
1699
- function Envelope() {
1700
- this.ver = 1;
1701
- this.sampleRate = 100.0;
1702
- this.tags = {};
1703
- }
1704
- return Envelope;
1705
- }());
1706
-
1707
- var Envelope = /** @class */ (function (_super) {
1708
- __extendsFn(Envelope, _super);
2418
+ var Envelope = /** @class */ (function () {
1709
2419
  function Envelope(logger, data, name) {
1710
- var _this = _super.call(this) || this;
1711
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
1712
- _this.data = data;
1713
- _this.time = toISOString(new Date());
1714
- _this.aiDataContract = {
2420
+ var _this = this;
2421
+ var _self = this;
2422
+ _self.ver = 1;
2423
+ _self.sampleRate = 100.0;
2424
+ _self.tags = {};
2425
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
2426
+ _self.data = data;
2427
+ _self.time = toISOString(new Date());
2428
+ _self.aiDataContract = {
1715
2429
  time: 1 ,
1716
2430
  iKey: 1 ,
1717
2431
  name: 1 ,
@@ -1721,62 +2435,27 @@
1721
2435
  tags: 1 ,
1722
2436
  data: 1
1723
2437
  };
1724
- return _this;
1725
2438
  }
1726
2439
  return Envelope;
1727
- }(Envelope$1));
1728
-
1729
- var EventData = /** @class */ (function () {
1730
- function EventData() {
1731
- this.ver = 2;
1732
- this.properties = {};
1733
- this.measurements = {};
1734
- }
1735
- return EventData;
1736
2440
  }());
1737
2441
 
1738
- var Event = /** @class */ (function (_super) {
1739
- __extendsFn(Event, _super);
2442
+ var Event = /** @class */ (function () {
1740
2443
  function Event(logger, name, properties, measurements) {
1741
- var _this = _super.call(this) || this;
1742
- _this.aiDataContract = {
2444
+ this.aiDataContract = {
1743
2445
  ver: 1 ,
1744
2446
  name: 1 ,
1745
2447
  properties: 0 ,
1746
2448
  measurements: 0
1747
2449
  };
1748
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
1749
- _this.properties = dataSanitizeProperties(logger, properties);
1750
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
1751
- return _this;
2450
+ var _self = this;
2451
+ _self.ver = 2;
2452
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
2453
+ _self.properties = dataSanitizeProperties(logger, properties);
2454
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
1752
2455
  }
1753
2456
  Event.envelopeType = "Microsoft.ApplicationInsights.{0}.Event";
1754
2457
  Event.dataType = "EventData";
1755
2458
  return Event;
1756
- }(EventData));
1757
-
1758
- var StackFrame = /** @class */ (function () {
1759
- function StackFrame() {
1760
- }
1761
- return StackFrame;
1762
- }());
1763
-
1764
- var ExceptionData = /** @class */ (function () {
1765
- function ExceptionData() {
1766
- this.ver = 2;
1767
- this.exceptions = [];
1768
- this.properties = {};
1769
- this.measurements = {};
1770
- }
1771
- return ExceptionData;
1772
- }());
1773
-
1774
- var ExceptionDetails = /** @class */ (function () {
1775
- function ExceptionDetails() {
1776
- this.hasFullStack = true;
1777
- this.parsedStack = [];
1778
- }
1779
- return ExceptionDetails;
1780
2459
  }());
1781
2460
 
1782
2461
  var NoMethod = "<no_method>";
@@ -2020,50 +2699,48 @@
2020
2699
  }
2021
2700
  return "" + (errorObj || "");
2022
2701
  }
2023
- var Exception = /** @class */ (function (_super) {
2024
- __extendsFn(Exception, _super);
2702
+ var Exception = /** @class */ (function () {
2025
2703
  function Exception(logger, exception, properties, measurements, severityLevel, id) {
2026
- var _this = _super.call(this) || this;
2027
- _this.aiDataContract = {
2704
+ this.aiDataContract = {
2028
2705
  ver: 1 ,
2029
2706
  exceptions: 1 ,
2030
2707
  severityLevel: 0 ,
2031
2708
  properties: 0 ,
2032
2709
  measurements: 0
2033
2710
  };
2711
+ var _self = this;
2712
+ _self.ver = 2;
2034
2713
  if (!_isExceptionInternal(exception)) {
2035
2714
  if (!properties) {
2036
2715
  properties = {};
2037
2716
  }
2038
- _this.exceptions = [new _ExceptionDetails(logger, exception, properties)];
2039
- _this.properties = dataSanitizeProperties(logger, properties);
2040
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2717
+ _self.exceptions = [new _ExceptionDetails(logger, exception, properties)];
2718
+ _self.properties = dataSanitizeProperties(logger, properties);
2719
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2041
2720
  if (severityLevel) {
2042
- _this.severityLevel = severityLevel;
2721
+ _self.severityLevel = severityLevel;
2043
2722
  }
2044
2723
  if (id) {
2045
- _this.id = id;
2724
+ _self.id = id;
2046
2725
  }
2047
2726
  }
2048
2727
  else {
2049
- _this.exceptions = exception.exceptions;
2050
- _this.properties = exception.properties;
2051
- _this.measurements = exception.measurements;
2728
+ _self.exceptions = exception.exceptions || [];
2729
+ _self.properties = exception.properties;
2730
+ _self.measurements = exception.measurements;
2052
2731
  if (exception.severityLevel) {
2053
- _this.severityLevel = exception.severityLevel;
2732
+ _self.severityLevel = exception.severityLevel;
2054
2733
  }
2055
2734
  if (exception.id) {
2056
- _this.id = exception.id;
2735
+ _self.id = exception.id;
2057
2736
  }
2058
2737
  if (exception.problemGroup) {
2059
- _this.problemGroup = exception.problemGroup;
2738
+ _self.problemGroup = exception.problemGroup;
2060
2739
  }
2061
- _this.ver = 2;
2062
2740
  if (!isNullOrUndefined(exception.isManual)) {
2063
- _this.isManual = exception.isManual;
2741
+ _self.isManual = exception.isManual;
2064
2742
  }
2065
2743
  }
2066
- return _this;
2067
2744
  }
2068
2745
  Exception.CreateAutoException = function (message, url, lineNumber, columnNumber, error, evt, stack, errorSrc) {
2069
2746
  var errorType = _getErrorType(error || evt || message);
@@ -2117,12 +2794,10 @@
2117
2794
  Exception.dataType = "ExceptionData";
2118
2795
  Exception.formatError = _formatErrorCode;
2119
2796
  return Exception;
2120
- }(ExceptionData));
2121
- var _ExceptionDetails = /** @class */ (function (_super) {
2122
- __extendsFn(_ExceptionDetails, _super);
2797
+ }());
2798
+ var _ExceptionDetails = /** @class */ (function () {
2123
2799
  function _ExceptionDetails(logger, exception, properties) {
2124
- var _this = _super.call(this) || this;
2125
- _this.aiDataContract = {
2800
+ this.aiDataContract = {
2126
2801
  id: 0 ,
2127
2802
  outerId: 0 ,
2128
2803
  typeName: 1 ,
@@ -2131,41 +2806,42 @@
2131
2806
  stack: 0 ,
2132
2807
  parsedStack: 2
2133
2808
  };
2809
+ var _self = this;
2134
2810
  if (!_isExceptionDetailsInternal(exception)) {
2135
2811
  var error = exception;
2136
2812
  var evt = error && error.evt;
2137
2813
  if (!isError(error)) {
2138
2814
  error = error[strError] || evt || error;
2139
2815
  }
2140
- _this.typeName = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
2141
- _this.message = dataSanitizeMessage(logger, _formatMessage(exception || error, _this.typeName)) || strNotSpecified;
2816
+ _self.typeName = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
2817
+ _self.message = dataSanitizeMessage(logger, _formatMessage(exception || error, _self.typeName)) || strNotSpecified;
2142
2818
  var stack = exception[strStackDetails] || _getStackFromErrorObj(exception);
2143
- _this.parsedStack = _parseStack(stack);
2144
- _this[strStack] = dataSanitizeException(logger, _formatStackTrace(stack));
2145
- _this.hasFullStack = isArray(_this.parsedStack) && _this.parsedStack.length > 0;
2819
+ _self.parsedStack = _parseStack(stack);
2820
+ _self[strStack] = dataSanitizeException(logger, _formatStackTrace(stack));
2821
+ _self.hasFullStack = isArray(_self.parsedStack) && _self.parsedStack.length > 0;
2146
2822
  if (properties) {
2147
- properties.typeName = properties.typeName || _this.typeName;
2823
+ properties.typeName = properties.typeName || _self.typeName;
2148
2824
  }
2149
2825
  }
2150
2826
  else {
2151
- _this.typeName = exception.typeName;
2152
- _this.message = exception.message;
2153
- _this[strStack] = exception[strStack];
2154
- _this.parsedStack = exception.parsedStack;
2155
- _this.hasFullStack = exception.hasFullStack;
2827
+ _self.typeName = exception.typeName;
2828
+ _self.message = exception.message;
2829
+ _self[strStack] = exception[strStack];
2830
+ _self.parsedStack = exception.parsedStack || [];
2831
+ _self.hasFullStack = exception.hasFullStack;
2156
2832
  }
2157
- return _this;
2158
2833
  }
2159
2834
  _ExceptionDetails.prototype.toInterface = function () {
2160
- var parsedStack = this.parsedStack instanceof Array
2161
- && arrMap(this.parsedStack, function (frame) { return frame.toInterface(); });
2835
+ var _self = this;
2836
+ var parsedStack = _self.parsedStack instanceof Array
2837
+ && arrMap(_self.parsedStack, function (frame) { return frame.toInterface(); });
2162
2838
  var exceptionDetailsInterface = {
2163
- id: this.id,
2164
- outerId: this.outerId,
2165
- typeName: this.typeName,
2166
- message: this.message,
2167
- hasFullStack: this.hasFullStack,
2168
- stack: this[strStack],
2839
+ id: _self.id,
2840
+ outerId: _self.outerId,
2841
+ typeName: _self.typeName,
2842
+ message: _self.message,
2843
+ hasFullStack: _self.hasFullStack,
2844
+ stack: _self[strStack],
2169
2845
  parsedStack: parsedStack || undefined
2170
2846
  };
2171
2847
  return exceptionDetailsInterface;
@@ -2178,94 +2854,68 @@
2178
2854
  return exceptionDetails;
2179
2855
  };
2180
2856
  return _ExceptionDetails;
2181
- }(ExceptionDetails));
2182
- var _StackFrame = /** @class */ (function (_super) {
2183
- __extendsFn(_StackFrame, _super);
2857
+ }());
2858
+ var _StackFrame = /** @class */ (function () {
2184
2859
  function _StackFrame(sourceFrame, level) {
2185
- var _this = _super.call(this) || this;
2186
- _this.sizeInBytes = 0;
2187
- _this.aiDataContract = {
2860
+ this.aiDataContract = {
2188
2861
  level: 1 ,
2189
2862
  method: 1 ,
2190
2863
  assembly: 0 ,
2191
2864
  fileName: 0 ,
2192
2865
  line: 0
2193
2866
  };
2867
+ var _self = this;
2868
+ _self.sizeInBytes = 0;
2194
2869
  if (typeof sourceFrame === "string") {
2195
2870
  var frame = sourceFrame;
2196
- _this.level = level;
2197
- _this.method = NoMethod;
2198
- _this.assembly = strTrim(frame);
2199
- _this.fileName = "";
2200
- _this.line = 0;
2871
+ _self.level = level;
2872
+ _self.method = NoMethod;
2873
+ _self.assembly = strTrim(frame);
2874
+ _self.fileName = "";
2875
+ _self.line = 0;
2201
2876
  var matches = frame.match(_StackFrame.regex);
2202
2877
  if (matches && matches.length >= 5) {
2203
- _this.method = strTrim(matches[2]) || _this.method;
2204
- _this.fileName = strTrim(matches[4]);
2205
- _this.line = parseInt(matches[5]) || 0;
2878
+ _self.method = strTrim(matches[2]) || _self.method;
2879
+ _self.fileName = strTrim(matches[4]);
2880
+ _self.line = parseInt(matches[5]) || 0;
2206
2881
  }
2207
2882
  }
2208
2883
  else {
2209
- _this.level = sourceFrame.level;
2210
- _this.method = sourceFrame.method;
2211
- _this.assembly = sourceFrame.assembly;
2212
- _this.fileName = sourceFrame.fileName;
2213
- _this.line = sourceFrame.line;
2214
- _this.sizeInBytes = 0;
2215
- }
2216
- _this.sizeInBytes += _this.method.length;
2217
- _this.sizeInBytes += _this.fileName.length;
2218
- _this.sizeInBytes += _this.assembly.length;
2219
- _this.sizeInBytes += _StackFrame.baseSize;
2220
- _this.sizeInBytes += _this.level.toString().length;
2221
- _this.sizeInBytes += _this.line.toString().length;
2222
- return _this;
2884
+ _self.level = sourceFrame.level;
2885
+ _self.method = sourceFrame.method;
2886
+ _self.assembly = sourceFrame.assembly;
2887
+ _self.fileName = sourceFrame.fileName;
2888
+ _self.line = sourceFrame.line;
2889
+ _self.sizeInBytes = 0;
2890
+ }
2891
+ _self.sizeInBytes += _self.method.length;
2892
+ _self.sizeInBytes += _self.fileName.length;
2893
+ _self.sizeInBytes += _self.assembly.length;
2894
+ _self.sizeInBytes += _StackFrame.baseSize;
2895
+ _self.sizeInBytes += _self.level.toString().length;
2896
+ _self.sizeInBytes += _self.line.toString().length;
2223
2897
  }
2224
2898
  _StackFrame.CreateFromInterface = function (frame) {
2225
2899
  return new _StackFrame(frame, null );
2226
2900
  };
2227
2901
  _StackFrame.prototype.toInterface = function () {
2902
+ var _self = this;
2228
2903
  return {
2229
- level: this.level,
2230
- method: this.method,
2231
- assembly: this.assembly,
2232
- fileName: this.fileName,
2233
- line: this.line
2904
+ level: _self.level,
2905
+ method: _self.method,
2906
+ assembly: _self.assembly,
2907
+ fileName: _self.fileName,
2908
+ line: _self.line
2234
2909
  };
2235
2910
  };
2236
2911
  _StackFrame.regex = /^([\s]+at)?[\s]{0,50}([^\@\()]+?)[\s]{0,50}(\@|\()([^\(\n]+):([0-9]+):([0-9]+)(\)?)$/;
2237
2912
  _StackFrame.baseSize = 58;
2238
2913
  return _StackFrame;
2239
- }(StackFrame));
2240
-
2241
- var MetricData = /** @class */ (function () {
2242
- function MetricData() {
2243
- this.ver = 2;
2244
- this.metrics = [];
2245
- this.properties = {};
2246
- this.measurements = {};
2247
- }
2248
- return MetricData;
2249
- }());
2250
-
2251
- var DataPointType;
2252
- (function (DataPointType) {
2253
- DataPointType[DataPointType["Measurement"] = 0] = "Measurement";
2254
- DataPointType[DataPointType["Aggregation"] = 1] = "Aggregation";
2255
- })(DataPointType || (DataPointType = {}));
2256
-
2257
- var DataPoint$1 = /** @class */ (function () {
2258
- function DataPoint() {
2259
- this.kind = DataPointType.Measurement;
2260
- }
2261
- return DataPoint;
2262
2914
  }());
2263
2915
 
2264
- var DataPoint = /** @class */ (function (_super) {
2265
- __extendsFn(DataPoint, _super);
2916
+ var DataPoint = /** @class */ (function () {
2266
2917
  function DataPoint() {
2267
- var _this = _super !== null && _super.apply(this, arguments) || this;
2268
- _this.aiDataContract = {
2918
+ this.aiDataContract = {
2269
2919
  name: 1 ,
2270
2920
  kind: 0 ,
2271
2921
  value: 1 ,
@@ -2274,20 +2924,20 @@
2274
2924
  max: 0 ,
2275
2925
  stdDev: 0
2276
2926
  };
2277
- return _this;
2927
+ this.kind = 0 ;
2278
2928
  }
2279
2929
  return DataPoint;
2280
- }(DataPoint$1));
2930
+ }());
2281
2931
 
2282
- var Metric = /** @class */ (function (_super) {
2283
- __extendsFn(Metric, _super);
2932
+ var Metric = /** @class */ (function () {
2284
2933
  function Metric(logger, name, value, count, min, max, stdDev, properties, measurements) {
2285
- var _this = _super.call(this) || this;
2286
- _this.aiDataContract = {
2934
+ this.aiDataContract = {
2287
2935
  ver: 1 ,
2288
2936
  metrics: 1 ,
2289
2937
  properties: 0
2290
2938
  };
2939
+ var _self = this;
2940
+ _self.ver = 2;
2291
2941
  var dataPoint = new DataPoint();
2292
2942
  dataPoint.count = count > 0 ? count : undefined;
2293
2943
  dataPoint.max = isNaN(max) || max === null ? undefined : max;
@@ -2295,33 +2945,18 @@
2295
2945
  dataPoint.name = dataSanitizeString(logger, name) || strNotSpecified;
2296
2946
  dataPoint.value = value;
2297
2947
  dataPoint.stdDev = isNaN(stdDev) || stdDev === null ? undefined : stdDev;
2298
- _this.metrics = [dataPoint];
2299
- _this.properties = dataSanitizeProperties(logger, properties);
2300
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2301
- return _this;
2948
+ _self.metrics = [dataPoint];
2949
+ _self.properties = dataSanitizeProperties(logger, properties);
2950
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2302
2951
  }
2303
2952
  Metric.envelopeType = "Microsoft.ApplicationInsights.{0}.Metric";
2304
2953
  Metric.dataType = "MetricData";
2305
2954
  return Metric;
2306
- }(MetricData));
2307
-
2308
- var PageViewData = /** @class */ (function (_super) {
2309
- __extendsFn(PageViewData, _super);
2310
- function PageViewData() {
2311
- var _this = _super.call(this) || this;
2312
- _this.ver = 2;
2313
- _this.properties = {};
2314
- _this.measurements = {};
2315
- return _this;
2316
- }
2317
- return PageViewData;
2318
- }(EventData));
2955
+ }());
2319
2956
 
2320
- var PageView = /** @class */ (function (_super) {
2321
- __extendsFn(PageView, _super);
2957
+ var PageView = /** @class */ (function () {
2322
2958
  function PageView(logger, name, url, durationMs, properties, measurements, id) {
2323
- var _this = _super.call(this) || this;
2324
- _this.aiDataContract = {
2959
+ this.aiDataContract = {
2325
2960
  ver: 1 ,
2326
2961
  name: 0 ,
2327
2962
  url: 0 ,
@@ -2330,37 +2965,26 @@
2330
2965
  measurements: 0 ,
2331
2966
  id: 0
2332
2967
  };
2333
- _this.id = dataSanitizeId(logger, id);
2334
- _this.url = dataSanitizeUrl(logger, url);
2335
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
2968
+ var _self = this;
2969
+ _self.ver = 2;
2970
+ _self.id = dataSanitizeId(logger, id);
2971
+ _self.url = dataSanitizeUrl(logger, url);
2972
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
2336
2973
  if (!isNaN(durationMs)) {
2337
- _this.duration = msToTimeSpan(durationMs);
2974
+ _self.duration = msToTimeSpan(durationMs);
2338
2975
  }
2339
- _this.properties = dataSanitizeProperties(logger, properties);
2340
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2341
- return _this;
2976
+ _self.properties = dataSanitizeProperties(logger, properties);
2977
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2342
2978
  }
2343
2979
  PageView.envelopeType = "Microsoft.ApplicationInsights.{0}.Pageview";
2344
2980
  PageView.dataType = "PageviewData";
2345
2981
  return PageView;
2346
- }(PageViewData));
2347
-
2348
- var RemoteDependencyData$1 = /** @class */ (function () {
2349
- function RemoteDependencyData() {
2350
- this.ver = 2;
2351
- this.success = true;
2352
- this.properties = {};
2353
- this.measurements = {};
2354
- }
2355
- return RemoteDependencyData;
2356
2982
  }());
2357
2983
 
2358
- var RemoteDependencyData = /** @class */ (function (_super) {
2359
- __extendsFn(RemoteDependencyData, _super);
2984
+ var RemoteDependencyData = /** @class */ (function () {
2360
2985
  function RemoteDependencyData(logger, id, absoluteUrl, commandName, value, success, resultCode, method, requestAPI, correlationContext, properties, measurements) {
2361
2986
  if (requestAPI === void 0) { requestAPI = "Ajax"; }
2362
- var _this = _super.call(this) || this;
2363
- _this.aiDataContract = {
2987
+ this.aiDataContract = {
2364
2988
  id: 1 ,
2365
2989
  ver: 1 ,
2366
2990
  name: 0 ,
@@ -2383,77 +3007,54 @@
2383
3007
  commandName: 0 ,
2384
3008
  dependencyTypeName: 0
2385
3009
  };
2386
- _this.id = id;
2387
- _this.duration = msToTimeSpan(value);
2388
- _this.success = success;
2389
- _this.resultCode = resultCode + "";
2390
- _this.type = dataSanitizeString(logger, requestAPI);
3010
+ var _self = this;
3011
+ _self.ver = 2;
3012
+ _self.id = id;
3013
+ _self.duration = msToTimeSpan(value);
3014
+ _self.success = success;
3015
+ _self.resultCode = resultCode + "";
3016
+ _self.type = dataSanitizeString(logger, requestAPI);
2391
3017
  var dependencyFields = AjaxHelperParseDependencyPath(logger, absoluteUrl, method, commandName);
2392
- _this.data = dataSanitizeUrl(logger, commandName) || dependencyFields.data;
2393
- _this.target = dataSanitizeString(logger, dependencyFields.target);
3018
+ _self.data = dataSanitizeUrl(logger, commandName) || dependencyFields.data;
3019
+ _self.target = dataSanitizeString(logger, dependencyFields.target);
2394
3020
  if (correlationContext) {
2395
- _this.target = "".concat(_this.target, " | ").concat(correlationContext);
3021
+ _self.target = "".concat(_self.target, " | ").concat(correlationContext);
2396
3022
  }
2397
- _this.name = dataSanitizeString(logger, dependencyFields.name);
2398
- _this.properties = dataSanitizeProperties(logger, properties);
2399
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
2400
- return _this;
3023
+ _self.name = dataSanitizeString(logger, dependencyFields.name);
3024
+ _self.properties = dataSanitizeProperties(logger, properties);
3025
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2401
3026
  }
2402
3027
  RemoteDependencyData.envelopeType = "Microsoft.ApplicationInsights.{0}.RemoteDependency";
2403
3028
  RemoteDependencyData.dataType = "RemoteDependencyData";
2404
3029
  return RemoteDependencyData;
2405
- }(RemoteDependencyData$1));
2406
-
2407
- var MessageData = /** @class */ (function () {
2408
- function MessageData() {
2409
- this.ver = 2;
2410
- this.properties = {};
2411
- this.measurements = {};
2412
- }
2413
- return MessageData;
2414
3030
  }());
2415
3031
 
2416
- var Trace = /** @class */ (function (_super) {
2417
- __extendsFn(Trace, _super);
3032
+ var Trace = /** @class */ (function () {
2418
3033
  function Trace(logger, message, severityLevel, properties, measurements) {
2419
- var _this = _super.call(this) || this;
2420
- _this.aiDataContract = {
3034
+ this.aiDataContract = {
2421
3035
  ver: 1 ,
2422
3036
  message: 1 ,
2423
3037
  severityLevel: 0 ,
2424
3038
  properties: 0
2425
3039
  };
3040
+ var _self = this;
3041
+ _self.ver = 2;
2426
3042
  message = message || strNotSpecified;
2427
- _this.message = dataSanitizeMessage(logger, message);
2428
- _this.properties = dataSanitizeProperties(logger, properties);
2429
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
3043
+ _self.message = dataSanitizeMessage(logger, message);
3044
+ _self.properties = dataSanitizeProperties(logger, properties);
3045
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2430
3046
  if (severityLevel) {
2431
- _this.severityLevel = severityLevel;
3047
+ _self.severityLevel = severityLevel;
2432
3048
  }
2433
- return _this;
2434
3049
  }
2435
3050
  Trace.envelopeType = "Microsoft.ApplicationInsights.{0}.Message";
2436
3051
  Trace.dataType = "MessageData";
2437
3052
  return Trace;
2438
- }(MessageData));
2439
-
2440
- var PageViewPerfData = /** @class */ (function (_super) {
2441
- __extendsFn(PageViewPerfData, _super);
2442
- function PageViewPerfData() {
2443
- var _this = _super.call(this) || this;
2444
- _this.ver = 2;
2445
- _this.properties = {};
2446
- _this.measurements = {};
2447
- return _this;
2448
- }
2449
- return PageViewPerfData;
2450
- }(PageViewData));
3053
+ }());
2451
3054
 
2452
- var PageViewPerformance = /** @class */ (function (_super) {
2453
- __extendsFn(PageViewPerformance, _super);
3055
+ var PageViewPerformance = /** @class */ (function () {
2454
3056
  function PageViewPerformance(logger, name, url, unused, properties, measurements, cs4BaseData) {
2455
- var _this = _super.call(this) || this;
2456
- _this.aiDataContract = {
3057
+ this.aiDataContract = {
2457
3058
  ver: 1 ,
2458
3059
  name: 0 ,
2459
3060
  url: 0 ,
@@ -2466,39 +3067,37 @@
2466
3067
  properties: 0 ,
2467
3068
  measurements: 0
2468
3069
  };
2469
- _this.url = dataSanitizeUrl(logger, url);
2470
- _this.name = dataSanitizeString(logger, name) || strNotSpecified;
2471
- _this.properties = dataSanitizeProperties(logger, properties);
2472
- _this.measurements = dataSanitizeMeasurements(logger, measurements);
3070
+ var _self = this;
3071
+ _self.ver = 2;
3072
+ _self.url = dataSanitizeUrl(logger, url);
3073
+ _self.name = dataSanitizeString(logger, name) || strNotSpecified;
3074
+ _self.properties = dataSanitizeProperties(logger, properties);
3075
+ _self.measurements = dataSanitizeMeasurements(logger, measurements);
2473
3076
  if (cs4BaseData) {
2474
- _this.domProcessing = cs4BaseData.domProcessing;
2475
- _this.duration = cs4BaseData.duration;
2476
- _this.networkConnect = cs4BaseData.networkConnect;
2477
- _this.perfTotal = cs4BaseData.perfTotal;
2478
- _this.receivedResponse = cs4BaseData.receivedResponse;
2479
- _this.sentRequest = cs4BaseData.sentRequest;
3077
+ _self.domProcessing = cs4BaseData.domProcessing;
3078
+ _self.duration = cs4BaseData.duration;
3079
+ _self.networkConnect = cs4BaseData.networkConnect;
3080
+ _self.perfTotal = cs4BaseData.perfTotal;
3081
+ _self.receivedResponse = cs4BaseData.receivedResponse;
3082
+ _self.sentRequest = cs4BaseData.sentRequest;
2480
3083
  }
2481
- return _this;
2482
3084
  }
2483
3085
  PageViewPerformance.envelopeType = "Microsoft.ApplicationInsights.{0}.PageviewPerformance";
2484
3086
  PageViewPerformance.dataType = "PageviewPerformanceData";
2485
3087
  return PageViewPerformance;
2486
- }(PageViewPerfData));
3088
+ }());
2487
3089
 
2488
- var Data = /** @class */ (function (_super) {
2489
- __extendsFn(Data, _super);
3090
+ var Data = /** @class */ (function () {
2490
3091
  function Data(baseType, data) {
2491
- var _this = _super.call(this) || this;
2492
- _this.aiDataContract = {
3092
+ this.aiDataContract = {
2493
3093
  baseType: 1 ,
2494
3094
  baseData: 1
2495
3095
  };
2496
- _this.baseType = baseType;
2497
- _this.baseData = data;
2498
- return _this;
3096
+ this.baseType = baseType;
3097
+ this.baseData = data;
2499
3098
  }
2500
3099
  return Data;
2501
- }(Data$1));
3100
+ }());
2502
3101
 
2503
3102
  function _aiNameFunc(baseName) {
2504
3103
  var aiName = "ai." + baseName + ".";
@@ -2861,7 +3460,7 @@
2861
3460
  }
2862
3461
  }
2863
3462
  var EnvelopeCreator = {
2864
- Version: "2.8.0-nightly.2202-06"
3463
+ Version: "2.8.0-nightly.2204-04"
2865
3464
  };
2866
3465
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
2867
3466
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -3156,65 +3755,81 @@
3156
3755
  return Serializer;
3157
3756
  }());
3158
3757
 
3159
- var OfflineListener = /** @class */ (function () {
3160
- function OfflineListener() {
3161
- var _window = getWindow();
3162
- var _document = getDocument();
3163
- var isListening = false;
3164
- var _onlineStatus = true;
3165
- dynamicProto(OfflineListener, this, function (_self) {
3166
- try {
3167
- if (_window) {
3168
- if (attachEvent(_window, "online", _setOnline)) {
3169
- attachEvent(_window, "offline", _setOffline);
3170
- isListening = true;
3171
- }
3172
- }
3173
- if (_document) {
3174
- var target = _document.body || _document;
3175
- if (!isUndefined(target.ononline)) {
3176
- target.ononline = _setOnline;
3177
- target.onoffline = _setOffline;
3178
- isListening = true;
3179
- }
3180
- }
3181
- if (isListening) {
3182
- var _navigator = getNavigator();
3183
- if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3184
- _onlineStatus = _navigator.onLine;
3185
- }
3758
+ function _disableEvents(target, evtNamespace) {
3759
+ eventOff(target, null, null, evtNamespace);
3760
+ }
3761
+ function createOfflineListener(parentEvtNamespace) {
3762
+ var _document = getDocument();
3763
+ var _navigator = getNavigator();
3764
+ var _isListening = false;
3765
+ var _onlineStatus = true;
3766
+ var _evtNamespace = mergeEvtNamespace(createUniqueNamespace("OfflineListener"), parentEvtNamespace);
3767
+ try {
3768
+ if (_enableEvents(getWindow())) {
3769
+ _isListening = true;
3770
+ }
3771
+ if (_document) {
3772
+ var target = _document.body || _document;
3773
+ if (target.ononline) {
3774
+ if (_enableEvents(target)) {
3775
+ _isListening = true;
3186
3776
  }
3187
3777
  }
3188
- catch (e) {
3189
- isListening = false;
3778
+ }
3779
+ if (_isListening) {
3780
+ if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3781
+ _onlineStatus = _navigator.onLine;
3190
3782
  }
3191
- _self.isListening = isListening;
3192
- _self.isOnline = function () {
3193
- var result = true;
3194
- var _navigator = getNavigator();
3195
- if (isListening) {
3196
- result = _onlineStatus;
3197
- }
3198
- else if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3199
- result = _navigator.onLine;
3200
- }
3201
- return result;
3202
- };
3203
- _self.isOffline = function () {
3204
- return !_self.isOnline();
3205
- };
3206
- function _setOnline() {
3207
- _onlineStatus = true;
3783
+ }
3784
+ }
3785
+ catch (e) {
3786
+ _isListening = false;
3787
+ }
3788
+ function _enableEvents(target) {
3789
+ var enabled = false;
3790
+ if (target) {
3791
+ enabled = eventOn(target, "online", _setOnline, _evtNamespace);
3792
+ if (enabled) {
3793
+ eventOn(target, "offline", _setOffline, _evtNamespace);
3208
3794
  }
3209
- function _setOffline() {
3210
- _onlineStatus = false;
3795
+ }
3796
+ return enabled;
3797
+ }
3798
+ function _setOnline() {
3799
+ _onlineStatus = true;
3800
+ }
3801
+ function _setOffline() {
3802
+ _onlineStatus = false;
3803
+ }
3804
+ function _isOnline() {
3805
+ var result = true;
3806
+ if (_isListening) {
3807
+ result = _onlineStatus;
3808
+ }
3809
+ else if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
3810
+ result = _navigator.onLine;
3811
+ }
3812
+ return result;
3813
+ }
3814
+ function _unload() {
3815
+ var win = getWindow();
3816
+ if (win && _isListening) {
3817
+ _disableEvents(win, _evtNamespace);
3818
+ if (_document) {
3819
+ var target = _document.body || _document;
3820
+ if (!isUndefined(target.ononline)) {
3821
+ _disableEvents(target, _evtNamespace);
3822
+ }
3211
3823
  }
3212
- });
3824
+ _isListening = false;
3825
+ }
3213
3826
  }
3214
- OfflineListener.Offline = new OfflineListener;
3215
- return OfflineListener;
3216
- }());
3217
- var Offline = OfflineListener.Offline;
3827
+ return {
3828
+ isOnline: _isOnline,
3829
+ isListening: function () { return _isListening; },
3830
+ unload: _unload
3831
+ };
3832
+ }
3218
3833
 
3219
3834
  var MIN_INPUT_LENGTH = 8;
3220
3835
  var HashCodeScoreGenerator = /** @class */ (function () {
@@ -3342,22 +3957,22 @@
3342
3957
  var _this = _super.call(this) || this;
3343
3958
  _this.priority = 1001;
3344
3959
  _this.identifier = BreezeChannelIdentifier;
3960
+ _this._senderConfig = _getDefaultAppInsightsChannelConfig();
3345
3961
  var _consecutiveErrors;
3346
3962
  var _retryAt;
3347
3963
  var _lastSend;
3348
- var _paused = false;
3964
+ var _paused;
3349
3965
  var _timeoutHandle;
3350
3966
  var _serializer;
3351
3967
  var _stamp_specific_redirects;
3352
- var _headers = {};
3968
+ var _headers;
3353
3969
  var _syncFetchPayload = 0;
3354
3970
  var _fallbackSender;
3355
3971
  var _syncUnloadSender;
3356
- _this._senderConfig = _getDefaultAppInsightsChannelConfig();
3972
+ var _offlineListener;
3973
+ var _evtNamespace;
3357
3974
  dynamicProto(Sender, _this, function (_self, _base) {
3358
- function _notImplemented() {
3359
- throwError("Method not implemented.");
3360
- }
3975
+ _initDefaults();
3361
3976
  _self.pause = function () {
3362
3977
  _clearScheduledTimer();
3363
3978
  _paused = true;
@@ -3372,14 +3987,15 @@
3372
3987
  _setupTimer();
3373
3988
  }
3374
3989
  };
3375
- _self.flush = function () {
3990
+ _self.flush = function (isAsync, callBack, sendReason) {
3991
+ if (isAsync === void 0) { isAsync = true; }
3376
3992
  if (!_paused) {
3377
3993
  _clearScheduledTimer();
3378
3994
  try {
3379
- _self.triggerSend(true, null, 1 );
3995
+ _self.triggerSend(isAsync, null, sendReason || 1 );
3380
3996
  }
3381
3997
  catch (e) {
3382
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3998
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3383
3999
  }
3384
4000
  }
3385
4001
  };
@@ -3390,7 +4006,7 @@
3390
4006
  _self.triggerSend(true, _doUnloadSend, 2 );
3391
4007
  }
3392
4008
  catch (e) {
3393
- _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) });
4009
+ _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) });
3394
4010
  }
3395
4011
  }
3396
4012
  else {
@@ -3398,11 +4014,13 @@
3398
4014
  }
3399
4015
  }
3400
4016
  };
3401
- _self.teardown = _notImplemented;
3402
4017
  _self.addHeader = function (name, value) {
3403
4018
  _headers[name] = value;
3404
4019
  };
3405
4020
  _self.initialize = function (config, core, extensions, pluginChain) {
4021
+ if (_self.isInitialized()) {
4022
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender is already initialized");
4023
+ }
3406
4024
  _base.initialize(config, core, extensions, pluginChain);
3407
4025
  var ctx = _self._getTelCtx();
3408
4026
  var identifier = _self.identifier;
@@ -3413,6 +4031,8 @@
3413
4031
  _self._sender = null;
3414
4032
  _stamp_specific_redirects = 0;
3415
4033
  var diagLog = _self.diagLog();
4034
+ _evtNamespace = mergeEvtNamespace(createUniqueNamespace("Sender"), core.evtNamespace && core.evtNamespace());
4035
+ _offlineListener = createOfflineListener(_evtNamespace);
3416
4036
  var defaultConfig = _getDefaultAppInsightsChannelConfig();
3417
4037
  objForEachKey(defaultConfig, function (field, value) {
3418
4038
  _self._senderConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };
@@ -3421,7 +4041,7 @@
3421
4041
  ? new SessionStorageSendBuffer(diagLog, _self._senderConfig) : new ArraySendBuffer(diagLog, _self._senderConfig);
3422
4042
  _self._sample = new Sample(_self._senderConfig.samplingPercentage(), diagLog);
3423
4043
  if (!_validateInstrumentationKey(config)) {
3424
- diagLog.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key " + config.instrumentationKey);
4044
+ _throwInternal(diagLog, LoggingSeverity.CRITICAL, _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key " + config.instrumentationKey);
3425
4045
  }
3426
4046
  if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders().length > 0) {
3427
4047
  arrForEach(_self._senderConfig.customHeaders(), function (customHeader) {
@@ -3467,22 +4087,22 @@
3467
4087
  return;
3468
4088
  }
3469
4089
  if (!telemetryItem) {
3470
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
4090
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
3471
4091
  return;
3472
4092
  }
3473
4093
  if (telemetryItem.baseData && !telemetryItem.baseType) {
3474
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
4094
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
3475
4095
  return;
3476
4096
  }
3477
4097
  if (!telemetryItem.baseType) {
3478
4098
  telemetryItem.baseType = "EventData";
3479
4099
  }
3480
4100
  if (!_self._sender) {
3481
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
4101
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
3482
4102
  return;
3483
4103
  }
3484
4104
  if (!_isSampledIn(telemetryItem)) {
3485
- itemCtx.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
4105
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
3486
4106
  return;
3487
4107
  }
3488
4108
  else {
@@ -3492,7 +4112,7 @@
3492
4112
  var defaultEnvelopeIkey = telemetryItem.iKey || _self._senderConfig.instrumentationKey();
3493
4113
  var aiEnvelope_1 = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, itemCtx.diagLog(), convertUndefined);
3494
4114
  if (!aiEnvelope_1) {
3495
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
4115
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
3496
4116
  return;
3497
4117
  }
3498
4118
  var doNotSendItem_1 = false;
@@ -3505,7 +4125,7 @@
3505
4125
  }
3506
4126
  }
3507
4127
  catch (e) {
3508
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
4128
+ _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3509
4129
  }
3510
4130
  });
3511
4131
  delete telemetryItem.tags[ProcessLegacy];
@@ -3523,7 +4143,7 @@
3523
4143
  _setupTimer();
3524
4144
  }
3525
4145
  catch (e) {
3526
- 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) });
4146
+ _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) });
3527
4147
  }
3528
4148
  _self.processNext(telemetryItem, itemCtx);
3529
4149
  };
@@ -3558,13 +4178,18 @@
3558
4178
  catch (e) {
3559
4179
  var ieVer = getIEVersion();
3560
4180
  if (!ieVer || ieVer > 9) {
3561
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
4181
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
3562
4182
  }
3563
4183
  }
3564
4184
  }
3565
4185
  };
4186
+ _self._doTeardown = function (unloadCtx, unloadState) {
4187
+ _self.onunloadFlush();
4188
+ _offlineListener.unload();
4189
+ _initDefaults();
4190
+ };
3566
4191
  _self._onError = function (payload, message, event) {
3567
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.OnError, "Failed to send telemetry.", { message: message });
4192
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.OnError, "Failed to send telemetry.", { message: message });
3568
4193
  _self._buffer.clearSent(payload);
3569
4194
  };
3570
4195
  _self._onPartialSuccess = function (payload, results) {
@@ -3589,7 +4214,7 @@
3589
4214
  }
3590
4215
  if (retry.length > 0) {
3591
4216
  _resendPayload(retry);
3592
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, "Partial success. " +
4217
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, "Partial success. " +
3593
4218
  "Delivered: " + payload.length + ", Failed: " + failed.length +
3594
4219
  ". Will retry to send " + retry.length + " our of " + results.itemsReceived + " items");
3595
4220
  }
@@ -3634,18 +4259,18 @@
3634
4259
  }
3635
4260
  if (!_self._senderConfig.isRetryDisabled() && _isRetriable(status)) {
3636
4261
  _resendPayload(payload);
3637
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
4262
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
3638
4263
  "Response code " + status + ". Will retry to send " + payload.length + " items.");
3639
4264
  }
3640
4265
  else {
3641
4266
  _self._onError(payload, errorMessage);
3642
4267
  }
3643
4268
  }
3644
- else if (Offline.isOffline()) {
4269
+ else if (_offlineListener && !_offlineListener.isOnline()) {
3645
4270
  if (!_self._senderConfig.isRetryDisabled()) {
3646
4271
  var offlineBackOffMultiplier = 10;
3647
4272
  _resendPayload(payload, offlineBackOffMultiplier);
3648
- _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."));
4273
+ _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."));
3649
4274
  }
3650
4275
  }
3651
4276
  else {
@@ -3712,8 +4337,8 @@
3712
4337
  }
3713
4338
  }
3714
4339
  if (droppedPayload.length > 0) {
3715
- _fallbackSender(droppedPayload, true);
3716
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
4340
+ _fallbackSender && _fallbackSender(droppedPayload, true);
4341
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
3717
4342
  }
3718
4343
  }
3719
4344
  }
@@ -3754,7 +4379,7 @@
3754
4379
  }
3755
4380
  else {
3756
4381
  _fallbackSender && _fallbackSender(payload, true);
3757
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
4382
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
3758
4383
  }
3759
4384
  }
3760
4385
  }
@@ -3845,7 +4470,7 @@
3845
4470
  }
3846
4471
  }
3847
4472
  catch (e) {
3848
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidBackendResponse, "Cannot parse the response. " + getExceptionName(e), {
4473
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidBackendResponse, "Cannot parse the response. " + getExceptionName(e), {
3849
4474
  response: response
3850
4475
  });
3851
4476
  }
@@ -3916,7 +4541,7 @@
3916
4541
  xdr.onerror = function (event) { return _self._onError(payload, _formatErrorMessageXdr(xdr), event); };
3917
4542
  var hostingProtocol = _window && _window.location && _window.location.protocol || "";
3918
4543
  if (_self._senderConfig.endpointUrl().lastIndexOf(hostingProtocol, 0) !== 0) {
3919
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
4544
+ _throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
3920
4545
  "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
3921
4546
  buffer.clear();
3922
4547
  return;
@@ -3947,7 +4572,7 @@
3947
4572
  manager.eventsSendRequest(sendRequest, isAsync);
3948
4573
  }
3949
4574
  catch (e) {
3950
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.NotificationException, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
4575
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.NotificationException, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
3951
4576
  }
3952
4577
  }
3953
4578
  }
@@ -3960,6 +4585,25 @@
3960
4585
  var regexp = new RegExp(UUID_Regex);
3961
4586
  return regexp.test(config.instrumentationKey);
3962
4587
  }
4588
+ function _initDefaults() {
4589
+ _self._sender = null;
4590
+ _self._buffer = null;
4591
+ _self._appId = null;
4592
+ _self._sample = null;
4593
+ _headers = {};
4594
+ _offlineListener = null;
4595
+ _consecutiveErrors = 0;
4596
+ _retryAt = null;
4597
+ _lastSend = null;
4598
+ _paused = false;
4599
+ _timeoutHandle = null;
4600
+ _serializer = null;
4601
+ _stamp_specific_redirects = 0;
4602
+ _syncFetchPayload = 0;
4603
+ _fallbackSender = null;
4604
+ _syncUnloadSender = null;
4605
+ _evtNamespace = null;
4606
+ }
3963
4607
  });
3964
4608
  return _this;
3965
4609
  }