@microsoft/applicationinsights-debugplugin-js 2.8.0-beta.2203-01 → 2.8.0-beta.2203-04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/browser/{ai.dbg.2.8.0-beta.2203-01.cjs.js → ai.dbg.2.8.0-beta.2203-04.cjs.js} +668 -327
  2. package/browser/ai.dbg.2.8.0-beta.2203-04.cjs.js.map +1 -0
  3. package/browser/ai.dbg.2.8.0-beta.2203-04.cjs.min.js +6 -0
  4. package/browser/ai.dbg.2.8.0-beta.2203-04.cjs.min.js.map +1 -0
  5. package/browser/{ai.dbg.2.8.0-beta.2203-01.gbl.js → ai.dbg.2.8.0-beta.2203-04.gbl.js} +668 -327
  6. package/browser/ai.dbg.2.8.0-beta.2203-04.gbl.js.map +1 -0
  7. package/browser/ai.dbg.2.8.0-beta.2203-04.gbl.min.js +6 -0
  8. package/browser/ai.dbg.2.8.0-beta.2203-04.gbl.min.js.map +1 -0
  9. package/browser/ai.dbg.2.8.0-beta.2203-04.integrity.json +66 -0
  10. package/browser/{ai.dbg.2.8.0-beta.2203-01.js → ai.dbg.2.8.0-beta.2203-04.js} +668 -327
  11. package/browser/ai.dbg.2.8.0-beta.2203-04.js.map +1 -0
  12. package/browser/ai.dbg.2.8.0-beta.2203-04.min.js +6 -0
  13. package/browser/ai.dbg.2.8.0-beta.2203-04.min.js.map +1 -0
  14. package/browser/ai.dbg.2.cjs.js +667 -326
  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 +667 -326
  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 +667 -326
  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 +667 -326
  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.2203-01.cjs.js.map +0 -1
  43. package/browser/ai.dbg.2.8.0-beta.2203-01.cjs.min.js +0 -6
  44. package/browser/ai.dbg.2.8.0-beta.2203-01.cjs.min.js.map +0 -1
  45. package/browser/ai.dbg.2.8.0-beta.2203-01.gbl.js.map +0 -1
  46. package/browser/ai.dbg.2.8.0-beta.2203-01.gbl.min.js +0 -6
  47. package/browser/ai.dbg.2.8.0-beta.2203-01.gbl.min.js.map +0 -1
  48. package/browser/ai.dbg.2.8.0-beta.2203-01.integrity.json +0 -66
  49. package/browser/ai.dbg.2.8.0-beta.2203-01.js.map +0 -1
  50. package/browser/ai.dbg.2.8.0-beta.2203-01.min.js +0 -6
  51. package/browser/ai.dbg.2.8.0-beta.2203-01.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Debug Plugin, 2.8.0-beta.2203-01
2
+ * Application Insights JavaScript SDK - Debug Plugin, 2.8.0-beta.2203-04
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,47 @@ 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 _createProxyFunction(source, funcName) {
675
+ var srcFunc = null;
676
+ var src = null;
677
+ if (isFunction(source)) {
678
+ srcFunc = source;
679
+ }
680
+ else {
681
+ src = source;
682
+ }
683
+ return function () {
684
+ var originalArguments = arguments;
685
+ if (srcFunc) {
686
+ src = srcFunc();
687
+ }
688
+ if (src) {
689
+ return src[funcName].apply(src, originalArguments);
690
+ }
691
+ };
692
+ }
693
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
694
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
695
+ if (target && name && source) {
696
+ if (overwriteTarget || isUndefined(target[name])) {
697
+ target[name] = _createProxyFunction(source, theFunc);
698
+ }
699
+ }
700
+ }
701
+ function createEnumStyle(values) {
702
+ var enumClass = {};
703
+ objForEachKey(values, function (field, value) {
704
+ enumClass[field] = value;
705
+ if (!isUndefined(enumClass[value])) {
706
+ throwError("[" + value + "] exists for " + field);
707
+ }
708
+ enumClass[value] = field;
709
+ });
710
+ return objFreeze(enumClass);
711
+ }
759
712
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
760
713
  var theArgs = arguments;
761
714
  var extended = theArgs[0] || {};
@@ -894,7 +847,7 @@ function isIE() {
894
847
  var nav = getNavigator();
895
848
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
896
849
  _navUserAgentCheck = nav.userAgent;
897
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
850
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
898
851
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
899
852
  }
900
853
  return _isTrident;
