@microsoft/applicationinsights-debugplugin-js 2.8.0-beta.2202-06 → 2.8.0-beta.2203-02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/browser/{ai.dbg.2.8.0-beta.2202-06.cjs.js → ai.dbg.2.8.0-beta.2203-02.cjs.js} +612 -329
  2. package/browser/ai.dbg.2.8.0-beta.2203-02.cjs.js.map +1 -0
  3. package/browser/ai.dbg.2.8.0-beta.2203-02.cjs.min.js +6 -0
  4. package/browser/ai.dbg.2.8.0-beta.2203-02.cjs.min.js.map +1 -0
  5. package/browser/{ai.dbg.2.8.0-beta.2202-06.gbl.js → ai.dbg.2.8.0-beta.2203-02.gbl.js} +612 -329
  6. package/browser/ai.dbg.2.8.0-beta.2203-02.gbl.js.map +1 -0
  7. package/browser/ai.dbg.2.8.0-beta.2203-02.gbl.min.js +6 -0
  8. package/browser/ai.dbg.2.8.0-beta.2203-02.gbl.min.js.map +1 -0
  9. package/browser/ai.dbg.2.8.0-beta.2203-02.integrity.json +66 -0
  10. package/browser/{ai.dbg.2.8.0-beta.2202-06.js → ai.dbg.2.8.0-beta.2203-02.js} +612 -329
  11. package/browser/ai.dbg.2.8.0-beta.2203-02.js.map +1 -0
  12. package/browser/ai.dbg.2.8.0-beta.2203-02.min.js +6 -0
  13. package/browser/ai.dbg.2.8.0-beta.2203-02.min.js.map +1 -0
  14. package/browser/ai.dbg.2.cjs.js +611 -328
  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 +611 -328
  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 +611 -328
  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.d.ts +1 -1
  27. package/dist/applicationinsights-debugplugin-js.js +611 -328
  28. package/dist/applicationinsights-debugplugin-js.js.map +1 -1
  29. package/dist/applicationinsights-debugplugin-js.min.js +2 -2
  30. package/dist/applicationinsights-debugplugin-js.min.js.map +1 -1
  31. package/dist/applicationinsights-debugplugin-js.rollup.d.ts +1 -1
  32. package/dist-esm/DebugPlugin.js +1 -1
  33. package/dist-esm/applicationinsights-debugplugin-js.js +1 -1
  34. package/dist-esm/components/Dashboard.js +1 -1
  35. package/dist-esm/components/LogEntry.js +1 -1
  36. package/dist-esm/components/debugBins.js +1 -1
  37. package/dist-esm/components/filterList.js +1 -1
  38. package/dist-esm/components/helpers.js +1 -1
  39. package/dist-esm/components/styleNodeSrc.js +1 -1
  40. package/dist-esm/interfaces/IDebugPluginConfig.js +1 -1
  41. package/package.json +3 -3
  42. package/browser/ai.dbg.2.8.0-beta.2202-06.cjs.js.map +0 -1
  43. package/browser/ai.dbg.2.8.0-beta.2202-06.cjs.min.js +0 -6
  44. package/browser/ai.dbg.2.8.0-beta.2202-06.cjs.min.js.map +0 -1
  45. package/browser/ai.dbg.2.8.0-beta.2202-06.gbl.js.map +0 -1
  46. package/browser/ai.dbg.2.8.0-beta.2202-06.gbl.min.js +0 -6
  47. package/browser/ai.dbg.2.8.0-beta.2202-06.gbl.min.js.map +0 -1
  48. package/browser/ai.dbg.2.8.0-beta.2202-06.integrity.json +0 -66
  49. package/browser/ai.dbg.2.8.0-beta.2202-06.js.map +0 -1
  50. package/browser/ai.dbg.2.8.0-beta.2202-06.min.js +0 -6
  51. package/browser/ai.dbg.2.8.0-beta.2202-06.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Debug Plugin, 2.8.0-beta.2202-06
2
+ * Application Insights JavaScript SDK - Debug Plugin, 2.8.0-beta.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  'use strict';
@@ -320,99 +320,14 @@ var perfDefaults = {
320
320
  };
321
321
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
322
322
 
323
- var LoggingSeverity;
324
- (function (LoggingSeverity) {
325
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
326
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
327
- })(LoggingSeverity || (LoggingSeverity = {}));
328
- var _InternalMessageId = {
329
- BrowserDoesNotSupportLocalStorage: 0,
330
- BrowserCannotReadLocalStorage: 1,
331
- BrowserCannotReadSessionStorage: 2,
332
- BrowserCannotWriteLocalStorage: 3,
333
- BrowserCannotWriteSessionStorage: 4,
334
- BrowserFailedRemovalFromLocalStorage: 5,
335
- BrowserFailedRemovalFromSessionStorage: 6,
336
- CannotSendEmptyTelemetry: 7,
337
- ClientPerformanceMathError: 8,
338
- ErrorParsingAISessionCookie: 9,
339
- ErrorPVCalc: 10,
340
- ExceptionWhileLoggingError: 11,
341
- FailedAddingTelemetryToBuffer: 12,
342
- FailedMonitorAjaxAbort: 13,
343
- FailedMonitorAjaxDur: 14,
344
- FailedMonitorAjaxOpen: 15,
345
- FailedMonitorAjaxRSC: 16,
346
- FailedMonitorAjaxSend: 17,
347
- FailedMonitorAjaxGetCorrelationHeader: 18,
348
- FailedToAddHandlerForOnBeforeUnload: 19,
349
- FailedToSendQueuedTelemetry: 20,
350
- FailedToReportDataLoss: 21,
351
- FlushFailed: 22,
352
- MessageLimitPerPVExceeded: 23,
353
- MissingRequiredFieldSpecification: 24,
354
- NavigationTimingNotSupported: 25,
355
- OnError: 26,
356
- SessionRenewalDateIsZero: 27,
357
- SenderNotInitialized: 28,
358
- StartTrackEventFailed: 29,
359
- StopTrackEventFailed: 30,
360
- StartTrackFailed: 31,
361
- StopTrackFailed: 32,
362
- TelemetrySampledAndNotSent: 33,
363
- TrackEventFailed: 34,
364
- TrackExceptionFailed: 35,
365
- TrackMetricFailed: 36,
366
- TrackPVFailed: 37,
367
- TrackPVFailedCalc: 38,
368
- TrackTraceFailed: 39,
369
- TransmissionFailed: 40,
370
- FailedToSetStorageBuffer: 41,
371
- FailedToRestoreStorageBuffer: 42,
372
- InvalidBackendResponse: 43,
373
- FailedToFixDepricatedValues: 44,
374
- InvalidDurationValue: 45,
375
- TelemetryEnvelopeInvalid: 46,
376
- CreateEnvelopeError: 47,
377
- CannotSerializeObject: 48,
378
- CannotSerializeObjectNonSerializable: 49,
379
- CircularReferenceDetected: 50,
380
- ClearAuthContextFailed: 51,
381
- ExceptionTruncated: 52,
382
- IllegalCharsInName: 53,
383
- ItemNotInArray: 54,
384
- MaxAjaxPerPVExceeded: 55,
385
- MessageTruncated: 56,
386
- NameTooLong: 57,
387
- SampleRateOutOfRange: 58,
388
- SetAuthContextFailed: 59,
389
- SetAuthContextFailedAccountName: 60,
390
- StringValueTooLong: 61,
391
- StartCalledMoreThanOnce: 62,
392
- StopCalledWithoutStart: 63,
393
- TelemetryInitializerFailed: 64,
394
- TrackArgumentsNotSpecified: 65,
395
- UrlTooLong: 66,
396
- SessionStorageBufferFull: 67,
397
- CannotAccessCookie: 68,
398
- IdTooLong: 69,
399
- InvalidEvent: 70,
400
- FailedMonitorAjaxSetRequestHeader: 71,
401
- SendBrowserInfoOnUserInit: 72,
402
- PluginException: 73,
403
- NotificationException: 74,
404
- SnippetScriptLoadFailure: 99,
405
- InvalidInstrumentationKey: 100,
406
- CannotParseAiBlobValue: 101,
407
- InvalidContentBlob: 102,
408
- TrackPageActionEventFailed: 103,
409
- FailedAddingCustomDefinedRequestContext: 104,
410
- InMemoryStorageBufferFull: 105
411
- };
323
+ var strEmpty$1 = "";
324
+ var strSetNextPlugin = "setNextPlugin";
325
+ var strIsInitialized = "isInitialized";
326
+ var strTeardown = "teardown";
327
+ var strCore = "core";
328
+ var strDisabled = "disabled";
329
+ var strDoTeardown = "_doTeardown";
412
330
 
