@microsoft/applicationinsights-debugplugin-js 2.7.5-nightly.2203-01 → 2.7.5-nightly.2204-03

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 (58) hide show
  1. package/browser/{ai.dbg.2.7.5-nightly.2203-01.cjs.js → ai.dbg.2.7.5-nightly.2204-03.cjs.js} +1022 -460
  2. package/browser/ai.dbg.2.7.5-nightly.2204-03.cjs.js.map +1 -0
  3. package/browser/ai.dbg.2.7.5-nightly.2204-03.cjs.min.js +6 -0
  4. package/browser/ai.dbg.2.7.5-nightly.2204-03.cjs.min.js.map +1 -0
  5. package/browser/{ai.dbg.2.7.5-nightly.2203-01.gbl.js → ai.dbg.2.7.5-nightly.2204-03.gbl.js} +1022 -460
  6. package/browser/ai.dbg.2.7.5-nightly.2204-03.gbl.js.map +1 -0
  7. package/browser/ai.dbg.2.7.5-nightly.2204-03.gbl.min.js +6 -0
  8. package/browser/ai.dbg.2.7.5-nightly.2204-03.gbl.min.js.map +1 -0
  9. package/browser/ai.dbg.2.7.5-nightly.2204-03.integrity.json +66 -0
  10. package/browser/{ai.dbg.2.7.5-nightly.2203-01.js → ai.dbg.2.7.5-nightly.2204-03.js} +1022 -460
  11. package/browser/ai.dbg.2.7.5-nightly.2204-03.js.map +1 -0
  12. package/browser/ai.dbg.2.7.5-nightly.2204-03.min.js +6 -0
  13. package/browser/ai.dbg.2.7.5-nightly.2204-03.min.js.map +1 -0
  14. package/browser/ai.dbg.2.cjs.js +1021 -459
  15. package/browser/ai.dbg.2.cjs.js.map +1 -1
  16. package/browser/ai.dbg.2.cjs.min.js +2 -2
  17. package/browser/ai.dbg.2.cjs.min.js.map +1 -1
  18. package/browser/ai.dbg.2.gbl.js +1021 -459
  19. package/browser/ai.dbg.2.gbl.js.map +1 -1
  20. package/browser/ai.dbg.2.gbl.min.js +2 -2
  21. package/browser/ai.dbg.2.gbl.min.js.map +1 -1
  22. package/browser/ai.dbg.2.js +1021 -459
  23. package/browser/ai.dbg.2.js.map +1 -1
  24. package/browser/ai.dbg.2.min.js +2 -2
  25. package/browser/ai.dbg.2.min.js.map +1 -1
  26. package/dist/applicationinsights-debugplugin-js.api.json +1 -1
  27. package/dist/applicationinsights-debugplugin-js.d.ts +1 -1
  28. package/dist/applicationinsights-debugplugin-js.js +1021 -459
  29. package/dist/applicationinsights-debugplugin-js.js.map +1 -1
  30. package/dist/applicationinsights-debugplugin-js.min.js +2 -2
  31. package/dist/applicationinsights-debugplugin-js.min.js.map +1 -1
  32. package/dist/applicationinsights-debugplugin-js.rollup.d.ts +1 -1
  33. package/dist-esm/DebugPlugin.js +1 -1
  34. package/dist-esm/applicationinsights-debugplugin-js.js +1 -1
  35. package/dist-esm/components/Dashboard.js +1 -1
  36. package/dist-esm/components/LogEntry.js +3 -3
  37. package/dist-esm/components/LogEntry.js.map +1 -1
  38. package/dist-esm/components/debugBins.js +1 -1
  39. package/dist-esm/components/filterList.js +1 -1
  40. package/dist-esm/components/helpers.js +1 -1
  41. package/dist-esm/components/styleNodeSrc.js +1 -1
  42. package/dist-esm/interfaces/IDebugPluginConfig.js +1 -1
  43. package/package.json +4 -4
  44. package/src/components/LogEntry.ts +2 -2
  45. package/src/components/debugBins.ts +7 -6
  46. package/src/components/helpers.ts +55 -45
  47. package/src/components/styleNodeSrc.ts +33 -33
  48. package/types/tsdoc-metadata.json +1 -1
  49. package/browser/ai.dbg.2.7.5-nightly.2203-01.cjs.js.map +0 -1
  50. package/browser/ai.dbg.2.7.5-nightly.2203-01.cjs.min.js +0 -6
  51. package/browser/ai.dbg.2.7.5-nightly.2203-01.cjs.min.js.map +0 -1
  52. package/browser/ai.dbg.2.7.5-nightly.2203-01.gbl.js.map +0 -1
  53. package/browser/ai.dbg.2.7.5-nightly.2203-01.gbl.min.js +0 -6
  54. package/browser/ai.dbg.2.7.5-nightly.2203-01.gbl.min.js.map +0 -1
  55. package/browser/ai.dbg.2.7.5-nightly.2203-01.integrity.json +0 -66
  56. package/browser/ai.dbg.2.7.5-nightly.2203-01.js.map +0 -1
  57. package/browser/ai.dbg.2.7.5-nightly.2203-01.min.js +0 -6
  58. package/browser/ai.dbg.2.7.5-nightly.2203-01.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Debug Plugin, 2.7.5-nightly.2203-01
2
+ * Application Insights JavaScript SDK - Debug Plugin, 2.7.5-nightly.2204-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -62,7 +62,9 @@
62
62
  (getGlobal() || {})["Reflect"];