@@ -903,9 +856,9 @@ function getIEVersion(userAgentStr) {
903
856
  if (userAgentStr === void 0) { userAgentStr = null; }
904
857
  if (!userAgentStr) {
905
858
  var navigator_1 = getNavigator() || {};
906
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
859
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
907
860
  }
908
- var ua = (userAgentStr || "").toLowerCase();
861
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
909
862
  if (strContains(ua, strMsie)) {
910
863
  var doc = getDocument() || {};
911
864
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -920,7 +873,7 @@ function getIEVersion(userAgentStr) {
920
873
  }
921
874
  function dumpObj(object) {
922
875
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
923
- var propertyValueDump = "";
876
+ var propertyValueDump = strEmpty$1;
924
877
  if (objectTypeDump === "[object Error]") {
925
878
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
926
879
  }
@@ -959,9 +912,9 @@ var strErrorToConsole = "errorToConsole";
959
912
  var strWarnToConsole = "warnToConsole";
960
913
  function _sanitizeDiagnosticText(text) {
961
914
  if (text) {
962
- return "\"" + text.replace(/\"/g, "") + "\"";
915
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
963
916
  }
964
- return "";
917
+ return strEmpty$1;
965
918
  }
966
919
  function _logToConsole(func, message) {
967
920
  var theConsole = getConsole();
@@ -983,12 +936,12 @@ var _InternalLogMessage = /** @class */ (function () {
983
936
  _self.message =
984
937
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
985
938
  msgId;
986
- var strProps = "";
939
+ var strProps = strEmpty$1;
987
940
  if (hasJSON()) {
988
941
  strProps = getJSON().stringify(properties);
989
942
  }
990
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
991
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
943
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
944
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
992
945
  _self.message += diagnosticText;
993
946
  }
994
947
  _InternalLogMessage.dataType = "MessageData";
@@ -1018,7 +971,7 @@ var DiagnosticLogger = /** @class */ (function () {
1018
971
  throw message;
1019
972
  }
1020
973
  else {
1021
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
974
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1022
975
  if (!isUndefined(message.message)) {
1023
976
  var logLevel = _self.consoleLoggingLevel();
1024
977
  if (isUserAct) {
@@ -1036,7 +989,7 @@ var DiagnosticLogger = /** @class */ (function () {
1036
989
  _self.logInternalMessage(severity, message);
1037
990
  }
1038
991
  else {
1039
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
992
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1040
993
  }
1041
994
  }
1042
995
  };
@@ -1068,13 +1021,13 @@ var DiagnosticLogger = /** @class */ (function () {
1068
1021
  if (severity <= _self.telemetryLoggingLevel()) {
1069
1022
  _self.queue.push(message);
1070
1023
  _messageCount++;
1071
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1024
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1072
1025
  }
1073
1026
  if (_messageCount === _self.maxInternalMessageLimit()) {
1074
1027
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1075
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1028
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1076
1029
  _self.queue.push(throttleMessage);
1077
- if (severity === LoggingSeverity.CRITICAL) {
1030
+ if (severity === 1 ) {
1078
1031
  _self.errorToConsole(throttleLimitMessage);
1079
1032
  }
1080
1033
  else {
@@ -1216,6 +1169,165 @@ function doPerf(mgrSource, getSource, func, details, isAsync) {
1216
1169
  return func();
1217
1170
  }
1218
1171
 
1172
+ var UInt32Mask = 0x100000000;
1173
+ var MaxUInt32 = 0xffffffff;
1174
+ var _mwcSeeded = false;
1175
+ var _mwcW = 123456789;
1176
+ var _mwcZ = 987654321;
1177
+ function _mwcSeed(seedValue) {
1178
+ if (seedValue < 0) {
1179
+ seedValue >>>= 0;
1180
+ }
1181
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1182
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1183
+ _mwcSeeded = true;
1184
+ }
1185
+ function _autoSeedMwc() {
1186
+ try {
1187
+ var now = dateNow() & 0x7fffffff;
1188
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1189
+ }
1190
+ catch (e) {
1191
+ }
1192
+ }
1193
+ function randomValue(maxValue) {
1194
+ if (maxValue > 0) {
1195
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1196
+ }
1197
+ return 0;
1198
+ }
1199
+ function random32(signed) {
1200
+ var value = 0;
1201
+ var c = getCrypto() || getMsCrypto();
1202
+ if (c && c.getRandomValues) {
1203
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1204
+ }
1205
+ if (value === 0 && isIE()) {
1206
+ if (!_mwcSeeded) {
1207
+ _autoSeedMwc();
1208
+ }
1209
+ value = mwcRandom32() & MaxUInt32;
1210
+ }
1211
+ if (value === 0) {
1212
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1213
+ }
1214
+ if (!signed) {
1215
+ value >>>= 0;
1216
+ }
1217
+ return value;
1218
+ }
1219
+ function mwcRandomSeed(value) {
1220
+ if (!value) {
1221
+ _autoSeedMwc();
1222
+ }
1223
+ else {
1224
+ _mwcSeed(value);
1225
+ }
1226
+ }
1227
+ function mwcRandom32(signed) {
1228
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1229
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1230
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1231
+ if (!signed) {
1232
+ value >>>= 0;
1233
+ }
1234
+ return value;
1235
+ }
1236
+ function newId(maxLength) {
1237
+ if (maxLength === void 0) { maxLength = 22; }
1238
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1239
+ var number = random32() >>> 0;
1240
+ var chars = 0;
1241
+ var result = strEmpty$1;
1242
+ while (result.length < maxLength) {
1243
+ chars++;
1244
+ result += base64chars.charAt(number & 0x3F);
1245
+ number >>>= 6;
1246
+ if (chars === 5) {
1247
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1248
+ chars = 0;
1249
+ }
1250
+ }
1251
+ return result;
1252
+ }
1253
+
1254
+ var _objDefineProperty = ObjDefineProperty;
1255
+ var version = "2.7.3";
1256
+ var instanceName = "." + newId(6);
1257
+ var _dataUid = 0;
1258
+ function _createAccessor(target, prop, value) {
1259
+ if (_objDefineProperty) {
1260
+ try {
1261
+ _objDefineProperty(target, prop, {
1262
+ value: value,
1263
+ enumerable: false,
1264
+ configurable: true
1265
+ });
1266
+ return true;
1267
+ }
1268
+ catch (e) {
1269
+ }
1270
+ }
1271
+ return false;
1272
+ }
1273
+ function _canAcceptData(target) {
1274
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1275
+ }
1276
+ function _getCache(data, target) {
1277
+ var theCache = target[data.id];
1278
+ if (!theCache) {
1279
+ theCache = {};
1280
+ try {
1281
+ if (_canAcceptData(target)) {
1282
+ if (!_createAccessor(target, data.id, theCache)) {
1283
+ target[data.id] = theCache;
1284
+ }
1285
+ }
1286
+ }
1287
+ catch (e) {
1288
+ }
1289
+ }
1290
+ return theCache;
1291
+ }
1292
+ function createUniqueNamespace(name, includeVersion) {
1293
+ if (includeVersion === void 0) { includeVersion = false; }
1294
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1295
+ }
1296
+ function createElmNodeData(name) {
1297
+ var data = {
1298
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1299
+ accept: function (target) {
1300
+ return _canAcceptData(target);
1301
+ },
1302
+ get: function (target, name, defValue, addDefault) {
1303
+ var theCache = target[data.id];
1304
+ if (!theCache) {
1305
+ if (addDefault) {
1306
+ theCache = _getCache(data, target);
1307
+ theCache[normalizeJsName(name)] = defValue;
1308
+ }
1309
+ return defValue;
1310
+ }
1311
+ return theCache[normalizeJsName(name)];
1312
+ },
1313
+ kill: function (target, name) {
1314
+ if (target && target[name]) {
1315
+ try {
1316
+ delete target[name];
1317
+ }
1318
+ catch (e) {
1319
+ }
1320
+ }
1321
+ }
1322
+ };
1323
+ return data;
1324
+ }
1325
+
1326
+ var pluginStateData = createElmNodeData("plugin");
1327
+ function _getPluginState(plugin) {
1328
+ return pluginStateData.get(plugin, "state", {}, true);
1329
+ }
1330
+
1219
1331
  var strTelemetryPluginChain = "TelemetryPluginChain";
1220
1332
  var strHasRunFlags = "_hasRun";
1221
1333
  var strGetTelCtx = "_getTelCtx";
@@ -1229,53 +1341,69 @@ function _getNextProxyStart(proxy, config, core, startAt) {
1229
1341
  }
1230
1342
  return createTelemetryProxyChain([startAt], config, core);
1231
1343
  }
1232
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1344
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1233
1345
  var _nextProxy = null;
1234
- var _onComplete = null;
1235
- if (startAt) {
1236
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1237
- }
1238
- else {
1239
- _nextProxy = telemetryChain;
1346
+ var _onComplete = [];
1347
+ if (startAt !== null) {
1348
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1240
1349
  }
1241
1350
  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);
1351
+ _next: _moveNext,
1352
+ ctx: {
1353
+ core: function () { return core; },
1354
+ diagLog: function () {
1355
+ return safeGetLogger(core, config);
1356
+ },
1357
+ getCfg: function () {
1358
+ return config;
1359
+ },
1360
+ getExtCfg: _getExtCfg,
1361
+ getConfig: _getConfig,
1362
+ hasNext: function () {
1363
+ return !!_nextProxy;
1364
+ },
1365
+ getNext: function () {
1366
+ return _nextProxy;
1367
+ },
1368
+ setNext: function (nextPlugin) {
1369
+ _nextProxy = nextPlugin;
1370
+ },
1371
+ iterate: _iterateChain,
1372
+ onComplete: _addOnComplete
1373
+ }
1374
+ };
1375
+ function _addOnComplete(onComplete, that) {
1376
+ var args = [];
1377
+ for (var _i = 2; _i < arguments.length; _i++) {
1378
+ args[_i - 2] = arguments[_i];
1379
+ }
1380
+ if (onComplete) {
1381
+ _onComplete.push({
1382
+ func: onComplete,
1383
+ self: !isUndefined(that) ? that : context.ctx,
1384
+ args: args
1265
1385
  });
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);
1386
+ }
1387
+ }
1388
+ function _moveNext() {
1389
+ var nextProxy = _nextProxy;
1390
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1391
+ if (!nextProxy) {
1392
+ var onComplete = _onComplete;
1393
+ if (onComplete && onComplete.length > 0) {
1394
+ arrForEach(onComplete, function (completeDetails) {
1395
+ try {
1396
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1397
+ }
1398
+ catch (e) {
1399
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1400
+ }
1401
+ });
1402
+ _onComplete = [];
1272
1403
  }
1273
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1274
- },
1275
- onComplete: function (onComplete) {
1276
- _onComplete = onComplete;
1277
1404
  }
1278
- };
1405
+ return nextProxy;
1406
+ }
1279
1407
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1280
1408
  if (defaultValue === void 0) { defaultValue = {}; }
1281
1409
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1318,29 +1446,53 @@ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1318
1446
  }
1319
1447
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1320
1448
  }
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;
1449
+ function _iterateChain(cb) {
1450
+ var nextPlugin;
1451
+ while (!!(nextPlugin = context._next())) {
1452
+ var plugin = nextPlugin.getPlugin();
1453
+ if (plugin) {
1454
+ cb(plugin);
1331
1455
  }
1332
1456
  }
1333
1457
  }
1334
- function _iterateChain(cb) {
1335
- while (_nextProxy) {
1336
- _processChain(function (nextPlugin) {
1337
- var plugin = nextPlugin.getPlugin();
1338
- if (plugin) {
1339
- cb(plugin);
1340
- }
1341
- });
1458
+ return context;
1459
+ }
1460
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1461
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1462
+ var context = internalContext.ctx;
1463
+ function _processNext(env) {
1464
+ var nextPlugin = internalContext._next();
1465
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1466
+ return !nextPlugin;
1467
+ }
1468
+ function _createNew(plugins, startAt) {
1469
+ if (plugins === void 0) { plugins = null; }
1470
+ if (isArray(plugins)) {
1471
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1472
+ }
1473
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1474
+ }
1475
+ context.processNext = _processNext;
1476
+ context.createNew = _createNew;
1477
+ return context;
1478
+ }
1479
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1480
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1481
+ var context = internalContext.ctx;
1482
+ function _processNext(unloadState) {
1483
+ var nextPlugin = internalContext._next();
1484
+ nextPlugin && nextPlugin.unload(context, unloadState);
1485
+ return !nextPlugin;
1486
+ }
1487
+ function _createNew(plugins, startAt) {
1488
+ if (plugins === void 0) { plugins = null; }
1489
+ if (isArray(plugins)) {
1490
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1342
1491
  }
1492
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1343
1493
  }
1494
+ context.processNext = _processNext;
1495
+ context.createNew = _createNew;
1344
1496
  return context;
1345
1497
  }
1346
1498
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1388,32 +1540,35 @@ function createTelemetryPluginProxy(plugin, config, core) {
1388
1540
  return nextProxy;
1389
1541
  },
1390
1542
  processTelemetry: _processTelemetry,
1543
+ unload: _unloadPlugin,
1391
1544
  _id: chainId,
1392
1545
  _setNext: function (nextPlugin) {
1393
1546
  nextProxy = nextPlugin;
1394
1547
  }
1395
1548
  };
1396
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1549
+ function _getTelCtx() {
1550
+ var itemCtx;
1551
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1552
+ itemCtx = plugin[strGetTelCtx]();
1553
+ }
1397
1554
  if (!itemCtx) {
1398
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1399
- itemCtx = plugin[strGetTelCtx]();
1400
- }
1401
- if (!itemCtx) {
1402
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1403
- }
1555
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1404
1556
  }
1557
+ return itemCtx;
1558
+ }
1559
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1560
+ var hasRun = false;
1405
1561
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1406
1562
  var hasRunContext = itemCtx[strHasRunFlags];
1407
1563
  if (!hasRunContext) {
1408
1564
  hasRunContext = itemCtx[strHasRunFlags] = {};
1409
1565
  }
1410
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1411
- hasRunContext[chainId] = true;
1412
- var hasRun = false;
1413
- itemCtx.setNext(nextProxy);
1414
- if (plugin) {
1566
+ itemCtx.setNext(nextProxy);
1567
+ if (plugin) {
1568
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1569
+ hasRunContext[chainId] = true;
1415
1570
  try {
1416
- var nextId = nextProxy ? nextProxy._id : "";
1571
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1417
1572
  if (nextId) {
1418
1573
  hasRunContext[nextId] = false;
1419
1574
  }
@@ -1425,18 +1580,21 @@ function createTelemetryPluginProxy(plugin, config, core) {
1425
1580
  hasRun = true;
1426
1581
  }
1427
1582
  if (!nextProxy || !hasNextRun) {
1428
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1583
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1429
1584
  }
1430
1585
  }
1431
- }
1432
- if (nextProxy && !hasRun) {
1433
- processProxyFn(itemCtx);
1434
- }
1435
- }, details, isAsync);
1586
+ }, details, isAsync);
1587
+ }
1588
+ return hasRun;
1436
1589
  }
