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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/browser/{ai.2.8.0-beta.2202-06.cjs.js → ai.2.8.0-beta.2203-02.cjs.js} +876 -515
  3. package/browser/ai.2.8.0-beta.2203-02.cjs.js.map +1 -0
  4. package/browser/ai.2.8.0-beta.2203-02.cjs.min.js +6 -0
  5. package/browser/ai.2.8.0-beta.2203-02.cjs.min.js.map +1 -0
  6. package/browser/{ai.2.8.0-beta.2202-06.gbl.js → ai.2.8.0-beta.2203-02.gbl.js} +876 -515
  7. package/browser/ai.2.8.0-beta.2203-02.gbl.js.map +1 -0
  8. package/browser/ai.2.8.0-beta.2203-02.gbl.min.js +6 -0
  9. package/browser/ai.2.8.0-beta.2203-02.gbl.min.js.map +1 -0
  10. package/browser/ai.2.8.0-beta.2203-02.integrity.json +66 -0
  11. package/browser/{ai.2.8.0-beta.2202-06.js → ai.2.8.0-beta.2203-02.js} +876 -515
  12. package/browser/ai.2.8.0-beta.2203-02.js.map +1 -0
  13. package/browser/ai.2.8.0-beta.2203-02.min.js +6 -0
  14. package/browser/ai.2.8.0-beta.2203-02.min.js.map +1 -0
  15. package/browser/ai.2.cjs.js +875 -514
  16. package/browser/ai.2.cjs.js.map +1 -1
  17. package/browser/ai.2.cjs.min.js +2 -2
  18. package/browser/ai.2.cjs.min.js.map +1 -1
  19. package/browser/ai.2.gbl.js +875 -514
  20. package/browser/ai.2.gbl.js.map +1 -1
  21. package/browser/ai.2.gbl.min.js +2 -2
  22. package/browser/ai.2.gbl.min.js.map +1 -1
  23. package/browser/ai.2.js +875 -514
  24. package/browser/ai.2.js.map +1 -1
  25. package/browser/ai.2.min.js +2 -2
  26. package/browser/ai.2.min.js.map +1 -1
  27. package/dist/applicationinsights-web.api.json +328 -568
  28. package/dist/applicationinsights-web.api.md +44 -32
  29. package/dist/applicationinsights-web.d.ts +298 -93
  30. package/dist/applicationinsights-web.js +941 -578
  31. package/dist/applicationinsights-web.js.map +1 -1
  32. package/dist/applicationinsights-web.min.js +2 -2
  33. package/dist/applicationinsights-web.min.js.map +1 -1
  34. package/dist/applicationinsights-web.rollup.d.ts +298 -93
  35. package/dist-esm/ApplicationInsightsContainer.js +1 -1
  36. package/dist-esm/ApplicationInsightsDeprecated.js +1 -1
  37. package/dist-esm/Init.js +1 -1
  38. package/dist-esm/Initialization.js +1 -1
  39. package/dist-esm/applicationinsights-web.js +1 -1
  40. package/package.json +7 -7
  41. package/types/Initialization.d.ts +6 -2
  42. package/browser/ai.2.8.0-beta.2202-06.cjs.js.map +0 -1
  43. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js +0 -6
  44. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js.map +0 -1
  45. package/browser/ai.2.8.0-beta.2202-06.gbl.js.map +0 -1
  46. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js +0 -6
  47. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js.map +0 -1
  48. package/browser/ai.2.8.0-beta.2202-06.integrity.json +0 -66
  49. package/browser/ai.2.8.0-beta.2202-06.js.map +0 -1
  50. package/browser/ai.2.8.0-beta.2202-06.min.js +0 -6
  51. package/browser/ai.2.8.0-beta.2202-06.min.js.map +0 -1
package/browser/ai.2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-06
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -350,99 +350,26 @@
350
350
  };
351
351
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
352
352
 
353
- var LoggingSeverity;
354
- (function (LoggingSeverity) {
355
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
356
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
357
- })(LoggingSeverity || (LoggingSeverity = {}));
358
- var _InternalMessageId = {
359
- BrowserDoesNotSupportLocalStorage: 0,
360
- BrowserCannotReadLocalStorage: 1,
361
- BrowserCannotReadSessionStorage: 2,
362
- BrowserCannotWriteLocalStorage: 3,
363
- BrowserCannotWriteSessionStorage: 4,
364
- BrowserFailedRemovalFromLocalStorage: 5,
365
- BrowserFailedRemovalFromSessionStorage: 6,
366
- CannotSendEmptyTelemetry: 7,
367
- ClientPerformanceMathError: 8,
368
- ErrorParsingAISessionCookie: 9,
369
- ErrorPVCalc: 10,
370
- ExceptionWhileLoggingError: 11,
371
- FailedAddingTelemetryToBuffer: 12,
372
- FailedMonitorAjaxAbort: 13,
373
- FailedMonitorAjaxDur: 14,
374
- FailedMonitorAjaxOpen: 15,
375
- FailedMonitorAjaxRSC: 16,
376
- FailedMonitorAjaxSend: 17,
377
- FailedMonitorAjaxGetCorrelationHeader: 18,
378
- FailedToAddHandlerForOnBeforeUnload: 19,
379
- FailedToSendQueuedTelemetry: 20,
380
- FailedToReportDataLoss: 21,
381
- FlushFailed: 22,
382
- MessageLimitPerPVExceeded: 23,
383
- MissingRequiredFieldSpecification: 24,
384
- NavigationTimingNotSupported: 25,
385
- OnError: 26,
386
- SessionRenewalDateIsZero: 27,
387
- SenderNotInitialized: 28,
388
- StartTrackEventFailed: 29,
389
- StopTrackEventFailed: 30,
390
- StartTrackFailed: 31,
391
- StopTrackFailed: 32,
392
- TelemetrySampledAndNotSent: 33,
393
- TrackEventFailed: 34,
394
- TrackExceptionFailed: 35,
395
- TrackMetricFailed: 36,
396
- TrackPVFailed: 37,
397
- TrackPVFailedCalc: 38,
398
- TrackTraceFailed: 39,
399
- TransmissionFailed: 40,
400
- FailedToSetStorageBuffer: 41,
401
- FailedToRestoreStorageBuffer: 42,
402
- InvalidBackendResponse: 43,
403
- FailedToFixDepricatedValues: 44,
404
- InvalidDurationValue: 45,
405
- TelemetryEnvelopeInvalid: 46,
406
- CreateEnvelopeError: 47,
407
- CannotSerializeObject: 48,
408
- CannotSerializeObjectNonSerializable: 49,
409
- CircularReferenceDetected: 50,
410
- ClearAuthContextFailed: 51,
411
- ExceptionTruncated: 52,
412
- IllegalCharsInName: 53,
413
- ItemNotInArray: 54,
414
- MaxAjaxPerPVExceeded: 55,
415
- MessageTruncated: 56,
416
- NameTooLong: 57,
417
- SampleRateOutOfRange: 58,
418
- SetAuthContextFailed: 59,
419
- SetAuthContextFailedAccountName: 60,
420
- StringValueTooLong: 61,
421
- StartCalledMoreThanOnce: 62,
422
- StopCalledWithoutStart: 63,
423
- TelemetryInitializerFailed: 64,
424
- TrackArgumentsNotSpecified: 65,
425
- UrlTooLong: 66,
426
- SessionStorageBufferFull: 67,
427
- CannotAccessCookie: 68,
428
- IdTooLong: 69,
429
- InvalidEvent: 70,
430
- FailedMonitorAjaxSetRequestHeader: 71,
431
- SendBrowserInfoOnUserInit: 72,
432
- PluginException: 73,
433
- NotificationException: 74,
434
- SnippetScriptLoadFailure: 99,
435
- InvalidInstrumentationKey: 100,
436
- CannotParseAiBlobValue: 101,
437
- InvalidContentBlob: 102,
438
- TrackPageActionEventFailed: 103,
439
- FailedAddingCustomDefinedRequestContext: 104,
440
- InMemoryStorageBufferFull: 105
441
- };
353
+ var strEmpty$1 = "";
354
+ var strProcessTelemetry = "processTelemetry";
355
+ var strPriority = "priority";
356
+ var strSetNextPlugin = "setNextPlugin";
357
+ var strIsInitialized = "isInitialized";
358
+ var strTeardown = "teardown";
359
+ var strCore = "core";
360
+ var strDisabled = "disabled";
361
+ var strDoTeardown = "_doTeardown";
362
+ var strProcessNext = "processNext";
363
+ var strResume = "resume";
364
+ var strPause = "pause";
365
+ var strNotificationListener = "NotificationListener";
366
+ var strAddNotificationListener = "add" + strNotificationListener;
367
+ var strRemoveNotificationListener = "remove" + strNotificationListener;
368
+ var strEventsSent = "eventsSent";
369
+ var strEventsDiscarded = "eventsDiscarded";
370
+ var strEventsSendRequest = "eventsSendRequest";
371
+ var strPerfEvent = "perfEvent";
442
372
 
443
- var strOnPrefix = "on";
444
- var strAttachEvent = "attachEvent";
445
- var strAddEventHelper = "addEventListener";
446
373
  var strToISOString = "toISOString";
447
374
  var cStrEndsWith = "endsWith";
448
375
  var strIndexOf = "indexOf";
@@ -452,7 +379,7 @@
452
379
  var strToString = "toString";
453
380
  var str__Proto = "__proto__";
454
381
  var strConstructor = "constructor";
455
- var _objDefineProperty = ObjDefineProperty;
382
+ var _objDefineProperty$1 = ObjDefineProperty;
456
383
  var _objFreeze = ObjClass.freeze;
457
384
  var _objKeys = ObjClass.keys;
458
385
  var StringProto = String[strShimPrototype];
@@ -501,25 +428,6 @@
501
428
  function isFunction(value) {
502
429
  return !!(value && typeof value === strShimFunction);
503
430
  }