63
63
  var extendStaticsFn = function (d, b) {
64
64
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
65
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
65
+ ({ __proto__: [] } instanceof Array && function (d, b) {
66
+ d.__proto__ = b;
67
+ }) ||
66
68
  function (d, b) {
67
69
  for (var p in b) {
68
70
  if (b[strShimHasOwnProperty](p)) {
@@ -77,7 +79,9 @@
77
79
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
78
80
  }
79
81
  extendStaticsFn(d, b);
80
- function __() { this.constructor = d; }
82
+ function __() {
83
+ this.constructor = d;
84
+ }
81
85
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
82
86
  }
83
87
 
@@ -322,99 +326,15 @@
322
326
  };
323
327
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
324
328
 
325
- var LoggingSeverity;
326
- (function (LoggingSeverity) {
327
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
328
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
329
- })(LoggingSeverity || (LoggingSeverity = {}));
330
- var _InternalMessageId = {
331
- BrowserDoesNotSupportLocalStorage: 0,
332
- BrowserCannotReadLocalStorage: 1,
333
- BrowserCannotReadSessionStorage: 2,
334
- BrowserCannotWriteLocalStorage: 3,
335
- BrowserCannotWriteSessionStorage: 4,
336
- BrowserFailedRemovalFromLocalStorage: 5,
337
- BrowserFailedRemovalFromSessionStorage: 6,
338
- CannotSendEmptyTelemetry: 7,
339
- ClientPerformanceMathError: 8,
340
- ErrorParsingAISessionCookie: 9,
341
- ErrorPVCalc: 10,
342
- ExceptionWhileLoggingError: 11,
343
- FailedAddingTelemetryToBuffer: 12,
344
- FailedMonitorAjaxAbort: 13,
345
- FailedMonitorAjaxDur: 14,
346
- FailedMonitorAjaxOpen: 15,
347
- FailedMonitorAjaxRSC: 16,
348
- FailedMonitorAjaxSend: 17,
349
- FailedMonitorAjaxGetCorrelationHeader: 18,
350
- FailedToAddHandlerForOnBeforeUnload: 19,
351
- FailedToSendQueuedTelemetry: 20,
352
- FailedToReportDataLoss: 21,
353
- FlushFailed: 22,
354
- MessageLimitPerPVExceeded: 23,
355
- MissingRequiredFieldSpecification: 24,
356
- NavigationTimingNotSupported: 25,
357
- OnError: 26,
358
- SessionRenewalDateIsZero: 27,
359
- SenderNotInitialized: 28,
360
- StartTrackEventFailed: 29,
361
- StopTrackEventFailed: 30,
362
- StartTrackFailed: 31,
363
- StopTrackFailed: 32,
364
- TelemetrySampledAndNotSent: 33,
365
- TrackEventFailed: 34,
366
- TrackExceptionFailed: 35,
367
- TrackMetricFailed: 36,
368
- TrackPVFailed: 37,
369
- TrackPVFailedCalc: 38,
370
- TrackTraceFailed: 39,
371
- TransmissionFailed: 40,
372
- FailedToSetStorageBuffer: 41,
373
- FailedToRestoreStorageBuffer: 42,
374
- InvalidBackendResponse: 43,
375
- FailedToFixDepricatedValues: 44,
376
- InvalidDurationValue: 45,
377
- TelemetryEnvelopeInvalid: 46,
378
- CreateEnvelopeError: 47,
379
- CannotSerializeObject: 48,
380
- CannotSerializeObjectNonSerializable: 49,
381
- CircularReferenceDetected: 50,
382
- ClearAuthContextFailed: 51,
383
- ExceptionTruncated: 52,
384
- IllegalCharsInName: 53,
385
- ItemNotInArray: 54,
386
- MaxAjaxPerPVExceeded: 55,
387
- MessageTruncated: 56,
388
- NameTooLong: 57,
389
- SampleRateOutOfRange: 58,
390
- SetAuthContextFailed: 59,
391
- SetAuthContextFailedAccountName: 60,
392
- StringValueTooLong: 61,
393
- StartCalledMoreThanOnce: 62,
394
- StopCalledWithoutStart: 63,
395
- TelemetryInitializerFailed: 64,
396
- TrackArgumentsNotSpecified: 65,
397
- UrlTooLong: 66,
398
- SessionStorageBufferFull: 67,
399
- CannotAccessCookie: 68,
400
- IdTooLong: 69,
401
- InvalidEvent: 70,
402
- FailedMonitorAjaxSetRequestHeader: 71,
403
- SendBrowserInfoOnUserInit: 72,
404
- PluginException: 73,
405
- NotificationException: 74,
406
- SnippetScriptLoadFailure: 99,
407
- InvalidInstrumentationKey: 100,
408
- CannotParseAiBlobValue: 101,
409
- InvalidContentBlob: 102,
410
- TrackPageActionEventFailed: 103,
411
- FailedAddingCustomDefinedRequestContext: 104,
412
- InMemoryStorageBufferFull: 105
413
- };
329
+ var strEmpty$1 = "";
330
+ var strSetNextPlugin = "setNextPlugin";
331
+ var strIsInitialized = "isInitialized";
332
+ var strTeardown = "teardown";
333
+ var strCore = "core";
334
+ var strUpdate = "update";
335
+ var strDisabled = "disabled";
336
+ var strDoTeardown = "_doTeardown";
414
337
 
415
- var strOnPrefix = "on";
416
- var strAttachEvent = "attachEvent";
417
- var strAddEventHelper = "addEventListener";
418
338
  var strToISOString = "toISOString";
419
339
  var cStrEndsWith = "endsWith";
420
340
  var strIndexOf = "indexOf";
@@ -424,7 +344,8 @@
424
344
  var strToString = "toString";
425
345
  var str__Proto = "__proto__";
426
346
  var strConstructor$1 = "constructor";
427
- var _objDefineProperty = ObjDefineProperty;
347
+ var _objDefineProperty$1 = ObjDefineProperty;
348
+ var _objFreeze = ObjClass.freeze;
428
349
  var _objKeys = ObjClass.keys;
429
350
  var StringProto = String[strShimPrototype];
430
351
  var _strTrim = StringProto[cStrTrim];
@@ -434,7 +355,10 @@
434
355
  var _isArray = Array.isArray;
435
356
  var _objToString = ObjProto[strToString];
436
357
  var _fnToString = ObjHasOwnProperty[strToString];
437
- _fnToString.call(ObjClass);
358
+ var _objFunctionString = _fnToString.call(ObjClass);
359
+ var rCamelCase = /-([a-z])/g;
360
+ var rNormalizeInvalid = /([^\w\d_$])/g;
361
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
438
362
  var _objGetPrototypeOf = Object["getPrototypeOf"];
439
363
  function _getObjProto(target) {
440
364
  if (target) {
@@ -448,6 +372,9 @@
448
372
  }
449
373
  return null;
450
374
  }
375
+ function objToString(obj) {
376
+ return _objToString.call(obj);
377
+ }
451
378
  function isTypeof(value, theType) {
452
379
  return typeof value === theType;
453
380
  }
@@ -469,24 +396,18 @@
469
396
  function isFunction(value) {
470
397
  return !!(value && typeof value === strShimFunction);
471
398
  }
472
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
473
- if (useCapture === void 0) { useCapture = false; }
474
- var result = false;
475
- if (!isNullOrUndefined(obj)) {
476
- try {
477
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
478
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
479
- result = true;
480
- }
481
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
482
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
483
- result = true;
484
- }
485
- }
486
- catch (e) {
487
- }
399
+ function normalizeJsName(name) {
400
+ var value = name;
401
+ if (value && isString(value)) {
402
+ value = value.replace(rCamelCase, function (_all, letter) {
403
+ return letter.toUpperCase();
404
+ });
405
+ value = value.replace(rNormalizeInvalid, "_");
406
+ value = value.replace(rLeadingNumeric, function (_all, match) {
407
+ return "_" + match;
408
+ });
488
409
  }
489
- return result;
410
+ return value;
490
411
  }
