@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
  (function (global, factory) {
@@ -322,99 +322,14 @@
322
322
  };
323
323
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
324
324
 
325
- var LoggingSeverity;
326
- (function (LoggingSeverity) {
327
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
328
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
329
- })(LoggingSeverity || (LoggingSeverity = {}));
330
- var _InternalMessageId = {
331
- BrowserDoesNotSupportLocalStorage: 0,
332
- BrowserCannotReadLocalStorage: 1,
333
- BrowserCannotReadSessionStorage: 2,
334
- BrowserCannotWriteLocalStorage: 3,
335
- BrowserCannotWriteSessionStorage: 4,
336
- BrowserFailedRemovalFromLocalStorage: 5,
337
- BrowserFailedRemovalFromSessionStorage: 6,
338
- CannotSendEmptyTelemetry: 7,
339
- ClientPerformanceMathError: 8,
340
- ErrorParsingAISessionCookie: 9,
341
- ErrorPVCalc: 10,
342
- ExceptionWhileLoggingError: 11,
343
- FailedAddingTelemetryToBuffer: 12,
344
- FailedMonitorAjaxAbort: 13,
345
- FailedMonitorAjaxDur: 14,
346
- FailedMonitorAjaxOpen: 15,
347
- FailedMonitorAjaxRSC: 16,
348
- FailedMonitorAjaxSend: 17,
349
- FailedMonitorAjaxGetCorrelationHeader: 18,
350
- FailedToAddHandlerForOnBeforeUnload: 19,
351
- FailedToSendQueuedTelemetry: 20,
352
- FailedToReportDataLoss: 21,
353
- FlushFailed: 22,
354
- MessageLimitPerPVExceeded: 23,
355
- MissingRequiredFieldSpecification: 24,
356
- NavigationTimingNotSupported: 25,
357
- OnError: 26,
358
- SessionRenewalDateIsZero: 27,
359
- SenderNotInitialized: 28,
360
- StartTrackEventFailed: 29,
361
- StopTrackEventFailed: 30,
362
- StartTrackFailed: 31,
363
- StopTrackFailed: 32,
364
- TelemetrySampledAndNotSent: 33,
365
- TrackEventFailed: 34,
366
- TrackExceptionFailed: 35,
367
- TrackMetricFailed: 36,
368
- TrackPVFailed: 37,
369
- TrackPVFailedCalc: 38,
370
- TrackTraceFailed: 39,
371
- TransmissionFailed: 40,
372
- FailedToSetStorageBuffer: 41,
373
- FailedToRestoreStorageBuffer: 42,
374
- InvalidBackendResponse: 43,
375
- FailedToFixDepricatedValues: 44,
376
- InvalidDurationValue: 45,
377
- TelemetryEnvelopeInvalid: 46,
378
- CreateEnvelopeError: 47,
379
- CannotSerializeObject: 48,
380
- CannotSerializeObjectNonSerializable: 49,
381
- CircularReferenceDetected: 50,
382
- ClearAuthContextFailed: 51,
383
- ExceptionTruncated: 52,
384
- IllegalCharsInName: 53,
385
- ItemNotInArray: 54,
386
- MaxAjaxPerPVExceeded: 55,
387
- MessageTruncated: 56,
388
- NameTooLong: 57,
389
- SampleRateOutOfRange: 58,
390
- SetAuthContextFailed: 59,
391
- SetAuthContextFailedAccountName: 60,
392
- StringValueTooLong: 61,
393
- StartCalledMoreThanOnce: 62,
394
- StopCalledWithoutStart: 63,
395
- TelemetryInitializerFailed: 64,
396
- TrackArgumentsNotSpecified: 65,
397
- UrlTooLong: 66,
398
- SessionStorageBufferFull: 67,
399
- CannotAccessCookie: 68,
400
- IdTooLong: 69,
401
- InvalidEvent: 70,
402
- FailedMonitorAjaxSetRequestHeader: 71,
403
- SendBrowserInfoOnUserInit: 72,
404
- PluginException: 73,
405
- NotificationException: 74,
406
- SnippetScriptLoadFailure: 99,
407
- InvalidInstrumentationKey: 100,
408
- CannotParseAiBlobValue: 101,
409
- InvalidContentBlob: 102,
410
- TrackPageActionEventFailed: 103,
411
- FailedAddingCustomDefinedRequestContext: 104,
412
- InMemoryStorageBufferFull: 105
413
- };
325
+ var strEmpty$1 = "";
326
+ var strSetNextPlugin = "setNextPlugin";
327
+ var strIsInitialized = "isInitialized";
328
+ var strTeardown = "teardown";
329
+ var strCore = "core";
330
+ var strDisabled = "disabled";
331
+ var strDoTeardown = "_doTeardown";
414
332
 
415
- var strOnPrefix = "on";
416
- var strAttachEvent = "attachEvent";
417
- var strAddEventHelper = "addEventListener";
418
333
  var strToISOString = "toISOString";
419
334
  var cStrEndsWith = "endsWith";
420
335
  var strIndexOf = "indexOf";
@@ -424,7 +339,7 @@
424
339
  var strToString = "toString";
425
340
  var str__Proto = "__proto__";
426
341
  var strConstructor$1 = "constructor";
427
- var _objDefineProperty = ObjDefineProperty;
342
+ var _objDefineProperty$1 = ObjDefineProperty;
428
343
  var _objFreeze = ObjClass.freeze;
429
344
  var _objKeys = ObjClass.keys;
430
345
  var StringProto = String[strShimPrototype];
@@ -436,6 +351,9 @@
436
351
  var _objToString = ObjProto[strToString];
437
352
  var _fnToString = ObjHasOwnProperty[strToString];
438
353
  var _objFunctionString = _fnToString.call(ObjClass);
354
+ var rCamelCase = /-([a-z])/g;
355
+ var rNormalizeInvalid = /([^\w\d_$])/g;
356
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
439
357
  var _objGetPrototypeOf = Object["getPrototypeOf"];
440
358
  function _getObjProto(target) {
441
359
  if (target) {
@@ -470,24 +388,18 @@
470
388
  function isFunction(value) {
471
389
  return !!(value && typeof value === strShimFunction);
472
390
  }
473
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
474
- if (useCapture === void 0) { useCapture = false; }
475
- var result = false;
476
- if (!isNullOrUndefined(obj)) {
477
- try {
478
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
479
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
480
- result = true;
481
- }
482
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
483
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
484
- result = true;
485
- }
486
- }
487
- catch (e) {
488
- }
391
+ function normalizeJsName(name) {
392
+ var value = name;
393
+ if (value && isString(value)) {
394
+ value = value.replace(rCamelCase, function (_all, letter) {
395
+ return letter.toUpperCase();
396
+ });
397
+ value = value.replace(rNormalizeInvalid, "_");
398
+ value = value.replace(rLeadingNumeric, function (_all, match) {
399
+ return "_" + match;
400
+ });
489
401
  }
490
- return result;
402
+ return value;
491
403
  }
492
404
  function objForEachKey(target, callbackfn) {
493
405
  if (target) {
@@ -710,7 +622,7 @@
710
622
  return result;
711
623
  }
712
624
  function objDefineAccessors(target, prop, getProp, setProp) {
713
- if (_objDefineProperty) {
625
+ if (_objDefineProperty$1) {
714
626
  try {
715
627
  var descriptor = {
716
628
  enumerable: true,
@@ -722,7 +634,7 @@
722
634
  if (setProp) {
723
635
  descriptor.set = setProp;
724
636
  }
725
- _objDefineProperty(target, prop, descriptor);
637
+ _objDefineProperty$1(target, prop, descriptor);
726
638
  return true;
727
639
  }
728
640
  catch (e) {
@@ -742,7 +654,7 @@
742
654
  if (isError(object)) {
743
655
  return object.name;
744
656
  }
745
- return "";
657
+ return strEmpty$1;
746
658
  }
747
659
  function setValue(target, field, value, valChk, srcChk) {
748
660
  var theValue = value;
@@ -758,6 +670,47 @@
758
670
  function isTruthy(value) {
759
671
  return !!value;
760
672
  }
673
+ function throwError(message) {
674
+ throw new Error(message);
675
+ }
676
+ function _createProxyFunction(source, funcName) {
677
+ var srcFunc = null;
678
+ var src = null;
679
+ if (isFunction(source)) {
680
+ srcFunc = source;
681
+ }
682
+ else {
683
+ src = source;
684
+ }
685
+ return function () {
686
+ var originalArguments = arguments;
687
+ if (srcFunc) {
688
+ src = srcFunc();
689
+ }
690
+ if (src) {
691
+ return src[funcName].apply(src, originalArguments);
692
+ }
693
+ };
694
+ }
695
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
696
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
697
+ if (target && name && source) {
698
+ if (overwriteTarget || isUndefined(target[name])) {
699
+ target[name] = _createProxyFunction(source, theFunc);
700
+ }
701
+ }
702
+ }
703
+ function createEnumStyle(values) {
704
+ var enumClass = {};
705
+ objForEachKey(values, function (field, value) {
706
+ enumClass[field] = value;
707
+ if (!isUndefined(enumClass[value])) {
708
+ throwError("[" + value + "] exists for " + field);
709
+ }
710
+ enumClass[value] = field;
711
+ });
712
+ return objFreeze(enumClass);
713
+ }
761
714
  function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
762
715
  var theArgs = arguments;
763
716
  var extended = theArgs[0] || {};
@@ -896,7 +849,7 @@
896
849
  var nav = getNavigator();
897
850
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
898
851
  _navUserAgentCheck = nav.userAgent;
899
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
852
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
900
853
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
901
854
  }
902
855
  return _isTrident;
@@ -905,9 +858,9 @@
905
858
  if (userAgentStr === void 0) { userAgentStr = null; }
906
859
  if (!userAgentStr) {
907
860
  var navigator_1 = getNavigator() || {};
908
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
861
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
909
862
  }
910
- var ua = (userAgentStr || "").toLowerCase();
863
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
911
864
  if (strContains(ua, strMsie)) {
912
865
  var doc = getDocument() || {};
913
866
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -922,7 +875,7 @@
922
875
  }
923
876
  function dumpObj(object) {
924
877
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
925
- var propertyValueDump = "";
878
+ var propertyValueDump = strEmpty$1;
926
879
  if (objectTypeDump === "[object Error]") {
927
880
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
928
881
  }
@@ -961,9 +914,9 @@
961
914
  var strWarnToConsole = "warnToConsole";
962
915
  function _sanitizeDiagnosticText(text) {
963
916
  if (text) {
964
- return "\"" + text.replace(/\"/g, "") + "\"";
917
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
965
918
  }
966
- return "";
919
+ return strEmpty$1;
967
920
  }
968
921
  function _logToConsole(func, message) {
969
922
  var theConsole = getConsole();
@@ -985,12 +938,12 @@
985
938
  _self.message =
986
939
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
987
940
  msgId;
988
- var strProps = "";
941
+ var strProps = strEmpty$1;
989
942
  if (hasJSON()) {
990
943
  strProps = getJSON().stringify(properties);
991
944
  }
992
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
993
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
945
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
946
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
994
947
  _self.message += diagnosticText;
995
948
  }
996
949
  _InternalLogMessage.dataType = "MessageData";
@@ -1020,7 +973,7 @@
1020
973
  throw message;
1021
974
  }
1022
975
  else {
1023
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
976
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1024
977
  if (!isUndefined(message.message)) {
1025
978
  var logLevel = _self.consoleLoggingLevel();
1026
979
  if (isUserAct) {
@@ -1038,7 +991,7 @@
1038
991
  _self.logInternalMessage(severity, message);
1039
992
  }
1040
993
  else {
1041
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
994
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1042
995
  }
1043
996
  }
1044
997
  };
@@ -1070,13 +1023,13 @@
1070
1023
  if (severity <= _self.telemetryLoggingLevel()) {
1071
1024
  _self.queue.push(message);
1072
1025
  _messageCount++;
1073
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1026
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1074
1027
  }
1075
1028
  if (_messageCount === _self.maxInternalMessageLimit()) {
1076
1029
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1077
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1030
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1078
1031
  _self.queue.push(throttleMessage);
1079
- if (severity === LoggingSeverity.CRITICAL) {
1032
+ if (severity === 1 ) {
1080
1033
  _self.errorToConsole(throttleLimitMessage);
1081
1034
  }
1082
1035
  else {
@@ -1218,6 +1171,165 @@
1218
1171
  return func();
1219
1172
  }
1220
1173
 
1174
+ var UInt32Mask = 0x100000000;
1175
+ var MaxUInt32 = 0xffffffff;
1176
+ var _mwcSeeded = false;
1177
+ var _mwcW = 123456789;
1178
+ var _mwcZ = 987654321;
1179
+ function _mwcSeed(seedValue) {
1180
+ if (seedValue < 0) {
1181
+ seedValue >>>= 0;
1182
+ }
1183
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1184
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1185
+ _mwcSeeded = true;
1186
+ }
1187
+ function _autoSeedMwc() {
1188
+ try {
1189
+ var now = dateNow() & 0x7fffffff;
1190
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1191
+ }
1192
+ catch (e) {
1193
+ }
1194
+ }
1195
+ function randomValue(maxValue) {
1196
+ if (maxValue > 0) {
1197
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1198
+ }
1199
+ return 0;
1200
+ }
1201
+ function random32(signed) {
1202
+ var value = 0;
1203
+ var c = getCrypto() || getMsCrypto();
1204
+ if (c && c.getRandomValues) {
1205
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1206
+ }
1207
+ if (value === 0 && isIE()) {
1208
+ if (!_mwcSeeded) {
1209
+ _autoSeedMwc();
1210
+ }
1211
+ value = mwcRandom32() & MaxUInt32;
1212
+ }
1213
+ if (value === 0) {
1214
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1215
+ }
1216
+ if (!signed) {
1217
+ value >>>= 0;
1218
+ }
1219
+ return value;
1220
+ }
1221
+ function mwcRandomSeed(value) {
1222
+ if (!value) {
1223
+ _autoSeedMwc();
1224
+ }
1225
+ else {
1226
+ _mwcSeed(value);
1227
+ }
1228
+ }
1229
+ function mwcRandom32(signed) {
1230
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1231
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1232
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1233
+ if (!signed) {
1234
+ value >>>= 0;
1235
+ }
1236
+ return value;
1237
+ }
1238
+ function newId(maxLength) {
1239
+ if (maxLength === void 0) { maxLength = 22; }
1240
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1241
+ var number = random32() >>> 0;
1242
+ var chars = 0;
1243
+ var result = strEmpty$1;
1244
+ while (result.length < maxLength) {
1245
+ chars++;
1246
+ result += base64chars.charAt(number & 0x3F);
1247
+ number >>>= 6;
1248
+ if (chars === 5) {
1249
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1250
+ chars = 0;
1251
+ }
1252
+ }
1253
+ return result;
1254
+ }
1255
+
1256
+ var _objDefineProperty = ObjDefineProperty;
1257
+ var version = "2.7.3";
1258
+ var instanceName = "." + newId(6);
1259
+ var _dataUid = 0;
1260
+ function _createAccessor(target, prop, value) {
1261
+ if (_objDefineProperty) {
1262
+ try {
1263
+ _objDefineProperty(target, prop, {
1264
+ value: value,
1265
+ enumerable: false,
1266
+ configurable: true
1267
+ });
1268
+ return true;
1269
+ }
1270
+ catch (e) {
1271
+ }
1272
+ }
1273
+ return false;
1274
+ }
1275
+ function _canAcceptData(target) {
1276
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1277
+ }
1278
+ function _getCache(data, target) {
1279
+ var theCache = target[data.id];
1280
+ if (!theCache) {
1281
+ theCache = {};
1282
+ try {
1283
+ if (_canAcceptData(target)) {
1284
+ if (!_createAccessor(target, data.id, theCache)) {
1285
+ target[data.id] = theCache;
1286
+ }
1287
+ }
1288
+ }
1289
+ catch (e) {
1290
+ }
1291
+ }
1292
+ return theCache;
1293
+ }
1294
+ function createUniqueNamespace(name, includeVersion) {
1295
+ if (includeVersion === void 0) { includeVersion = false; }
1296
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1297
+ }
1298
+ function createElmNodeData(name) {
1299
+ var data = {
1300
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1301
+ accept: function (target) {
1302
+ return _canAcceptData(target);
1303
+ },
1304
+ get: function (target, name, defValue, addDefault) {
1305
+ var theCache = target[data.id];
1306
+ if (!theCache) {
1307
+ if (addDefault) {
1308
+ theCache = _getCache(data, target);
1309
+ theCache[normalizeJsName(name)] = defValue;
1310
+ }
1311
+ return defValue;
1312
+ }
1313
+ return theCache[normalizeJsName(name)];
1314
+ },
1315
+ kill: function (target, name) {
1316
+ if (target && target[name]) {
1317
+ try {
1318
+ delete target[name];
1319
+ }
1320
+ catch (e) {
1321
+ }
1322
+ }
1323
+ }
1324
+ };
1325
+ return data;
1326
+ }
1327
+
1328
+ var pluginStateData = createElmNodeData("plugin");
1329
+ function _getPluginState(plugin) {
1330
+ return pluginStateData.get(plugin, "state", {}, true);
1331
+ }
1332
+
1221
1333
  var strTelemetryPluginChain = "TelemetryPluginChain";
1222
1334
  var strHasRunFlags = "_hasRun";
1223
1335
  var strGetTelCtx = "_getTelCtx";
@@ -1231,53 +1343,69 @@
1231
1343
  }
1232
1344
  return createTelemetryProxyChain([startAt], config, core);
1233
1345
  }
1234
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1346
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1235
1347
  var _nextProxy = null;
1236
- var _onComplete = null;
1237
- if (startAt) {
1238
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1239
- }
1240
- else {
1241
- _nextProxy = telemetryChain;
1348
+ var _onComplete = [];
1349
+ if (startAt !== null) {
1350
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1242
1351
  }
1243
1352
  var context = {
1244
- core: function () {
1245
- return core;
1246
- },
1247
- diagLog: function () {
1248
- return safeGetLogger(core, config);
1249
- },
1250
- getCfg: function () {
1251
- return config;
1252
- },
1253
- getExtCfg: _getExtCfg,
1254
- getConfig: _getConfig,
1255
- hasNext: function () {
1256
- return _nextProxy != null;
1257
- },
1258
- getNext: function () {
1259
- return _nextProxy;
1260
- },
1261
- setNext: function (nextPlugin) {
1262
- _nextProxy = nextPlugin;
1263
- },
1264
- processNext: function (env) {
1265
- _processChain(function (nextPlugin) {
1266
- nextPlugin.processTelemetry(env, context);
1353
+ _next: _moveNext,
1354
+ ctx: {
1355
+ core: function () { return core; },
1356
+ diagLog: function () {
1357
+ return safeGetLogger(core, config);
1358
+ },
1359
+ getCfg: function () {
1360
+ return config;
1361
+ },
1362
+ getExtCfg: _getExtCfg,
1363
+ getConfig: _getConfig,
1364
+ hasNext: function () {
1365
+ return !!_nextProxy;
1366
+ },
1367
+ getNext: function () {
1368
+ return _nextProxy;
1369
+ },
1370
+ setNext: function (nextPlugin) {
1371
+ _nextProxy = nextPlugin;
1372
+ },
1373
+ iterate: _iterateChain,
1374
+ onComplete: _addOnComplete
1375
+ }
1376
+ };
1377
+ function _addOnComplete(onComplete, that) {
1378
+ var args = [];
1379
+ for (var _i = 2; _i < arguments.length; _i++) {
1380
+ args[_i - 2] = arguments[_i];
1381
+ }
1382
+ if (onComplete) {
1383
+ _onComplete.push({
1384
+ func: onComplete,
1385
+ self: !isUndefined(that) ? that : context.ctx,
1386
+ args: args
1267
1387
  });
1268
- },
1269
- iterate: _iterateChain,
1270
- createNew: function (plugins, startAt) {
1271
- if (plugins === void 0) { plugins = null; }
1272
- if (isArray(plugins)) {
1273
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1388
+ }
1389
+ }
1390
+ function _moveNext() {
1391
+ var nextProxy = _nextProxy;
1392
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1393
+ if (!nextProxy) {
1394
+ var onComplete = _onComplete;
1395
+ if (onComplete && onComplete.length > 0) {
1396
+ arrForEach(onComplete, function (completeDetails) {
1397
+ try {
1398
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1399
+ }
1400
+ catch (e) {
1401
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1402
+ }
1403
+ });
1404
+ _onComplete = [];
1274
1405
  }
1275
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1276
- },
1277
- onComplete: function (onComplete) {
1278
- _onComplete = onComplete;
1279
1406
  }
1280
- };
1407
+ return nextProxy;
1408
+ }
1281
1409
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1282
1410
  if (defaultValue === void 0) { defaultValue = {}; }
1283
1411
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1320,29 +1448,53 @@
1320
1448
  }
1321
1449
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1322
1450
  }
1323
- function _processChain(cb) {
1324
- var nextPlugin = _nextProxy;
1325
- if (nextPlugin) {
1326
- _nextProxy = nextPlugin.getNext();
1327
- cb(nextPlugin);
1328
- }
1329
- else {
1330
- if (_onComplete) {
1331
- _onComplete();
1332
- _onComplete = null;
1451
+ function _iterateChain(cb) {
1452
+ var nextPlugin;
1453
+ while (!!(nextPlugin = context._next())) {
1454
+ var plugin = nextPlugin.getPlugin();
1455
+ if (plugin) {
1456
+ cb(plugin);
1333
1457
  }
1334
1458
  }
1335
1459
  }
1336
- function _iterateChain(cb) {
1337
- while (_nextProxy) {
1338
- _processChain(function (nextPlugin) {
1339
- var plugin = nextPlugin.getPlugin();
1340
- if (plugin) {
1341
- cb(plugin);
1342
- }
1343
- });
1460
+ return context;
1461
+ }
1462
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1463
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1464
+ var context = internalContext.ctx;
1465
+ function _processNext(env) {
1466
+ var nextPlugin = internalContext._next();
1467
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1468
+ return !nextPlugin;
1469
+ }
1470
+ function _createNew(plugins, startAt) {
1471
+ if (plugins === void 0) { plugins = null; }
1472
+ if (isArray(plugins)) {
1473
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1474
+ }
1475
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1476
+ }
1477
+ context.processNext = _processNext;
1478
+ context.createNew = _createNew;
1479
+ return context;
1480
+ }
1481
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1482
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1483
+ var context = internalContext.ctx;
1484
+ function _processNext(unloadState) {
1485
+ var nextPlugin = internalContext._next();
1486
+ nextPlugin && nextPlugin.unload(context, unloadState);
1487
+ return !nextPlugin;
1488
+ }
1489
+ function _createNew(plugins, startAt) {
1490
+ if (plugins === void 0) { plugins = null; }
1491
+ if (isArray(plugins)) {
1492
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1344
1493
  }
1494
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1345
1495
  }
1496
+ context.processNext = _processNext;
1497
+ context.createNew = _createNew;
1346
1498
  return context;
1347
1499
  }
1348
1500
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1390,32 +1542,35 @@
1390
1542
  return nextProxy;
1391
1543
  },
1392
1544
  processTelemetry: _processTelemetry,
1545
+ unload: _unloadPlugin,
1393
1546
  _id: chainId,
1394
1547
  _setNext: function (nextPlugin) {
1395
1548
  nextProxy = nextPlugin;
1396
1549
  }
1397
1550
  };
1398
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1551
+ function _getTelCtx() {
1552
+ var itemCtx;
1553
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1554
+ itemCtx = plugin[strGetTelCtx]();
1555
+ }
1399
1556
  if (!itemCtx) {
1400
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1401
- itemCtx = plugin[strGetTelCtx]();
1402
- }
1403
- if (!itemCtx) {
1404
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1405
- }
1557
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1406
1558
  }
1559
+ return itemCtx;
1560
+ }
1561
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1562
+ var hasRun = false;
1407
1563
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1408
1564
  var hasRunContext = itemCtx[strHasRunFlags];
1409
1565
  if (!hasRunContext) {
1410
1566
  hasRunContext = itemCtx[strHasRunFlags] = {};
1411
1567
  }
1412
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1413
- hasRunContext[chainId] = true;
1414
- var hasRun = false;
1415
- itemCtx.setNext(nextProxy);
1416
- if (plugin) {
1568
+ itemCtx.setNext(nextProxy);
1569
+ if (plugin) {
1570
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1571
+ hasRunContext[chainId] = true;
1417
1572
  try {
1418
- var nextId = nextProxy ? nextProxy._id : "";
1573
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1419
1574
  if (nextId) {
1420
1575
  hasRunContext[nextId] = false;
1421
1576
  }
@@ -1427,18 +1582,21 @@
1427
1582
  hasRun = true;
1428
1583
  }
1429
1584
  if (!nextProxy || !hasNextRun) {
1430
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1585
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1431
1586
  }
1432
1587
  }
1433
- }
1434
- if (nextProxy && !hasRun) {
1435
- processProxyFn(itemCtx);
1436
- }
1437
- }, details, isAsync);
1588
+ }, details, isAsync);
1589
+ }
1590
+ return hasRun;
1438
1591
  }
1439
1592
  function _processTelemetry(env, itemCtx) {
1440
- _processChain(itemCtx, function (itemCtx) {
1441
- if (!hasProcessTelemetry) {
1593
+ itemCtx = itemCtx || _getTelCtx();
1594
+ function _callProcessTelemetry(itemCtx) {
1595
+ if (!plugin || !hasProcessTelemetry) {
1596
+ return false;
1597
+ }
1598
+ var pluginState = _getPluginState(plugin);
1599
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1442
1600
  return false;
1443
1601
  }
1444
1602
  if (hasSetNext) {
@@ -1446,9 +1604,31 @@
1446
1604
  }
1447
1605
  plugin.processTelemetry(env, itemCtx);
1448
1606
  return true;
1449
- }, function (itemCtx) {
1450
- nextProxy.processTelemetry(env, itemCtx);
1451
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1607
+ }
1608
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1609
+ itemCtx.processNext(env);
1610
+ }
1611
+ }
1612
+ function _unloadPlugin(unloadCtx, unloadState) {
1613
+ function _callTeardown() {
1614
+ var hasRun = false;
1615
+ if (plugin) {
1616
+ var pluginState = _getPluginState(plugin);
1617
+ var pluginCore = plugin[strCore] || pluginState.core;
1618
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1619
+ pluginState[strCore] = null;
1620
+ pluginState[strTeardown] = true;
1621
+ pluginState[strIsInitialized] = false;
1622
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1623
+ hasRun = true;
1624
+ }
1625
+ }
1626
+ }
1627
+ return hasRun;
1628
+ }
1629
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1630
+ unloadCtx.processNext(unloadState);
1631
+ }
1452
1632
  }