504
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
505
- if (useCapture === void 0) { useCapture = false; }
506
- var result = false;
507
- if (!isNullOrUndefined(obj)) {
508
- try {
509
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
510
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
511
- result = true;
512
- }
513
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
514
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
515
- result = true;
516
- }
517
- }
518
- catch (e) {
519
- }
520
- }
521
- return result;
522
- }
523
431
  function normalizeJsName(name) {
524
432
  var value = name;
525
433
  if (value && isString(value)) {
@@ -751,7 +659,7 @@
751
659
  return result;
752
660
  }
753
661
  function objDefineAccessors(target, prop, getProp, setProp) {
754
- if (_objDefineProperty) {
662
+ if (_objDefineProperty$1) {
755
663
  try {
756
664
  var descriptor = {
757
665
  enumerable: true,
@@ -763,7 +671,7 @@
763
671
  if (setProp) {
764
672
  descriptor.set = setProp;
765
673
  }
766
- _objDefineProperty(target, prop, descriptor);
674
+ _objDefineProperty$1(target, prop, descriptor);
767
675
  return true;
768
676
  }
769
677
  catch (e) {
@@ -783,7 +691,7 @@
783
691
  if (isError(object)) {
784
692
  return object.name;
785
693
  }
786
- return "";
694
+ return strEmpty$1;
787
695
  }
788
696
  function setValue(target, field, value, valChk, srcChk) {
789
697
  var theValue = value;
@@ -900,6 +808,17 @@
900
808
  return class_1;
901
809
  }());
902
810
  }
811
+ function createEnumStyle(values) {
812
+ var enumClass = {};
813
+ objForEachKey(values, function (field, value) {
814
+ enumClass[field] = value;
815
+ if (!isUndefined(enumClass[value])) {
816
+ throwError("Value: [" + value + "] already exists for " + field);
817
+ }
818
+ enumClass[value] = field;
819
+ });
820
+ return objFreeze(enumClass);
821
+ }
903
822
  function optimizeObject(theObject) {
904
823
  if (theObject && ObjAssign) {
905
824
  theObject = ObjClass(ObjAssign({}, theObject));
@@ -1089,7 +1008,7 @@
1089
1008
  var nav = getNavigator();
1090
1009
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
1091
1010
  _navUserAgentCheck = nav.userAgent;
1092
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
1011
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
1093
1012
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1094
1013
  }
1095
1014
  return _isTrident;
@@ -1098,9 +1017,9 @@
1098
1017
  if (userAgentStr === void 0) { userAgentStr = null; }
1099
1018
  if (!userAgentStr) {
1100
1019
  var navigator_1 = getNavigator() || {};
1101
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
1020
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
1102
1021
  }
1103
- var ua = (userAgentStr || "").toLowerCase();
1022
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
1104
1023
  if (strContains(ua, strMsie)) {
1105
1024
  var doc = getDocument() || {};
1106
1025
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -1115,7 +1034,7 @@
1115
1034
  }
1116
1035
  function dumpObj(object) {
1117
1036
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
1118
- var propertyValueDump = "";
1037
+ var propertyValueDump = strEmpty$1;
1119
1038
  if (objectTypeDump === "[object Error]") {
1120
1039
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
1121
1040
  }
@@ -1209,9 +1128,9 @@
1209
1128
  var strWarnToConsole = "warnToConsole";
1210
1129
  function _sanitizeDiagnosticText(text) {
1211
1130
  if (text) {
1212
- return "\"" + text.replace(/\"/g, "") + "\"";
1131
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
1213
1132
  }
1214
- return "";
1133
+ return strEmpty$1;
1215
1134
  }
1216
1135
  function _logToConsole(func, message) {
1217
1136
  var theConsole = getConsole();
@@ -1233,12 +1152,12 @@
1233
1152
  _self.message =
1234
1153
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1235
1154
  msgId;
1236
- var strProps = "";
1155
+ var strProps = strEmpty$1;
1237
1156
  if (hasJSON()) {
1238
1157
  strProps = getJSON().stringify(properties);
1239
1158
  }
1240
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
1241
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
1159
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
1160
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
1242
1161
  _self.message += diagnosticText;
1243
1162
  }
1244
1163
  _InternalLogMessage.dataType = "MessageData";
@@ -1268,7 +1187,7 @@
1268
1187
  throw message;
1269
1188
  }
1270
1189
  else {
1271
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
1190
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1272
1191
  if (!isUndefined(message.message)) {
1273
1192
  var logLevel = _self.consoleLoggingLevel();
1274
1193
  if (isUserAct) {
@@ -1286,7 +1205,7 @@
1286
1205
  _self.logInternalMessage(severity, message);
1287
1206
  }
1288
1207
  else {
1289
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1208
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1290
1209
  }
1291
1210
  }
1292
1211
  };
@@ -1318,13 +1237,13 @@
1318
1237
  if (severity <= _self.telemetryLoggingLevel()) {
1319
1238
  _self.queue.push(message);
1320
1239
  _messageCount++;
1321
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1240
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1322
1241
  }
1323
1242
  if (_messageCount === _self.maxInternalMessageLimit()) {
1324
1243
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1325
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1244
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1326
1245
  _self.queue.push(throttleMessage);
1327
- if (severity === LoggingSeverity.CRITICAL) {
1246
+ if (severity === 1 ) {
1328
1247
  _self.errorToConsole(throttleLimitMessage);
1329
1248
  }
1330
1249
  else {
@@ -1498,6 +1417,217 @@
1498
1417
  return _defaultPerfManager;
1499
1418
  }
1500
1419
 
1420
+ var UInt32Mask = 0x100000000;
1421
+ var MaxUInt32 = 0xffffffff;
1422
+ var _mwcSeeded = false;
1423
+ var _mwcW = 123456789;
1424
+ var _mwcZ = 987654321;
1425
+ function _mwcSeed(seedValue) {
1426
+ if (seedValue < 0) {
1427
+ seedValue >>>= 0;
1428
+ }
1429
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1430
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1431
+ _mwcSeeded = true;
1432
+ }
1433
+ function _autoSeedMwc() {
1434
+ try {
1435
+ var now = dateNow() & 0x7fffffff;
1436
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1437
+ }
1438
+ catch (e) {
1439
+ }
1440
+ }
1441
+ function randomValue(maxValue) {
1442
+ if (maxValue > 0) {
1443
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1444
+ }
1445
+ return 0;
1446
+ }
1447
+ function random32(signed) {
1448
+ var value = 0;
1449
+ var c = getCrypto() || getMsCrypto();
1450
+ if (c && c.getRandomValues) {
1451
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1452
+ }
1453
+ if (value === 0 && isIE()) {
1454
+ if (!_mwcSeeded) {
1455
+ _autoSeedMwc();
1456
+ }
1457
+ value = mwcRandom32() & MaxUInt32;
1458
+ }
1459
+ if (value === 0) {
1460
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1461
+ }
1462
+ if (!signed) {
1463
+ value >>>= 0;
1464
+ }
1465
+ return value;
1466
+ }
1467
+ function mwcRandomSeed(value) {
1468
+ if (!value) {
1469
+ _autoSeedMwc();
1470
+ }
1471
+ else {
1472
+ _mwcSeed(value);
1473
+ }
1474
+ }
1475
+ function mwcRandom32(signed) {
1476
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1477
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1478
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1479
+ if (!signed) {
1480
+ value >>>= 0;
1481
+ }
1482
+ return value;
1483
+ }
1484
+ function newId(maxLength) {
1485
+ if (maxLength === void 0) { maxLength = 22; }
1486
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1487
+ var number = random32() >>> 0;
1488
+ var chars = 0;
1489
+ var result = strEmpty$1;
1490
+ while (result.length < maxLength) {
1491
+ chars++;
1492
+ result += base64chars.charAt(number & 0x3F);
1493
+ number >>>= 6;
1494
+ if (chars === 5) {
1495
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1496
+ chars = 0;
1497
+ }
1498
+ }
1499
+ return result;
1500
+ }
1501
+
1502
+ var _objDefineProperty = ObjDefineProperty;
1503
+ var version = "2.7.3";
1504
+ var instanceName = "." + newId(6);
1505
+ var _dataUid = 0;
1506
+ function _createAccessor(target, prop, value) {
1507
+ if (_objDefineProperty) {
1508
+ try {
1509
+ _objDefineProperty(target, prop, {
1510
+ value: value,
1511
+ enumerable: false,
1512
+ configurable: true
1513
+ });
1514
+ return true;
1515
+ }
1516
+ catch (e) {
1517
+ }
1518
+ }
1519
+ return false;
1520
+ }
1521
+ function _canAcceptData(target) {
1522
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1523
+ }
1524
+ function _getCache(data, target) {
1525
+ var theCache = target[data.id];
1526
+ if (!theCache) {
1527
+ theCache = {};
1528
+ try {
1529
+ if (_canAcceptData(target)) {
1530
+ if (!_createAccessor(target, data.id, theCache)) {
1531
+ target[data.id] = theCache;
1532
+ }
1533
+ }
1534
+ }
1535
+ catch (e) {
1536
+ }
1537
+ }
1538
+ return theCache;
1539
+ }
1540
+ function createUniqueNamespace(name, includeVersion) {
1541
+ if (includeVersion === void 0) { includeVersion = false; }
1542
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1543
+ }
1544
+ function createElmNodeData(name) {
1545
+ var data = {
1546
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1547
+ accept: function (target) {
1548
+ return _canAcceptData(target);
1549
+ },
1550
+ get: function (target, name, defValue, addDefault) {
1551
+ var theCache = target[data.id];
1552
+ if (!theCache) {
1553
+ if (addDefault) {
1554
+ theCache = _getCache(data, target);
1555
+ theCache[normalizeJsName(name)] = defValue;
1556
+ }
1557
+ return defValue;
1558
+ }
1559
+ return theCache[normalizeJsName(name)];
1560
+ },
1561
+ kill: function (target, name) {
1562
+ if (target && target[name]) {
1563
+ try {
1564
+ delete target[name];
1565
+ }
1566
+ catch (e) {
1567
+ }
1568
+ }
1569
+ }
1570
+ };
1571
+ return data;
1572
+ }
1573
+
1574
+ var pluginStateData = createElmNodeData("plugin");
1575
+ function _getPluginState(plugin) {
1576
+ return pluginStateData.get(plugin, "state", {}, true);
1577
+ }
1578
+ function initializePlugins(processContext, extensions) {
1579
+ var initPlugins = [];
1580
+ var lastPlugin = null;
1581
+ var proxy = processContext.getNext();
1582
+ var pluginState;
1583
+ while (proxy) {
1584
+ var thePlugin = proxy.getPlugin();
1585
+ if (thePlugin) {
1586
+ if (lastPlugin &&
1587
+ isFunction(lastPlugin[strSetNextPlugin]) &&
1588
+ isFunction(thePlugin[strProcessTelemetry])) {
1589
+ lastPlugin[strSetNextPlugin](thePlugin);
1590
+ }
1591
+ var isInitialized = false;
1592
+ if (isFunction(thePlugin[strIsInitialized])) {
1593
+ isInitialized = thePlugin[strIsInitialized]();
1594
+ }
1595
+ else {
1596
+ pluginState = _getPluginState(thePlugin);
1597
+ isInitialized = pluginState[strIsInitialized];
1598
+ }
1599
+ if (!isInitialized) {
1600
+ initPlugins.push(thePlugin);
1601
+ }
1602
+ lastPlugin = thePlugin;
1603
+ proxy = proxy.getNext();
1604
+ }
1605
+ }
1606
+ arrForEach(initPlugins, function (thePlugin) {
1607
+ var core = processContext.core();
1608
+ thePlugin.initialize(processContext.getCfg(), core, extensions, processContext.getNext());
1609
+ pluginState = _getPluginState(thePlugin);
1610
+ if (!thePlugin[strCore] && !pluginState[strCore]) {
1611
+ pluginState[strCore] = core;
1612
+ }
1613
+ pluginState[strIsInitialized] = true;
1614
+ delete pluginState[strTeardown];
1615
+ });
1616
+ }
1617
+ function sortPlugins(plugins) {
1618
+ return plugins.sort(function (extA, extB) {
1619
+ var result = 0;
1620
+ var bHasProcess = isFunction(extB[strProcessTelemetry]);
1621
+ if (isFunction(extA[strProcessTelemetry])) {
1622
+ result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
1623
+ }
1624
+ else if (bHasProcess) {
1625
+ result = -1;
1626
+ }
1627
+ return result;
1628
+ });
1629
+ }
1630
+
1501
1631
  var strTelemetryPluginChain = "TelemetryPluginChain";
1502
1632
  var strHasRunFlags = "_hasRun";
1503
1633
  var strGetTelCtx = "_getTelCtx";
@@ -1511,53 +1641,66 @@
1511
1641
  }
1512
1642
  return createTelemetryProxyChain([startAt], config, core);
1513
1643
  }
1514
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1515
- var _nextProxy = null;
1516
- var _onComplete = null;
1517
- if (startAt) {
1518
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1519
- }
1520
- else {
1521
- _nextProxy = telemetryChain;
1522
- }
1644
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1645
+ var _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1646
+ var _onComplete = [];
1523
1647
  var context = {
1524
- core: function () {
1525
- return core;
1526
- },
1527
- diagLog: function () {
1528
- return safeGetLogger(core, config);
1529
- },
1530
- getCfg: function () {
1531
- return config;
1532
- },
1533
- getExtCfg: _getExtCfg,
1534
- getConfig: _getConfig,
1535
- hasNext: function () {
1536
- return _nextProxy != null;
1537
- },
1538
- getNext: function () {
1539
- return _nextProxy;
1540
- },
1541
- setNext: function (nextPlugin) {
1542
- _nextProxy = nextPlugin;
1543
- },
1544
- processNext: function (env) {
1545
- _processChain(function (nextPlugin) {
1546
- nextPlugin.processTelemetry(env, context);
1648
+ _next: _moveNext,
1649
+ ctx: {
1650
+ core: function () { return core; },
1651
+ diagLog: function () {
1652
+ return safeGetLogger(core, config);
1653
+ },
1654
+ getCfg: function () {
1655
+ return config;
1656
+ },
1657
+ getExtCfg: _getExtCfg,
1658
+ getConfig: _getConfig,
1659
+ hasNext: function () {
1660
+ return !!_nextProxy;
1661
+ },
1662
+ getNext: function () {
1663
+ return _nextProxy;
1664
+ },
1665
+ setNext: function (nextPlugin) {
1666
+ _nextProxy = nextPlugin;
1667
+ },
1668
+ iterate: _iterateChain,
1669
+ onComplete: _addOnComplete
1670
+ }
1671
+ };
1672
+ function _addOnComplete(onComplete, that) {
1673
+ var args = [];
1674
+ for (var _i = 2; _i < arguments.length; _i++) {
1675
+ args[_i - 2] = arguments[_i];
1676
+ }
1677
+ if (onComplete) {
1678
+ _onComplete.push({
1679
+ func: onComplete,
1680
+ self: !isUndefined(that) ? that : context.ctx,
1681
+ args: args
1547
1682
  });
1548
- },
1549
- iterate: _iterateChain,
1550
- createNew: function (plugins, startAt) {
1551
- if (plugins === void 0) { plugins = null; }
1552
- if (isArray(plugins)) {
1553
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1683
+ }
1684
+ }
1685
+ function _moveNext() {
1686
+ var nextProxy = _nextProxy;
1687
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1688
+ if (!nextProxy) {
1689
+ var onComplete = _onComplete;
1690
+ if (onComplete && onComplete.length > 0) {
1691
+ arrForEach(onComplete, function (completeDetails) {
1692
+ try {
1693
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1694
+ }
1695
+ catch (e) {
1696
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1697
+ }
1698
+ });
1699
+ _onComplete = [];
1554
1700
  }
1555
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1556
- },
1557
- onComplete: function (onComplete) {
1558
- _onComplete = onComplete;
1559
1701
  }
1560
- };
1702
+ return nextProxy;
1703
+ }
1561
1704
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1562
1705
  if (defaultValue === void 0) { defaultValue = {}; }
1563
1706
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1600,29 +1743,53 @@
1600
1743
  }
1601
1744
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1602
1745
  }
1603
- function _processChain(cb) {
1604
- var nextPlugin = _nextProxy;
1605
- if (nextPlugin) {
1606
- _nextProxy = nextPlugin.getNext();
1607
- cb(nextPlugin);
1608
- }
1609
- else {
1610
- if (_onComplete) {
1611
- _onComplete();
1612
- _onComplete = null;
1746
+ function _iterateChain(cb) {
1747
+ var nextPlugin;
1748
+ while (!!(nextPlugin = context._next())) {
1749
+ var plugin = nextPlugin.getPlugin();
1750
+ if (plugin) {
1751
+ cb(plugin);
1613
1752
  }
1614
1753
  }
1615
1754
  }
1616
- function _iterateChain(cb) {
1617
- while (_nextProxy) {
1618
- _processChain(function (nextPlugin) {
1619
- var plugin = nextPlugin.getPlugin();
1620
- if (plugin) {
1621
- cb(plugin);
1622
- }
1623
- });
1755
+ return context;
1756
+ }
1757
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1758
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1759
+ var context = internalContext.ctx;
1760
+ function _processNext(env) {
1761
+ var nextPlugin = internalContext._next();
1762
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1763
+ return !nextPlugin;
1764
+ }
1765
+ function _createNew(plugins, startAt) {
1766
+ if (plugins === void 0) { plugins = null; }
1767
+ if (isArray(plugins)) {
1768
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1769
+ }
1770
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1771
+ }
1772
+ context.processNext = _processNext;
1773
+ context.createNew = _createNew;
1774
+ return context;
1775
+ }
1776
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1777
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1778
+ var context = internalContext.ctx;
1779
+ function _processNext(unloadState) {
1780
+ var nextPlugin = internalContext._next();
1781
+ nextPlugin && nextPlugin.unload(context, unloadState);
1782
+ return !nextPlugin;
1783
+ }
1784
+ function _createNew(plugins, startAt) {
1785
+ if (plugins === void 0) { plugins = null; }
1786
+ if (isArray(plugins)) {
1787
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1624
1788
  }
1789
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1625
1790
  }
1791
+ context.processNext = _processNext;
1792
+ context.createNew = _createNew;
1626
1793
  return context;
1627
1794
  }
1628
1795
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1670,32 +1837,35 @@
1670
1837
  return nextProxy;
1671
1838
  },
1672
1839
  processTelemetry: _processTelemetry,
1840
+ unload: _unloadPlugin,
1673
1841
  _id: chainId,
1674
1842
  _setNext: function (nextPlugin) {
1675
1843
  nextProxy = nextPlugin;
1676
1844
  }
1677
1845
  };
1678
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1846
+ function _getTelCtx() {
1847
+ var itemCtx;
1848
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1849
+ itemCtx = plugin[strGetTelCtx]();
1850
+ }
1679
1851
  if (!itemCtx) {
1680
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1681
- itemCtx = plugin[strGetTelCtx]();
1682
- }
1683
- if (!itemCtx) {
1684
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1685
- }
1852
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1686
1853
  }
1854
+ return itemCtx;
1855
+ }
1856
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1857
+ var hasRun = false;
1687
1858
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1688
1859
  var hasRunContext = itemCtx[strHasRunFlags];
1689
1860
  if (!hasRunContext) {
1690
1861
  hasRunContext = itemCtx[strHasRunFlags] = {};
1691
1862
  }
1692
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1693
- hasRunContext[chainId] = true;
1694
- var hasRun = false;
1695
- itemCtx.setNext(nextProxy);
1696
- if (plugin) {
1863
+ itemCtx.setNext(nextProxy);
1864
+ if (plugin) {
1865
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1866
+ hasRunContext[chainId] = true;
1697
1867
  try {
1698
- var nextId = nextProxy ? nextProxy._id : "";
1868
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1699
1869
  if (nextId) {
1700
1870
  hasRunContext[nextId] = false;
1701
1871
  }
@@ -1707,18 +1877,21 @@
1707
1877
  hasRun = true;
1708
1878
  }
1709
1879
  if (!nextProxy || !hasNextRun) {
1710
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1880
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1711
1881
  }
1712
1882
  }
1713
- }
1714
- if (nextProxy && !hasRun) {
1715
- processProxyFn(itemCtx);
1716
- }
1717
- }, details, isAsync);
1883
+ }, details, isAsync);
1884
+ }
1885
+ return hasRun;
1718
1886
  }