491
412
  function objForEachKey(target, callbackfn) {
492
413
  if (target) {
@@ -548,6 +469,22 @@
548
469
  function isSymbol(value) {
549
470
  return typeof value === "symbol";
550
471
  }
472
+ function isPlainObject(value) {
473
+ var result = false;
474
+ if (value && typeof value === "object") {
475
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
476
+ if (!proto) {
477
+ result = true;
478
+ }
479
+ else {
480
+ if (proto[strConstructor$1] && ObjHasOwnProperty.call(proto, strConstructor$1)) {
481
+ proto = proto[strConstructor$1];
482
+ }
483
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
484
+ }
485
+ }
486
+ return result;
487
+ }
551
488
  function toISOString(date) {
552
489
  if (date) {
553
490
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -693,7 +630,7 @@
693
630
  return result;
694
631
  }
695
632
  function objDefineAccessors(target, prop, getProp, setProp) {
696
- if (_objDefineProperty) {
633
+ if (_objDefineProperty$1) {
697
634
  try {
698
635
  var descriptor = {
699
636
  enumerable: true,
@@ -705,7 +642,7 @@
705
642
  if (setProp) {
706
643
  descriptor.set = setProp;
707
644
  }
708
- _objDefineProperty(target, prop, descriptor);
645
+ _objDefineProperty$1(target, prop, descriptor);
709
646
  return true;
710
647
  }
711
648
  catch (e) {
@@ -713,6 +650,10 @@
713
650
  }
714
651
  return false;
715
652
  }
653
+ function _doNothing(value) {
654
+ return value;
655
+ }
656
+ var objFreeze = _objFreeze || _doNothing;
716
657
  function dateNow() {
717
658
  var dt = Date;
718
659
  return dt.now ? dt.now() : new dt().getTime();
@@ -721,7 +662,7 @@
721
662
  if (isError(object)) {
722
663
  return object.name;
723
664
  }
724
- return "";
665
+ return strEmpty$1;
725
666
  }
726
667
  function setValue(target, field, value, valChk, srcChk) {
727
668
  var theValue = value;
@@ -737,6 +678,91 @@
737
678
  function isTruthy(value) {
738
679
  return !!value;
739
680
  }
681
+ function throwError(message) {
682
+ throw new Error(message);
683
+ }
684
+ function _createProxyFunction(source, funcName) {
685
+ var srcFunc = null;
686
+ var src = null;
687
+ if (isFunction(source)) {
688
+ srcFunc = source;
689
+ }
690
+ else {
691
+ src = source;
692
+ }
693
+ return function () {
694
+ var originalArguments = arguments;
695
+ if (srcFunc) {
696
+ src = srcFunc();
697
+ }
698
+ if (src) {
699
+ return src[funcName].apply(src, originalArguments);
700
+ }
701
+ };
702
+ }
703
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
704
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
705
+ if (target && name && source) {
706
+ if (overwriteTarget || isUndefined(target[name])) {
707
+ target[name] = _createProxyFunction(source, theFunc);
708
+ }
709
+ }
710
+ }
711
+ function createEnumStyle(values) {
712
+ var enumClass = {};
713
+ objForEachKey(values, function (field, value) {
714
+ enumClass[field] = value;
715
+ if (!isUndefined(enumClass[value])) {
716
+ throwError("[" + value + "] exists for " + field);
717
+ }
718
+ enumClass[value] = field;
719
+ });
720
+ return objFreeze(enumClass);
721
+ }
722
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
723
+ var theArgs = arguments;
724
+ var extended = theArgs[0] || {};
725
+ var argLen = theArgs.length;
726
+ var deep = false;
727
+ var idx = 1;
728
+ if (argLen > 0 && isBoolean(extended)) {
729
+ deep = extended;
730
+ extended = theArgs[idx] || {};
731
+ idx++;
732
+ }
733
+ if (!isObject(extended)) {
734
+ extended = {};
735
+ }
736
+ for (; idx < argLen; idx++) {
737
+ var arg = theArgs[idx];
738
+ var isArgArray = isArray(arg);
739
+ var isArgObj = isObject(arg);
740
+ for (var prop in arg) {
741
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
742
+ if (!propOk) {
743
+ continue;
744
+ }
745
+ var newValue = arg[prop];
746
+ var isNewArray = void 0;
747
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
748
+ var clone = extended[prop];
749
+ if (isNewArray) {
750
+ if (!isArray(clone)) {
751
+ clone = [];
752
+ }
753
+ }
754
+ else if (!isPlainObject(clone)) {
755
+ clone = {};
756
+ }
757
+ newValue = objExtend(deep, clone, newValue);
758
+ }
759
+ if (newValue !== undefined) {
760
+ extended[prop] = newValue;
761
+ }
762
+ }
763
+ }
764
+ return extended;
765
+ }
740
766
 
741
767
  var strWindow = "window";
742
768
  var strDocument = "document";
@@ -831,7 +857,7 @@
831
857
  var nav = getNavigator();
832
858
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
833
859
  _navUserAgentCheck = nav.userAgent;
834
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
860
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
835
861
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
836
862
  }
837
863
  return _isTrident;
@@ -840,9 +866,9 @@
840
866
  if (userAgentStr === void 0) { userAgentStr = null; }
841
867
  if (!userAgentStr) {
842
868
  var navigator_1 = getNavigator() || {};
843
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
869
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
844
870
  }
845
- var ua = (userAgentStr || "").toLowerCase();
871
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
846
872
  if (strContains(ua, strMsie)) {
847
873
  var doc = getDocument() || {};
848
874
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -857,7 +883,7 @@
857
883
  }
858
884
  function dumpObj(object) {
859
885
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
860
- var propertyValueDump = "";
886
+ var propertyValueDump = strEmpty$1;
861
887
  if (objectTypeDump === "[object Error]") {
862
888
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
863
889
  }
@@ -896,9 +922,9 @@
896
922
  var strWarnToConsole = "warnToConsole";
897
923
  function _sanitizeDiagnosticText(text) {
898
924
  if (text) {
899
- return "\"" + text.replace(/\"/g, "") + "\"";
925
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
900
926
  }
901
- return "";
927
+ return strEmpty$1;
902
928
  }
903
929
  function _logToConsole(func, message) {
904
930
  var theConsole = getConsole();
@@ -920,12 +946,12 @@
920
946
  _self.message =
921
947
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
922
948
  msgId;
923
- var strProps = "";
949
+ var strProps = strEmpty$1;
924
950
  if (hasJSON()) {
925
951
  strProps = getJSON().stringify(properties);
926
952
  }
927
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
928
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
953
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
954
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
929
955
  _self.message += diagnosticText;
930
956
  }
931
957
  _InternalLogMessage.dataType = "MessageData";
@@ -955,7 +981,7 @@
955
981
  throw message;
956
982
  }
957
983
  else {
958
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
984
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
959
985
  if (!isUndefined(message.message)) {
960
986
  var logLevel = _self.consoleLoggingLevel();
961
987
  if (isUserAct) {
@@ -973,7 +999,7 @@
973
999
  _self.logInternalMessage(severity, message);
974
1000
  }
975
1001
  else {
976
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1002
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
977
1003
  }
978
1004
  }
979
1005
  };
@@ -1005,13 +1031,13 @@
1005
1031
  if (severity <= _self.telemetryLoggingLevel()) {
1006
1032
  _self.queue.push(message);
1007
1033
  _messageCount++;
1008
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1034
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1009
1035
  }
1010
1036
  if (_messageCount === _self.maxInternalMessageLimit()) {
1011
1037
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1012
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1038
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1013
1039
  _self.queue.push(throttleMessage);
1014
- if (severity === LoggingSeverity.CRITICAL) {
1040
+ if (severity === 1 ) {
1015
1041
  _self.errorToConsole(throttleLimitMessage);
1016
1042
  }
1017
1043
  else {
@@ -1040,6 +1066,10 @@
1040
1066
  }
1041
1067
  return DiagnosticLogger;
1042
1068
  }());
1069
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1070
+ if (isUserAct === void 0) { isUserAct = false; }
1071
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1072
+ }
1043
1073
 
1044
1074
  var strExecutionContextKey = "ctx";
1045
1075
  var PerfEvent = /** @class */ (function () {
@@ -1153,252 +1183,509 @@
1153
1183
  return func();
1154
1184
  }
1155
1185
 
1156
- var TelemetryPluginChain = /** @class */ (function () {
1157
- function TelemetryPluginChain(plugin, defItemCtx) {
1158
- var _self = this;
1159
- var _nextProxy = null;
1160
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1161
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1162
- _self._hasRun = false;
1163
- _self.getPlugin = function () {
1164
- return plugin;
1165
- };
1166
- _self.getNext = function () {
1167
- return _nextProxy;
1168
- };
1169
- _self.setNext = function (nextPlugin) {
1170
- _nextProxy = nextPlugin;
1171
- };
1172
- _self.processTelemetry = function (env, itemCtx) {
1173
- if (!itemCtx) {
1174
- itemCtx = defItemCtx;
1186
+ var UInt32Mask = 0x100000000;
1187
+ var MaxUInt32 = 0xffffffff;
1188
+ var _mwcSeeded = false;
1189
+ var _mwcW = 123456789;
1190
+ var _mwcZ = 987654321;
1191
+ function _mwcSeed(seedValue) {
1192
+ if (seedValue < 0) {
1193
+ seedValue >>>= 0;
1194
+ }
1195
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1196
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1197
+ _mwcSeeded = true;
1198
+ }
1199
+ function _autoSeedMwc() {
1200
+ try {
1201
+ var now = dateNow() & 0x7fffffff;
1202
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1203
+ }
1204
+ catch (e) {
1205
+ }
1206
+ }
1207
+ function randomValue(maxValue) {
1208
+ if (maxValue > 0) {
1209
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1210
+ }
1211
+ return 0;
1212
+ }
1213
+ function random32(signed) {
1214
+ var value = 0;
1215
+ var c = getCrypto() || getMsCrypto();
1216
+ if (c && c.getRandomValues) {
1217
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1218
+ }
1219
+ if (value === 0 && isIE()) {
1220
+ if (!_mwcSeeded) {
1221
+ _autoSeedMwc();
1222
+ }
1223
+ value = mwcRandom32() & MaxUInt32;
1224
+ }
1225
+ if (value === 0) {
1226
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1227
+ }
1228
+ if (!signed) {
1229
+ value >>>= 0;
1230
+ }
1231
+ return value;
1232
+ }
1233
+ function mwcRandomSeed(value) {
1234
+ if (!value) {
1235
+ _autoSeedMwc();
1236
+ }
1237
+ else {
1238
+ _mwcSeed(value);
1239
+ }
1240
+ }
1241
+ function mwcRandom32(signed) {
1242
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1243
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1244
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1245
+ if (!signed) {
1246
+ value >>>= 0;
1247
+ }
1248
+ return value;
1249
+ }
1250
+ function newId(maxLength) {
1251
+ if (maxLength === void 0) { maxLength = 22; }
1252
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1253
+ var number = random32() >>> 0;
1254
+ var chars = 0;
1255
+ var result = strEmpty$1;
1256
+ while (result.length < maxLength) {
1257
+ chars++;
1258
+ result += base64chars.charAt(number & 0x3F);
1259
+ number >>>= 6;
1260
+ if (chars === 5) {
1261
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1262
+ chars = 0;
1263
+ }
1264
+ }
1265
+ return result;
1266
+ }
1267
+
1268
+ var _objDefineProperty = ObjDefineProperty;
1269
+ var version = "2.7.5-nightly.2204-03";
1270
+ var instanceName = "." + newId(6);
1271
+ var _dataUid = 0;
1272
+ function _createAccessor(target, prop, value) {
1273
+ if (_objDefineProperty) {
1274
+ try {
1275
+ _objDefineProperty(target, prop, {
1276
+ value: value,
1277
+ enumerable: false,
1278
+ configurable: true
1279
+ });
1280
+ return true;
1281
+ }
1282
+ catch (e) {
1283
+ }
1284
+ }
1285
+ return false;
1286
+ }
1287
+ function _canAcceptData(target) {
1288
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1289
+ }
1290
+ function _getCache(data, target) {
1291
+ var theCache = target[data.id];
1292
+ if (!theCache) {
1293
+ theCache = {};
1294
+ try {
1295
+ if (_canAcceptData(target)) {
1296
+ if (!_createAccessor(target, data.id, theCache)) {
1297
+ target[data.id] = theCache;
1298
+ }
1175
1299
  }
1176
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1177
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1178
- if (plugin && _hasProcessTelemetry) {
1179
- _self._hasRun = true;
1300
+ }
1301
+ catch (e) {
1302
+ }
1303
+ }
1304
+ return theCache;
1305
+ }
1306
+ function createUniqueNamespace(name, includeVersion) {
1307
+ if (includeVersion === void 0) { includeVersion = false; }
1308
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1309
+ }
1310
+ function createElmNodeData(name) {
1311
+ var data = {
1312
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1313
+ accept: function (target) {
1314
+ return _canAcceptData(target);
1315
+ },
1316
+ get: function (target, name, defValue, addDefault) {
1317
+ var theCache = target[data.id];
1318
+ if (!theCache) {
1319
+ if (addDefault) {
1320
+ theCache = _getCache(data, target);
1321
+ theCache[normalizeJsName(name)] = defValue;
1322
+ }
1323
+ return defValue;
1324
+ }
1325
+ return theCache[normalizeJsName(name)];
1326
+ },
1327
+ kill: function (target, name) {
1328
+ if (target && target[name]) {
1329
+ try {
1330
+ delete target[name];
1331
+ }
1332
+ catch (e) {
1333
+ }
1334
+ }
1335
+ }
1336
+ };
1337
+ return data;
1338
+ }
1339
+
1340
+ var pluginStateData = createElmNodeData("plugin");
1341
+ function _getPluginState(plugin) {
1342
+ return pluginStateData.get(plugin, "state", {}, true);
1343
+ }
1344
+
1345
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1346
+ var strHasRunFlags = "_hasRun";
1347
+ var strGetTelCtx = "_getTelCtx";
1348
+ var _chainId = 0;
1349
+ function _getNextProxyStart(proxy, config, core, startAt) {
1350
+ while (proxy) {
1351
+ if (proxy.getPlugin() === startAt) {
1352
+ return proxy;
1353
+ }
1354
+ proxy = proxy.getNext();
1355
+ }
1356
+ return createTelemetryProxyChain([startAt], config, core);
1357
+ }
1358
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1359
+ var _nextProxy = null;
1360
+ var _onComplete = [];
1361
+ if (startAt !== null) {
1362
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1363
+ }
1364
+ var context = {
1365
+ _next: _moveNext,
1366
+ ctx: {
1367
+ core: function () {
1368
+ return core;
1369
+ },
1370
+ diagLog: function () {
1371
+ return safeGetLogger(core, config);
1372
+ },
1373
+ getCfg: function () {
1374
+ return config;
1375
+ },
1376
+ getExtCfg: _getExtCfg,
1377
+ getConfig: _getConfig,
1378
+ hasNext: function () {
1379
+ return !!_nextProxy;
1380
+ },
1381
+ getNext: function () {
1382
+ return _nextProxy;
1383
+ },
1384
+ setNext: function (nextPlugin) {
1385
+ _nextProxy = nextPlugin;
1386
+ },
1387
+ iterate: _iterateChain,
1388
+ onComplete: _addOnComplete
1389
+ }
1390
+ };
1391
+ function _addOnComplete(onComplete, that) {
1392
+ var args = [];
1393
+ for (var _i = 2; _i < arguments.length; _i++) {
1394
+ args[_i - 2] = arguments[_i];
1395
+ }
1396
+ if (onComplete) {
1397
+ _onComplete.push({
1398
+ func: onComplete,
1399
+ self: !isUndefined(that) ? that : context.ctx,
1400
+ args: args
1401
+ });
1402
+ }
1403
+ }
1404
+ function _moveNext() {
1405
+ var nextProxy = _nextProxy;
1406
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1407
+ if (!nextProxy) {
1408
+ var onComplete = _onComplete;
1409
+ if (onComplete && onComplete.length > 0) {
1410
+ arrForEach(onComplete, function (completeDetails) {
1180
1411
  try {
1181
- itemCtx.setNext(_nextProxy);
1182
- if (_hasSetNext) {
1183
- plugin.setNextPlugin(_nextProxy);
1184
- }
1185
- _nextProxy && (_nextProxy._hasRun = false);
1186
- plugin.processTelemetry(env, itemCtx);
1412
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1187
1413
  }
1188
- catch (error) {
1189
- var hasRun = _nextProxy && _nextProxy._hasRun;
1190
- if (!_nextProxy || !hasRun) {
1191
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1192
- }
1193
- if (_nextProxy && !hasRun) {
1194
- _nextProxy.processTelemetry(env, itemCtx);
1195
- }
1414
+ catch (e) {
1415
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1196
1416
  }
1197
- }
1198
- else if (_nextProxy) {
1199
- _self._hasRun = true;
1200
- _nextProxy.processTelemetry(env, itemCtx);
1201
- }
1202
- }, function () { return ({ item: env }); }, !(env.sync));
1203
- };
1417
+ });
1418
+ _onComplete = [];
1419
+ }
1420
+ }
1421
+ return nextProxy;
1204
1422
  }
1205
- return TelemetryPluginChain;
1206
- }());
1207
-
1208
- function _createProxyChain(plugins, itemCtx) {
1209
- var proxies = [];
1210
- if (plugins && plugins.length > 0) {
1211
- var lastProxy = null;
1212
- for (var idx = 0; idx < plugins.length; idx++) {
1213
- var thePlugin = plugins[idx];
1214
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1215
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1216
- proxies.push(newProxy);
1217
- if (lastProxy) {
1218
- lastProxy.setNext(newProxy);
1423
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1424
+ if (defaultValue === void 0) { defaultValue = {}; }
1425
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1426
+ var theConfig;
1427
+ if (config) {
1428
+ var extConfig = config.extensionConfig;
1429
+ if (extConfig && identifier) {
1430
+ theConfig = extConfig[identifier];
1431
+ }
1432
+ }
1433
+ if (!theConfig) {
1434
+ theConfig = defaultValue;
1435
+ }
1436
+ else if (isObject(defaultValue)) {
1437
+ if (mergeDefault !== 0 ) {
1438
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1439
+ if (config && mergeDefault === 2 ) {
1440
+ objForEachKey(defaultValue, function (field) {
1441
+ if (isNullOrUndefined(newConfig_1[field])) {
1442
+ var cfgValue = config[field];
1443
+ if (!isNullOrUndefined(cfgValue)) {
1444
+ newConfig_1[field] = cfgValue;
1445
+ }
1446
+ }
1447
+ });
1219
1448
  }
1220
- lastProxy = newProxy;
1221
1449
  }
1222
1450
  }
1451
+ return theConfig;
1223
1452
  }
1224
- return proxies.length > 0 ? proxies[0] : null;
1225
- }
1226
- function _copyProxyChain(proxy, itemCtx, startAt) {
1227
- var plugins = [];
1228
- var add = startAt ? false : true;
1229
- if (proxy) {
1230
- while (proxy) {
1231
- var thePlugin = proxy.getPlugin();
1232
- if (add || thePlugin === startAt) {
1233
- add = true;
1234
- plugins.push(thePlugin);
1453
+ function _getConfig(identifier, field, defaultValue) {
1454
+ if (defaultValue === void 0) { defaultValue = false; }
1455
+ var theValue;
1456
+ var extConfig = _getExtCfg(identifier, null);
1457
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1458
+ theValue = extConfig[field];
1459
+ }
1460
+ else if (config && !isNullOrUndefined(config[field])) {
1461
+ theValue = config[field];
1462
+ }
1463
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1464
+ }
1465
+ function _iterateChain(cb) {
1466
+ var nextPlugin;
1467
+ while (!!(nextPlugin = context._next())) {
1468
+ var plugin = nextPlugin.getPlugin();
1469
+ if (plugin) {
1470
+ cb(plugin);
1235
1471
  }
1236
- proxy = proxy.getNext();
1237
1472
  }
1238
1473
  }
1239
- if (!add) {
1240
- plugins.push(startAt);
1474
+ return context;
1475
+ }
1476
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1477
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1478
+ var context = internalContext.ctx;
1479
+ function _processNext(env) {
1480
+ var nextPlugin = internalContext._next();
1481
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1482
+ return !nextPlugin;
1483
+ }
1484
+ function _createNew(plugins, startAt) {
1485
+ if (plugins === void 0) { plugins = null; }
1486
+ if (isArray(plugins)) {
1487
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1488
+ }
1489
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1241
1490
  }
1242
- return _createProxyChain(plugins, itemCtx);
1491
+ context.processNext = _processNext;
1492
+ context.createNew = _createNew;
1493
+ return context;
1243
1494
  }
1244
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1245
- var plugins = srcPlugins;
1246
- var add = false;
1247
- if (startAt && srcPlugins) {
1248
- plugins = [];
1249
- arrForEach(srcPlugins, function (thePlugin) {
1250
- if (add || thePlugin === startAt) {
1251
- add = true;
1252
- plugins.push(thePlugin);
1495
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1496
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1497
+ var context = internalContext.ctx;
1498
+ function _processNext(unloadState) {
1499
+ var nextPlugin = internalContext._next();
1500
+ nextPlugin && nextPlugin.unload(context, unloadState);
1501
+ return !nextPlugin;
1502
+ }
1503
+ function _createNew(plugins, startAt) {
1504
+ if (plugins === void 0) { plugins = null; }
1505
+ if (isArray(plugins)) {
1506
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1507
+ }
1508
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1509
+ }
1510
+ context.processNext = _processNext;
1511
+ context.createNew = _createNew;
1512
+ return context;
1513
+ }
1514
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1515
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1516
+ var context = internalContext.ctx;
1517
+ function _processNext(updateState) {
1518
+ return context.iterate(function (plugin) {
1519
+ if (isFunction(plugin[strUpdate])) {
1520
+ plugin[strUpdate](context, updateState);
1253
1521
  }
1254
1522
  });
1255
1523
  }
1256
- if (startAt && !add) {
1257
- if (!plugins) {
1258
- plugins = [];
1524
+ function _createNew(plugins, startAt) {
1525
+ if (plugins === void 0) { plugins = null; }
1526
+ if (isArray(plugins)) {
1527
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1259
1528
  }
1260
- plugins.push(startAt);
1529
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1261
1530
  }
1262
- return _createProxyChain(plugins, itemCtx);
1531
+ context.processNext = _processNext;
1532
+ context.createNew = _createNew;
1533
+ return context;
1263
1534
  }
1264
- var ProcessTelemetryContext = /** @class */ (function () {
1265
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1266
- var _self = this;
1267
- var _nextProxy = null;
1268
- if (startAt !== null) {
1269
- if (plugins && isFunction(plugins.getPlugin)) {
1270
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1535
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1536
+ var firstProxy = null;
1537
+ var add = startAt ? false : true;
1538
+ if (isArray(plugins) && plugins.length > 0) {
1539
+ var lastProxy_1 = null;
1540
+ arrForEach(plugins, function (thePlugin) {
1541
+ if (!add && startAt === thePlugin) {
1542
+ add = true;
1271
1543
  }
1272
- else {
1273
- if (startAt) {
1274
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1544
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1545
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1546
+ if (!firstProxy) {
1547
+ firstProxy = newProxy;
1275
1548
  }
1276
- else if (isUndefined(startAt)) {
1277
- _nextProxy = _createProxyChain(plugins, _self);
1549
+ if (lastProxy_1) {
1550
+ lastProxy_1._setNext(newProxy);
1278
1551
  }
1552
+ lastProxy_1 = newProxy;
1279
1553
  }
1554
+ });
1555
+ }
1556
+ if (startAt && !firstProxy) {
1557
+ return createTelemetryProxyChain([startAt], config, core);
1558
+ }
1559
+ return firstProxy;
1560
+ }
1561
+ function createTelemetryPluginProxy(plugin, config, core) {
1562
+ var nextProxy = null;
1563
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1564
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1565
+ var chainId;
1566
+ if (plugin) {
1567
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1568
+ }
1569
+ else {
1570
+ chainId = "Unknown-0-" + _chainId++;
1571
+ }
1572
+ var proxyChain = {
1573
+ getPlugin: function () {
1574
+ return plugin;
1575
+ },
1576
+ getNext: function () {
1577
+ return nextProxy;
1578
+ },
1579
+ processTelemetry: _processTelemetry,
1580
+ unload: _unloadPlugin,
1581
+ update: _updatePlugin,
1582
+ _id: chainId,
1583
+ _setNext: function (nextPlugin) {
1584
+ nextProxy = nextPlugin;
1280
1585
  }
1281
- _self.core = function () {
1282
- return core;
1283
- };
1284
- _self.diagLog = function () {
1285
- return safeGetLogger(core, config);
1286
- };
1287
- _self.getCfg = function () {
1288
- return config;
1289
- };
1290
- _self.getExtCfg = function (identifier, defaultValue) {
1291
- if (defaultValue === void 0) { defaultValue = {}; }
1292
- var theConfig;
1293
- if (config) {
1294
- var extConfig = config.extensionConfig;
1295
- if (extConfig && identifier) {
1296
- theConfig = extConfig[identifier];
1586
+ };
1587
+ function _getTelCtx() {
1588
+ var itemCtx;
1589
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1590
+ itemCtx = plugin[strGetTelCtx]();
1591
+ }
1592
+ if (!itemCtx) {
1593
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1594
+ }
1595
+ return itemCtx;
1596
+ }
1597
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1598
+ var hasRun = false;
1599
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1600
+ var hasRunContext = itemCtx[strHasRunFlags];
1601
+ if (!hasRunContext) {
1602
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1603
+ }
1604
+ itemCtx.setNext(nextProxy);
1605
+ if (plugin) {
1606
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1607
+ hasRunContext[chainId] = true;
1608
+ try {
1609
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1610
+ if (nextId) {
1611
+ hasRunContext[nextId] = false;
1612
+ }
1613
+ hasRun = processPluginFn(itemCtx);
1297
1614
  }
1615
+ catch (error) {
1616
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1617
+ if (hasNextRun) {
1618
+ hasRun = true;
1619
+ }
1620
+ if (!nextProxy || !hasNextRun) {
1621
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1622
+ }
1623
+ }
1624
+ }, details, isAsync);
1625
+ }
1626
+ return hasRun;
1627
+ }
1628
+ function _processTelemetry(env, itemCtx) {
1629
+ itemCtx = itemCtx || _getTelCtx();
1630
+ function _callProcessTelemetry(itemCtx) {
1631
+ if (!plugin || !hasProcessTelemetry) {
1632
+ return false;
1298
1633
  }
1299
- return (theConfig ? theConfig : defaultValue);
1300
- };
1301
- _self.getConfig = function (identifier, field, defaultValue) {
1302
- if (defaultValue === void 0) { defaultValue = false; }
1303
- var theValue;
1304
- var extConfig = _self.getExtCfg(identifier, null);
1305
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1306
- theValue = extConfig[field];
1634
+ var pluginState = _getPluginState(plugin);
1635
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1636
+ return false;
1307
1637
  }
1308
- else if (config && !isNullOrUndefined(config[field])) {
1309
- theValue = config[field];
1638
+ if (hasSetNext) {
1639
+ plugin.setNextPlugin(nextProxy);
1310
1640
  }
1311
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1312
- };
1313
- _self.hasNext = function () {
1314
- return _nextProxy != null;
1315
- };
1316
- _self.getNext = function () {
1317
- return _nextProxy;
1318
- };
1319
- _self.setNext = function (nextPlugin) {
1320
- _nextProxy = nextPlugin;
1321
- };
1322
- _self.processNext = function (env) {
1323
- var nextPlugin = _nextProxy;
1324
- if (nextPlugin) {
1325
- _nextProxy = nextPlugin.getNext();
1326
- nextPlugin.processTelemetry(env, _self);
1641
+ plugin.processTelemetry(env, itemCtx);
1642
+ return true;
1643
+ }
1644
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1645
+ itemCtx.processNext(env);
1646
+ }
1647
+ }
1648
+ function _unloadPlugin(unloadCtx, unloadState) {
1649
+ function _callTeardown() {
1650
+ var hasRun = false;
1651
+ if (plugin) {
1652
+ var pluginState = _getPluginState(plugin);
1653
+ var pluginCore = plugin[strCore] || pluginState.core;
1654
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1655
+ pluginState[strCore] = null;
1656
+ pluginState[strTeardown] = true;
1657
+ pluginState[strIsInitialized] = false;
1658
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1659
+ hasRun = true;
1660
+ }
1661
+ }
1327
1662
  }
1328
- };
1329
- _self.createNew = function (plugins, startAt) {
1330
- if (plugins === void 0) { plugins = null; }
1331
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1332
- };
1663
+ return hasRun;
1664
+ }
1665
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1666
+ unloadCtx.processNext(unloadState);
1667
+ }
1333
1668
  }
1334
- return ProcessTelemetryContext;
1335
- }());
1336
-
1337
- var strExtensionConfig = "extensionConfig";
1338
-
1339
- var strGetPlugin = "getPlugin";
1340
- var BaseTelemetryPlugin = /** @class */ (function () {
1341
- function BaseTelemetryPlugin() {
1342
- var _self = this;
1343
- var _isinitialized = false;
1344
- var _rootCtx = null;
1345
- var _nextPlugin = null;
1346
- _self.core = null;
1347
- _self.diagLog = function (itemCtx) {
1348
- return _self._getTelCtx(itemCtx).diagLog();
1349
- };
1350
- _self.isInitialized = function () {
1351
- return _isinitialized;
1352
- };
1353
- _self.setInitialized = function (isInitialized) {
1354
- _isinitialized = isInitialized;
1355
- };
1356
- _self.setNextPlugin = function (next) {
1357
- _nextPlugin = next;
1358
- };
1359
- _self.processNext = function (env, itemCtx) {
1360
- if (itemCtx) {
1361
- itemCtx.processNext(env);
1362
- }
1363
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1364
- _nextPlugin.processTelemetry(env, null);
1365
- }
1366
- };
1367
- _self._getTelCtx = function (currentCtx) {
1368
- if (currentCtx === void 0) { currentCtx = null; }
1369
- var itemCtx = currentCtx;
1370
- if (!itemCtx) {
1371
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1372
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1373
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1374
- }
1375
- else {
1376
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1669
+ function _updatePlugin(updateCtx, updateState) {
1670
+ function _callUpdate() {
1671
+ var hasRun = false;
1672
+ if (plugin) {
1673
+ var pluginState = _getPluginState(plugin);
1674
+ var pluginCore = plugin[strCore] || pluginState.core;
1675
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1676
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1677
+ hasRun = true;
1678
+ }
1377
1679
  }
1378
1680
  }
1379
- return itemCtx;
1380
- };
1381
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1382
- if (config) {
1383
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1384
- }
1385
- if (!pluginChain && core) {
1386
- pluginChain = core.getProcessTelContext().getNext();
1387
- }
1388
- var nextPlugin = _nextPlugin;
1389
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1390
- nextPlugin = _nextPlugin[strGetPlugin]();
1391
- }
1392
- _self.core = core;
1393
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1394
- _isinitialized = true;
1395
- };
1681
+ return hasRun;
1682
+ }
1683
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1684
+ updateCtx.processNext(updateState);
1685
+ }
1396
1686
  }
1397
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1398
- this._baseTelInit(config, core, extensions, pluginChain);
1399
- };
1400
- return BaseTelemetryPlugin;
1401
- }());
1687
+ return objFreeze(proxyChain);
1688
+ }
1402
1689
 
1403
1690
  var strToGMTString = "toGMTString";
1404
1691
  var strToUTCString = "toUTCString";
@@ -1408,7 +1695,6 @@
1408
1695
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1409
1696
  var strDisableCookiesUsage = "disableCookiesUsage";
1410
1697
  var strConfigCookieMgr = "_ckMgr";
1411
- var strEmpty = "";
1412
1698
  var _supportsCookies = null;
1413
1699
  var _allowUaSameSite = null;
1414
1700
  var _parsedCookieValue = null;
@@ -1466,7 +1752,7 @@
1466
1752
  var result = false;
1467
1753
  if (_isMgrEnabled(cookieMgr)) {
1468
1754
  var values = {};
1469
- var theValue = strTrim(value || strEmpty);
1755
+ var theValue = strTrim(value || strEmpty$1);
1470
1756
  var idx = theValue.indexOf(";");
1471
1757
  if (idx !== -1) {
1472
1758
  theValue = strTrim(value.substring(0, idx));
@@ -1481,11 +1767,11 @@
1481
1767
  if (expireMs > 0) {
1482
1768
  var expiry = new Date();
1483
1769
  expiry.setTime(expireMs);
1484
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1770
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1485
1771
  }
1486
1772
  }
1487
1773
  if (!_isIE) {
1488
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1774
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1489
1775
  }
1490
1776
  }
1491
1777
  var location_1 = getLocation();
@@ -1506,7 +1792,7 @@
1506
1792
  return result;
1507
1793
  },
1508
1794
  get: function (name) {
1509
- var value = strEmpty;
1795
+ var value = strEmpty$1;
1510
1796
  if (_isMgrEnabled(cookieMgr)) {
1511
1797
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1512
1798
  }
@@ -1531,7 +1817,7 @@
1531
1817
  values["max-age"] = "0";
1532
1818
  }
1533
1819
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1534
- delCookie(name, _formatCookieValue(strEmpty, values));
1820
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1535
1821
  result = true;
1536
1822
  }
1537
1823
  return result;
@@ -1548,7 +1834,7 @@
1548
1834
  _supportsCookies = doc[strCookie] !== undefined;
1549
1835
  }
1550
1836
  catch (e) {
1551
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1837
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1552
1838
  }
1553
1839
  }
1554
1840
  return _supportsCookies;
@@ -1558,7 +1844,7 @@
1558
1844
  if (theValue && theValue.length) {
1559
1845
  var parts = strTrim(theValue).split(";");
1560
1846
  arrForEach(parts, function (thePart) {
1561
- thePart = strTrim(thePart || strEmpty);
1847
+ thePart = strTrim(thePart || strEmpty$1);
1562
1848
  if (thePart) {
1563
1849
  var idx = thePart.indexOf("=");
1564
1850
  if (idx === -1) {
@@ -1579,21 +1865,21 @@
1579
1865
  return null;
1580
1866
  }
1581
1867
  function _formatCookieValue(value, values) {
1582
- var cookieValue = value || strEmpty;
1868
+ var cookieValue = value || strEmpty$1;
1583
1869
  objForEachKey(values, function (name, theValue) {
1584
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1870
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1585
1871
  });
1586
1872
  return cookieValue;
1587
1873
  }
1588
1874
  function _getCookieValue(name) {
1589
- var cookieValue = strEmpty;
1875
+ var cookieValue = strEmpty$1;
1590
1876
  if (_doc) {
1591
- var theCookie = _doc[strCookie] || strEmpty;
1877
+ var theCookie = _doc[strCookie] || strEmpty$1;
1592
1878
  if (_parsedCookieValue !== theCookie) {
1593
1879
  _cookieCache = _extractParts(theCookie);
1594
1880
  _parsedCookieValue = theCookie;
1595
1881
  }
1596
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1882
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1597
1883
  }
1598
1884
  return cookieValue;
1599
1885
  }
@@ -1627,86 +1913,290 @@
1627
1913
  return false;
1628
1914
  }
1629
1915
 
1630
- var UInt32Mask = 0x100000000;
1631
- var MaxUInt32 = 0xffffffff;
1632
- var _mwcSeeded = false;
1633
- var _mwcW = 123456789;
1634
- var _mwcZ = 987654321;
1635
- function _mwcSeed(seedValue) {
1636
- if (seedValue < 0) {
1637
- seedValue >>>= 0;
1916
+ var strExtensionConfig = "extensionConfig";
1917
+
1918
+ function createUnloadHandlerContainer() {
1919
+ var handlers = [];
1920
+ function _addHandler(handler) {
1921
+ if (handler) {
1922
+ handlers.push(handler);
1923
+ }
1638
1924
  }
1639
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1640
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1641
- _mwcSeeded = true;
1925
+ function _runHandlers(unloadCtx, unloadState) {
1926
+ arrForEach(handlers, function (handler) {
1927
+ try {
1928
+ handler(unloadCtx, unloadState);
1929
+ }
1930
+ catch (e) {
1931
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1932
+ }
1933
+ });
1934
+ handlers = [];
1935
+ }
1936
+ return {
1937
+ add: _addHandler,
1938
+ run: _runHandlers
1939
+ };
1642
1940
  }
1643
- function _autoSeedMwc() {
1644
- try {
1645
- var now = dateNow() & 0x7fffffff;
1646
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1941
+
1942
+ var strGetPlugin = "getPlugin";
1943
+ var BaseTelemetryPlugin = /** @class */ (function () {
1944
+ function BaseTelemetryPlugin() {
1945
+ var _self = this;
1946
+ var _isinitialized;
1947
+ var _rootCtx;
1948
+ var _nextPlugin;
1949
+ var _unloadHandlerContainer;
1950
+ var _hooks;
1951
+ _initDefaults();
1952
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1953
+ _self.initialize = function (config, core, extensions, pluginChain) {
1954
+ _setDefaults(config, core, pluginChain);
1955
+ _isinitialized = true;
1956
+ };
1957
+ _self.teardown = function (unloadCtx, unloadState) {
1958
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1959
+ return;
1960
+ }
1961
+ var result;
1962
+ var unloadDone = false;
1963
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1964
+ var theUnloadState = unloadState || {
1965
+ reason: 0 ,
1966
+ isAsync: false
1967
+ };
1968
+ function _unloadCallback() {
1969
+ if (!unloadDone) {
1970
+ unloadDone = true;
1971
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1972
+ arrForEach(_hooks, function (fn) {
1973
+ fn.rm();
1974
+ });
1975
+ _hooks = [];
1976
+ if (result === true) {
1977
+ theUnloadCtx.processNext(theUnloadState);
1978
+ }
1979
+ _initDefaults();
1980
+ }
1981
+ }
1982
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1983
+ _unloadCallback();
1984
+ }
1985
+ else {
1986
+ result = true;
1987
+ }
1988
+ return result;
1989
+ };
1990
+ _self.update = function (updateCtx, updateState) {
1991
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1992
+ return;
1993
+ }
1994
+ var result;
1995
+ var updateDone = false;
1996
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1997
+ var theUpdateState = updateState || {
1998
+ reason: 0
1999
+ };
2000
+ function _updateCallback() {
2001
+ if (!updateDone) {
2002
+ updateDone = true;
2003
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
2004
+ }
2005
+ }
2006
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
2007
+ _updateCallback();
2008
+ }
2009
+ else {
2010
+ result = true;
2011
+ }
2012
+ return result;
2013
+ };
2014
+ _self._addHook = function (hooks) {
2015
+ if (hooks) {
2016
+ if (isArray(hooks)) {
2017
+ _hooks = _hooks.concat(hooks);
2018
+ }
2019
+ else {
2020
+ _hooks.push(hooks);
2021
+ }
2022
+ }
2023
+ };
2024
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2025
+ });
2026
+ _self.diagLog = function (itemCtx) {
2027
+ return _getTelCtx(itemCtx).diagLog();
2028
+ };
2029
+ _self[strIsInitialized] = function () {
2030
+ return _isinitialized;
2031
+ };
2032
+ _self.setInitialized = function (isInitialized) {
2033
+ _isinitialized = isInitialized;
2034
+ };
2035
+ _self[strSetNextPlugin] = function (next) {
2036
+ _nextPlugin = next;
2037
+ };
2038
+ _self.processNext = function (env, itemCtx) {
2039
+ if (itemCtx) {
2040
+ itemCtx.processNext(env);
2041
+ }
2042
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2043
+ _nextPlugin.processTelemetry(env, null);
2044
+ }
2045
+ };
2046
+ _self._getTelCtx = _getTelCtx;
2047
+ function _getTelCtx(currentCtx) {
2048
+ if (currentCtx === void 0) { currentCtx = null; }
2049
+ var itemCtx = currentCtx;
2050
+ if (!itemCtx) {
2051
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2052
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2053
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2054
+ }
2055
+ else {
2056
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2057
+ }
2058
+ }
2059
+ return itemCtx;
2060
+ }
2061
+ function _setDefaults(config, core, pluginChain) {
2062
+ if (config) {
2063
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2064
+ }
2065
+ if (!pluginChain && core) {
2066
+ pluginChain = core.getProcessTelContext().getNext();
2067
+ }
2068
+ var nextPlugin = _nextPlugin;
2069
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2070
+ nextPlugin = _nextPlugin[strGetPlugin]();
2071
+ }
2072
+ _self.core = core;
2073
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2074
+ }
2075
+ function _initDefaults() {
2076
+ _isinitialized = false;
2077
+ _self.core = null;
2078
+ _rootCtx = null;
2079
+ _nextPlugin = null;
2080
+ _hooks = [];
2081
+ _unloadHandlerContainer = createUnloadHandlerContainer();
2082
+ }
1647
2083
  }
1648
- catch (e) {
2084
+ return BaseTelemetryPlugin;
2085
+ }());
2086
+
2087
+ var strOnPrefix = "on";
2088
+ var strAttachEvent = "attachEvent";
2089
+ var strAddEventHelper = "addEventListener";
2090
+ var strEvents = "events";
2091
+ createUniqueNamespace("aiEvtPageHide");
2092
+ createUniqueNamespace("aiEvtPageShow");
2093
+ var rRemoveEmptyNs = /\.[\.]+/g;
2094
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
2095
+ var _guid = 1;
2096
+ var elmNodeData = createElmNodeData("events");
2097
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2098
+ function _normalizeNamespace(name) {
2099
+ if (name && name.replace) {
2100
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2101
+ }
2102
+ return name;
2103
+ }
2104
+ function _getEvtNamespace(eventName, evtNamespace) {
2105
+ if (evtNamespace) {
2106
+ var theNamespace_1 = "";
2107
+ if (isArray(evtNamespace)) {
2108
+ theNamespace_1 = "";
2109
+ arrForEach(evtNamespace, function (name) {
2110
+ name = _normalizeNamespace(name);
2111
+ if (name) {
2112
+ if (name[0] !== ".") {
2113
+ name = "." + name;
2114
+ }
2115
+ theNamespace_1 += name;
2116
+ }
2117
+ });
2118
+ }
2119
+ else {
2120
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
2121
+ }
2122
+ if (theNamespace_1) {
2123
+ if (theNamespace_1[0] !== ".") {
2124
+ theNamespace_1 = "." + theNamespace_1;
2125
+ }
2126
+ eventName = (eventName || "") + theNamespace_1;
2127
+ }
1649
2128
  }
2129
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2130
+ return {
2131
+ type: parsedEvent[1],
2132
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2133
+ };
1650
2134
  }
1651
- function randomValue(maxValue) {
1652
- if (maxValue > 0) {
1653
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
2135
+ function _getRegisteredEvents(target, evtName, addDefault) {
2136
+ if (addDefault === void 0) { addDefault = true; }
2137
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2138
+ var registeredEvents = aiEvts[evtName];
2139
+ if (!registeredEvents) {
2140
+ registeredEvents = aiEvts[evtName] = [];
1654
2141
  }
1655
- return 0;
2142
+ return registeredEvents;
1656
2143
  }
1657
- function random32(signed) {
1658
- var value;
1659
- var c = getCrypto() || getMsCrypto();
1660
- if (c && c.getRandomValues) {
1661
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1662
- }
1663
- else if (isIE()) {
1664
- if (!_mwcSeeded) {
1665
- _autoSeedMwc();
2144
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2145
+ var result = false;
2146
+ if (obj && evtName && evtName.type && handlerRef) {
2147
+ if (obj[strAddEventHelper]) {
2148
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2149
+ result = true;
2150
+ }
2151
+ else if (obj[strAttachEvent]) {
2152
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2153
+ result = true;
1666
2154
  }
1667
- value = mwcRandom32() & MaxUInt32;
1668
- }
1669
- else {
1670
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1671
- }
1672
- if (!signed) {
1673
- value >>>= 0;
1674
2155
  }
1675
- return value;
2156
+ return result;
1676
2157
  }
1677
- function mwcRandomSeed(value) {
1678
- if (!value) {
1679
- _autoSeedMwc();
1680
- }
1681
- else {
1682
- _mwcSeed(value);
2158
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2159
+ if (useCapture === void 0) { useCapture = false; }
2160
+ var result = false;
2161
+ if (target) {
2162
+ try {
2163
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2164
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2165
+ if (result && elmNodeData.accept(target)) {
2166
+ var registeredEvent = {
2167
+ guid: _guid++,
2168
+ evtName: evtName,
2169
+ handler: handlerRef,
2170
+ capture: useCapture
2171
+ };
2172
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2173
+ }
2174
+ }
2175
+ catch (e) {
2176
+ }
1683
2177
  }
2178
+ return result;
1684
2179
  }
1685
- function mwcRandom32(signed) {
1686
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1687
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1688
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1689
- if (!signed) {
1690
- value >>>= 0;
1691
- }
1692
- return value;
2180
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
2181
+ if (useCapture === void 0) { useCapture = false; }
2182
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
1693
2183
  }
1694
-
1695
- var _cookieMgrs = null;
1696
- var _canUseCookies;
1697
- function addEventHandler(eventName, callback) {
2184
+ function addEventHandler(eventName, callback, evtNamespace) {
1698
2185
  var result = false;
1699
2186
  var w = getWindow();
1700
2187
  if (w) {
1701
- result = attachEvent(w, eventName, callback);
1702
- result = attachEvent(w["body"], eventName, callback) || result;
2188
+ result = eventOn(w, eventName, callback, evtNamespace);
2189
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1703
2190
  }
1704
2191
  var doc = getDocument();
1705
2192
  if (doc) {
1706
- result = attachEvent(doc, eventName, callback) || result;
2193
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1707
2194
  }
1708
2195
  return result;
1709
2196
  }
2197
+
2198
+ var _cookieMgrs = null;
2199
+ var _canUseCookies;
1710
2200
  function newGuid() {
1711
2201
  function randomHexDigit() {
1712
2202
  return randomValue(15);
@@ -1723,26 +2213,9 @@
1723
2213
  }
1724
2214
  return dateNow();
1725
2215
  }
1726
- function newId(maxLength) {
1727
- if (maxLength === void 0) { maxLength = 22; }
1728
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1729
- var number = random32() >>> 0;
1730
- var chars = 0;
1731
- var result = "";
1732
- while (result.length < maxLength) {
1733
- chars++;
1734
- result += base64chars.charAt(number & 0x3F);
1735
- number >>>= 6;
1736
- if (chars === 5) {
1737
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1738
- chars = 0;
1739
- }
1740
- }
1741
- return result;
1742
- }
1743
2216
  function generateW3CId() {
1744
2217
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1745
- var oct = "", tmp;
2218
+ var oct = strEmpty$1, tmp;
1746
2219
  for (var a = 0; a < 4; a++) {
1747
2220
  tmp = random32();
1748
2221
  oct +=
@@ -1837,6 +2310,95 @@
1837
2310
  return _legacyCookieMgr(null, logger).del(name);
1838
2311
  }
1839
2312
 
2313
+ createEnumStyle({
2314
+ CRITICAL: 1 ,
2315
+ WARNING: 2
2316
+ });
2317
+ var _InternalMessageId = createEnumStyle({
2318
+ BrowserDoesNotSupportLocalStorage: 0 ,
2319
+ BrowserCannotReadLocalStorage: 1 ,
2320
+ BrowserCannotReadSessionStorage: 2 ,
2321
+ BrowserCannotWriteLocalStorage: 3 ,
2322
+ BrowserCannotWriteSessionStorage: 4 ,
2323
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2324
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2325
+ CannotSendEmptyTelemetry: 7 ,
2326
+ ClientPerformanceMathError: 8 ,
2327
+ ErrorParsingAISessionCookie: 9 ,
2328
+ ErrorPVCalc: 10 ,
2329
+ ExceptionWhileLoggingError: 11 ,
2330
+ FailedAddingTelemetryToBuffer: 12 ,
2331
+ FailedMonitorAjaxAbort: 13 ,
2332
+ FailedMonitorAjaxDur: 14 ,
2333
+ FailedMonitorAjaxOpen: 15 ,
2334
+ FailedMonitorAjaxRSC: 16 ,
2335
+ FailedMonitorAjaxSend: 17 ,
2336
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2337
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2338
+ FailedToSendQueuedTelemetry: 20 ,
2339
+ FailedToReportDataLoss: 21 ,
2340
+ FlushFailed: 22 ,
2341
+ MessageLimitPerPVExceeded: 23 ,
2342
+ MissingRequiredFieldSpecification: 24 ,
2343
+ NavigationTimingNotSupported: 25 ,
2344
+ OnError: 26 ,
2345
+ SessionRenewalDateIsZero: 27 ,
2346
+ SenderNotInitialized: 28 ,
2347
+ StartTrackEventFailed: 29 ,
2348
+ StopTrackEventFailed: 30 ,
2349
+ StartTrackFailed: 31 ,
2350
+ StopTrackFailed: 32 ,
2351
+ TelemetrySampledAndNotSent: 33 ,
2352
+ TrackEventFailed: 34 ,
2353
+ TrackExceptionFailed: 35 ,
2354
+ TrackMetricFailed: 36 ,
2355
+ TrackPVFailed: 37 ,
2356
+ TrackPVFailedCalc: 38 ,
2357
+ TrackTraceFailed: 39 ,
2358
+ TransmissionFailed: 40 ,
2359
+ FailedToSetStorageBuffer: 41 ,
2360
+ FailedToRestoreStorageBuffer: 42 ,
2361
+ InvalidBackendResponse: 43 ,
2362
+ FailedToFixDepricatedValues: 44 ,
2363
+ InvalidDurationValue: 45 ,
2364
+ TelemetryEnvelopeInvalid: 46 ,
2365
+ CreateEnvelopeError: 47 ,
2366
+ CannotSerializeObject: 48 ,
2367
+ CannotSerializeObjectNonSerializable: 49 ,
2368
+ CircularReferenceDetected: 50 ,
2369
+ ClearAuthContextFailed: 51 ,
2370
+ ExceptionTruncated: 52 ,
2371
+ IllegalCharsInName: 53 ,
2372
+ ItemNotInArray: 54 ,
2373
+ MaxAjaxPerPVExceeded: 55 ,
2374
+ MessageTruncated: 56 ,
2375
+ NameTooLong: 57 ,
2376
+ SampleRateOutOfRange: 58 ,
2377
+ SetAuthContextFailed: 59 ,
2378
+ SetAuthContextFailedAccountName: 60 ,
2379
+ StringValueTooLong: 61 ,
2380
+ StartCalledMoreThanOnce: 62 ,
2381
+ StopCalledWithoutStart: 63 ,
2382
+ TelemetryInitializerFailed: 64 ,
2383
+ TrackArgumentsNotSpecified: 65 ,
2384
+ UrlTooLong: 66 ,
2385
+ SessionStorageBufferFull: 67 ,
2386
+ CannotAccessCookie: 68 ,
2387
+ IdTooLong: 69 ,
2388
+ InvalidEvent: 70 ,
2389
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2390
+ SendBrowserInfoOnUserInit: 72 ,
2391
+ PluginException: 73 ,
2392
+ NotificationException: 74 ,
2393
+ SnippetScriptLoadFailure: 99 ,
2394
+ InvalidInstrumentationKey: 100 ,
2395
+ CannotParseAiBlobValue: 101 ,
2396
+ InvalidContentBlob: 102 ,
2397
+ TrackPageActionEventFailed: 103 ,
2398
+ FailedAddingCustomDefinedRequestContext: 104 ,
2399
+ InMemoryStorageBufferFull: 105
2400
+ });
2401
+
1840
2402
  var aiInstrumentHooks = "_aiHooks";
1841
2403
  var cbNames = [
1842
2404
  "req", "rsp", "hkErr", "fnErr"
@@ -1895,6 +2457,7 @@
1895
2457
  };
1896
2458
  var hookCtx = [];
1897
2459
  var cbArgs = _createArgs([funcArgs], orgArgs);
2460
+ funcArgs.evt = getGlobalInst("event");
1898
2461
  function _createArgs(target, theArgs) {
1899
2462
  _arrLoop(theArgs, function (arg) {
1900
2463
  target.push(arg);
@@ -1988,6 +2551,7 @@
1988
2551
  return event;
1989
2552
  }
1990
2553
 
2554
+ var strEmpty = "";
1991
2555
  function stringToBoolOrDefault(str, defaultValue) {
1992
2556
  if (defaultValue === void 0) { defaultValue = false; }
1993
2557
  if (str === undefined || str === null) {
@@ -2000,16 +2564,16 @@
2000
2564
  totalms = 0;
2001
2565
  }
2002
2566
  totalms = Math.round(totalms);
2003
- var ms = "" + totalms % 1000;
2004
- var sec = "" + Math.floor(totalms / 1000) % 60;
2005
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
2006
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2567
+ var ms = strEmpty + totalms % 1000;
2568
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2569
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2570
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2007
2571
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2008
2572
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2009
2573
  sec = sec.length < 2 ? "0" + sec : sec;
2010
2574
  min = min.length < 2 ? "0" + min : min;
2011
2575
  hour = hour.length < 2 ? "0" + hour : hour;
2012
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2576
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
2013
2577
  }
2014
2578
  function getExtensionByName(extensions, identifier) {
2015
2579
  var extension = null;
@@ -2027,17 +2591,15 @@
2027
2591
 
2028
2592
  var strNotSpecified = "not_specified";
2029
2593
 
2030
- var StorageType;
2031
- (function (StorageType) {
2032
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
2033
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
2034
- })(StorageType || (StorageType = {}));
2035
- var DistributedTracingModes;
2036
- (function (DistributedTracingModes) {
2037
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
2038
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
2039
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
2040
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2594
+ var StorageType = createEnumStyle({
2595
+ LocalStorage: 0 ,
2596
+ SessionStorage: 1
2597
+ });
2598
+ createEnumStyle({
2599
+ AI: 0 ,
2600
+ AI_AND_W3C: 1 ,
2601
+ W3C: 2
2602
+ });
2041
2603
 
2042
2604
  var _canUseLocalStorage = undefined;
2043
2605
  var _canUseSessionStorage = undefined;
@@ -2075,8 +2637,8 @@
2075
2637
  _canUseLocalStorage = false;
2076
2638
  _canUseSessionStorage = false;
2077
2639
  }
2078
- function utlCanUseLocalStorage() {
2079
- if (_canUseLocalStorage === undefined) {
2640
+ function utlCanUseLocalStorage(reset) {
2641
+ if (reset || _canUseLocalStorage === undefined) {
2080
2642
  _canUseLocalStorage = !!_getVerifiedStorageObject(StorageType.LocalStorage);
2081
2643
  }
2082
2644
  return _canUseLocalStorage;
@@ -2089,7 +2651,7 @@
2089
2651
  }
2090
2652
  catch (e) {
2091
2653
  _canUseLocalStorage = false;
2092
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2654
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2093
2655
  }
2094
2656
  }
2095
2657
  return null;
@@ -2103,7 +2665,7 @@
2103
2665
  }
2104
2666
  catch (e) {
2105
2667
  _canUseLocalStorage = false;
2106
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2668
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2107
2669
  }
2108
2670
  }
2109
2671
  return false;
@@ -2117,13 +2679,13 @@
2117
2679
  }
2118
2680
  catch (e) {
2119
2681
  _canUseLocalStorage = false;
2120
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2682
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2121
2683
  }
2122
2684
  }
2123
2685
  return false;
2124
2686
  }
2125
- function utlCanUseSessionStorage() {
2126
- if (_canUseSessionStorage === undefined) {
2687
+ function utlCanUseSessionStorage(reset) {
2688
+ if (reset || _canUseSessionStorage === undefined) {
2127
2689
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
2128
2690
  }
2129
2691
  return _canUseSessionStorage;
@@ -2145,7 +2707,7 @@
2145
2707
  }
2146
2708
  catch (e) {
2147
2709
  _canUseSessionStorage = false;
2148
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2710
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2149
2711
  }
2150
2712
  }
2151
2713
  return null;
@@ -2159,7 +2721,7 @@
2159
2721
  }
2160
2722
  catch (e) {
2161
2723
  _canUseSessionStorage = false;
2162
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2724
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2163
2725
  }
2164
2726
  }
2165
2727
  return false;
@@ -2173,7 +2735,7 @@
2173
2735
  }
2174
2736
  catch (e) {
2175
2737
  _canUseSessionStorage = false;
2176
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2738
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2177
2739
  }
2178
2740
  }
2179
2741
  return false;
@@ -2802,7 +3364,7 @@
2802
3364
  }
2803
3365
  }
2804
3366
  else if (isString(value) || isNumber(value) || isBoolean(value)) {
2805
- return _testValue(rg, value.toString());
3367
+ return _testValue(rg, objToString(value));
2806
3368
  }
2807
3369
  }
2808
3370
  return false;