1437
1590
  function _processTelemetry(env, itemCtx) {
1438
- _processChain(itemCtx, function (itemCtx) {
1439
- if (!hasProcessTelemetry) {
1591
+ itemCtx = itemCtx || _getTelCtx();
1592
+ function _callProcessTelemetry(itemCtx) {
1593
+ if (!plugin || !hasProcessTelemetry) {
1594
+ return false;
1595
+ }
1596
+ var pluginState = _getPluginState(plugin);
1597
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1440
1598
  return false;
1441
1599
  }
1442
1600
  if (hasSetNext) {
@@ -1444,9 +1602,31 @@ function createTelemetryPluginProxy(plugin, config, core) {
1444
1602
  }
1445
1603
  plugin.processTelemetry(env, itemCtx);
1446
1604
  return true;
1447
- }, function (itemCtx) {
1448
- nextProxy.processTelemetry(env, itemCtx);
1449
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1605
+ }
1606
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1607
+ itemCtx.processNext(env);
1608
+ }
1609
+ }
1610
+ function _unloadPlugin(unloadCtx, unloadState) {
1611
+ function _callTeardown() {
1612
+ var hasRun = false;
1613
+ if (plugin) {
1614
+ var pluginState = _getPluginState(plugin);
1615
+ var pluginCore = plugin[strCore] || pluginState.core;
1616
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1617
+ pluginState[strCore] = null;
1618
+ pluginState[strTeardown] = true;
1619
+ pluginState[strIsInitialized] = false;
1620
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1621
+ hasRun = true;
1622
+ }
1623
+ }
1624
+ }
1625
+ return hasRun;
1626
+ }
1627
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1628
+ unloadCtx.processNext(unloadState);
1629
+ }
1450
1630
  }