1719
1887
  function _processTelemetry(env, itemCtx) {
1720
- _processChain(itemCtx, function (itemCtx) {
1721
- if (!hasProcessTelemetry) {
1888
+ itemCtx = itemCtx || _getTelCtx();
1889
+ function _callProcessTelemetry(itemCtx) {
1890
+ if (!plugin || !hasProcessTelemetry) {
1891
+ return false;
1892
+ }
1893
+ var pluginState = _getPluginState(plugin);
1894
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1722
1895
  return false;
1723
1896
  }
1724
1897
  if (hasSetNext) {
@@ -1726,52 +1899,33 @@
1726
1899
  }
1727
1900
  plugin.processTelemetry(env, itemCtx);
1728
1901
  return true;
1729
- }, function (itemCtx) {
1730
- nextProxy.processTelemetry(env, itemCtx);
1731
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1732
- }
1733
- return objFreeze(proxyChain);
1734
- }
1735
-
1736
- var processTelemetry = "processTelemetry";
1737
- var priority = "priority";
1738
- var setNextPlugin = "setNextPlugin";
1739
- var isInitialized = "isInitialized";
1740
- function initializePlugins(processContext, extensions) {
1741
- var initPlugins = [];
1742
- var lastPlugin = null;
1743
- var proxy = processContext.getNext();
1744
- while (proxy) {
1745
- var thePlugin = proxy.getPlugin();
1746
- if (thePlugin) {
1747
- if (lastPlugin &&
1748
- isFunction(lastPlugin[setNextPlugin]) &&
1749
- isFunction(thePlugin[processTelemetry])) {
1750
- lastPlugin[setNextPlugin](thePlugin);
1751
- }
1752
- if (!isFunction(thePlugin[isInitialized]) || !thePlugin[isInitialized]()) {
1753
- initPlugins.push(thePlugin);
1754
- }
1755
- lastPlugin = thePlugin;
1756
- proxy = proxy.getNext();
1902
+ }
1903
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1904
+ itemCtx.processNext(env);
1757
1905
  }
1758
1906
  }
1759
- arrForEach(initPlugins, function (thePlugin) {
1760
- thePlugin.initialize(processContext.getCfg(), processContext.core(), extensions, processContext.getNext());
1761
- });
1762
- }
1763
- function sortPlugins(plugins) {
1764
- return plugins.sort(function (extA, extB) {
1765
- var result = 0;
1766
- var bHasProcess = isFunction(extB[processTelemetry]);
1767
- if (isFunction(extA[processTelemetry])) {
1768
- result = bHasProcess ? extA[priority] - extB[priority] : 1;
1907
+ function _unloadPlugin(unloadCtx, unloadState) {
1908
+ function _callTeardown() {
1909
+ var hasRun = false;
1910
+ if (plugin) {
1911
+ var pluginState = _getPluginState(plugin);
1912
+ var pluginCore = plugin[strCore] || pluginState.core;
1913
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1914
+ pluginState[strCore] = null;
1915
+ pluginState[strTeardown] = true;
1916
+ pluginState[strIsInitialized] = false;
1917
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1918
+ hasRun = true;
1919
+ }
1920
+ }
1921
+ }
1922
+ return hasRun;
1769
1923
  }
1770
- else if (bHasProcess) {
1771
- result = -1;
1924
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1925
+ unloadCtx.processNext(unloadState);
1772
1926
  }
1773
- return result;
1774
- });
1927
+ }
1928
+ return objFreeze(proxyChain);
1775
1929
  }