413
- var strOnPrefix = "on";
414
- var strAttachEvent = "attachEvent";
415
- var strAddEventHelper = "addEventListener";
416
331
  var strToISOString = "toISOString";
417
332
  var cStrEndsWith = "endsWith";
418
333
  var strIndexOf = "indexOf";
@@ -422,7 +337,7 @@ var cStrTrim = "trim";
422
337
  var strToString = "toString";
423
338
  var str__Proto = "__proto__";
424
339
  var strConstructor$1 = "constructor";
425
- var _objDefineProperty = ObjDefineProperty;
340
+ var _objDefineProperty$1 = ObjDefineProperty;
426
341
  var _objFreeze = ObjClass.freeze;
427
342
  var _objKeys = ObjClass.keys;
428
343
  var StringProto = String[strShimPrototype];
@@ -434,6 +349,9 @@ var _isArray = Array.isArray;
434
349
  var _objToString = ObjProto[strToString];
435
350
  var _fnToString = ObjHasOwnProperty[strToString];
436
351
  var _objFunctionString = _fnToString.call(ObjClass);
352
+ var rCamelCase = /-([a-z])/g;
353
+ var rNormalizeInvalid = /([^\w\d_$])/g;
354
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
437
355
  var _objGetPrototypeOf = Object["getPrototypeOf"];