1451
1631
  return objFreeze(proxyChain);
1452
1632
  }
@@ -1459,7 +1639,6 @@ var strEnabled = "enabled";
1459
1639
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1460
1640
  var strDisableCookiesUsage = "disableCookiesUsage";
1461
1641
  var strConfigCookieMgr = "_ckMgr";
1462
- var strEmpty = "";
1463
1642
  var _supportsCookies = null;
1464
1643
  var _allowUaSameSite = null;
1465
1644
  var _parsedCookieValue = null;
@@ -1517,7 +1696,7 @@ function createCookieMgr(rootConfig, logger) {
1517
1696
  var result = false;
1518
1697
  if (_isMgrEnabled(cookieMgr)) {
1519
1698
  var values = {};
1520
- var theValue = strTrim(value || strEmpty);
1699
+ var theValue = strTrim(value || strEmpty$1);
1521
1700
  var idx = theValue.indexOf(";");
1522
1701
  if (idx !== -1) {
1523
1702
  theValue = strTrim(value.substring(0, idx));
@@ -1532,11 +1711,11 @@ function createCookieMgr(rootConfig, logger) {
1532
1711
  if (expireMs > 0) {
1533
1712
  var expiry = new Date();
1534
1713
  expiry.setTime(expireMs);
1535
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1714
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1536
1715
  }
1537
1716
  }
1538
1717
  if (!_isIE) {
1539
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1718
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1540
1719
  }
1541
1720
  }
1542
1721
  var location_1 = getLocation();
@@ -1557,7 +1736,7 @@ function createCookieMgr(rootConfig, logger) {
1557
1736
  return result;
1558
1737
  },
1559
1738
  get: function (name) {
1560
- var value = strEmpty;
1739
+ var value = strEmpty$1;
1561
1740
  if (_isMgrEnabled(cookieMgr)) {
1562
1741
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1563
1742
  }
@@ -1582,7 +1761,7 @@ function createCookieMgr(rootConfig, logger) {
1582
1761
  values["max-age"] = "0";
1583
1762
  }
1584
1763
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1585
- delCookie(name, _formatCookieValue(strEmpty, values));
1764
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1586
1765
  result = true;
1587
1766
  }
1588
1767
  return result;
@@ -1599,7 +1778,7 @@ function areCookiesSupported(logger) {
1599
1778
  _supportsCookies = doc[strCookie] !== undefined;
1600
1779
  }
1601
1780
  catch (e) {
1602
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1781
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1603
1782
  }
1604
1783
  }
1605
1784
  return _supportsCookies;
@@ -1609,7 +1788,7 @@ function _extractParts(theValue) {
1609
1788
  if (theValue && theValue.length) {
1610
1789
  var parts = strTrim(theValue).split(";");
1611
1790
  arrForEach(parts, function (thePart) {
1612
- thePart = strTrim(thePart || strEmpty);
1791
+ thePart = strTrim(thePart || strEmpty$1);
1613
1792
  if (thePart) {
1614
1793
  var idx = thePart.indexOf("=");
1615
1794
  if (idx === -1) {
@@ -1630,21 +1809,21 @@ function _formatDate(theDate, func) {
1630
1809
  return null;
1631
1810
  }
1632
1811
  function _formatCookieValue(value, values) {
1633
- var cookieValue = value || strEmpty;
1812
+ var cookieValue = value || strEmpty$1;
1634
1813
  objForEachKey(values, function (name, theValue) {
1635
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1814
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1636
1815
  });
1637
1816
  return cookieValue;
1638
1817
  }
1639
1818
  function _getCookieValue(name) {
1640
- var cookieValue = strEmpty;
1819
+ var cookieValue = strEmpty$1;
1641
1820
  if (_doc) {
1642
- var theCookie = _doc[strCookie] || strEmpty;
1821
+ var theCookie = _doc[strCookie] || strEmpty$1;
1643
1822
  if (_parsedCookieValue !== theCookie) {
1644
1823
  _cookieCache = _extractParts(theCookie);
1645
1824
  _parsedCookieValue = theCookie;
1646
1825
  }
1647
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1826
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1648
1827
  }
1649
1828
  return cookieValue;
1650
1829
  }
@@ -1680,6 +1859,30 @@ function uaDisallowsSameSiteNone(userAgent) {
1680
1859
 
1681
1860
  var strExtensionConfig = "extensionConfig";
1682
1861
 
1862
+ function createUnloadHandlerContainer() {
1863
+ var handlers = [];
1864
+ function _addHandler(handler) {
1865
+ if (handler) {
1866
+ handlers.push(handler);
1867
+ }
1868
+ }
1869
+ function _runHandlers(unloadCtx, unloadState) {
1870
+ arrForEach(handlers, function (handler) {
1871
+ try {
1872
+ handler(unloadCtx, unloadState);
1873
+ }
1874
+ catch (e) {
1875
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1876
+ }
1877
+ });
1878
+ handlers = [];
1879
+ }
1880
+ return {
1881
+ add: _addHandler,
1882
+ run: _runHandlers
1883
+ };
1884
+ }
1885
+
1683
1886
  var strGetPlugin = "getPlugin";
1684
1887
  var BaseTelemetryPlugin = /** @class */ (function () {
1685
1888
  function BaseTelemetryPlugin() {
@@ -1687,6 +1890,7 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1687
1890
  var _isinitialized;
1688
1891
  var _rootCtx;
1689
1892
  var _nextPlugin;
1893
+ var _unloadHandlerContainer;
1690
1894
  var _hooks;
1691
1895
  _initDefaults();
1692
1896
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1694,6 +1898,39 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1694
1898
  _setDefaults(config, core, pluginChain);
1695
1899
  _isinitialized = true;
1696
1900
  };
1901
+ _self.teardown = function (unloadCtx, unloadState) {
1902
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1903
+ return;
1904
+ }
1905
+ var result;
1906
+ var unloadDone = false;
1907
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1908
+ var theUnloadState = unloadState || {
1909
+ reason: 0 ,
1910
+ isAsync: false
1911
+ };
1912
+ function _unloadCallback() {
1913
+ if (!unloadDone) {
1914
+ unloadDone = true;
1915
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1916
+ arrForEach(_hooks, function (fn) {
1917
+ fn.rm();
1918
+ });
1919
+ _hooks = [];
1920
+ if (result === true) {
1921
+ theUnloadCtx.processNext(theUnloadState);
1922
+ }
1923
+ _initDefaults();
1924
+ }
1925
+ }
1926
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1927
+ _unloadCallback();
1928
+ }
1929
+ else {
1930
+ result = true;
1931
+ }
1932
+ return result;
1933
+ };
1697
1934
  _self._addHook = function (hooks) {
1698
1935
  if (hooks) {
1699
1936
  if (isArray(hooks)) {
@@ -1704,17 +1941,18 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1704
1941
  }
1705
1942
  }
1706
1943
  };
1944
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1707
1945
  });
1708
1946
  _self.diagLog = function (itemCtx) {
1709
1947
  return _getTelCtx(itemCtx).diagLog();
1710
1948
  };
1711
- _self.isInitialized = function () {
1949
+ _self[strIsInitialized] = function () {
1712
1950
  return _isinitialized;
1713
1951
  };
1714
1952
  _self.setInitialized = function (isInitialized) {
1715
1953
  _isinitialized = isInitialized;
1716
1954
  };
1717
- _self.setNextPlugin = function (next) {
1955
+ _self[strSetNextPlugin] = function (next) {
1718
1956
  _nextPlugin = next;
1719
1957
  };
1720
1958
  _self.processNext = function (env, itemCtx) {
@@ -1760,108 +1998,123 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1760
1998
  _rootCtx = null;
1761
1999
  _nextPlugin = null;
1762
2000
  _hooks = [];
2001
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1763
2002
  }
1764
2003
  }
1765
2004
  return BaseTelemetryPlugin;
1766
2005
  }());
1767
2006
 
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();
2007
+ var strOnPrefix = "on";
2008
+ var strAttachEvent = "attachEvent";
2009
+ var strAddEventHelper = "addEventListener";
2010
+ var strEvents = "events";
2011
+ createUniqueNamespace("aiEvtPageHide");
2012
+ createUniqueNamespace("aiEvtPageShow");
2013
+ var _guid = 1;
2014
+ var elmNodeData = createElmNodeData("events");
2015
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2016
+ function _normalizeNamespace(name) {
2017
+ if (name && name.replace) {
2018
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2019
+ }
2020
+ return name;
2021
+ }
2022
+ function _getEvtNamespace(eventName, namespaces) {
2023
+ if (namespaces) {
2024
+ var theNamespace_1 = "";
2025
+ if (isArray(namespaces)) {
2026
+ theNamespace_1 = "";
2027
+ arrForEach(namespaces, function (name) {
2028
+ name = _normalizeNamespace(name);
2029
+ if (name) {
2030
+ if (name[0] !== ".") {
2031
+ name = "." + name;
2032
+ }
2033
+ theNamespace_1 += name;
2034
+ }
2035
+ });
2036
+ }
2037
+ else {
2038
+ theNamespace_1 = _normalizeNamespace(namespaces);
2039
+ }
2040
+ if (theNamespace_1) {
2041
+ if (theNamespace_1[0] !== ".") {
2042
+ theNamespace_1 = "." + theNamespace_1;
2043
+ }
2044
+ eventName = (eventName || "") + theNamespace_1;
1804
2045
  }
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
2046
  }
1813
- return value;
2047
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
2048
+ return {
2049
+ type: parsedEvent[1],
2050
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
2051
+ };
1814
2052
  }
1815
- function mwcRandomSeed(value) {
1816
- if (!value) {
1817
- _autoSeedMwc();
1818
- }
1819
- else {
1820
- _mwcSeed(value);
2053
+ function _getRegisteredEvents(target, evtName, addDefault) {
2054
+ if (addDefault === void 0) { addDefault = true; }
2055
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2056
+ var registeredEvents = aiEvts[evtName];
2057
+ if (!registeredEvents) {
2058
+ registeredEvents = aiEvts[evtName] = [];
1821
2059
  }
2060
+ return registeredEvents;
1822
2061
  }
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;
2062
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2063
+ var result = false;
2064
+ if (obj && evtName && evtName.type && handlerRef) {
2065
+ if (obj[strAddEventHelper]) {
2066
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2067
+ result = true;
2068
+ }
2069
+ else if (obj[strAttachEvent]) {
2070
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2071
+ result = true;
2072
+ }
1829
2073
  }
1830
- return value;
2074
+ return result;
1831
2075
  }
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;
2076
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2077
+ if (useCapture === void 0) { useCapture = false; }
2078
+ var result = false;
2079
+ if (target) {
2080
+ try {
2081
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2082
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2083
+ if (result && elmNodeData.accept(target)) {
2084
+ var registeredEvent = {
2085
+ guid: _guid++,
2086
+ evtName: evtName,
2087
+ handler: handlerRef,
2088
+ capture: useCapture
2089
+ };
2090
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2091
+ }
2092
+ }
2093
+ catch (e) {
1845
2094
  }
1846
2095
  }
1847
2096
  return result;
1848
2097
  }
1849
-
1850
- var _cookieMgrs = null;
1851
- var _canUseCookies;
1852
- function addEventHandler(eventName, callback) {
2098
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
2099
+ if (useCapture === void 0) { useCapture = false; }
2100
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
2101
+ }
2102
+ function addEventHandler(eventName, callback, evtNamespace) {
1853
2103
  var result = false;
1854
2104
  var w = getWindow();
1855
2105
  if (w) {
1856
- result = attachEvent(w, eventName, callback);
1857
- result = attachEvent(w["body"], eventName, callback) || result;
2106
+ result = eventOn(w, eventName, callback, evtNamespace);
2107
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1858
2108
  }
1859
2109
  var doc = getDocument();
1860
2110
  if (doc) {
1861
- result = attachEvent(doc, eventName, callback) || result;
2111
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1862
2112
  }
1863
2113
  return result;
1864
2114
  }
2115
+
2116
+ var _cookieMgrs = null;
2117
+ var _canUseCookies;
1865
2118
  function newGuid() {
1866
2119
  function randomHexDigit() {
1867
2120
  return randomValue(15);
@@ -1880,7 +2133,7 @@ function perfNow() {
1880
2133
  }
1881
2134
  function generateW3CId() {
1882
2135
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1883
- var oct = "", tmp;
2136
+ var oct = strEmpty$1, tmp;
1884
2137
  for (var a = 0; a < 4; a++) {
1885
2138
  tmp = random32();
1886
2139
  oct +=
@@ -1975,6 +2228,95 @@ function deleteCookie(logger, name) {
1975
2228
  return _legacyCookieMgr(null, logger).del(name);
1976
2229
  }
1977
2230
 
2231
+ createEnumStyle({
2232
+ CRITICAL: 1 ,
2233
+ WARNING: 2
2234
+ });
2235
+ var _InternalMessageId = createEnumStyle({
2236
+ BrowserDoesNotSupportLocalStorage: 0 ,
2237
+ BrowserCannotReadLocalStorage: 1 ,
2238
+ BrowserCannotReadSessionStorage: 2 ,
2239
+ BrowserCannotWriteLocalStorage: 3 ,
2240
+ BrowserCannotWriteSessionStorage: 4 ,
2241
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2242
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2243
+ CannotSendEmptyTelemetry: 7 ,
2244
+ ClientPerformanceMathError: 8 ,
2245
+ ErrorParsingAISessionCookie: 9 ,
2246
+ ErrorPVCalc: 10 ,
2247
+ ExceptionWhileLoggingError: 11 ,
2248
+ FailedAddingTelemetryToBuffer: 12 ,
2249
+ FailedMonitorAjaxAbort: 13 ,
2250
+ FailedMonitorAjaxDur: 14 ,
2251
+ FailedMonitorAjaxOpen: 15 ,
2252
+ FailedMonitorAjaxRSC: 16 ,
2253
+ FailedMonitorAjaxSend: 17 ,
2254
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2255
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2256
+ FailedToSendQueuedTelemetry: 20 ,
2257
+ FailedToReportDataLoss: 21 ,
2258
+ FlushFailed: 22 ,
2259
+ MessageLimitPerPVExceeded: 23 ,
2260
+ MissingRequiredFieldSpecification: 24 ,
2261
+ NavigationTimingNotSupported: 25 ,
2262
+ OnError: 26 ,
2263
+ SessionRenewalDateIsZero: 27 ,
2264
+ SenderNotInitialized: 28 ,
2265
+ StartTrackEventFailed: 29 ,
2266
+ StopTrackEventFailed: 30 ,
2267
+ StartTrackFailed: 31 ,
2268
+ StopTrackFailed: 32 ,
2269
+ TelemetrySampledAndNotSent: 33 ,
2270
+ TrackEventFailed: 34 ,
2271
+ TrackExceptionFailed: 35 ,
2272
+ TrackMetricFailed: 36 ,
2273
+ TrackPVFailed: 37 ,
2274
+ TrackPVFailedCalc: 38 ,
2275
+ TrackTraceFailed: 39 ,
2276
+ TransmissionFailed: 40 ,
2277
+ FailedToSetStorageBuffer: 41 ,
2278
+ FailedToRestoreStorageBuffer: 42 ,
2279
+ InvalidBackendResponse: 43 ,
2280
+ FailedToFixDepricatedValues: 44 ,
2281
+ InvalidDurationValue: 45 ,
2282
+ TelemetryEnvelopeInvalid: 46 ,
2283
+ CreateEnvelopeError: 47 ,
2284
+ CannotSerializeObject: 48 ,
2285
+ CannotSerializeObjectNonSerializable: 49 ,
2286
+ CircularReferenceDetected: 50 ,
2287
+ ClearAuthContextFailed: 51 ,
2288
+ ExceptionTruncated: 52 ,
2289
+ IllegalCharsInName: 53 ,
2290
+ ItemNotInArray: 54 ,
2291
+ MaxAjaxPerPVExceeded: 55 ,
2292
+ MessageTruncated: 56 ,
2293
+ NameTooLong: 57 ,
2294
+ SampleRateOutOfRange: 58 ,
2295
+ SetAuthContextFailed: 59 ,
2296
+ SetAuthContextFailedAccountName: 60 ,
2297
+ StringValueTooLong: 61 ,
2298
+ StartCalledMoreThanOnce: 62 ,
2299
+ StopCalledWithoutStart: 63 ,
2300
+ TelemetryInitializerFailed: 64 ,
2301
+ TrackArgumentsNotSpecified: 65 ,
2302
+ UrlTooLong: 66 ,
2303
+ SessionStorageBufferFull: 67 ,
2304
+ CannotAccessCookie: 68 ,
2305
+ IdTooLong: 69 ,
2306
+ InvalidEvent: 70 ,
2307
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2308
+ SendBrowserInfoOnUserInit: 72 ,
2309
+ PluginException: 73 ,
2310
+ NotificationException: 74 ,
2311
+ SnippetScriptLoadFailure: 99 ,
2312
+ InvalidInstrumentationKey: 100 ,
2313
+ CannotParseAiBlobValue: 101 ,
2314
+ InvalidContentBlob: 102 ,
2315
+ TrackPageActionEventFailed: 103 ,
2316
+ FailedAddingCustomDefinedRequestContext: 104 ,
2317
+ InMemoryStorageBufferFull: 105
2318
+ });
2319
+
1978
2320
  var aiInstrumentHooks = "_aiHooks";
1979
2321
  var cbNames = [
1980
2322
  "req", "rsp", "hkErr", "fnErr"
@@ -2127,6 +2469,7 @@ function createDomEvent(eventName) {
2127
2469
  return event;
2128
2470
  }
2129
2471
 
2472
+ var strEmpty = "";
2130
2473
  function stringToBoolOrDefault(str, defaultValue) {
2131
2474
  if (defaultValue === void 0) { defaultValue = false; }
2132
2475
  if (str === undefined || str === null) {
@@ -2139,16 +2482,16 @@ function msToTimeSpan(totalms) {
2139
2482
  totalms = 0;
2140
2483
  }
2141
2484
  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;
2485
+ var ms = strEmpty + totalms % 1000;
2486
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2487
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2488
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2146
2489
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2147
2490
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2148
2491
  sec = sec.length < 2 ? "0" + sec : sec;
2149
2492
  min = min.length < 2 ? "0" + min : min;
2150
2493
  hour = hour.length < 2 ? "0" + hour : hour;
2151
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2494
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
2152
2495
  }
2153
2496
  function getExtensionByName(extensions, identifier) {
2154
2497
  var extension = null;
@@ -2166,17 +2509,15 @@ function isCrossOriginError(message, url, lineNumber, columnNumber, error) {
2166
2509
 
2167
2510
  var strNotSpecified = "not_specified";
2168
2511
 
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 = {}));
2512
+ var StorageType = createEnumStyle({
2513
+ LocalStorage: 0 ,
2514
+ SessionStorage: 1
2515
+ });
2516
+ createEnumStyle({
2517
+ AI: 0 ,
2518
+ AI_AND_W3C: 1 ,
2519
+ W3C: 2
2520
+ });
2180
2521
 
2181
2522
  var _canUseLocalStorage = undefined;
2182
2523
  var _canUseSessionStorage = undefined;
@@ -2228,7 +2569,7 @@ function utlGetLocalStorage(logger, name) {
2228
2569
  }
2229
2570
  catch (e) {
2230
2571
  _canUseLocalStorage = false;
2231
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2572
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2232
2573
  }
2233
2574
  }
2234
2575
  return null;
@@ -2242,7 +2583,7 @@ function utlSetLocalStorage(logger, name, data) {
2242
2583
  }
2243
2584
  catch (e) {
2244
2585
  _canUseLocalStorage = false;
2245
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2586
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2246
2587
  }
2247
2588
  }
2248
2589
  return false;
@@ -2256,7 +2597,7 @@ function utlRemoveStorage(logger, name) {
2256
2597
  }
2257
2598
  catch (e) {
2258
2599
  _canUseLocalStorage = false;
2259
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2600
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2260
2601
  }
2261
2602
  }
2262
2603
  return false;
@@ -2284,7 +2625,7 @@ function utlGetSessionStorage(logger, name) {
2284
2625
  }
2285
2626
  catch (e) {
2286
2627
  _canUseSessionStorage = false;
2287
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2628
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2288
2629
  }
2289
2630
  }
2290
2631
  return null;
@@ -2298,7 +2639,7 @@ function utlSetSessionStorage(logger, name, data) {
2298
2639
  }
2299
2640
  catch (e) {
2300
2641
  _canUseSessionStorage = false;
2301
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2642
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2302
2643
  }
2303
2644
  }
2304
2645
  return false;
@@ -2312,7 +2653,7 @@ function utlRemoveSessionStorage(logger, name) {
2312
2653
  }
2313
2654
  catch (e) {
2314
2655
  _canUseSessionStorage = false;
2315
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2656
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2316
2657
  }
2317
2658
  }
2318
2659
  return false;