1776
1930
 
1777
1931
  var strToGMTString = "toGMTString";
@@ -1782,7 +1936,6 @@
1782
1936
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1783
1937
  var strDisableCookiesUsage = "disableCookiesUsage";
1784
1938
  var strConfigCookieMgr = "_ckMgr";
1785
- var strEmpty = "";
1786
1939
  var _supportsCookies = null;
1787
1940
  var _allowUaSameSite = null;
1788
1941
  var _parsedCookieValue = null;
@@ -1859,7 +2012,7 @@
1859
2012
  var result = false;
1860
2013
  if (_isMgrEnabled(cookieMgr)) {
1861
2014
  var values = {};
1862
- var theValue = strTrim(value || strEmpty);
2015
+ var theValue = strTrim(value || strEmpty$1);
1863
2016
  var idx = theValue.indexOf(";");
1864
2017
  if (idx !== -1) {
1865
2018
  theValue = strTrim(value.substring(0, idx));
@@ -1874,11 +2027,11 @@
1874
2027
  if (expireMs > 0) {
1875
2028
  var expiry = new Date();
1876
2029
  expiry.setTime(expireMs);
1877
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
2030
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1878
2031
  }
1879
2032
  }
1880
2033
  if (!_isIE) {
1881
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
2034
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1882
2035
  }
1883
2036
  }
1884
2037
  var location_1 = getLocation();
@@ -1899,7 +2052,7 @@
1899
2052
  return result;
1900
2053
  },
1901
2054
  get: function (name) {
1902
- var value = strEmpty;
2055
+ var value = strEmpty$1;
1903
2056
  if (_isMgrEnabled(cookieMgr)) {
1904
2057
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1905
2058
  }
@@ -1924,7 +2077,7 @@
1924
2077
  values["max-age"] = "0";
1925
2078
  }
1926
2079
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1927
- delCookie(name, _formatCookieValue(strEmpty, values));
2080
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1928
2081
  result = true;
1929
2082
  }
1930
2083
  return result;
@@ -1941,7 +2094,7 @@
1941
2094
  _supportsCookies = doc[strCookie] !== undefined;
1942
2095
  }
1943
2096
  catch (e) {
1944
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2097
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1945
2098
  }
1946
2099
  }
1947
2100
  return _supportsCookies;
@@ -1951,7 +2104,7 @@
1951
2104
  if (theValue && theValue.length) {
1952
2105
  var parts = strTrim(theValue).split(";");
1953
2106
  arrForEach(parts, function (thePart) {
1954
- thePart = strTrim(thePart || strEmpty);
2107
+ thePart = strTrim(thePart || strEmpty$1);
1955
2108
  if (thePart) {
1956
2109
  var idx = thePart.indexOf("=");
1957
2110
  if (idx === -1) {
@@ -1972,21 +2125,21 @@
1972
2125
  return null;
1973
2126
  }
1974
2127
  function _formatCookieValue(value, values) {
1975
- var cookieValue = value || strEmpty;
2128
+ var cookieValue = value || strEmpty$1;
1976
2129
  objForEachKey(values, function (name, theValue) {
1977
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
2130
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1978
2131
  });
1979
2132
  return cookieValue;
1980
2133
  }
1981
2134
  function _getCookieValue(name) {
1982
- var cookieValue = strEmpty;
2135
+ var cookieValue = strEmpty$1;
1983
2136
  if (_doc) {
1984
- var theCookie = _doc[strCookie] || strEmpty;
2137
+ var theCookie = _doc[strCookie] || strEmpty$1;
1985
2138
  if (_parsedCookieValue !== theCookie) {
1986
2139
  _cookieCache = _extractParts(theCookie);
1987
2140
  _parsedCookieValue = theCookie;
1988
2141
  }
1989
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
2142
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1990
2143
  }
1991
2144
  return cookieValue;
1992
2145
  }
@@ -2042,87 +2195,110 @@
2042
2195
  }
2043
2196
  }
2044
2197
  function createChannelControllerPlugin(channelQueue, core) {
2045
- function _getTelCtx(itemCtx) {
2046
- if (!itemCtx) {
2047
- itemCtx = createProcessTelemetryContext(null, core.config, core, null);
2198
+ var _a;
2199
+ function _getTelCtx() {
2200
+ return createProcessTelemetryContext(null, core.config, core, null);
2201
+ }
2202
+ function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
2203
+ var waiting = theChannels ? (theChannels.length + 1) : 1;
2204
+ function _runChainOnComplete() {
2205
+ waiting--;
2206
+ if (waiting === 0) {
2207
+ onComplete && onComplete();
2208
+ onComplete = null;
2209
+ }
2048
2210
  }
2049
- return itemCtx;
2050
- }
2051
- function _processChannelQueue(itemCtx, processFn, onComplete) {
2052
- if (channelQueue && channelQueue.length > 0) {
2053
- var waiting_1 = channelQueue.length;
2054
- arrForEach(channelQueue, function (channels) {
2211
+ if (waiting > 0) {
2212
+ arrForEach(theChannels, function (channels) {
2055
2213
  if (channels && channels.queue.length > 0) {
2056
2214
  var channelChain = channels.chain;
2057
- var chainCtx = _getTelCtx(itemCtx).createNew(channelChain);
2058
- chainCtx.onComplete(function () {
2059
- waiting_1--;
2060
- if (waiting_1 === 0) {
2061
- onComplete && onComplete();
2062
- onComplete = null;
2063
- }
2064
- });
2215
+ var chainCtx = itemCtx.createNew(channelChain);
2216
+ chainCtx.onComplete(_runChainOnComplete);
2065
2217
  processFn(chainCtx);
2066
2218
  }
2067
2219
  else {
2068
- waiting_1--;
2220
+ waiting--;
2069
2221
  }
2070
2222
  });
2071
- if (waiting_1 === 0) {
2072
- onComplete && onComplete();
2073
- }
2074
- }
2075
- else {
2076
- onComplete && onComplete();
2077
2223
  }
2224
+ _runChainOnComplete();
2078
2225
  }
2079
- var isInitialized = false;
2080
- var channelController = {
2081
- identifier: "ChannelControllerPlugin",
2082
- priority: ChannelControllerPriority,
2083
- initialize: function (config, core, extensions, pluginChain) {
2084
- isInitialized = true;
2226
+ function _doTeardown(unloadCtx, unloadState) {
2227
+ var theUnloadState = unloadState || {
2228
+ reason: 0 ,
2229
+ isAsync: false
2230
+ };
2231
+ _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
2232
+ chainCtx[strProcessNext](theUnloadState);
2233
+ }, function () {
2234
+ unloadCtx[strProcessNext](theUnloadState);
2235
+ isInitialized = false;
2236
+ });
2237
+ return true;
2238
+ }
2239
+ function _getChannel(pluginIdentifier) {
2240
+ var thePlugin = null;
2241
+ if (channelQueue && channelQueue.length > 0) {
2085
2242
  arrForEach(channelQueue, function (channels) {
2086
2243
  if (channels && channels.queue.length > 0) {
2087
- initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2244
+ arrForEach(channels.queue, function (ext) {
2245
+ if (ext.identifier === pluginIdentifier) {
2246
+ thePlugin = ext;
2247
+ return -1;
2248
+ }
2249
+ });
2250
+ if (thePlugin) {
2251
+ return -1;
2252
+ }
2088
2253
  }
2089
2254
  });
2090
- },
2091
- isInitialized: function () { return isInitialized; },
2092
- processTelemetry: function (item, itemCtx) {
2093
- _processChannelQueue(itemCtx, function (chainCtx) {
2094
- chainCtx.processNext(item);
2095
- }, function () {
2096
- itemCtx.processNext(item);
2097
- });
2098
- },
2099
- pause: function () {
2100
- _processChannelQueue(null, function (chainCtx) {
2101
- chainCtx.iterate(function (plugin) {
2102
- plugin.pause && plugin.pause();
2255
+ }
2256
+ return thePlugin;
2257
+ }
2258
+ var isInitialized = false;
2259
+ var channelController = (_a = {
2260
+ identifier: "ChannelControllerPlugin",
2261
+ priority: ChannelControllerPriority,
2262
+ initialize: function (config, core, extensions, pluginChain) {
2263
+ isInitialized = true;
2264
+ arrForEach(channelQueue, function (channels) {
2265
+ if (channels && channels.queue.length > 0) {
2266
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2267
+ }
2103
2268
  });
2104
- });
2269
+ },
2270
+ isInitialized: function () { return isInitialized; },
2271
+ processTelemetry: function (item, itemCtx) {
2272
+ _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
2273
+ chainCtx[strProcessNext](item);
2274
+ }, function () {
2275
+ itemCtx[strProcessNext](item);
2276
+ });
2277
+ }
2105
2278
  },
2106
- resume: function () {
2107
- _processChannelQueue(null, function (chainCtx) {
2279
+ _a[strPause] = function () {
2280
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2108
2281
  chainCtx.iterate(function (plugin) {
2109
- plugin.resume && plugin.resume();
2282
+ plugin[strPause] && plugin[strPause]();
2110
2283
  });
2111
- });
2284
+ }, null);
2112
2285
  },
2113
- teardown: function () {
2114
- _processChannelQueue(null, function (chainCtx) {
2286
+ _a[strResume] = function () {
2287
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2115
2288
  chainCtx.iterate(function (plugin) {
2116
- plugin.teardown && plugin.teardown();
2289
+ plugin[strResume] && plugin[strResume]();
2117
2290
  });
2118
- });
2291
+ }, null);
2119
2292
  },
2120
- flush: function (isAsync, callBack, sendReason, cbTimeout) {
2293
+ _a[strTeardown] = _doTeardown,
2294
+ _a.getChannel = _getChannel,
2295
+ _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
2296
+ var waiting = 1;
2121
2297
  var doneIterating = false;
2122
- var waiting = 0;
2123
2298
  var cbTimer = null;
2124
2299
  cbTimeout = cbTimeout || 5000;
2125
2300
  function doCallback() {
2301
+ waiting--;
2126
2302
  if (doneIterating && waiting === 0) {
2127
2303
  if (cbTimer) {
2128
2304
  clearTimeout(cbTimer);
@@ -2132,32 +2308,38 @@
2132
2308
  callBack = null;
2133
2309
  }
2134
2310
  }
2135
- waiting = 1;
2136
- _processChannelQueue(null, function (chainCtx) {
2311
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2137
2312
  chainCtx.iterate(function (plugin) {
2138
2313
  if (plugin.flush) {
2139
2314
  waiting++;
2315
+ var handled_1 = false;
2140
2316
  if (!plugin.flush(isAsync, function () {
2141
- waiting--;
2317
+ handled_1 = true;
2142
2318
  doCallback();
2143
2319
  }, sendReason)) {
2144
- if (cbTimer == null) {
2145
- cbTimer = setTimeout(function () {
2146
- cbTimer = null;
2147
- callBack && callBack(false);
2148
- callBack = null;
2149
- }, cbTimeout);
2320
+ if (!handled_1) {
2321
+ if (isAsync && cbTimer == null) {
2322
+ cbTimer = setTimeout(function () {
2323
+ cbTimer = null;
2324
+ doCallback();
2325
+ }, cbTimeout);
2326
+ }
2327
+ else {
2328
+ doCallback();
2329
+ }
2150
2330
  }
2151
2331
  }
2152
2332
  }
2153
2333
  });
2154
2334
  }, function () {
2155
- waiting--;
2156
2335
  doneIterating = true;
2157
2336
  doCallback();
2158
2337
  });
2159
- }
2160
- };
2338
+ },
2339
+ _a._setQueue = function (queue) {
2340
+ channelQueue = queue;
2341
+ },
2342
+ _a);
2161
2343
  return channelController;
2162
2344
  }
2163
2345
  function createChannelQueues(channels, extensions, config, core) {
@@ -2191,6 +2373,38 @@
2191
2373
  _setDefaults(config, core, pluginChain);
2192
2374
  _isinitialized = true;
2193
2375
  };
2376
+ _self.teardown = function (unloadCtx, unloadState) {
2377
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
2378
+ return;
2379
+ }
2380
+ var result;
2381
+ var unloadDone = false;
2382
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2383
+ var theUnloadState = unloadState || {
2384
+ reason: 0 ,
2385
+ isAsync: false
2386
+ };
2387
+ function _unloadCallback() {
2388
+ if (!unloadDone) {
2389
+ unloadDone = true;
2390
+ arrForEach(_hooks, function (fn) {
2391
+ fn.rm();
2392
+ });
2393
+ _hooks = [];
2394
+ if (result === true) {
2395
+ theUnloadCtx.processNext(theUnloadState);
2396
+ }
2397
+ _initDefaults();
2398
+ }
2399
+ }
2400
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2401
+ _unloadCallback();
2402
+ }
2403
+ else {
2404
+ result = true;
2405
+ }
2406
+ return result;
2407
+ };
2194
2408
  _self._addHook = function (hooks) {
2195
2409
  if (hooks) {
2196
2410
  if (isArray(hooks)) {
@@ -2205,13 +2419,13 @@
2205
2419
  _self.diagLog = function (itemCtx) {
2206
2420
  return _getTelCtx(itemCtx).diagLog();
2207
2421
  };
2208
- _self.isInitialized = function () {
2422
+ _self[strIsInitialized] = function () {
2209
2423
  return _isinitialized;
2210
2424
  };
2211
2425
  _self.setInitialized = function (isInitialized) {
2212
2426
  _isinitialized = isInitialized;
2213
2427
  };
2214
- _self.setNextPlugin = function (next) {
2428
+ _self[strSetNextPlugin] = function (next) {
2215
2429
  _nextPlugin = next;
2216
2430
  };
2217
2431
  _self.processNext = function (env, itemCtx) {
@@ -2303,7 +2517,7 @@
2303
2517
  }
2304
2518
  }
2305
2519
  catch (e) {
2306
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2520
+ itemCtx.diagLog().throwInternal(1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2307
2521
  }
2308
2522
  }
2309
2523
  }
@@ -2311,8 +2525,7 @@
2311
2525
  _self.processNext(item, itemCtx);
2312
2526
  }
2313
2527
  };
2314
- _self.unload = function (itemCtx, isAsync) {
2315
- _base.unload(itemCtx, isAsync);
2528
+ _self[strDoTeardown] = function () {
2316
2529
  _initDefaults();
2317
2530
  };
2318
2531
  });
@@ -2356,6 +2569,16 @@
2356
2569
  core: coreExtensions
2357
2570
  };
2358
2571
  }