1453
1633
  return objFreeze(proxyChain);
1454
1634
  }
@@ -1461,7 +1641,6 @@
1461
1641
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1462
1642
  var strDisableCookiesUsage = "disableCookiesUsage";
1463
1643
  var strConfigCookieMgr = "_ckMgr";
1464
- var strEmpty = "";
1465
1644
  var _supportsCookies = null;
1466
1645
  var _allowUaSameSite = null;
1467
1646
  var _parsedCookieValue = null;
@@ -1519,7 +1698,7 @@
1519
1698
  var result = false;
1520
1699
  if (_isMgrEnabled(cookieMgr)) {
1521
1700
  var values = {};
1522
- var theValue = strTrim(value || strEmpty);
1701
+ var theValue = strTrim(value || strEmpty$1);
1523
1702
  var idx = theValue.indexOf(";");
1524
1703
  if (idx !== -1) {
1525
1704
  theValue = strTrim(value.substring(0, idx));
@@ -1534,11 +1713,11 @@
1534
1713
  if (expireMs > 0) {
1535
1714
  var expiry = new Date();
1536
1715
  expiry.setTime(expireMs);
1537
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1716
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1538
1717
  }
1539
1718
  }
1540
1719
  if (!_isIE) {
1541
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1720
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1542
1721
  }
1543
1722
  }