438
356
  function _getObjProto(target) {
439
357
  if (target) {
@@ -468,24 +386,18 @@ function isObject(value) {
468
386
  function isFunction(value) {
469
387
  return !!(value && typeof value === strShimFunction);
470
388
  }
471
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
472
- if (useCapture === void 0) { useCapture = false; }
473
- var result = false;
474
- if (!isNullOrUndefined(obj)) {
475
- try {
476
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
477
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
478
- result = true;
479
- }
480
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
481
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
482
- result = true;
483
- }
484
- }
485
- catch (e) {
486
- }
389
+ function normalizeJsName(name) {
390
+ var value = name;
391
+ if (value && isString(value)) {
392
+ value = value.replace(rCamelCase, function (_all, letter) {
393
+ return letter.toUpperCase();
394
+ });
395
+ value = value.replace(rNormalizeInvalid, "_");
396
+ value = value.replace(rLeadingNumeric, function (_all, match) {
397
+ return "_" + match;
398
+ });
487
399
  }
488
- return result;
400
+ return value;
489
401
  }
490
402
  function objForEachKey(target, callbackfn) {
491
403
  if (target) {
@@ -708,7 +620,7 @@ function objKeys(obj) {
708
620
  return result;
709
621
  }
710
622
  function objDefineAccessors(target, prop, getProp, setProp) {
711
- if (_objDefineProperty) {
623
+ if (_objDefineProperty$1) {
712
624
  try {
713
625
  var descriptor = {
714
626
  enumerable: true,
@@ -720,7 +632,7 @@ function objDefineAccessors(target, prop, getProp, setProp) {
720
632
  if (setProp) {
721
633
  descriptor.set = setProp;
722
634
  }
723
- _objDefineProperty(target, prop, descriptor);
635
+ _objDefineProperty$1(target, prop, descriptor);
724
636
  return true;
725
637
  }
726
638
  catch (e) {
@@ -740,7 +652,7 @@ function getExceptionName(object) {
740
652
  if (isError(object)) {
741
653
  return object.name;
742
654
  }
743
- return "";
655
+ return strEmpty$1;
744
656
  }
745
657
  function setValue(target, field, value, valChk, srcChk) {
746
658
  var theValue = value;
@@ -756,6 +668,20 @@ function setValue(target, field, value, valChk, srcChk) {
756
668
  function isTruthy(value) {
757
669
  return !!value;
758
670
  }
671
+ function throwError(message) {
672
+ throw new Error(message);
673
+ }
674
+ function createEnumStyle(values) {
675
+ var enumClass = {};
676
+ objForEachKey(values, function (field, value) {
677
+ enumClass[field] = value;
678
+ if (!isUndefined(enumClass[value])) {
679
+ throwError("Value: [" + value + "] already exists for " + field);
680
+ }
681
+ enumClass[value] = field;
682
+ });
683
+ return objFreeze(enumClass);
684
+ }
759
685
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
760
686
  var theArgs = arguments;
761
687
  var extended = theArgs[0] || {};
@@ -894,7 +820,7 @@ function isIE() {
894
820
  var nav = getNavigator();
895
821
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
896
822
  _navUserAgentCheck = nav.userAgent;
897
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
823
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
898
824
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
899
825
  }
900
826
  return _isTrident;
@@ -903,9 +829,9 @@ function getIEVersion(userAgentStr) {
903
829
  if (userAgentStr === void 0) { userAgentStr = null; }
904
830
  if (!userAgentStr) {
905
831
  var navigator_1 = getNavigator() || {};
906
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
832
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
907
833
  }
908
- var ua = (userAgentStr || "").toLowerCase();
834
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
909
835
  if (strContains(ua, strMsie)) {
910
836
  var doc = getDocument() || {};
911
837
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -920,7 +846,7 @@ function getIEVersion(userAgentStr) {
920
846
  }
921
847
  function dumpObj(object) {
922
848
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
923
- var propertyValueDump = "";
849
+ var propertyValueDump = strEmpty$1;
924
850
  if (objectTypeDump === "[object Error]") {
925
851
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
926
852
  }
@@ -959,9 +885,9 @@ var strErrorToConsole = "errorToConsole";
959
885
  var strWarnToConsole = "warnToConsole";
960
886
  function _sanitizeDiagnosticText(text) {
961
887
  if (text) {
962
- return "\"" + text.replace(/\"/g, "") + "\"";
888
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
963
889
  }
964
- return "";
890
+ return strEmpty$1;
965
891
  }
966
892
  function _logToConsole(func, message) {
967
893
  var theConsole = getConsole();
@@ -983,12 +909,12 @@ var _InternalLogMessage = /** @class */ (function () {
983
909
  _self.message =
984
910
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
985
911
  msgId;
986
- var strProps = "";
912
+ var strProps = strEmpty$1;
987
913
  if (hasJSON()) {
988
914
  strProps = getJSON().stringify(properties);
989
915
  }
990
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
991
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
916
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
917
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
992
918
  _self.message += diagnosticText;
993
919
  }
994
920
  _InternalLogMessage.dataType = "MessageData";
@@ -1018,7 +944,7 @@ var DiagnosticLogger = /** @class */ (function () {
1018
944
  throw message;
1019
945
  }
1020
946
  else {
1021
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
947
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1022
948
  if (!isUndefined(message.message)) {
1023
949
  var logLevel = _self.consoleLoggingLevel();
1024
950
  if (isUserAct) {
@@ -1036,7 +962,7 @@ var DiagnosticLogger = /** @class */ (function () {
1036
962
  _self.logInternalMessage(severity, message);
1037
963
  }
1038
964
  else {
1039
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
965
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1040
966
  }
1041
967
  }
1042
968
  };
@@ -1068,13 +994,13 @@ var DiagnosticLogger = /** @class */ (function () {
1068
994
  if (severity <= _self.telemetryLoggingLevel()) {
1069
995
  _self.queue.push(message);
1070
996
  _messageCount++;
1071
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
997
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1072
998
  }
1073
999
  if (_messageCount === _self.maxInternalMessageLimit()) {
1074
1000
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1075
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1001
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1076
1002
  _self.queue.push(throttleMessage);
1077
- if (severity === LoggingSeverity.CRITICAL) {
1003
+ if (severity === 1 ) {
1078
1004
  _self.errorToConsole(throttleLimitMessage);
1079
1005
  }
1080
1006
  else {
@@ -1216,6 +1142,165 @@ function doPerf(mgrSource, getSource, func, details, isAsync) {
1216
1142
  return func();
1217
1143
  }
1218
1144
 
1145
+ var UInt32Mask = 0x100000000;
1146
+ var MaxUInt32 = 0xffffffff;
1147
+ var _mwcSeeded = false;
1148
+ var _mwcW = 123456789;
1149
+ var _mwcZ = 987654321;
1150
+ function _mwcSeed(seedValue) {
1151
+ if (seedValue < 0) {
1152
+ seedValue >>>= 0;
1153
+ }
1154
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1155
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1156
+ _mwcSeeded = true;
1157
+ }
1158
+ function _autoSeedMwc() {
1159
+ try {
1160
+ var now = dateNow() & 0x7fffffff;
1161
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1162
+ }
1163
+ catch (e) {
1164
+ }
1165
+ }
1166
+ function randomValue(maxValue) {
1167
+ if (maxValue > 0) {
1168
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1169
+ }
1170
+ return 0;
1171
+ }
1172
+ function random32(signed) {
1173
+ var value = 0;
1174
+ var c = getCrypto() || getMsCrypto();
1175
+ if (c && c.getRandomValues) {
1176
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1177
+ }
1178
+ if (value === 0 && isIE()) {
1179
+ if (!_mwcSeeded) {
1180
+ _autoSeedMwc();
1181
+ }
1182
+ value = mwcRandom32() & MaxUInt32;
1183
+ }
1184
+ if (value === 0) {
1185
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1186
+ }
1187
+ if (!signed) {
1188
+ value >>>= 0;
1189
+ }
1190
+ return value;
1191
+ }
1192
+ function mwcRandomSeed(value) {
1193
+ if (!value) {
1194
+ _autoSeedMwc();
1195
+ }
1196
+ else {
1197
+ _mwcSeed(value);
1198
+ }
1199
+ }
1200
+ function mwcRandom32(signed) {
1201
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1202
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1203
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1204
+ if (!signed) {
1205
+ value >>>= 0;
1206
+ }
1207
+ return value;
1208
+ }
1209
+ function newId(maxLength) {
1210
+ if (maxLength === void 0) { maxLength = 22; }
1211
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1212
+ var number = random32() >>> 0;
1213
+ var chars = 0;
1214
+ var result = strEmpty$1;
1215
+ while (result.length < maxLength) {
1216
+ chars++;
1217
+ result += base64chars.charAt(number & 0x3F);
1218
+ number >>>= 6;
1219
+ if (chars === 5) {
1220
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1221
+ chars = 0;
1222
+ }
1223
+ }
1224
+ return result;
1225
+ }
1226
+
1227
+ var _objDefineProperty = ObjDefineProperty;
1228
+ var version = "2.7.3";
1229
+ var instanceName = "." + newId(6);
1230
+ var _dataUid = 0;
1231
+ function _createAccessor(target, prop, value) {
1232
+ if (_objDefineProperty) {
1233
+ try {
1234
+ _objDefineProperty(target, prop, {
1235
+ value: value,
1236
+ enumerable: false,
1237
+ configurable: true
1238
+ });
1239
+ return true;
1240
+ }
1241
+ catch (e) {
1242
+ }
1243
+ }
1244
+ return false;
1245
+ }
1246
+ function _canAcceptData(target) {
1247
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1248
+ }
1249
+ function _getCache(data, target) {
1250
+ var theCache = target[data.id];
1251
+ if (!theCache) {
1252
+ theCache = {};
1253
+ try {
1254
+ if (_canAcceptData(target)) {
1255
+ if (!_createAccessor(target, data.id, theCache)) {
1256
+ target[data.id] = theCache;
1257
+ }
1258
+ }
1259
+ }
1260
+ catch (e) {
1261
+ }
1262
+ }
1263
+ return theCache;
1264
+ }
1265
+ function createUniqueNamespace(name, includeVersion) {
1266
+ if (includeVersion === void 0) { includeVersion = false; }
1267
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1268
+ }
1269
+ function createElmNodeData(name) {
1270
+ var data = {
1271
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1272
+ accept: function (target) {
1273
+ return _canAcceptData(target);
1274
+ },
1275
+ get: function (target, name, defValue, addDefault) {
1276
+ var theCache = target[data.id];
1277
+ if (!theCache) {
1278
+ if (addDefault) {
1279
+ theCache = _getCache(data, target);
1280
+ theCache[normalizeJsName(name)] = defValue;
1281
+ }
1282
+ return defValue;
1283
+ }
1284
+ return theCache[normalizeJsName(name)];
1285
+ },
1286
+ kill: function (target, name) {
1287
+ if (target && target[name]) {
1288
+ try {
1289
+ delete target[name];
1290
+ }
1291
+ catch (e) {
1292
+ }
1293
+ }
1294
+ }
1295
+ };
1296
+ return data;
1297
+ }
1298
+
1299
+ var pluginStateData = createElmNodeData("plugin");
1300
+ function _getPluginState(plugin) {
1301
+ return pluginStateData.get(plugin, "state", {}, true);
1302
+ }
1303
+
1219
1304
  var strTelemetryPluginChain = "TelemetryPluginChain";
1220
1305
  var strHasRunFlags = "_hasRun";
1221
1306
  var strGetTelCtx = "_getTelCtx";
@@ -1229,53 +1314,66 @@ function _getNextProxyStart(proxy, config, core, startAt) {
1229
1314
  }
1230
1315
  return createTelemetryProxyChain([startAt], config, core);
1231
1316
  }
1232
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1233
- var _nextProxy = null;
1234
- var _onComplete = null;
1235
- if (startAt) {
1236
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1237
- }
1238
- else {
1239
- _nextProxy = telemetryChain;
1240
- }
1317
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1318
+ var _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1319
+ var _onComplete = [];
1241
1320
  var context = {
1242
- core: function () {
1243
- return core;
1244
- },
1245
- diagLog: function () {
1246
- return safeGetLogger(core, config);
1247
- },
1248
- getCfg: function () {
1249
- return config;
1250
- },
1251
- getExtCfg: _getExtCfg,
1252
- getConfig: _getConfig,
1253
- hasNext: function () {
1254
- return _nextProxy != null;
1255
- },
1256
- getNext: function () {
1257
- return _nextProxy;
1258
- },
1259
- setNext: function (nextPlugin) {
1260
- _nextProxy = nextPlugin;
1261
- },
1262
- processNext: function (env) {
1263
- _processChain(function (nextPlugin) {
1264
- nextPlugin.processTelemetry(env, context);
1321
+ _next: _moveNext,
1322
+ ctx: {
1323
+ core: function () { return core; },
1324
+ diagLog: function () {
1325
+ return safeGetLogger(core, config);
1326
+ },
1327
+ getCfg: function () {
1328
+ return config;
1329
+ },
1330
+ getExtCfg: _getExtCfg,
1331
+ getConfig: _getConfig,
1332
+ hasNext: function () {
1333
+ return !!_nextProxy;
1334
+ },
1335
+ getNext: function () {
1336
+ return _nextProxy;
1337
+ },
1338
+ setNext: function (nextPlugin) {
1339
+ _nextProxy = nextPlugin;
1340
+ },
1341
+ iterate: _iterateChain,
1342
+ onComplete: _addOnComplete
1343
+ }
1344
+ };
1345
+ function _addOnComplete(onComplete, that) {
1346
+ var args = [];
1347
+ for (var _i = 2; _i < arguments.length; _i++) {
1348
+ args[_i - 2] = arguments[_i];
1349
+ }
1350
+ if (onComplete) {
1351
+ _onComplete.push({
1352
+ func: onComplete,
1353
+ self: !isUndefined(that) ? that : context.ctx,
1354
+ args: args
1265
1355
  });
1266
- },
1267
- iterate: _iterateChain,
1268
- createNew: function (plugins, startAt) {
1269
- if (plugins === void 0) { plugins = null; }
1270
- if (isArray(plugins)) {
1271
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1356
+ }
1357
+ }
1358
+ function _moveNext() {
1359
+ var nextProxy = _nextProxy;
1360
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1361
+ if (!nextProxy) {
1362
+ var onComplete = _onComplete;
1363
+ if (onComplete && onComplete.length > 0) {
1364
+ arrForEach(onComplete, function (completeDetails) {
1365
+ try {
1366
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1367
+ }
1368
+ catch (e) {
1369
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1370
+ }
1371
+ });
1372
+ _onComplete = [];
1272
1373
  }
1273
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1274
- },
1275
- onComplete: function (onComplete) {
1276
- _onComplete = onComplete;
1277
1374
  }
1278
- };
1375
+ return nextProxy;
1376
+ }
1279
1377
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1280
1378
  if (defaultValue === void 0) { defaultValue = {}; }
1281
1379
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1318,29 +1416,53 @@ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1318
1416
  }
1319
1417
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1320
1418
  }
1321
- function _processChain(cb) {
1322
- var nextPlugin = _nextProxy;
1323
- if (nextPlugin) {
1324
- _nextProxy = nextPlugin.getNext();
1325
- cb(nextPlugin);
1326
- }
1327
- else {
1328
- if (_onComplete) {
1329
- _onComplete();
1330
- _onComplete = null;
1419
+ function _iterateChain(cb) {
1420
+ var nextPlugin;
1421
+ while (!!(nextPlugin = context._next())) {
1422
+ var plugin = nextPlugin.getPlugin();
1423
+ if (plugin) {
1424
+ cb(plugin);
1331
1425
  }
1332
1426
  }
1333
1427
  }
1334
- function _iterateChain(cb) {
1335
- while (_nextProxy) {
1336
- _processChain(function (nextPlugin) {
1337
- var plugin = nextPlugin.getPlugin();
1338
- if (plugin) {
1339
- cb(plugin);
1340
- }
1341
- });
1428
+ return context;
1429
+ }
1430
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1431
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1432
+ var context = internalContext.ctx;
1433
+ function _processNext(env) {
1434
+ var nextPlugin = internalContext._next();
1435
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1436
+ return !nextPlugin;
1437
+ }
1438
+ function _createNew(plugins, startAt) {
1439
+ if (plugins === void 0) { plugins = null; }
1440
+ if (isArray(plugins)) {
1441
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1442
+ }
1443
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1444
+ }
1445
+ context.processNext = _processNext;
1446
+ context.createNew = _createNew;
1447
+ return context;
1448
+ }
1449
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1450
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1451
+ var context = internalContext.ctx;
1452
+ function _processNext(unloadState) {
1453
+ var nextPlugin = internalContext._next();
1454
+ nextPlugin && nextPlugin.unload(context, unloadState);
1455
+ return !nextPlugin;
1456
+ }
1457
+ function _createNew(plugins, startAt) {
1458
+ if (plugins === void 0) { plugins = null; }
1459
+ if (isArray(plugins)) {
1460
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1342
1461
  }
1462
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1343
1463
  }
1464
+ context.processNext = _processNext;
1465
+ context.createNew = _createNew;
1344
1466
  return context;
1345
1467
  }
1346
1468
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1388,32 +1510,35 @@ function createTelemetryPluginProxy(plugin, config, core) {
1388
1510
  return nextProxy;
1389
1511
  },
1390
1512
  processTelemetry: _processTelemetry,
1513
+ unload: _unloadPlugin,
1391
1514
  _id: chainId,
1392
1515
  _setNext: function (nextPlugin) {
1393
1516
  nextProxy = nextPlugin;
1394
1517
  }
1395
1518
  };
1396
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1519
+ function _getTelCtx() {
1520
+ var itemCtx;
1521
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1522
+ itemCtx = plugin[strGetTelCtx]();
1523
+ }
1397
1524
  if (!itemCtx) {
1398
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1399
- itemCtx = plugin[strGetTelCtx]();
1400
- }
1401
- if (!itemCtx) {
1402
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1403
- }
1525
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1404
1526
  }
1527
+ return itemCtx;
1528
+ }
1529
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1530
+ var hasRun = false;
1405
1531
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1406
1532
  var hasRunContext = itemCtx[strHasRunFlags];
1407
1533
  if (!hasRunContext) {
1408
1534
  hasRunContext = itemCtx[strHasRunFlags] = {};
1409
1535
  }
1410
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1411
- hasRunContext[chainId] = true;
1412
- var hasRun = false;
1413
- itemCtx.setNext(nextProxy);
1414
- if (plugin) {
1536
+ itemCtx.setNext(nextProxy);
1537
+ if (plugin) {
1538
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1539
+ hasRunContext[chainId] = true;
1415
1540
  try {
1416
- var nextId = nextProxy ? nextProxy._id : "";
1541
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1417
1542
  if (nextId) {
1418
1543
  hasRunContext[nextId] = false;
1419
1544
  }
@@ -1425,18 +1550,21 @@ function createTelemetryPluginProxy(plugin, config, core) {
1425
1550
  hasRun = true;
1426
1551
  }
1427
1552
  if (!nextProxy || !hasNextRun) {
1428
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1553
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1429
1554
  }
1430
1555
  }
1431
- }
1432
- if (nextProxy && !hasRun) {
1433
- processProxyFn(itemCtx);
1434
- }
1435
- }, details, isAsync);
1556
+ }, details, isAsync);
1557
+ }
1558
+ return hasRun;
1436
1559
  }
1437
1560
  function _processTelemetry(env, itemCtx) {
1438
- _processChain(itemCtx, function (itemCtx) {
1439
- if (!hasProcessTelemetry) {
1561
+ itemCtx = itemCtx || _getTelCtx();
1562
+ function _callProcessTelemetry(itemCtx) {
1563
+ if (!plugin || !hasProcessTelemetry) {
1564
+ return false;
1565
+ }
1566
+ var pluginState = _getPluginState(plugin);
1567
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1440
1568
  return false;
1441
1569
  }
1442
1570
  if (hasSetNext) {
@@ -1444,9 +1572,31 @@ function createTelemetryPluginProxy(plugin, config, core) {
1444
1572
  }
1445
1573
  plugin.processTelemetry(env, itemCtx);
1446
1574
  return true;
1447
- }, function (itemCtx) {
1448
- nextProxy.processTelemetry(env, itemCtx);
1449
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1575
+ }
1576
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1577
+ itemCtx.processNext(env);
1578
+ }
1579
+ }
1580
+ function _unloadPlugin(unloadCtx, unloadState) {
1581
+ function _callTeardown() {
1582
+ var hasRun = false;
1583
+ if (plugin) {
1584
+ var pluginState = _getPluginState(plugin);
1585
+ var pluginCore = plugin[strCore] || pluginState.core;
1586
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1587
+ pluginState[strCore] = null;
1588
+ pluginState[strTeardown] = true;
1589
+ pluginState[strIsInitialized] = false;
1590
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1591
+ hasRun = true;
1592
+ }
1593
+ }
1594
+ }
1595
+ return hasRun;
1596
+ }
1597
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1598
+ unloadCtx.processNext(unloadState);
1599
+ }
1450
1600
  }
1451
1601
  return objFreeze(proxyChain);
1452
1602
  }
@@ -1459,7 +1609,6 @@ var strEnabled = "enabled";
1459
1609
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1460
1610
  var strDisableCookiesUsage = "disableCookiesUsage";
1461
1611
  var strConfigCookieMgr = "_ckMgr";
1462
- var strEmpty = "";
1463
1612
  var _supportsCookies = null;
1464
1613
  var _allowUaSameSite = null;
1465
1614
  var _parsedCookieValue = null;
@@ -1517,7 +1666,7 @@ function createCookieMgr(rootConfig, logger) {
1517
1666
  var result = false;
1518
1667
  if (_isMgrEnabled(cookieMgr)) {
1519
1668
  var values = {};
1520
- var theValue = strTrim(value || strEmpty);
1669
+ var theValue = strTrim(value || strEmpty$1);
1521
1670
  var idx = theValue.indexOf(";");
1522
1671
  if (idx !== -1) {
1523
1672
  theValue = strTrim(value.substring(0, idx));
@@ -1532,11 +1681,11 @@ function createCookieMgr(rootConfig, logger) {
1532
1681
  if (expireMs > 0) {
1533
1682
  var expiry = new Date();
1534
1683
  expiry.setTime(expireMs);
1535
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1684
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1536
1685
  }
1537
1686
  }
1538
1687
  if (!_isIE) {
1539
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1688
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1540
1689
  }
1541
1690
  }
1542
1691
  var location_1 = getLocation();
@@ -1557,7 +1706,7 @@ function createCookieMgr(rootConfig, logger) {
1557
1706
  return result;
1558
1707
  },
1559
1708
  get: function (name) {
1560
- var value = strEmpty;
1709
+ var value = strEmpty$1;
1561
1710
  if (_isMgrEnabled(cookieMgr)) {
1562
1711
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1563
1712
  }
@@ -1582,7 +1731,7 @@ function createCookieMgr(rootConfig, logger) {
1582
1731
  values["max-age"] = "0";
1583
1732
  }
1584
1733
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1585
- delCookie(name, _formatCookieValue(strEmpty, values));
1734
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1586
1735
  result = true;
1587
1736
  }
1588
1737
  return result;
@@ -1599,7 +1748,7 @@ function areCookiesSupported(logger) {
1599
1748
  _supportsCookies = doc[strCookie] !== undefined;
1600
1749
  }
1601
1750
  catch (e) {
1602
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1751
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1603
1752
  }
1604
1753
  }
1605
1754
  return _supportsCookies;
@@ -1609,7 +1758,7 @@ function _extractParts(theValue) {
1609
1758
  if (theValue && theValue.length) {
1610
1759
  var parts = strTrim(theValue).split(";");
1611
1760
  arrForEach(parts, function (thePart) {
1612
- thePart = strTrim(thePart || strEmpty);
1761
+ thePart = strTrim(thePart || strEmpty$1);
1613
1762
  if (thePart) {
1614
1763
  var idx = thePart.indexOf("=");
1615
1764
  if (idx === -1) {
@@ -1630,21 +1779,21 @@ function _formatDate(theDate, func) {
1630
1779
  return null;
1631
1780
  }
1632
1781
  function _formatCookieValue(value, values) {
1633
- var cookieValue = value || strEmpty;
1782
+ var cookieValue = value || strEmpty$1;
1634
1783
  objForEachKey(values, function (name, theValue) {
1635
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1784
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1636
1785
  });
1637
1786
  return cookieValue;
1638
1787
  }
1639
1788
  function _getCookieValue(name) {
1640
- var cookieValue = strEmpty;
1789
+ var cookieValue = strEmpty$1;
1641
1790
  if (_doc) {
1642
- var theCookie = _doc[strCookie] || strEmpty;
1791
+ var theCookie = _doc[strCookie] || strEmpty$1;
1643
1792
  if (_parsedCookieValue !== theCookie) {
1644
1793
  _cookieCache = _extractParts(theCookie);
1645
1794
  _parsedCookieValue = theCookie;
1646
1795
  }
1647
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1796
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1648
1797
  }
1649
1798
  return cookieValue;
1650
1799
  }
@@ -1694,6 +1843,38 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1694
1843
  _setDefaults(config, core, pluginChain);
1695
1844
  _isinitialized = true;
1696
1845
  };
1846
+ _self.teardown = function (unloadCtx, unloadState) {
1847
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1848
+ return;
1849
+ }
1850
+ var result;
1851
+ var unloadDone = false;
1852
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1853
+ var theUnloadState = unloadState || {
1854
+ reason: 0 ,
1855
+ isAsync: false
1856
+ };
1857
+ function _unloadCallback() {
1858
+ if (!unloadDone) {
1859
+ unloadDone = true;
1860
+ arrForEach(_hooks, function (fn) {
1861
+ fn.rm();
1862
+ });
1863
+ _hooks = [];
1864
+ if (result === true) {
1865
+ theUnloadCtx.processNext(theUnloadState);
1866
+ }
1867
+ _initDefaults();
1868
+ }
1869
+ }
1870
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1871
+ _unloadCallback();
1872
+ }
1873
+ else {
1874
+ result = true;
1875
+ }
1876
+ return result;
1877
+ };
1697
1878
  _self._addHook = function (hooks) {
1698
1879
  if (hooks) {
1699
1880
  if (isArray(hooks)) {
@@ -1708,13 +1889,13 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1708
1889
  _self.diagLog = function (itemCtx) {
1709
1890
  return _getTelCtx(itemCtx).diagLog();
1710
1891
  };
1711
- _self.isInitialized = function () {
1892
+ _self[strIsInitialized] = function () {
1712
1893
  return _isinitialized;
1713
1894
  };
1714
1895
  _self.setInitialized = function (isInitialized) {
1715
1896
  _isinitialized = isInitialized;
1716
1897
  };
1717
- _self.setNextPlugin = function (next) {
1898
+ _self[strSetNextPlugin] = function (next) {
1718
1899
  _nextPlugin = next;
1719
1900
  };
1720
1901
  _self.processNext = function (env, itemCtx) {
@@ -1765,103 +1946,117 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1765
1946
  return BaseTelemetryPlugin;
1766
1947
  }());
1767
1948
 
1768
- var UInt32Mask = 0x100000000;
1769
- var MaxUInt32 = 0xffffffff;
1770
- var _mwcSeeded = false;
1771
- var _mwcW = 123456789;
1772
- var _mwcZ = 987654321;
1773
- function _mwcSeed(seedValue) {
1774
- if (seedValue < 0) {
1775
- seedValue >>>= 0;
1776
- }
1777
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1778
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1779
- _mwcSeeded = true;
1780
- }
1781
- function _autoSeedMwc() {
1782
- try {
1783
- var now = dateNow() & 0x7fffffff;
1784
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1785
- }
1786
- catch (e) {
1787
- }
1788
- }
1789
- function randomValue(maxValue) {
1790
- if (maxValue > 0) {
1791
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1792
- }
1793
- return 0;
1794
- }
1795
- function random32(signed) {
1796
- var value = 0;
1797
- var c = getCrypto() || getMsCrypto();
1798
- if (c && c.getRandomValues) {
1799
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1800
- }
1801
- if (value === 0 && isIE()) {
1802
- if (!_mwcSeeded) {
1803
- _autoSeedMwc();
1949
+ var strOnPrefix = "on";
1950
+ var strAttachEvent = "attachEvent";
1951
+ var strAddEventHelper = "addEventListener";
1952
+ var strEvents = "events";
1953
+ createUniqueNamespace("aiEvtPageHide");
1954
+ createUniqueNamespace("aiEvtPageShow");
1955
+ var _guid = 1;
1956
+ var elmNodeData = createElmNodeData("events");
1957
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1958
+ function _normalizeNamespace(name) {
1959
+ if (name && name.replace) {
1960
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1961
+ }
1962
+ return name;
1963
+ }
1964
+ function _getEvtNamespace(eventName, namespaces) {
1965
+ if (namespaces) {
1966
+ var theNamespace_1 = "";
1967
+ if (isArray(namespaces)) {
1968
+ theNamespace_1 = "";
1969
+ arrForEach(namespaces, function (name) {
1970
+ name = _normalizeNamespace(name);
1971
+ if (name) {
1972
+ if (name[0] !== ".") {
1973
+ name = "." + name;
1974
+ }
1975
+ theNamespace_1 += name;
1976
+ }
1977
+ });
1978
+ }
1979
+ else {
1980
+ theNamespace_1 = _normalizeNamespace(namespaces);
1981
+ }
1982
+ if (theNamespace_1) {
1983
+ if (theNamespace_1[0] !== ".") {
1984
+ theNamespace_1 = "." + theNamespace_1;
1985
+ }
1986
+ eventName = (eventName || "") + theNamespace_1;
1804
1987
  }
1805
- value = mwcRandom32() & MaxUInt32;
1806
- }
1807
- if (value === 0) {
1808
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1809
- }
1810
- if (!signed) {
1811
- value >>>= 0;
1812
1988
  }
1813
- return value;
1989
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
1990
+ return {
1991
+ type: parsedEvent[1],
1992
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
1993
+ };
1814
1994
  }
1815
- function mwcRandomSeed(value) {
1816
- if (!value) {
1817
- _autoSeedMwc();
1818
- }
1819
- else {
1820
- _mwcSeed(value);
1995
+ function _getRegisteredEvents(target, evtName, addDefault) {
1996
+ if (addDefault === void 0) { addDefault = true; }
1997
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1998
+ var registeredEvents = aiEvts[evtName];
1999
+ if (!registeredEvents) {
2000
+ registeredEvents = aiEvts[evtName] = [];
1821
2001
  }
2002
+ return registeredEvents;
1822
2003
  }
1823
- function mwcRandom32(signed) {
1824
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1825
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1826
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1827
- if (!signed) {
1828
- value >>>= 0;
2004
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2005
+ var result = false;
2006
+ if (obj && evtName && evtName.type && handlerRef) {
2007
+ if (obj[strAddEventHelper]) {
2008
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2009
+ result = true;
2010
+ }
2011
+ else if (obj[strAttachEvent]) {
2012
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2013
+ result = true;
2014
+ }
1829
2015
  }
1830
- return value;
2016
+ return result;
1831
2017
  }
1832
- function newId(maxLength) {
1833
- if (maxLength === void 0) { maxLength = 22; }
1834
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1835
- var number = random32() >>> 0;
1836
- var chars = 0;
1837
- var result = "";
1838
- while (result.length < maxLength) {
1839
- chars++;
1840
- result += base64chars.charAt(number & 0x3F);
1841
- number >>>= 6;
1842
- if (chars === 5) {
1843
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1844
- chars = 0;
2018
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2019
+ if (useCapture === void 0) { useCapture = false; }
2020
+ var result = false;
2021
+ if (target) {
2022
+ try {
2023
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2024
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2025
+ if (result && elmNodeData.accept(target)) {
2026
+ var registeredEvent = {
2027
+ guid: _guid++,
2028
+ evtName: evtName,
2029
+ handler: handlerRef,
2030
+ capture: useCapture
2031
+ };
2032
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2033
+ }
2034
+ }
2035
+ catch (e) {
1845
2036
  }
1846
2037
  }
1847
2038
  return result;
1848
2039
  }
1849
-
1850
- var _cookieMgrs = null;
1851
- var _canUseCookies;
1852
- function addEventHandler(eventName, callback) {
2040
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
2041
+ if (useCapture === void 0) { useCapture = false; }
2042
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
2043
+ }
2044
+ function addEventHandler(eventName, callback, evtNamespace) {
1853
2045
  var result = false;
1854
2046
  var w = getWindow();
1855
2047
  if (w) {
1856
- result = attachEvent(w, eventName, callback);
1857
- result = attachEvent(w["body"], eventName, callback) || result;
2048
+ result = eventOn(w, eventName, callback, evtNamespace);
2049
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1858
2050
  }
1859
2051
  var doc = getDocument();
1860
2052
  if (doc) {
1861
- result = attachEvent(doc, eventName, callback) || result;
2053
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1862
2054
  }
1863
2055
  return result;
1864
2056
  }
2057
+
2058
+ var _cookieMgrs = null;
2059
+ var _canUseCookies;
1865
2060
  function newGuid() {
1866
2061
  function randomHexDigit() {
1867
2062
  return randomValue(15);
@@ -1880,7 +2075,7 @@ function perfNow() {
1880
2075
  }
1881
2076
  function generateW3CId() {
1882
2077
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1883
- var oct = "", tmp;
2078
+ var oct = strEmpty$1, tmp;
1884
2079
  for (var a = 0; a < 4; a++) {
1885
2080
  tmp = random32();
1886
2081
  oct +=
@@ -1975,6 +2170,95 @@ function deleteCookie(logger, name) {
1975
2170
  return _legacyCookieMgr(null, logger).del(name);
1976
2171
  }
1977
2172
 
2173
+ createEnumStyle({
2174
+ CRITICAL: 1 ,
2175
+ WARNING: 2
2176
+ });
2177
+ var _InternalMessageId = createEnumStyle({
2178
+ BrowserDoesNotSupportLocalStorage: 0 ,
2179
+ BrowserCannotReadLocalStorage: 1 ,
2180
+ BrowserCannotReadSessionStorage: 2 ,
2181
+ BrowserCannotWriteLocalStorage: 3 ,
2182
+ BrowserCannotWriteSessionStorage: 4 ,
2183
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2184
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2185
+ CannotSendEmptyTelemetry: 7 ,
2186
+ ClientPerformanceMathError: 8 ,
2187
+ ErrorParsingAISessionCookie: 9 ,
2188
+ ErrorPVCalc: 10 ,
2189
+ ExceptionWhileLoggingError: 11 ,
2190
+ FailedAddingTelemetryToBuffer: 12 ,
2191
+ FailedMonitorAjaxAbort: 13 ,
2192
+ FailedMonitorAjaxDur: 14 ,
2193
+ FailedMonitorAjaxOpen: 15 ,
2194
+ FailedMonitorAjaxRSC: 16 ,
2195
+ FailedMonitorAjaxSend: 17 ,
2196
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2197
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2198
+ FailedToSendQueuedTelemetry: 20 ,
2199
+ FailedToReportDataLoss: 21 ,
2200
+ FlushFailed: 22 ,
2201
+ MessageLimitPerPVExceeded: 23 ,
2202
+ MissingRequiredFieldSpecification: 24 ,
2203
+ NavigationTimingNotSupported: 25 ,
2204
+ OnError: 26 ,
2205
+ SessionRenewalDateIsZero: 27 ,
2206
+ SenderNotInitialized: 28 ,
2207
+ StartTrackEventFailed: 29 ,
2208
+ StopTrackEventFailed: 30 ,
2209
+ StartTrackFailed: 31 ,
2210
+ StopTrackFailed: 32 ,
2211
+ TelemetrySampledAndNotSent: 33 ,
2212
+ TrackEventFailed: 34 ,
2213
+ TrackExceptionFailed: 35 ,
2214
+ TrackMetricFailed: 36 ,
2215
+ TrackPVFailed: 37 ,
2216
+ TrackPVFailedCalc: 38 ,
2217
+ TrackTraceFailed: 39 ,
2218
+ TransmissionFailed: 40 ,
2219
+ FailedToSetStorageBuffer: 41 ,
2220
+ FailedToRestoreStorageBuffer: 42 ,
2221
+ InvalidBackendResponse: 43 ,
2222
+ FailedToFixDepricatedValues: 44 ,
2223
+ InvalidDurationValue: 45 ,
2224
+ TelemetryEnvelopeInvalid: 46 ,
2225
+ CreateEnvelopeError: 47 ,
2226
+ CannotSerializeObject: 48 ,
2227
+ CannotSerializeObjectNonSerializable: 49 ,
2228
+ CircularReferenceDetected: 50 ,
2229
+ ClearAuthContextFailed: 51 ,
2230
+ ExceptionTruncated: 52 ,
2231
+ IllegalCharsInName: 53 ,
2232
+ ItemNotInArray: 54 ,
2233
+ MaxAjaxPerPVExceeded: 55 ,
2234
+ MessageTruncated: 56 ,
2235
+ NameTooLong: 57 ,
2236
+ SampleRateOutOfRange: 58 ,
2237
+ SetAuthContextFailed: 59 ,
2238
+ SetAuthContextFailedAccountName: 60 ,
2239
+ StringValueTooLong: 61 ,
2240
+ StartCalledMoreThanOnce: 62 ,
2241
+ StopCalledWithoutStart: 63 ,
2242
+ TelemetryInitializerFailed: 64 ,
2243
+ TrackArgumentsNotSpecified: 65 ,
2244
+ UrlTooLong: 66 ,
2245
+ SessionStorageBufferFull: 67 ,
2246
+ CannotAccessCookie: 68 ,
2247
+ IdTooLong: 69 ,
2248
+ InvalidEvent: 70 ,
2249
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2250
+ SendBrowserInfoOnUserInit: 72 ,
2251
+ PluginException: 73 ,
2252
+ NotificationException: 74 ,
2253
+ SnippetScriptLoadFailure: 99 ,
2254
+ InvalidInstrumentationKey: 100 ,
2255
+ CannotParseAiBlobValue: 101 ,
2256
+ InvalidContentBlob: 102 ,
2257
+ TrackPageActionEventFailed: 103 ,
2258
+ FailedAddingCustomDefinedRequestContext: 104 ,
2259
+ InMemoryStorageBufferFull: 105
2260
+ });
2261
+
1978
2262
  var aiInstrumentHooks = "_aiHooks";
1979
2263
  var cbNames = [
1980
2264
  "req", "rsp", "hkErr", "fnErr"
@@ -2127,6 +2411,7 @@ function createDomEvent(eventName) {
2127
2411
  return event;
2128
2412
  }
2129
2413
 
2414
+ var strEmpty = "";
2130
2415
  function stringToBoolOrDefault(str, defaultValue) {
2131
2416
  if (defaultValue === void 0) { defaultValue = false; }
2132
2417
  if (str === undefined || str === null) {
@@ -2139,16 +2424,16 @@ function msToTimeSpan(totalms) {
2139
2424
  totalms = 0;
2140
2425
  }
2141
2426
  totalms = Math.round(totalms);
2142
- var ms = "" + totalms % 1000;
2143
- var sec = "" + Math.floor(totalms / 1000) % 60;
2144
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
2145
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2427
+ var ms = strEmpty + totalms % 1000;
2428
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2429
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2430
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2146
2431
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2147
2432
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2148
2433
  sec = sec.length < 2 ? "0" + sec : sec;
2149
2434
  min = min.length < 2 ? "0" + min : min;
2150
2435
  hour = hour.length < 2 ? "0" + hour : hour;
2151
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2436
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
2152
2437
  }
2153
2438
  function getExtensionByName(extensions, identifier) {
2154
2439
  var extension = null;
@@ -2166,17 +2451,15 @@ function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
2166
2451
 
2167
2452
  var strNotSpecified = "not_specified";
2168
2453
 
2169
- var StorageType;
2170
- (function (StorageType) {
2171
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
2172
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
2173
- })(StorageType || (StorageType = {}));
2174
- var DistributedTracingModes;
2175
- (function (DistributedTracingModes) {
2176
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
2177
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
2178
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
2179
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2454
+ var StorageType = createEnumStyle({
2455
+ LocalStorage: 0 ,
2456
+ SessionStorage: 1
2457
+ });
2458
+ createEnumStyle({
2459
+ AI: 0 ,
2460
+ AI_AND_W3C: 1 ,
2461
+ W3C: 2
2462
+ });
2180
2463
 
2181
2464
  var _canUseLocalStorage = undefined;
2182
2465
  var _canUseSessionStorage = undefined;
@@ -2228,7 +2511,7 @@ function utlGetLocalStorage(logger, name) {
2228
2511
  }
2229
2512
  catch (e) {
2230
2513
  _canUseLocalStorage = false;
2231
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2514
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2232
2515
  }
2233
2516
  }
2234
2517
  return null;
@@ -2242,7 +2525,7 @@ function utlSetLocalStorage(logger, name, data) {
2242
2525
  }
2243
2526
  catch (e) {
2244
2527
  _canUseLocalStorage = false;
2245
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2528
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2246
2529
  }
2247
2530
  }
2248
2531
  return false;
@@ -2256,7 +2539,7 @@ function utlRemoveStorage(logger, name) {
2256
2539
  }
2257
2540
  catch (e) {
2258
2541
  _canUseLocalStorage = false;
2259
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2542
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2260
2543
  }
2261
2544
  }
2262
2545
  return false;
@@ -2284,7 +2567,7 @@ function utlGetSessionStorage(logger, name) {
2284
2567
  }
2285
2568
  catch (e) {
2286
2569
  _canUseSessionStorage = false;
2287
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2570
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2288
2571
  }
2289
2572
  }
2290
2573
  return null;
@@ -2298,7 +2581,7 @@ function utlSetSessionStorage(logger, name, data) {
2298
2581
  }
2299
2582
  catch (e) {
2300
2583
  _canUseSessionStorage = false;
2301
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2584
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2302
2585
  }
2303
2586
  }
2304
2587
  return false;
@@ -2312,7 +2595,7 @@ function utlRemoveSessionStorage(logger, name) {
2312
2595
  }
2313
2596
  catch (e) {
2314
2597
  _canUseSessionStorage = false;
2315
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2598
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2316
2599
  }
2317
2600
  }
2318
2601
  return false;
@@ -3547,4 +3830,4 @@ var DebugPlugin = /** @class */ (function (_super) {
3547
3830
  var DebugPlugin$1 = DebugPlugin;
3548
3831
 
3549
3832
  exports.DebugPlugin = DebugPlugin$1;
3550
- //# sourceMappingURL=ai.dbg.2.8.0-beta.2202-06.cjs.js.map
3833
+ //# sourceMappingURL=ai.dbg.2.8.0-beta.2203-02.cjs.js.map