2572
+ function _createDummyNotificationManager() {
2573
+ var _a;
2574
+ return objCreateFn((_a = {},
2575
+ _a[strAddNotificationListener] = function (listener) { },
2576
+ _a[strRemoveNotificationListener] = function (listener) { },
2577
+ _a[strEventsSent] = function (events) { },
2578
+ _a[strEventsDiscarded] = function (events, reason) { },
2579
+ _a[strEventsSendRequest] = function (sendReason, isAsync) { },
2580
+ _a));
2581
+ }
2359
2582
  var BaseCore = /** @class */ (function () {
2360
2583
  function BaseCore() {
2361
2584
  var _isInitialized;
@@ -2372,6 +2595,7 @@
2372
2595
  var _channelQueue;
2373
2596
  var _telemetryInitializerPlugin;
2374
2597
  var _internalLogsEventName;
2598
+ var _evtNamespace;
2375
2599
  var _debugListener;
2376
2600
  var _internalLogPoller = 0;
2377
2601
  dynamicProto(BaseCore, this, function (_self) {
@@ -2417,24 +2641,16 @@
2417
2641
  setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
2418
2642
  setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
2419
2643
  if (_self.isInitialized()) {
2420
- _self.getProcessTelContext().processNext(telemetryItem);
2644
+ _createTelCtx().processNext(telemetryItem);
2421
2645
  }
2422
2646
  else {
2423
2647
  _eventQueue.push(telemetryItem);
2424
2648
  }
2425
2649
  };
2426
- _self.getProcessTelContext = function () {
2427
- return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2428
- };
2650
+ _self.getProcessTelContext = _createTelCtx;
2429
2651
  _self.getNotifyMgr = function () {
2430
2652
  if (!_notificationManager) {
2431
- _notificationManager = objCreateFn({
2432
- addNotificationListener: function (listener) { },
2433
- removeNotificationListener: function (listener) { },
2434
- eventsSent: function (events) { },
2435
- eventsDiscarded: function (events, reason) { },
2436
- eventsSendRequest: function (sendReason, isAsync) { }
2437
- });
2653
+ _notificationManager = _createDummyNotificationManager();
2438
2654
  _self[strNotificationManager] = _notificationManager;
2439
2655
  }
2440
2656
  return _notificationManager;
@@ -2477,7 +2693,7 @@
2477
2693
  var eventQueue = _eventQueue;
2478
2694
  _eventQueue = [];
2479
2695
  arrForEach(eventQueue, function (event) {
2480
- _self.getProcessTelContext().processNext(event);
2696
+ _createTelCtx().processNext(event);
2481
2697
  });
2482
2698
  }
2483
2699
  };
@@ -2504,9 +2720,12 @@
2504
2720
  };
2505
2721
  proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2506
2722
  _self.getPlugin = _getPlugin;
2723
+ _self.evtNamespace = function () {
2724
+ return _evtNamespace;
2725
+ };
2507
2726
  function _initDefaults() {
2508
2727
  _isInitialized = false;
2509
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
2728
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 });
2510
2729
  _self.config = null;
2511
2730
  _self._extensions = [];
2512
2731
  _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
@@ -2522,6 +2741,10 @@
2522
2741
  _channelConfig = null;
2523
2742
  _channelQueue = null;
2524
2743
  _internalLogsEventName = null;
2744
+ _evtNamespace = createUniqueNamespace("AIBaseCore", true);
2745
+ }
2746
+ function _createTelCtx() {
2747
+ return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2525
2748
  }
2526
2749
  function _initPluginChain(config) {
2527
2750
  var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
@@ -2529,26 +2752,49 @@
2529
2752
  _pluginChain = null;
2530
2753
  var allExtensions = theExtensions.all;
2531
2754
  _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
2532
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2755
+ if (_channelControl) {
2756
+ var idx = allExtensions.indexOf(_channelControl);
2757
+ if (idx !== -1) {
2758
+ allExtensions.splice(idx, 1);
2759
+ }
2760
+ idx = _coreExtensions.indexOf(_channelControl);
2761
+ if (idx !== -1) {
2762
+ _coreExtensions.splice(idx, 1);
2763
+ }
2764
+ _channelControl._setQueue(_channelQueue);
2765
+ }
2766
+ else {
2767
+ _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2768
+ }
2533
2769
  allExtensions.push(_channelControl);
2534
2770
  _coreExtensions.push(_channelControl);
2535
2771
  _self._extensions = sortPlugins(allExtensions);
2536
2772
  _channelControl.initialize(config, _self, allExtensions);
2537
- initializePlugins(_self.getProcessTelContext(), allExtensions);
2773
+ initializePlugins(_createTelCtx(), allExtensions);
2538
2774
  _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
2539
2775
  }