1544
1723
  var location_1 = getLocation();
@@ -1559,7 +1738,7 @@
1559
1738
  return result;
1560
1739
  },
1561
1740
  get: function (name) {
1562
- var value = strEmpty;
1741
+ var value = strEmpty$1;
1563
1742
  if (_isMgrEnabled(cookieMgr)) {
1564
1743
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1565
1744
  }
@@ -1584,7 +1763,7 @@
1584
1763
  values["max-age"] = "0";
1585
1764
  }
1586
1765
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1587
- delCookie(name, _formatCookieValue(strEmpty, values));
1766
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1588
1767
  result = true;
1589
1768
  }
1590
1769
  return result;
@@ -1601,7 +1780,7 @@
1601
1780
  _supportsCookies = doc[strCookie] !== undefined;
1602
1781
  }
1603
1782
  catch (e) {
1604
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1783
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1605
1784
  }
1606
1785
  }
1607
1786
  return _supportsCookies;
@@ -1611,7 +1790,7 @@
1611
1790
  if (theValue && theValue.length) {
1612
1791
  var parts = strTrim(theValue).split(";");
1613
1792
  arrForEach(parts, function (thePart) {
1614
- thePart = strTrim(thePart || strEmpty);
1793
+ thePart = strTrim(thePart || strEmpty$1);
1615
1794
  if (thePart) {
1616
1795
  var idx = thePart.indexOf("=");
1617
1796
  if (idx === -1) {
@@ -1632,21 +1811,21 @@
1632
1811
  return null;
1633
1812
  }
1634
1813
  function _formatCookieValue(value, values) {
1635
- var cookieValue = value || strEmpty;
1814
+ var cookieValue = value || strEmpty$1;
1636
1815
  objForEachKey(values, function (name, theValue) {
1637
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1816
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1638
1817
  });
1639
1818
  return cookieValue;
1640
1819
  }
1641
1820
  function _getCookieValue(name) {
1642
- var cookieValue = strEmpty;
1821
+ var cookieValue = strEmpty$1;
1643
1822
  if (_doc) {
1644
- var theCookie = _doc[strCookie] || strEmpty;
1823
+ var theCookie = _doc[strCookie] || strEmpty$1;
1645
1824
  if (_parsedCookieValue !== theCookie) {
1646
1825
  _cookieCache = _extractParts(theCookie);
1647
1826
  _parsedCookieValue = theCookie;
1648
1827
  }
1649
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1828
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1650
1829
  }
1651
1830
  return cookieValue;
1652
1831
  }
@@ -1682,6 +1861,30 @@
1682
1861
 
1683
1862
  var strExtensionConfig = "extensionConfig";
1684
1863
 
1864
+ function createUnloadHandlerContainer() {
1865
+ var handlers = [];
1866
+ function _addHandler(handler) {
1867
+ if (handler) {
1868
+ handlers.push(handler);
1869
+ }
1870
+ }
1871
+ function _runHandlers(unloadCtx, unloadState) {
1872
+ arrForEach(handlers, function (handler) {
1873
+ try {
1874
+ handler(unloadCtx, unloadState);
1875
+ }
1876
+ catch (e) {
1877
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1878
+ }
1879
+ });
1880
+ handlers = [];
1881
+ }
1882
+ return {
1883
+ add: _addHandler,
1884
+ run: _runHandlers
1885
+ };
1886
+ }
1887
+
1685
1888
  var strGetPlugin = "getPlugin";
1686
1889
  var BaseTelemetryPlugin = /** @class */ (function () {
1687
1890
  function BaseTelemetryPlugin() {
@@ -1689,6 +1892,7 @@
1689
1892
  var _isinitialized;
1690
1893
  var _rootCtx;
1691
1894
  var _nextPlugin;
1895
+ var _unloadHandlerContainer;
1692
1896
  var _hooks;
1693
1897
  _initDefaults();
1694
1898
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1696,6 +1900,39 @@
1696
1900
  _setDefaults(config, core, pluginChain);
1697
1901
  _isinitialized = true;
1698
1902
  };
1903
+ _self.teardown = function (unloadCtx, unloadState) {
1904
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1905
+ return;
1906
+ }
1907
+ var result;
1908
+ var unloadDone = false;
1909
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1910
+ var theUnloadState = unloadState || {
1911
+ reason: 0 ,
1912
+ isAsync: false
1913
+ };
1914
+ function _unloadCallback() {
1915
+ if (!unloadDone) {
1916
+ unloadDone = true;
1917
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1918
+ arrForEach(_hooks, function (fn) {
1919
+ fn.rm();
1920
+ });
1921
+ _hooks = [];
1922
+ if (result === true) {
1923
+ theUnloadCtx.processNext(theUnloadState);
1924
+ }
1925
+ _initDefaults();
1926
+ }
1927
+ }
1928
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1929
+ _unloadCallback();
1930
+ }
1931
+ else {
1932
+ result = true;
1933
+ }
1934
+ return result;
1935
+ };
1699
1936
  _self._addHook = function (hooks) {
1700
1937
  if (hooks) {
1701
1938
  if (isArray(hooks)) {
@@ -1706,17 +1943,18 @@
1706
1943
  }
1707
1944
  }
1708
1945
  };
1946
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1709
1947
  });
1710
1948
  _self.diagLog = function (itemCtx) {
1711
1949
  return _getTelCtx(itemCtx).diagLog();
1712
1950
  };
1713
- _self.isInitialized = function () {
1951
+ _self[strIsInitialized] = function () {
1714
1952
  return _isinitialized;
1715
1953
  };
1716
1954
  _self.setInitialized = function (isInitialized) {
1717
1955
  _isinitialized = isInitialized;
1718
1956
  };
1719
- _self.setNextPlugin = function (next) {
1957
+ _self[strSetNextPlugin] = function (next) {
1720
1958
  _nextPlugin = next;
1721
1959
  };
1722
1960
  _self.processNext = function (env, itemCtx) {
@@ -1762,108 +2000,123 @@
1762
2000
  _rootCtx = null;
1763
2001
  _nextPlugin = null;
1764
2002
  _hooks = [];
2003
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1765
2004
  }
1766
2005
  }
1767
2006
  return BaseTelemetryPlugin;
1768
2007
  }());
1769
2008
 
1770
- var UInt32Mask = 0x100000000;
1771
- var MaxUInt32 = 0xffffffff;
1772
- var _mwcSeeded = false;
1773
- var _mwcW = 123456789;
1774
- var _mwcZ = 987654321;
1775
- function _mwcSeed(seedValue) {
1776
- if (seedValue < 0) {
1777
- seedValue >>>= 0;
1778
- }
1779
- _mwcW = (123456789 + seedValue) & MaxUInt32;
1780
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
1781
- _mwcSeeded = true;
1782
- }
1783
- function _autoSeedMwc() {
1784
- try {
1785
- var now = dateNow() & 0x7fffffff;
1786
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1787
- }
1788
- catch (e) {
1789
- }
1790
- }
1791
- function randomValue(maxValue) {
1792
- if (maxValue > 0) {
1793
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1794
- }
1795
- return 0;
1796
- }
1797
- function random32(signed) {
1798
- var value = 0;
1799
- var c = getCrypto() || getMsCrypto();
1800
- if (c && c.getRandomValues) {
1801
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1802
- }
1803
- if (value === 0 && isIE()) {
1804
- if (!_mwcSeeded) {
1805
- _autoSeedMwc();
2009
+ var strOnPrefix = "on";
2010
+ var strAttachEvent = "attachEvent";
2011
+ var strAddEventHelper = "addEventListener";
2012
+ var strEvents = "events";
2013
+ createUniqueNamespace("aiEvtPageHide");
2014
+ createUniqueNamespace("aiEvtPageShow");
2015
+ var _guid = 1;
2016
+ var elmNodeData = createElmNodeData("events");
2017
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2018
+ function _normalizeNamespace(name) {
2019
+ if (name && name.replace) {
2020
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2021
+ }
2022
+ return name;
2023
+ }
2024
+ function _getEvtNamespace(eventName, namespaces) {
2025
+ if (namespaces) {
2026
+ var theNamespace_1 = "";
2027
+ if (isArray(namespaces)) {
2028
+ theNamespace_1 = "";
2029
+ arrForEach(namespaces, function (name) {
2030
+ name = _normalizeNamespace(name);
2031
+ if (name) {
2032
+ if (name[0] !== ".") {
2033
+ name = "." + name;
2034
+ }
2035
+ theNamespace_1 += name;
2036
+ }
2037
+ });
2038
+ }
2039
+ else {
2040
+ theNamespace_1 = _normalizeNamespace(namespaces);
2041
+ }
2042
+ if (theNamespace_1) {
2043
+ if (theNamespace_1[0] !== ".") {
2044
+ theNamespace_1 = "." + theNamespace_1;
2045
+ }
2046
+ eventName = (eventName || "") + theNamespace_1;
1806
2047
  }
1807
- value = mwcRandom32() & MaxUInt32;
1808
- }
1809
- if (value === 0) {
1810
- value = Math.floor((UInt32Mask * Math.random()) | 0);
1811
- }
1812
- if (!signed) {
1813
- value >>>= 0;
1814
2048
  }
1815
- return value;
2049
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
2050
+ return {
2051
+ type: parsedEvent[1],
2052
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
2053
+ };
1816
2054
  }
1817
- function mwcRandomSeed(value) {
1818
- if (!value) {
1819
- _autoSeedMwc();
1820
- }
1821
- else {
1822
- _mwcSeed(value);
2055
+ function _getRegisteredEvents(target, evtName, addDefault) {
2056
+ if (addDefault === void 0) { addDefault = true; }
2057
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2058
+ var registeredEvents = aiEvts[evtName];
2059
+ if (!registeredEvents) {
2060
+ registeredEvents = aiEvts[evtName] = [];
1823
2061
  }
2062
+ return registeredEvents;
1824
2063
  }
1825
- function mwcRandom32(signed) {
1826
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1827
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1828
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1829
- if (!signed) {
1830
- value >>>= 0;
2064
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2065
+ var result = false;
2066
+ if (obj && evtName && evtName.type && handlerRef) {
2067
+ if (obj[strAddEventHelper]) {
2068
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2069
+ result = true;
2070
+ }
2071
+ else if (obj[strAttachEvent]) {
2072
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2073
+ result = true;
2074
+ }
1831
2075
  }
1832
- return value;
2076
+ return result;
1833
2077
  }
1834
- function newId(maxLength) {
1835
- if (maxLength === void 0) { maxLength = 22; }
1836
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1837
- var number = random32() >>> 0;
1838
- var chars = 0;
1839
- var result = "";
1840
- while (result.length < maxLength) {
1841
- chars++;
1842
- result += base64chars.charAt(number & 0x3F);
1843
- number >>>= 6;
1844
- if (chars === 5) {
1845
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1846
- chars = 0;
2078
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2079
+ if (useCapture === void 0) { useCapture = false; }
2080
+ var result = false;
2081
+ if (target) {
2082
+ try {
2083
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2084
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2085
+ if (result && elmNodeData.accept(target)) {
2086
+ var registeredEvent = {
2087
+ guid: _guid++,
2088
+ evtName: evtName,
2089
+ handler: handlerRef,
2090
+ capture: useCapture
2091
+ };
2092
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2093
+ }
2094
+ }
2095
+ catch (e) {
1847
2096
  }
1848
2097
  }
1849
2098
  return result;
1850
2099
  }
1851
-
1852
- var _cookieMgrs = null;
1853
- var _canUseCookies;
1854
- function addEventHandler(eventName, callback) {
2100
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
2101
+ if (useCapture === void 0) { useCapture = false; }
2102
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
2103
+ }
2104
+ function addEventHandler(eventName, callback, evtNamespace) {
1855
2105
  var result = false;
1856
2106
  var w = getWindow();
1857
2107
  if (w) {
1858
- result = attachEvent(w, eventName, callback);
1859
- result = attachEvent(w["body"], eventName, callback) || result;
2108
+ result = eventOn(w, eventName, callback, evtNamespace);
2109
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
1860
2110
  }
1861
2111
  var doc = getDocument();
1862
2112
  if (doc) {
1863
- result = attachEvent(doc, eventName, callback) || result;
2113
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
1864
2114
  }
1865
2115
  return result;
1866
2116
  }
2117
+
2118
+ var _cookieMgrs = null;
2119
+ var _canUseCookies;
1867
2120
  function newGuid() {
1868
2121
  function randomHexDigit() {
1869
2122
  return randomValue(15);
@@ -1882,7 +2135,7 @@
1882
2135
  }
1883
2136
  function generateW3CId() {
1884
2137
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1885
- var oct = "", tmp;
2138
+ var oct = strEmpty$1, tmp;
1886
2139
  for (var a = 0; a < 4; a++) {
1887
2140
  tmp = random32();
1888
2141
  oct +=
@@ -1977,6 +2230,95 @@
1977
2230
  return _legacyCookieMgr(null, logger).del(name);
1978
2231
  }
1979
2232
 
2233
+ createEnumStyle({
2234
+ CRITICAL: 1 ,
2235
+ WARNING: 2
2236
+ });
2237
+ var _InternalMessageId = createEnumStyle({
2238
+ BrowserDoesNotSupportLocalStorage: 0 ,
2239
+ BrowserCannotReadLocalStorage: 1 ,
2240
+ BrowserCannotReadSessionStorage: 2 ,
2241
+ BrowserCannotWriteLocalStorage: 3 ,
2242
+ BrowserCannotWriteSessionStorage: 4 ,
2243
+ BrowserFailedRemovalFromLocalStorage: 5 ,
2244
+ BrowserFailedRemovalFromSessionStorage: 6 ,
2245
+ CannotSendEmptyTelemetry: 7 ,
2246
+ ClientPerformanceMathError: 8 ,
2247
+ ErrorParsingAISessionCookie: 9 ,
2248
+ ErrorPVCalc: 10 ,
2249
+ ExceptionWhileLoggingError: 11 ,
2250
+ FailedAddingTelemetryToBuffer: 12 ,
2251
+ FailedMonitorAjaxAbort: 13 ,
2252
+ FailedMonitorAjaxDur: 14 ,
2253
+ FailedMonitorAjaxOpen: 15 ,
2254
+ FailedMonitorAjaxRSC: 16 ,
2255
+ FailedMonitorAjaxSend: 17 ,
2256
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
2257
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
2258
+ FailedToSendQueuedTelemetry: 20 ,
2259
+ FailedToReportDataLoss: 21 ,
2260
+ FlushFailed: 22 ,
2261
+ MessageLimitPerPVExceeded: 23 ,
2262
+ MissingRequiredFieldSpecification: 24 ,
2263
+ NavigationTimingNotSupported: 25 ,
2264
+ OnError: 26 ,
2265
+ SessionRenewalDateIsZero: 27 ,
2266
+ SenderNotInitialized: 28 ,
2267
+ StartTrackEventFailed: 29 ,
2268
+ StopTrackEventFailed: 30 ,
2269
+ StartTrackFailed: 31 ,
2270
+ StopTrackFailed: 32 ,
2271
+ TelemetrySampledAndNotSent: 33 ,
2272
+ TrackEventFailed: 34 ,
2273
+ TrackExceptionFailed: 35 ,
2274
+ TrackMetricFailed: 36 ,
2275
+ TrackPVFailed: 37 ,
2276
+ TrackPVFailedCalc: 38 ,
2277
+ TrackTraceFailed: 39 ,
2278
+ TransmissionFailed: 40 ,
2279
+ FailedToSetStorageBuffer: 41 ,
2280
+ FailedToRestoreStorageBuffer: 42 ,
2281
+ InvalidBackendResponse: 43 ,
2282
+ FailedToFixDepricatedValues: 44 ,
2283
+ InvalidDurationValue: 45 ,
2284
+ TelemetryEnvelopeInvalid: 46 ,
2285
+ CreateEnvelopeError: 47 ,
2286
+ CannotSerializeObject: 48 ,
2287
+ CannotSerializeObjectNonSerializable: 49 ,
2288
+ CircularReferenceDetected: 50 ,
2289
+ ClearAuthContextFailed: 51 ,
2290
+ ExceptionTruncated: 52 ,
2291
+ IllegalCharsInName: 53 ,
2292
+ ItemNotInArray: 54 ,
2293
+ MaxAjaxPerPVExceeded: 55 ,
2294
+ MessageTruncated: 56 ,
2295
+ NameTooLong: 57 ,
2296
+ SampleRateOutOfRange: 58 ,
2297
+ SetAuthContextFailed: 59 ,
2298
+ SetAuthContextFailedAccountName: 60 ,
2299
+ StringValueTooLong: 61 ,
2300
+ StartCalledMoreThanOnce: 62 ,
2301
+ StopCalledWithoutStart: 63 ,
2302
+ TelemetryInitializerFailed: 64 ,
2303
+ TrackArgumentsNotSpecified: 65 ,
2304
+ UrlTooLong: 66 ,
2305
+ SessionStorageBufferFull: 67 ,
2306
+ CannotAccessCookie: 68 ,
2307
+ IdTooLong: 69 ,
2308
+ InvalidEvent: 70 ,
2309
+ FailedMonitorAjaxSetRequestHeader: 71 ,
2310
+ SendBrowserInfoOnUserInit: 72 ,
2311
+ PluginException: 73 ,
2312
+ NotificationException: 74 ,
2313
+ SnippetScriptLoadFailure: 99 ,
2314
+ InvalidInstrumentationKey: 100 ,
2315
+ CannotParseAiBlobValue: 101 ,
2316
+ InvalidContentBlob: 102 ,
2317
+ TrackPageActionEventFailed: 103 ,
2318
+ FailedAddingCustomDefinedRequestContext: 104 ,
2319
+ InMemoryStorageBufferFull: 105
2320
+ });
2321
+
1980
2322
  var aiInstrumentHooks = "_aiHooks";
1981
2323
  var cbNames = [
1982
2324
  "req", "rsp", "hkErr", "fnErr"
@@ -2129,6 +2471,7 @@
2129
2471
  return event;
2130
2472
  }
2131
2473
 
2474
+ var strEmpty = "";
2132
2475
  function stringToBoolOrDefault(str, defaultValue) {
2133
2476
  if (defaultValue === void 0) { defaultValue = false; }
2134
2477
  if (str === undefined || str === null) {
@@ -2141,16 +2484,16 @@
2141
2484
  totalms = 0;
2142
2485
  }
2143
2486
  totalms = Math.round(totalms);
2144
- var ms = "" + totalms % 1000;
2145
- var sec = "" + Math.floor(totalms / 1000) % 60;
2146
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
2147
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2487
+ var ms = strEmpty + totalms % 1000;
2488
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
2489
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
2490
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2148
2491
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2149
2492
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2150
2493
  sec = sec.length < 2 ? "0" + sec : sec;
2151
2494
  min = min.length < 2 ? "0" + min : min;
2152
2495
  hour = hour.length < 2 ? "0" + hour : hour;
2153
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
2496
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
2154
2497
  }
2155
2498
  function getExtensionByName(extensions, identifier) {
2156
2499
  var extension = null;
@@ -2168,17 +2511,15 @@
2168
2511
 
2169
2512
  var strNotSpecified = "not_specified";
2170
2513
 
2171
- var StorageType;
2172
- (function (StorageType) {
2173
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
2174
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
2175
- })(StorageType || (StorageType = {}));
2176
- var DistributedTracingModes;
2177
- (function (DistributedTracingModes) {
2178
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
2179
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
2180
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
2181
- })(DistributedTracingModes || (DistributedTracingModes = {}));
2514
+ var StorageType = createEnumStyle({
2515
+ LocalStorage: 0 ,
2516
+ SessionStorage: 1
2517
+ });
2518
+ createEnumStyle({
2519
+ AI: 0 ,
2520
+ AI_AND_W3C: 1 ,
2521
+ W3C: 2
2522
+ });
2182
2523
 
2183
2524
  var _canUseLocalStorage = undefined;
2184
2525
  var _canUseSessionStorage = undefined;
@@ -2230,7 +2571,7 @@
2230
2571
  }
2231
2572
  catch (e) {
2232
2573
  _canUseLocalStorage = false;
2233
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2574
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2234
2575
  }
2235
2576
  }
2236
2577
  return null;
@@ -2244,7 +2585,7 @@
2244
2585
  }
2245
2586
  catch (e) {
2246
2587
  _canUseLocalStorage = false;
2247
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2588
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2248
2589
  }
2249
2590
  }
2250
2591
  return false;
@@ -2258,7 +2599,7 @@
2258
2599
  }
2259
2600
  catch (e) {
2260
2601
  _canUseLocalStorage = false;
2261
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2602
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2262
2603
  }
2263
2604
  }
2264
2605
  return false;
@@ -2286,7 +2627,7 @@
2286
2627
  }
2287
2628
  catch (e) {
2288
2629
  _canUseSessionStorage = false;
2289
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2630
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2290
2631
  }
2291
2632
  }
2292
2633
  return null;
@@ -2300,7 +2641,7 @@
2300
2641
  }
2301
2642
  catch (e) {
2302
2643
  _canUseSessionStorage = false;
2303
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2644
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2304
2645
  }
2305
2646
  }
2306
2647
  return false;
@@ -2314,7 +2655,7 @@
2314
2655
  }
2315
2656
  catch (e) {
2316
2657
  _canUseSessionStorage = false;
2317
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2658
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2318
2659
  }
2319
2660
  }
2320
2661
  return false;
@@ -3553,4 +3894,4 @@
3553
3894
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3554
3895
 
3555
3896
  }));
3556
- //# sourceMappingURL=ai.dbg.2.8.0-beta.2203-01.js.map
3897
+ //# sourceMappingURL=ai.dbg.2.8.0-beta.2203-04.js.map