2540
2776
  function _getPlugin(pluginIdentifier) {
2541
2777
  var theExt = null;
2542
2778
  var thePlugin = null;
2543
2779
  arrForEach(_self._extensions, function (ext) {
2544
- if (ext.identifier === pluginIdentifier) {
2780
+ if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
2545
2781
  thePlugin = ext;
2546
2782
  return -1;
2547
2783
  }
2548
2784
  });
2785
+ if (!thePlugin && _channelControl) {
2786
+ thePlugin = _channelControl.getChannel(pluginIdentifier);
2787
+ }
2549
2788
  if (thePlugin) {
2550
2789
  theExt = {
2551
- plugin: thePlugin
2790
+ plugin: thePlugin,
2791
+ setEnabled: function (enabled) {
2792
+ _getPluginState(thePlugin)[strDisabled] = !enabled;
2793
+ },
2794
+ isEnabled: function () {
2795
+ var pluginState = _getPluginState(thePlugin);
2796
+ return !pluginState[strTeardown] && !pluginState[strDisabled];
2797
+ }
2552
2798
  };
2553
2799
  }
2554
2800
  return theExt;
@@ -2556,7 +2802,9 @@
2556
2802
  function _getPluginChain() {
2557
2803
  if (!_pluginChain) {
2558
2804
  var extensions = (_coreExtensions || []).slice();
2559
- extensions.push(_telemetryInitializerPlugin);
2805
+ if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {
2806
+ extensions.push(_telemetryInitializerPlugin);
2807
+ }
2560
2808
  _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
2561
2809
  }
2562
2810
  return _pluginChain;
@@ -2579,12 +2827,12 @@
2579
2827
  }
2580
2828
  function _initDebugListener(config) {
2581
2829
  if (config.disableDbgExt === true && _debugListener) {
2582
- _notificationManager.removeNotificationListener(_debugListener);
2830
+ _notificationManager[strRemoveNotificationListener](_debugListener);
2583
2831
  _debugListener = null;
2584
2832
  }
2585
2833
  if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
2586
2834
  _debugListener = getDebugListener(config);
2587
- _notificationManager.addNotificationListener(_debugListener);
2835
+ _notificationManager[strAddNotificationListener](_debugListener);
2588
2836
  }
2589
2837
  }
2590
2838
  function _initPerfManager(config) {
@@ -2600,10 +2848,6 @@
2600
2848
  return BaseCore;
2601
2849
  }());
2602
2850
 
2603
- var strEventsSent = "eventsSent";
2604
- var strEventsDiscarded = "eventsDiscarded";
2605
- var strEventsSendRequest = "eventsSendRequest";
2606
- var strPerfEvent = "perfEvent";
2607
2851
  function _runListeners(listeners, name, isAsync, callback) {
2608
2852
  arrForEach(listeners, function (listener) {
2609
2853
  if (listener && listener[name]) {
@@ -2625,32 +2869,32 @@
2625
2869
  this.listeners = [];
2626
2870
  var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
2627
2871
  dynamicProto(NotificationManager, this, function (_self) {
2628
- _self.addNotificationListener = function (listener) {
2872
+ _self[strAddNotificationListener] = function (listener) {
2629
2873
  _self.listeners.push(listener);
2630
2874
  };
2631
- _self.removeNotificationListener = function (listener) {
2875
+ _self[strRemoveNotificationListener] = function (listener) {
2632
2876
  var index = arrIndexOf(_self.listeners, listener);
2633
2877
  while (index > -1) {
2634
2878
  _self.listeners.splice(index, 1);
2635
2879
  index = arrIndexOf(_self.listeners, listener);
2636
2880
  }
2637
2881
  };
2638
- _self.eventsSent = function (events) {
2882
+ _self[strEventsSent] = function (events) {
2639
2883
  _runListeners(_self.listeners, strEventsSent, true, function (listener) {
2640
2884
  listener[strEventsSent](events);
2641
2885
  });
2642
2886
  };
2643
- _self.eventsDiscarded = function (events, reason) {
2887
+ _self[strEventsDiscarded] = function (events, reason) {
2644
2888
  _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
2645
2889
  listener[strEventsDiscarded](events, reason);
2646
2890
  });
2647
2891
  };
2648
- _self.eventsSendRequest = function (sendReason, isAsync) {
2892
+ _self[strEventsSendRequest] = function (sendReason, isAsync) {
2649
2893
  _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
2650
2894
  listener[strEventsSendRequest](sendReason, isAsync);
2651
2895
  });
2652
2896
  };
2653
- _self.perfEvent = function (perfEvent) {
2897
+ _self[strPerfEvent] = function (perfEvent) {
2654
2898
  if (perfEvent) {
2655
2899
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
2656
2900
  _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
@@ -2705,147 +2949,179 @@
2705
2949
  return AppInsightsCore;
2706
2950
  }(BaseCore));
2707
2951
 
2708
- var UInt32Mask = 0x100000000;
2709
- var MaxUInt32 = 0xffffffff;
2710
- var _mwcSeeded = false;
2711
- var _mwcW = 123456789;
2712
- var _mwcZ = 987654321;
2713
- function _mwcSeed(seedValue) {
2714
- if (seedValue < 0) {
2715
- seedValue >>>= 0;
2952
+ var strOnPrefix = "on";
2953
+ var strAttachEvent = "attachEvent";
2954
+ var strAddEventHelper = "addEventListener";
2955
+ var strEvents = "events";
2956
+ var strVisibilityChangeEvt = "visibilitychange";
2957
+ var strPageHide = "pagehide";
2958
+ var strUnload = "unload";
2959
+ var strBeforeUnload = "beforeunload";
2960
+ var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
2961
+ createUniqueNamespace("aiEvtPageShow");
2962
+ var _guid = 1;
2963
+ var elmNodeData = createElmNodeData("events");
2964
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2965
+ function _normalizeNamespace(name) {
2966
+ if (name && name.replace) {
2967
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2968
+ }
2969
+ return name;
2970
+ }
2971
+ function _getEvtNamespace(eventName, namespaces) {
2972
+ if (namespaces) {
2973
+ var theNamespace_1 = "";
2974
+ if (isArray(namespaces)) {
2975
+ theNamespace_1 = "";
2976
+ arrForEach(namespaces, function (name) {
2977
+ name = _normalizeNamespace(name);
2978
+ if (name) {
2979
+ if (name[0] !== ".") {
2980
+ name = "." + name;
2981
+ }
2982
+ theNamespace_1 += name;
2983
+ }
2984
+ });
2985
+ }
2986
+ else {
2987
+ theNamespace_1 = _normalizeNamespace(namespaces);
2988
+ }
2989
+ if (theNamespace_1) {
2990
+ if (theNamespace_1[0] !== ".") {
2991
+ theNamespace_1 = "." + theNamespace_1;
2992
+ }
2993
+ eventName = (eventName || "") + theNamespace_1;
2994
+ }
2716
2995
  }
2717
- _mwcW = (123456789 + seedValue) & MaxUInt32;
2718
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
2719
- _mwcSeeded = true;
2996
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
2997
+ return {
2998
+ type: parsedEvent[1],
2999
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
3000
+ };
2720
3001
  }
2721
- function _autoSeedMwc() {
2722
- try {
2723
- var now = dateNow() & 0x7fffffff;
2724
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2725
- }
2726
- catch (e) {
3002
+ function _getRegisteredEvents(target, evtName, addDefault) {
3003
+ if (addDefault === void 0) { addDefault = true; }
3004
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
3005
+ var registeredEvents = aiEvts[evtName];
3006
+ if (!registeredEvents) {
3007
+ registeredEvents = aiEvts[evtName] = [];
2727
3008
  }
3009
+ return registeredEvents;
2728
3010
  }
2729
- function randomValue(maxValue) {
2730
- if (maxValue > 0) {
2731
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
2732
- }
2733
- return 0;
2734
- }
2735
- function random32(signed) {
2736
- var value = 0;
2737
- var c = getCrypto() || getMsCrypto();
2738
- if (c && c.getRandomValues) {
2739
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
2740
- }
2741
- if (value === 0 && isIE()) {
2742
- if (!_mwcSeeded) {
2743
- _autoSeedMwc();
3011
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
3012
+ var result = false;
3013
+ if (obj && evtName && evtName.type && handlerRef) {
3014
+ if (obj[strAddEventHelper]) {
3015
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
3016
+ result = true;
3017
+ }
3018
+ else if (obj[strAttachEvent]) {
3019
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
3020
+ result = true;
2744
3021
  }
2745
- value = mwcRandom32() & MaxUInt32;
2746
- }
2747
- if (value === 0) {
2748
- value = Math.floor((UInt32Mask * Math.random()) | 0);
2749
- }
2750
- if (!signed) {
2751
- value >>>= 0;
2752
3022
  }
2753
- return value;
3023
+ return result;
2754
3024
  }
2755
- function mwcRandomSeed(value) {
2756
- if (!value) {
2757
- _autoSeedMwc();
3025
+ function mergeEvtNamespace(theNamespace, namespaces) {
3026
+ var newNamespaces;
3027
+ if (namespaces) {
3028
+ if (isArray(namespaces)) {
3029
+ newNamespaces = [theNamespace].concat(namespaces);
3030
+ }
3031
+ else {
3032
+ newNamespaces = [theNamespace, namespaces];
3033
+ }
2758
3034
  }
2759
3035
  else {
2760
- _mwcSeed(value);
3036
+ newNamespaces = theNamespace;
2761
3037
  }
3038
+ return newNamespaces;
2762
3039
  }
2763
- function mwcRandom32(signed) {
2764
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
2765
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
2766
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
2767
- if (!signed) {
2768
- value >>>= 0;
2769
- }
2770
- return value;
2771
- }
2772
- function newId(maxLength) {
2773
- if (maxLength === void 0) { maxLength = 22; }
2774
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2775
- var number = random32() >>> 0;
2776
- var chars = 0;
2777
- var result = "";
2778
- while (result.length < maxLength) {
2779
- chars++;
2780
- result += base64chars.charAt(number & 0x3F);
2781
- number >>>= 6;
2782
- if (chars === 5) {
2783
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2784
- chars = 0;
3040
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
3041
+ if (useCapture === void 0) { useCapture = false; }
3042
+ var result = false;
3043
+ if (target) {
3044
+ try {
3045
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
3046
+ result = _doAttach(target, evtName, handlerRef, useCapture);
3047
+ if (result && elmNodeData.accept(target)) {
3048
+ var registeredEvent = {
3049
+ guid: _guid++,
3050
+ evtName: evtName,
3051
+ handler: handlerRef,
3052
+ capture: useCapture
3053
+ };
3054
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
3055
+ }
3056
+ }
3057
+ catch (e) {
2785
3058
  }
2786
3059
  }
2787
3060
  return result;
2788
3061
  }
2789
-
2790
- var strVisibilityChangeEvt = "visibilitychange";
2791
- var strPageHide = "pagehide";
2792
- var _cookieMgrs = null;
2793
- var _canUseCookies;
2794
- function addEventHandler(eventName, callback) {
3062
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3063
+ if (useCapture === void 0) { useCapture = false; }
3064
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3065
+ }
3066
+ function addEventHandler(eventName, callback, evtNamespace) {
2795
3067
  var result = false;
2796
3068
  var w = getWindow();
2797
3069
  if (w) {
2798
- result = attachEvent(w, eventName, callback);
2799
- result = attachEvent(w["body"], eventName, callback) || result;
3070
+ result = eventOn(w, eventName, callback, evtNamespace);
3071
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2800
3072
  }
2801
3073
  var doc = getDocument();
2802
3074
  if (doc) {
2803
- result = attachEvent(doc, eventName, callback) || result;
3075
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
2804
3076
  }
2805
3077
  return result;
2806
3078
  }
2807
- function addEventListeners(events, listener, excludeEvents) {
3079
+ function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
2808
3080
  var added = false;
2809
- if (listener && events && isArray(events)) {
2810
- var excluded_1 = [];
3081
+ if (listener && events && events.length > 0) {
2811
3082
  arrForEach(events, function (name) {
2812
- if (isString(name)) {
3083
+ if (name) {
2813
3084
  if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
2814
- added = addEventHandler(name, listener) || added;
2815
- }
2816
- else {
2817
- excluded_1.push(name);
3085
+ added = addEventHandler(name, listener, evtNamespace) || added;
2818
3086
  }
2819
3087
  }
2820
3088
  });
2821
- if (!added && excluded_1.length > 0) {
2822
- added = addEventListeners(excluded_1, listener);
3089
+ }
3090
+ return added;
3091
+ }
3092
+ function addEventListeners(events, listener, excludeEvents, evtNamespace) {
3093
+ var added = false;
3094
+ if (listener && events && isArray(events)) {
3095
+ added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
3096
+ if (!added && excludeEvents && excludeEvents.length > 0) {
3097
+ added = _addEventListeners(events, listener, null, evtNamespace);
2823
3098
  }
2824
3099
  }
2825
3100
  return added;
2826
3101
  }
2827
- function addPageUnloadEventListener(listener, excludeEvents) {
2828
- return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
3102
+ function addPageUnloadEventListener(listener, excludeEvents, evtNamespace) {
3103
+ return addEventListeners([strBeforeUnload, strUnload, strPageHide], listener, excludeEvents, evtNamespace);
2829
3104
  }
2830
- function addPageHideEventListener(listener, excludeEvents) {
3105
+ function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
2831
3106
  function _handlePageVisibility(evt) {
2832
3107
  var doc = getDocument();
2833
3108
  if (listener && doc && doc.visibilityState === "hidden") {
2834
3109
  listener(evt);
2835
3110
  }
2836
3111
  }
2837
- var pageUnloadAdded = false;
2838
- if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
2839
- pageUnloadAdded = addEventHandler(strPageHide, listener);
2840
- }
3112
+ var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
3113
+ var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
2841
3114
  if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
2842
- pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
3115
+ pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
2843
3116
  }
2844
3117
  if (!pageUnloadAdded && excludeEvents) {
2845
- pageUnloadAdded = addPageHideEventListener(listener);
3118
+ pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
2846
3119
  }
2847
3120
  return pageUnloadAdded;
2848
3121
  }
3122
+
3123
+ var _cookieMgrs = null;
3124
+ var _canUseCookies;
2849
3125
  function newGuid() {
2850
3126
  function randomHexDigit() {
2851
3127
  return randomValue(15);
@@ -2864,7 +3140,7 @@
2864
3140
  }
2865
3141
  function generateW3CId() {
2866
3142
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2867
- var oct = "", tmp;
3143
+ var oct = strEmpty$1, tmp;
2868
3144
  for (var a = 0; a < 4; a++) {
2869
3145
  tmp = random32();
2870
3146
  oct +=
@@ -2959,6 +3235,95 @@
2959
3235
  return _legacyCookieMgr(null, logger).del(name);
2960
3236
  }
2961
3237
 
3238
+ var LoggingSeverity = createEnumStyle({
3239
+ CRITICAL: 1 ,
3240
+ WARNING: 2
3241
+ });
3242
+ var _InternalMessageId = createEnumStyle({
3243
+ BrowserDoesNotSupportLocalStorage: 0 ,
3244
+ BrowserCannotReadLocalStorage: 1 ,
3245
+ BrowserCannotReadSessionStorage: 2 ,
3246
+ BrowserCannotWriteLocalStorage: 3 ,
3247
+ BrowserCannotWriteSessionStorage: 4 ,
3248
+ BrowserFailedRemovalFromLocalStorage: 5 ,
3249
+ BrowserFailedRemovalFromSessionStorage: 6 ,
3250
+ CannotSendEmptyTelemetry: 7 ,
3251
+ ClientPerformanceMathError: 8 ,
3252
+ ErrorParsingAISessionCookie: 9 ,
3253
+ ErrorPVCalc: 10 ,
3254
+ ExceptionWhileLoggingError: 11 ,
3255
+ FailedAddingTelemetryToBuffer: 12 ,
3256
+ FailedMonitorAjaxAbort: 13 ,
3257
+ FailedMonitorAjaxDur: 14 ,
3258
+ FailedMonitorAjaxOpen: 15 ,
3259
+ FailedMonitorAjaxRSC: 16 ,
3260
+ FailedMonitorAjaxSend: 17 ,
3261
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
3262
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
3263
+ FailedToSendQueuedTelemetry: 20 ,
3264
+ FailedToReportDataLoss: 21 ,
3265
+ FlushFailed: 22 ,
3266
+ MessageLimitPerPVExceeded: 23 ,
3267
+ MissingRequiredFieldSpecification: 24 ,
3268
+ NavigationTimingNotSupported: 25 ,
3269
+ OnError: 26 ,
3270
+ SessionRenewalDateIsZero: 27 ,
3271
+ SenderNotInitialized: 28 ,
3272
+ StartTrackEventFailed: 29 ,
3273
+ StopTrackEventFailed: 30 ,
3274
+ StartTrackFailed: 31 ,
3275
+ StopTrackFailed: 32 ,
3276
+ TelemetrySampledAndNotSent: 33 ,
3277
+ TrackEventFailed: 34 ,
3278
+ TrackExceptionFailed: 35 ,
3279
+ TrackMetricFailed: 36 ,
3280
+ TrackPVFailed: 37 ,
3281
+ TrackPVFailedCalc: 38 ,
3282
+ TrackTraceFailed: 39 ,
3283
+ TransmissionFailed: 40 ,
3284
+ FailedToSetStorageBuffer: 41 ,
3285
+ FailedToRestoreStorageBuffer: 42 ,
3286
+ InvalidBackendResponse: 43 ,
3287
+ FailedToFixDepricatedValues: 44 ,
3288
+ InvalidDurationValue: 45 ,
3289
+ TelemetryEnvelopeInvalid: 46 ,
3290
+ CreateEnvelopeError: 47 ,
3291
+ CannotSerializeObject: 48 ,
3292
+ CannotSerializeObjectNonSerializable: 49 ,
3293
+ CircularReferenceDetected: 50 ,
3294
+ ClearAuthContextFailed: 51 ,
3295
+ ExceptionTruncated: 52 ,
3296
+ IllegalCharsInName: 53 ,
3297
+ ItemNotInArray: 54 ,
3298
+ MaxAjaxPerPVExceeded: 55 ,
3299
+ MessageTruncated: 56 ,
3300
+ NameTooLong: 57 ,
3301
+ SampleRateOutOfRange: 58 ,
3302
+ SetAuthContextFailed: 59 ,
3303
+ SetAuthContextFailedAccountName: 60 ,
3304
+ StringValueTooLong: 61 ,
3305
+ StartCalledMoreThanOnce: 62 ,
3306
+ StopCalledWithoutStart: 63 ,
3307
+ TelemetryInitializerFailed: 64 ,
3308
+ TrackArgumentsNotSpecified: 65 ,
3309
+ UrlTooLong: 66 ,
3310
+ SessionStorageBufferFull: 67 ,
3311
+ CannotAccessCookie: 68 ,
3312
+ IdTooLong: 69 ,
3313
+ InvalidEvent: 70 ,
3314
+ FailedMonitorAjaxSetRequestHeader: 71 ,
3315
+ SendBrowserInfoOnUserInit: 72 ,
3316
+ PluginException: 73 ,
3317
+ NotificationException: 74 ,
3318
+ SnippetScriptLoadFailure: 99 ,
3319
+ InvalidInstrumentationKey: 100 ,
3320
+ CannotParseAiBlobValue: 101 ,
3321
+ InvalidContentBlob: 102 ,
3322
+ TrackPageActionEventFailed: 103 ,
3323
+ FailedAddingCustomDefinedRequestContext: 104 ,
3324
+ InMemoryStorageBufferFull: 105
3325
+ });
3326
+
2962
3327
  var aiInstrumentHooks = "_aiHooks";
2963
3328
  var cbNames = [
2964
3329
  "req", "rsp", "hkErr", "fnErr"
@@ -3134,7 +3499,7 @@
3134
3499
  name = strTrim(name.toString());
3135
3500
  if (name.length > 150 ) {
3136
3501
  nameTrunc = name.substring(0, 150 );
3137
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
3502
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
3138
3503
  }
3139
3504
  }
3140
3505
  return nameTrunc || name;
@@ -3147,7 +3512,7 @@
3147
3512
  value = strTrim(value);
3148
3513
  if (value.toString().length > maxLength) {
3149
3514
  valueTrunc = value.toString().substring(0, maxLength);
3150
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
3515
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
3151
3516
  }
3152
3517
  }
3153
3518
  return valueTrunc || value;
@@ -3160,7 +3525,7 @@
3160
3525
  if (message) {
3161
3526
  if (message.length > 32768 ) {
3162
3527
  messageTrunc = message.substring(0, 32768 );
3163
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
3528
+ logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
3164
3529
  }
3165
3530
  }
3166
3531
  return messageTrunc || message;
@@ -3171,7 +3536,7 @@
3171
3536
  var value = "" + exception;
3172
3537
  if (value.length > 32768 ) {
3173
3538
  exceptionTrunc = value.substring(0, 32768 );
3174
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
3539
+ logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
3175
3540
  }
3176
3541
  }
3177
3542
  return exceptionTrunc || exception;
@@ -3185,7 +3550,7 @@
3185
3550
  value = getJSON().stringify(value);
3186
3551
  }
3187
3552
  catch (e) {
3188
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
3553
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
3189
3554
  }
3190
3555
  }
3191
3556
  value = dataSanitizeString(logger, value, 8192 );
@@ -3216,7 +3581,7 @@
3216
3581
  input = strTrim(input);
3217
3582
  if (input.length > maxLength) {
3218
3583
  inputTrunc = input.substring(0, maxLength);
3219
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
3584
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
3220
3585
  }
3221
3586
  }
3222
3587
  return inputTrunc || input;
@@ -3262,6 +3627,7 @@
3262
3627
  return event;
3263
3628
  }
3264
3629
 
3630
+ var strEmpty = "";
3265
3631
  function stringToBoolOrDefault(str, defaultValue) {
3266
3632
  if (defaultValue === void 0) { defaultValue = false; }
3267
3633
  if (str === undefined || str === null) {
@@ -3274,16 +3640,16 @@
3274
3640
  totalms = 0;
3275
3641
  }
3276
3642
  totalms = Math.round(totalms);
3277
- var ms = "" + totalms % 1000;
3278
- var sec = "" + Math.floor(totalms / 1000) % 60;
3279
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
3280
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
3643
+ var ms = strEmpty + totalms % 1000;
3644
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
3645
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
3646
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
3281
3647
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
3282
3648
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
3283
3649
  sec = sec.length < 2 ? "0" + sec : sec;
3284
3650
  min = min.length < 2 ? "0" + min : min;
3285
3651
  hour = hour.length < 2 ? "0" + hour : hour;
3286
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
3652
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
3287
3653
  }
3288
3654
  function getExtensionByName(extensions, identifier) {
3289
3655
  var extension = null;
@@ -3307,17 +3673,15 @@
3307
3673
  var strNotSpecified = "not_specified";
3308
3674
  var strIkey = "iKey";
3309
3675
 
3310
- var StorageType;
3311
- (function (StorageType) {
3312
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
3313
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
3314
- })(StorageType || (StorageType = {}));
3315
- var DistributedTracingModes;
3316
- (function (DistributedTracingModes) {
3317
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
3318
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
3319
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
3320
- })(DistributedTracingModes || (DistributedTracingModes = {}));
3676
+ var StorageType = createEnumStyle({
3677
+ LocalStorage: 0 ,
3678
+ SessionStorage: 1
3679
+ });
3680
+ var DistributedTracingModes = createEnumStyle({
3681
+ AI: 0 ,
3682
+ AI_AND_W3C: 1 ,
3683
+ W3C: 2
3684
+ });
3321
3685
 
3322
3686
  var _canUseLocalStorage = undefined;
3323
3687
  var _canUseSessionStorage = undefined;
@@ -3369,7 +3733,7 @@
3369
3733
  }
3370
3734
  catch (e) {
3371
3735
  _canUseLocalStorage = false;
3372
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
3736
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
3373
3737
  }
3374
3738
  }
3375
3739
  return null;
@@ -3383,7 +3747,7 @@
3383
3747
  }
3384
3748
  catch (e) {
3385
3749
  _canUseLocalStorage = false;
3386
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
3750
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
3387
3751
  }
3388
3752
  }
3389
3753
  return false;
@@ -3397,7 +3761,7 @@
3397
3761
  }
3398
3762
  catch (e) {
3399
3763
  _canUseLocalStorage = false;
3400
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
3764
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
3401
3765
  }
3402
3766
  }
3403
3767
  return false;
@@ -3425,7 +3789,7 @@
3425
3789
  }
3426
3790
  catch (e) {
3427
3791
  _canUseSessionStorage = false;
3428
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3792
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3429
3793
  }
3430
3794
  }
3431
3795
  return null;
@@ -3439,7 +3803,7 @@
3439
3803
  }
3440
3804
  catch (e) {
3441
3805
  _canUseSessionStorage = false;
3442
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3806
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3443
3807
  }
3444
3808
  }
3445
3809
  return false;
@@ -3453,7 +3817,7 @@
3453
3817
  }
3454
3818
  catch (e) {
3455
3819
  _canUseSessionStorage = false;
3456
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
3820
+ logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
3457
3821
  }
3458
3822
  }
3459
3823
  return false;
@@ -5612,7 +5976,7 @@
5612
5976
  config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
5613
5977
  return config;
5614
5978
  };
5615
- ApplicationInsights.Version = "2.8.0-beta.2202-06";
5979
+ ApplicationInsights.Version = "2.8.0-beta.2203-02";
5616
5980
  return ApplicationInsights;
5617
5981
  }(BaseTelemetryPlugin));
5618
5982
  var Timing = /** @class */ (function () {
@@ -5919,7 +6283,7 @@
5919
6283
  }
5920
6284
  }
5921
6285
  var EnvelopeCreator = {
5922
- Version: "2.8.0-beta.2202-06"
6286
+ Version: "2.8.0-beta.2203-02"
5923
6287
  };
5924
6288
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
5925
6289
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -7188,7 +7552,7 @@
7188
7552
  return Device;
7189
7553
  }());
7190
7554
 
7191
- var Version = "2.8.0-beta.2202-06";
7555
+ var Version = "2.8.0-beta.2203-02";
7192
7556
  var Internal = /** @class */ (function () {
7193
7557
  function Internal(config) {
7194
7558
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;
@@ -7872,19 +8236,21 @@
7872
8236
  var _enableAjaxPerfTracking = false;
7873
8237
  var _maxAjaxCallsPerView = 0;
7874
8238
  var _enableResponseHeaderTracking = false;
7875
- var _hooks = [];
7876
8239
  var _disabledUrls = {};
7877
8240
  var _excludeRequestFromAutoTrackingPatterns;
7878
8241
  var _addRequestContext;
7879
- dynamicProto(AjaxMonitor, _this, function (_self, base) {
8242
+ var _evtNamespace;
8243
+ dynamicProto(AjaxMonitor, _this, function (_self, _base) {
8244
+ var _addHook = _base._addHook;
7880
8245
  _self.initialize = function (config, core, extensions, pluginChain) {
7881
8246
  if (!_self.isInitialized()) {
7882
- base.initialize(config, core, extensions, pluginChain);
8247
+ _base.initialize(config, core, extensions, pluginChain);
7883
8248
  var ctx_1 = _self._getTelCtx();
7884
8249
  var defaultConfig = AjaxMonitor.getDefaultConfig();
7885
8250
  objForEachKey(defaultConfig, function (field, value) {
7886
8251
  _config[field] = ctx_1.getConfig(AjaxMonitor.identifier, field, value);
7887
8252
  });
8253
+ _evtNamespace = mergeEvtNamespace(createUniqueNamespace("ajax"), core && core.evtNamespace && core.evtNamespace());
7888
8254
  var distributedTracingMode = _config.distributedTracingMode;
7889
8255
  _enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
7890
8256
  _enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
@@ -7893,8 +8259,8 @@
7893
8259
  _enableResponseHeaderTracking = _config.enableResponseHeaderTracking;
7894
8260
  _excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
7895
8261
  _addRequestContext = _config.addRequestContext;
7896
- _isUsingAIHeaders = distributedTracingMode === DistributedTracingModes.AI || distributedTracingMode === DistributedTracingModes.AI_AND_W3C;
7897
- _isUsingW3CHeaders = distributedTracingMode === DistributedTracingModes.AI_AND_W3C || distributedTracingMode === DistributedTracingModes.W3C;
8262
+ _isUsingAIHeaders = distributedTracingMode === 0 || distributedTracingMode === 1 ;
8263
+ _isUsingW3CHeaders = distributedTracingMode === 1 || distributedTracingMode === 2 ;
7898
8264
  if (_enableAjaxPerfTracking) {
7899
8265
  var iKey = config.instrumentationKey || "unkwn";
7900
8266
  if (iKey.length > 5) {
@@ -7922,14 +8288,9 @@
7922
8288
  }
7923
8289
  }
7924
8290
  };
7925
- _self.teardown = function () {
7926
- arrForEach(_hooks, function (fn) {
7927
- fn.rm();
7928
- });
7929
- _hooks = [];
8291
+ _self._doTeardown = function () {
7930
8292
  _fetchInitialized = false;
7931
8293
  _xhrInitialized = false;
7932
- _self.setInitialized(false);
7933
8294
  };
7934
8295
  _self.trackDependencyData = function (dependency, properties) {
7935
8296
  _self[strTrackDependencyDataInternal](dependency, properties);
@@ -7996,8 +8357,8 @@
7996
8357
  };
7997
8358
  _self[strTrackDependencyDataInternal] = function (dependency, properties, systemProperties) {
7998
8359
  if (_maxAjaxCallsPerView === -1 || _trackAjaxAttempts < _maxAjaxCallsPerView) {
7999
- if ((_config.distributedTracingMode === DistributedTracingModes.W3C
8000
- || _config.distributedTracingMode === DistributedTracingModes.AI_AND_W3C)
8360
+ if ((_config.distributedTracingMode === 2
8361
+ || _config.distributedTracingMode === 1 )
8001
8362
  && typeof dependency.id === "string" && dependency.id[dependency.id.length - 1] !== ".") {
8002
8363
  dependency.id += ".";
8003
8364
  }
@@ -8032,7 +8393,7 @@
8032
8393
  var global = getGlobal();
8033
8394
  var isPolyfill = fetch.polyfill;
8034
8395
  if (_config.disableFetchTracking === false) {
8035
- _hooks.push(InstrumentFunc(global, strFetch, {
8396
+ _addHook(InstrumentFunc(global, strFetch, {
8036
8397
  req: function (callDetails, input, init) {
8037
8398
  var fetchData;
8038
8399
  if (_fetchInitialized &&
@@ -8080,7 +8441,7 @@
8080
8441
  _fetchInitialized = true;
8081
8442
  }
8082
8443
  else if (isPolyfill) {
8083
- _hooks.push(InstrumentFunc(global, strFetch, {
8444
+ _addHook(InstrumentFunc(global, strFetch, {
8084
8445
  req: function (callDetails, input, init) {
8085
8446
  _isDisabledRequest(null, input, init);
8086
8447
  }
@@ -8091,7 +8452,7 @@
8091
8452
  }
8092
8453
  }
8093
8454
  function _hookProto(target, funcName, callbacks) {
8094
- _hooks.push(InstrumentProto(target, funcName, callbacks));
8455
+ _addHook(InstrumentProto(target, funcName, callbacks));
8095
8456
  }
8096
8457
  function _instrumentXhr() {
8097
8458
  if (_supportsAjaxMonitoring(_self) && !_xhrInitialized) {
@@ -8213,7 +8574,7 @@
8213
8574
  xhr[strAjaxData] = ajaxData;
8214
8575
  }
8215
8576
  function _attachToOnReadyStateChange(xhr) {
8216
- xhr[strAjaxData].xhrMonitoringState.stateChangeAttached = attachEvent(xhr, "readystatechange", function () {
8577
+ xhr[strAjaxData].xhrMonitoringState.stateChangeAttached = eventOn(xhr, "readystatechange", function () {
8217
8578
  try {
8218
8579
  if (xhr && xhr.readyState === 4 && _isMonitoredXhrInstance(xhr)) {
8219
8580
  _onAjaxComplete(xhr);
@@ -8228,7 +8589,7 @@
8228
8589
  });
8229
8590
  }
8230
8591
  }
8231
- });
8592
+ }, _evtNamespace);
8232
8593
  }
8233
8594
  function _getResponseText(xhr) {
8234
8595
  try {
@@ -8513,7 +8874,7 @@
8513
8874
  disableFetchTracking: true,
8514
8875
  excludeRequestFromAutoTrackingPatterns: undefined,
8515
8876
  disableCorrelationHeaders: false,
8516
- distributedTracingMode: DistributedTracingModes.AI_AND_W3C,
8877
+ distributedTracingMode: 1 ,
8517
8878
  correlationHeaderExcludedDomains: [
8518
8879
  "*.blob.core.windows.net",
8519
8880
  "*.blob.core.chinacloudapi.cn",