@microsoft/applicationinsights-web-basic 2.8.0-beta.2202-07 → 2.8.0-beta.2203-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser/aib.2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-03
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 cStrStartsWith = "startsWith";
@@ -453,7 +380,7 @@
453
380
  var strToString = "toString";
454
381
  var str__Proto = "__proto__";
455
382
  var strConstructor = "constructor";
456
- var _objDefineProperty = ObjDefineProperty;
383
+ var _objDefineProperty$1 = ObjDefineProperty;
457
384
  var _objFreeze = ObjClass.freeze;
458
385
  ObjClass.seal;
459
386
  var _objKeys = ObjClass.keys;
@@ -467,6 +394,9 @@
467
394
  var _objToString = ObjProto[strToString];
468
395
  var _fnToString = ObjHasOwnProperty[strToString];
469
396
  var _objFunctionString = _fnToString.call(ObjClass);
397
+ var rCamelCase = /-([a-z])/g;
398
+ var rNormalizeInvalid = /([^\w\d_$])/g;
399
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
470
400
  var _objGetPrototypeOf = Object["getPrototypeOf"];
471
401
  function _getObjProto(target) {
472
402
  if (target) {
@@ -501,24 +431,18 @@
501
431
  function isFunction(value) {
502
432
  return !!(value && typeof value === strShimFunction);
503
433
  }
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
- }
434
+ function normalizeJsName(name) {
435
+ var value = name;
436
+ if (value && isString(value)) {
437
+ value = value.replace(rCamelCase, function (_all, letter) {
438
+ return letter.toUpperCase();
439
+ });
440
+ value = value.replace(rNormalizeInvalid, "_");
441
+ value = value.replace(rLeadingNumeric, function (_all, match) {
442
+ return "_" + match;
443
+ });
520
444
  }
521
- return result;
445
+ return value;
522
446
  }
523
447
  function objForEachKey(target, callbackfn) {
524
448
  if (target) {
@@ -738,7 +662,7 @@
738
662
  return result;
739
663
  }
740
664
  function objDefineAccessors(target, prop, getProp, setProp) {
741
- if (_objDefineProperty) {
665
+ if (_objDefineProperty$1) {
742
666
  try {
743
667
  var descriptor = {
744
668
  enumerable: true,
@@ -750,7 +674,7 @@
750
674
  if (setProp) {
751
675
  descriptor.set = setProp;
752
676
  }
753
- _objDefineProperty(target, prop, descriptor);
677
+ _objDefineProperty$1(target, prop, descriptor);
754
678
  return true;
755
679
  }
756
680
  catch (e) {
@@ -770,7 +694,7 @@
770
694
  if (isError(object)) {
771
695
  return object.name;
772
696
  }
773
- return "";
697
+ return strEmpty$1;
774
698
  }
775
699
  function setValue(target, field, value, valChk, srcChk) {
776
700
  var theValue = value;
@@ -857,6 +781,17 @@
857
781
  return class_1;
858
782
  }());
859
783
  }
784
+ function createEnumStyle(values) {
785
+ var enumClass = {};
786
+ objForEachKey(values, function (field, value) {
787
+ enumClass[field] = value;
788
+ if (!isUndefined(enumClass[value])) {
789
+ throwError("[" + value + "] exists for " + field);
790
+ }
791
+ enumClass[value] = field;
792
+ });
793
+ return objFreeze(enumClass);
794
+ }
860
795
  function optimizeObject(theObject) {
861
796
  if (theObject && ObjAssign) {
862
797
  theObject = ObjClass(ObjAssign({}, theObject));
@@ -1028,7 +963,7 @@
1028
963
  var nav = getNavigator();
1029
964
  if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
1030
965
  _navUserAgentCheck = nav.userAgent;
1031
- var userAgent = (_navUserAgentCheck || "").toLowerCase();
966
+ var userAgent = (_navUserAgentCheck || strEmpty$1).toLowerCase();
1032
967
  _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1033
968
  }
1034
969
  return _isTrident;
@@ -1037,9 +972,9 @@
1037
972
  if (userAgentStr === void 0) { userAgentStr = null; }
1038
973
  if (!userAgentStr) {
1039
974
  var navigator_1 = getNavigator() || {};
1040
- userAgentStr = navigator_1 ? (navigator_1.userAgent || "").toLowerCase() : "";
975
+ userAgentStr = navigator_1 ? (navigator_1.userAgent || strEmpty$1).toLowerCase() : strEmpty$1;
1041
976
  }
1042
- var ua = (userAgentStr || "").toLowerCase();
977
+ var ua = (userAgentStr || strEmpty$1).toLowerCase();
1043
978
  if (strContains(ua, strMsie)) {
1044
979
  var doc = getDocument() || {};
1045
980
  return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
@@ -1054,7 +989,7 @@
1054
989
  }
1055
990
  function dumpObj(object) {
1056
991
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
1057
- var propertyValueDump = "";
992
+ var propertyValueDump = strEmpty$1;
1058
993
  if (objectTypeDump === "[object Error]") {
1059
994
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
1060
995
  }
@@ -1148,9 +1083,9 @@
1148
1083
  var strWarnToConsole = "warnToConsole";
1149
1084
  function _sanitizeDiagnosticText(text) {
1150
1085
  if (text) {
1151
- return "\"" + text.replace(/\"/g, "") + "\"";
1086
+ return "\"" + text.replace(/\"/g, strEmpty$1) + "\"";
1152
1087
  }
1153
- return "";
1088
+ return strEmpty$1;
1154
1089
  }
1155
1090
  function _logToConsole(func, message) {
1156
1091
  var theConsole = getConsole();
@@ -1172,12 +1107,12 @@
1172
1107
  _self.message =
1173
1108
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1174
1109
  msgId;
1175
- var strProps = "";
1110
+ var strProps = strEmpty$1;
1176
1111
  if (hasJSON()) {
1177
1112
  strProps = getJSON().stringify(properties);
1178
1113
  }
1179
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
1180
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
1114
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty$1) +
1115
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty$1);
1181
1116
  _self.message += diagnosticText;
1182
1117
  }
1183
1118
  _InternalLogMessage.dataType = "MessageData";
@@ -1207,7 +1142,7 @@
1207
1142
  throw message;
1208
1143
  }
1209
1144
  else {
1210
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
1145
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
1211
1146
  if (!isUndefined(message.message)) {
1212
1147
  var logLevel = _self.consoleLoggingLevel();
1213
1148
  if (isUserAct) {
@@ -1225,7 +1160,7 @@
1225
1160
  _self.logInternalMessage(severity, message);
1226
1161
  }
1227
1162
  else {
1228
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
1163
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1229
1164
  }
1230
1165
  }
1231
1166
  };
@@ -1257,13 +1192,13 @@
1257
1192
  if (severity <= _self.telemetryLoggingLevel()) {
1258
1193
  _self.queue.push(message);
1259
1194
  _messageCount++;
1260
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
1195
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1261
1196
  }
1262
1197
  if (_messageCount === _self.maxInternalMessageLimit()) {
1263
1198
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1264
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
1199
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1265
1200
  _self.queue.push(throttleMessage);
1266
- if (severity === LoggingSeverity.CRITICAL) {
1201
+ if (severity === 1 ) {
1267
1202
  _self.errorToConsole(throttleLimitMessage);
1268
1203
  }
1269
1204
  else {
@@ -1437,6 +1372,217 @@
1437
1372
  return _defaultPerfManager;
1438
1373
  }
1439
1374
 
1375
+ var UInt32Mask = 0x100000000;
1376
+ var MaxUInt32 = 0xffffffff;
1377
+ var _mwcSeeded = false;
1378
+ var _mwcW = 123456789;
1379
+ var _mwcZ = 987654321;
1380
+ function _mwcSeed(seedValue) {
1381
+ if (seedValue < 0) {
1382
+ seedValue >>>= 0;
1383
+ }
1384
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1385
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1386
+ _mwcSeeded = true;
1387
+ }
1388
+ function _autoSeedMwc() {
1389
+ try {
1390
+ var now = dateNow() & 0x7fffffff;
1391
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1392
+ }
1393
+ catch (e) {
1394
+ }
1395
+ }
1396
+ function randomValue(maxValue) {
1397
+ if (maxValue > 0) {
1398
+ return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1399
+ }
1400
+ return 0;
1401
+ }
1402
+ function random32(signed) {
1403
+ var value = 0;
1404
+ var c = getCrypto() || getMsCrypto();
1405
+ if (c && c.getRandomValues) {
1406
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1407
+ }
1408
+ if (value === 0 && isIE()) {
1409
+ if (!_mwcSeeded) {
1410
+ _autoSeedMwc();
1411
+ }
1412
+ value = mwcRandom32() & MaxUInt32;
1413
+ }
1414
+ if (value === 0) {
1415
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1416
+ }
1417
+ if (!signed) {
1418
+ value >>>= 0;
1419
+ }
1420
+ return value;
1421
+ }
1422
+ function mwcRandomSeed(value) {
1423
+ if (!value) {
1424
+ _autoSeedMwc();
1425
+ }
1426
+ else {
1427
+ _mwcSeed(value);
1428
+ }
1429
+ }
1430
+ function mwcRandom32(signed) {
1431
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1432
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1433
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1434
+ if (!signed) {
1435
+ value >>>= 0;
1436
+ }
1437
+ return value;
1438
+ }
1439
+ function newId(maxLength) {
1440
+ if (maxLength === void 0) { maxLength = 22; }
1441
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1442
+ var number = random32() >>> 0;
1443
+ var chars = 0;
1444
+ var result = strEmpty$1;
1445
+ while (result.length < maxLength) {
1446
+ chars++;
1447
+ result += base64chars.charAt(number & 0x3F);
1448
+ number >>>= 6;
1449
+ if (chars === 5) {
1450
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1451
+ chars = 0;
1452
+ }
1453
+ }
1454
+ return result;
1455
+ }
1456
+
1457
+ var _objDefineProperty = ObjDefineProperty;
1458
+ var version = "2.7.3";
1459
+ var instanceName = "." + newId(6);
1460
+ var _dataUid = 0;
1461
+ function _createAccessor(target, prop, value) {
1462
+ if (_objDefineProperty) {
1463
+ try {
1464
+ _objDefineProperty(target, prop, {
1465
+ value: value,
1466
+ enumerable: false,
1467
+ configurable: true
1468
+ });
1469
+ return true;
1470
+ }
1471
+ catch (e) {
1472
+ }
1473
+ }
1474
+ return false;
1475
+ }
1476
+ function _canAcceptData(target) {
1477
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1478
+ }
1479
+ function _getCache(data, target) {
1480
+ var theCache = target[data.id];
1481
+ if (!theCache) {
1482
+ theCache = {};
1483
+ try {
1484
+ if (_canAcceptData(target)) {
1485
+ if (!_createAccessor(target, data.id, theCache)) {
1486
+ target[data.id] = theCache;
1487
+ }
1488
+ }
1489
+ }
1490
+ catch (e) {
1491
+ }
1492
+ }
1493
+ return theCache;
1494
+ }
1495
+ function createUniqueNamespace(name, includeVersion) {
1496
+ if (includeVersion === void 0) { includeVersion = false; }
1497
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1498
+ }
1499
+ function createElmNodeData(name) {
1500
+ var data = {
1501
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1502
+ accept: function (target) {
1503
+ return _canAcceptData(target);
1504
+ },
1505
+ get: function (target, name, defValue, addDefault) {
1506
+ var theCache = target[data.id];
1507
+ if (!theCache) {
1508
+ if (addDefault) {
1509
+ theCache = _getCache(data, target);
1510
+ theCache[normalizeJsName(name)] = defValue;
1511
+ }
1512
+ return defValue;
1513
+ }
1514
+ return theCache[normalizeJsName(name)];
1515
+ },
1516
+ kill: function (target, name) {
1517
+ if (target && target[name]) {
1518
+ try {
1519
+ delete target[name];
1520
+ }
1521
+ catch (e) {
1522
+ }
1523
+ }
1524
+ }
1525
+ };
1526
+ return data;
1527
+ }
1528
+
1529
+ var pluginStateData = createElmNodeData("plugin");
1530
+ function _getPluginState(plugin) {
1531
+ return pluginStateData.get(plugin, "state", {}, true);
1532
+ }
1533
+ function initializePlugins(processContext, extensions) {
1534
+ var initPlugins = [];
1535
+ var lastPlugin = null;
1536
+ var proxy = processContext.getNext();
1537
+ var pluginState;
1538
+ while (proxy) {
1539
+ var thePlugin = proxy.getPlugin();
1540
+ if (thePlugin) {
1541
+ if (lastPlugin &&
1542
+ isFunction(lastPlugin[strSetNextPlugin]) &&
1543
+ isFunction(thePlugin[strProcessTelemetry])) {
1544
+ lastPlugin[strSetNextPlugin](thePlugin);
1545
+ }
1546
+ var isInitialized = false;
1547
+ if (isFunction(thePlugin[strIsInitialized])) {
1548
+ isInitialized = thePlugin[strIsInitialized]();
1549
+ }
1550
+ else {
1551
+ pluginState = _getPluginState(thePlugin);
1552
+ isInitialized = pluginState[strIsInitialized];
1553
+ }
1554
+ if (!isInitialized) {
1555
+ initPlugins.push(thePlugin);
1556
+ }
1557
+ lastPlugin = thePlugin;
1558
+ proxy = proxy.getNext();
1559
+ }
1560
+ }
1561
+ arrForEach(initPlugins, function (thePlugin) {
1562
+ var core = processContext.core();
1563
+ thePlugin.initialize(processContext.getCfg(), core, extensions, processContext.getNext());
1564
+ pluginState = _getPluginState(thePlugin);
1565
+ if (!thePlugin[strCore] && !pluginState[strCore]) {
1566
+ pluginState[strCore] = core;
1567
+ }
1568
+ pluginState[strIsInitialized] = true;
1569
+ delete pluginState[strTeardown];
1570
+ });
1571
+ }
1572
+ function sortPlugins(plugins) {
1573
+ return plugins.sort(function (extA, extB) {
1574
+ var result = 0;
1575
+ var bHasProcess = isFunction(extB[strProcessTelemetry]);
1576
+ if (isFunction(extA[strProcessTelemetry])) {
1577
+ result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
1578
+ }
1579
+ else if (bHasProcess) {
1580
+ result = -1;
1581
+ }
1582
+ return result;
1583
+ });
1584
+ }
1585
+
1440
1586
  var strTelemetryPluginChain = "TelemetryPluginChain";
1441
1587
  var strHasRunFlags = "_hasRun";
1442
1588
  var strGetTelCtx = "_getTelCtx";
@@ -1450,53 +1596,69 @@
1450
1596
  }
1451
1597
  return createTelemetryProxyChain([startAt], config, core);
1452
1598
  }
1453
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1599
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1454
1600
  var _nextProxy = null;
1455
- var _onComplete = null;
1456
- if (startAt) {
1457
- _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1458
- }
1459
- else {
1460
- _nextProxy = telemetryChain;
1601
+ var _onComplete = [];
1602
+ if (startAt !== null) {
1603
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1461
1604
  }
1462
1605
  var context = {
1463
- core: function () {
1464
- return core;
1465
- },
1466
- diagLog: function () {
1467
- return safeGetLogger(core, config);
1468
- },
1469
- getCfg: function () {
1470
- return config;
1471
- },
1472
- getExtCfg: _getExtCfg,
1473
- getConfig: _getConfig,
1474
- hasNext: function () {
1475
- return _nextProxy != null;
1476
- },
1477
- getNext: function () {
1478
- return _nextProxy;
1479
- },
1480
- setNext: function (nextPlugin) {
1481
- _nextProxy = nextPlugin;
1482
- },
1483
- processNext: function (env) {
1484
- _processChain(function (nextPlugin) {
1485
- nextPlugin.processTelemetry(env, context);
1606
+ _next: _moveNext,
1607
+ ctx: {
1608
+ core: function () { return core; },
1609
+ diagLog: function () {
1610
+ return safeGetLogger(core, config);
1611
+ },
1612
+ getCfg: function () {
1613
+ return config;
1614
+ },
1615
+ getExtCfg: _getExtCfg,
1616
+ getConfig: _getConfig,
1617
+ hasNext: function () {
1618
+ return !!_nextProxy;
1619
+ },
1620
+ getNext: function () {
1621
+ return _nextProxy;
1622
+ },
1623
+ setNext: function (nextPlugin) {
1624
+ _nextProxy = nextPlugin;
1625
+ },
1626
+ iterate: _iterateChain,
1627
+ onComplete: _addOnComplete
1628
+ }
1629
+ };
1630
+ function _addOnComplete(onComplete, that) {
1631
+ var args = [];
1632
+ for (var _i = 2; _i < arguments.length; _i++) {
1633
+ args[_i - 2] = arguments[_i];
1634
+ }
1635
+ if (onComplete) {
1636
+ _onComplete.push({
1637
+ func: onComplete,
1638
+ self: !isUndefined(that) ? that : context.ctx,
1639
+ args: args
1486
1640
  });
1487
- },
1488
- iterate: _iterateChain,
1489
- createNew: function (plugins, startAt) {
1490
- if (plugins === void 0) { plugins = null; }
1491
- if (isArray(plugins)) {
1492
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1641
+ }
1642
+ }
1643
+ function _moveNext() {
1644
+ var nextProxy = _nextProxy;
1645
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1646
+ if (!nextProxy) {
1647
+ var onComplete = _onComplete;
1648
+ if (onComplete && onComplete.length > 0) {
1649
+ arrForEach(onComplete, function (completeDetails) {
1650
+ try {
1651
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1652
+ }
1653
+ catch (e) {
1654
+ core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1655
+ }
1656
+ });
1657
+ _onComplete = [];
1493
1658
  }
1494
- return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1495
- },
1496
- onComplete: function (onComplete) {
1497
- _onComplete = onComplete;
1498
1659
  }
1499
- };
1660
+ return nextProxy;
1661
+ }
1500
1662
  function _getExtCfg(identifier, defaultValue, mergeDefault) {
1501
1663
  if (defaultValue === void 0) { defaultValue = {}; }
1502
1664
  if (mergeDefault === void 0) { mergeDefault = 0 ; }
@@ -1539,29 +1701,53 @@
1539
1701
  }
1540
1702
  return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1541
1703
  }
1542
- function _processChain(cb) {
1543
- var nextPlugin = _nextProxy;
1544
- if (nextPlugin) {
1545
- _nextProxy = nextPlugin.getNext();
1546
- cb(nextPlugin);
1547
- }
1548
- else {
1549
- if (_onComplete) {
1550
- _onComplete();
1551
- _onComplete = null;
1704
+ function _iterateChain(cb) {
1705
+ var nextPlugin;
1706
+ while (!!(nextPlugin = context._next())) {
1707
+ var plugin = nextPlugin.getPlugin();
1708
+ if (plugin) {
1709
+ cb(plugin);
1552
1710
  }
1553
1711
  }
1554
1712
  }
1555
- function _iterateChain(cb) {
1556
- while (_nextProxy) {
1557
- _processChain(function (nextPlugin) {
1558
- var plugin = nextPlugin.getPlugin();
1559
- if (plugin) {
1560
- cb(plugin);
1561
- }
1562
- });
1713
+ return context;
1714
+ }
1715
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1716
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1717
+ var context = internalContext.ctx;
1718
+ function _processNext(env) {
1719
+ var nextPlugin = internalContext._next();
1720
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1721
+ return !nextPlugin;
1722
+ }
1723
+ function _createNew(plugins, startAt) {
1724
+ if (plugins === void 0) { plugins = null; }
1725
+ if (isArray(plugins)) {
1726
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1727
+ }
1728
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1729
+ }
1730
+ context.processNext = _processNext;
1731
+ context.createNew = _createNew;
1732
+ return context;
1733
+ }
1734
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1735
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1736
+ var context = internalContext.ctx;
1737
+ function _processNext(unloadState) {
1738
+ var nextPlugin = internalContext._next();
1739
+ nextPlugin && nextPlugin.unload(context, unloadState);
1740
+ return !nextPlugin;
1741
+ }
1742
+ function _createNew(plugins, startAt) {
1743
+ if (plugins === void 0) { plugins = null; }
1744
+ if (isArray(plugins)) {
1745
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1563
1746
  }
1747
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1564
1748
  }
1749
+ context.processNext = _processNext;
1750
+ context.createNew = _createNew;
1565
1751
  return context;
1566
1752
  }
1567
1753
  function createTelemetryProxyChain(plugins, config, core, startAt) {
@@ -1609,32 +1795,35 @@
1609
1795
  return nextProxy;
1610
1796
  },
1611
1797
  processTelemetry: _processTelemetry,
1798
+ unload: _unloadPlugin,
1612
1799
  _id: chainId,
1613
1800
  _setNext: function (nextPlugin) {
1614
1801
  nextProxy = nextPlugin;
1615
1802
  }
1616
1803
  };
1617
- function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1804
+ function _getTelCtx() {
1805
+ var itemCtx;
1806
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1807
+ itemCtx = plugin[strGetTelCtx]();
1808
+ }
1618
1809
  if (!itemCtx) {
1619
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1620
- itemCtx = plugin[strGetTelCtx]();
1621
- }
1622
- if (!itemCtx) {
1623
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1624
- }
1810
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1625
1811
  }
1812
+ return itemCtx;
1813
+ }
1814
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1815
+ var hasRun = false;
1626
1816
  var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1627
1817
  var hasRunContext = itemCtx[strHasRunFlags];
1628
1818
  if (!hasRunContext) {
1629
1819
  hasRunContext = itemCtx[strHasRunFlags] = {};
1630
1820
  }
1631
- doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1632
- hasRunContext[chainId] = true;
1633
- var hasRun = false;
1634
- itemCtx.setNext(nextProxy);
1635
- if (plugin) {
1821
+ itemCtx.setNext(nextProxy);
1822
+ if (plugin) {
1823
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1824
+ hasRunContext[chainId] = true;
1636
1825
  try {
1637
- var nextId = nextProxy ? nextProxy._id : "";
1826
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1638
1827
  if (nextId) {
1639
1828
  hasRunContext[nextId] = false;
1640
1829
  }
@@ -1646,18 +1835,21 @@
1646
1835
  hasRun = true;
1647
1836
  }
1648
1837
  if (!nextProxy || !hasNextRun) {
1649
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1838
+ itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1650
1839
  }
1651
1840
  }
1652
- }
1653
- if (nextProxy && !hasRun) {
1654
- processProxyFn(itemCtx);
1655
- }
1656
- }, details, isAsync);
1841
+ }, details, isAsync);
1842
+ }
1843
+ return hasRun;
1657
1844
  }
1658
1845
  function _processTelemetry(env, itemCtx) {
1659
- _processChain(itemCtx, function (itemCtx) {
1660
- if (!hasProcessTelemetry) {
1846
+ itemCtx = itemCtx || _getTelCtx();
1847
+ function _callProcessTelemetry(itemCtx) {
1848
+ if (!plugin || !hasProcessTelemetry) {
1849
+ return false;
1850
+ }
1851
+ var pluginState = _getPluginState(plugin);
1852
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1661
1853
  return false;
1662
1854
  }
1663
1855
  if (hasSetNext) {
@@ -1665,52 +1857,33 @@
1665
1857
  }
1666
1858
  plugin.processTelemetry(env, itemCtx);
1667
1859
  return true;
1668
- }, function (itemCtx) {
1669
- nextProxy.processTelemetry(env, itemCtx);
1670
- }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1860
+ }
1861
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1862
+ itemCtx.processNext(env);
1863
+ }
1671
1864
  }
1672
- return objFreeze(proxyChain);
1673
- }
1674
-
1675
- var processTelemetry = "processTelemetry";
1676
- var priority = "priority";
1677
- var setNextPlugin = "setNextPlugin";
1678
- var isInitialized = "isInitialized";
1679
- function initializePlugins(processContext, extensions) {
1680
- var initPlugins = [];
1681
- var lastPlugin = null;
1682
- var proxy = processContext.getNext();
1683
- while (proxy) {
1684
- var thePlugin = proxy.getPlugin();
1685
- if (thePlugin) {
1686
- if (lastPlugin &&
1687
- isFunction(lastPlugin[setNextPlugin]) &&
1688
- isFunction(thePlugin[processTelemetry])) {
1689
- lastPlugin[setNextPlugin](thePlugin);
1690
- }
1691
- if (!isFunction(thePlugin[isInitialized]) || !thePlugin[isInitialized]()) {
1692
- initPlugins.push(thePlugin);
1865
+ function _unloadPlugin(unloadCtx, unloadState) {
1866
+ function _callTeardown() {
1867
+ var hasRun = false;
1868
+ if (plugin) {
1869
+ var pluginState = _getPluginState(plugin);
1870
+ var pluginCore = plugin[strCore] || pluginState.core;
1871
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1872
+ pluginState[strCore] = null;
1873
+ pluginState[strTeardown] = true;
1874
+ pluginState[strIsInitialized] = false;
1875
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1876
+ hasRun = true;
1877
+ }
1878
+ }
1693
1879
  }
1694
- lastPlugin = thePlugin;
1695
- proxy = proxy.getNext();
1880
+ return hasRun;
1881
+ }
1882
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1883
+ unloadCtx.processNext(unloadState);
1696
1884
  }
1697
1885
  }
1698
- arrForEach(initPlugins, function (thePlugin) {
1699
- thePlugin.initialize(processContext.getCfg(), processContext.core(), extensions, processContext.getNext());
1700
- });
1701
- }
1702
- function sortPlugins(plugins) {
1703
- return plugins.sort(function (extA, extB) {
1704
- var result = 0;
1705
- var bHasProcess = isFunction(extB[processTelemetry]);
1706
- if (isFunction(extA[processTelemetry])) {
1707
- result = bHasProcess ? extA[priority] - extB[priority] : 1;
1708
- }
1709
- else if (bHasProcess) {
1710
- result = -1;
1711
- }
1712
- return result;
1713
- });
1886
+ return objFreeze(proxyChain);
1714
1887
  }
1715
1888
 
1716
1889
  var strToGMTString = "toGMTString";
@@ -1721,7 +1894,6 @@
1721
1894
  var strIsCookieUseDisabled = "isCookieUseDisabled";
1722
1895
  var strDisableCookiesUsage = "disableCookiesUsage";
1723
1896
  var strConfigCookieMgr = "_ckMgr";
1724
- var strEmpty = "";
1725
1897
  var _supportsCookies = null;
1726
1898
  var _allowUaSameSite = null;
1727
1899
  var _parsedCookieValue = null;
@@ -1779,7 +1951,7 @@
1779
1951
  var result = false;
1780
1952
  if (_isMgrEnabled(cookieMgr)) {
1781
1953
  var values = {};
1782
- var theValue = strTrim(value || strEmpty);
1954
+ var theValue = strTrim(value || strEmpty$1);
1783
1955
  var idx = theValue.indexOf(";");
1784
1956
  if (idx !== -1) {
1785
1957
  theValue = strTrim(value.substring(0, idx));
@@ -1794,11 +1966,11 @@
1794
1966
  if (expireMs > 0) {
1795
1967
  var expiry = new Date();
1796
1968
  expiry.setTime(expireMs);
1797
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
1969
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1798
1970
  }
1799
1971
  }
1800
1972
  if (!_isIE) {
1801
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
1973
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1802
1974
  }
1803
1975
  }
1804
1976
  var location_1 = getLocation();
@@ -1819,7 +1991,7 @@
1819
1991
  return result;
1820
1992
  },
1821
1993
  get: function (name) {
1822
- var value = strEmpty;
1994
+ var value = strEmpty$1;
1823
1995
  if (_isMgrEnabled(cookieMgr)) {
1824
1996
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1825
1997
  }
@@ -1844,7 +2016,7 @@
1844
2016
  values["max-age"] = "0";
1845
2017
  }
1846
2018
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1847
- delCookie(name, _formatCookieValue(strEmpty, values));
2019
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1848
2020
  result = true;
1849
2021
  }
1850
2022
  return result;
@@ -1861,7 +2033,7 @@
1861
2033
  _supportsCookies = doc[strCookie] !== undefined;
1862
2034
  }
1863
2035
  catch (e) {
1864
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2036
+ logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1865
2037
  }
1866
2038
  }
1867
2039
  return _supportsCookies;
@@ -1871,7 +2043,7 @@
1871
2043
  if (theValue && theValue.length) {
1872
2044
  var parts = strTrim(theValue).split(";");
1873
2045
  arrForEach(parts, function (thePart) {
1874
- thePart = strTrim(thePart || strEmpty);
2046
+ thePart = strTrim(thePart || strEmpty$1);
1875
2047
  if (thePart) {
1876
2048
  var idx = thePart.indexOf("=");
1877
2049
  if (idx === -1) {
@@ -1892,21 +2064,21 @@
1892
2064
  return null;
1893
2065
  }
1894
2066
  function _formatCookieValue(value, values) {
1895
- var cookieValue = value || strEmpty;
2067
+ var cookieValue = value || strEmpty$1;
1896
2068
  objForEachKey(values, function (name, theValue) {
1897
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
2069
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1898
2070
  });
1899
2071
  return cookieValue;
1900
2072
  }
1901
2073
  function _getCookieValue(name) {
1902
- var cookieValue = strEmpty;
2074
+ var cookieValue = strEmpty$1;
1903
2075
  if (_doc) {
1904
- var theCookie = _doc[strCookie] || strEmpty;
2076
+ var theCookie = _doc[strCookie] || strEmpty$1;
1905
2077
  if (_parsedCookieValue !== theCookie) {
1906
2078
  _cookieCache = _extractParts(theCookie);
1907
2079
  _parsedCookieValue = theCookie;
1908
2080
  }
1909
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
2081
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1910
2082
  }
1911
2083
  return cookieValue;
1912
2084
  }
@@ -1962,87 +2134,110 @@
1962
2134
  }
1963
2135
  }
1964
2136
  function createChannelControllerPlugin(channelQueue, core) {
1965
- function _getTelCtx(itemCtx) {
1966
- if (!itemCtx) {
1967
- itemCtx = createProcessTelemetryContext(null, core.config, core, null);
2137
+ var _a;
2138
+ function _getTelCtx() {
2139
+ return createProcessTelemetryContext(null, core.config, core, null);
2140
+ }
2141
+ function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
2142
+ var waiting = theChannels ? (theChannels.length + 1) : 1;
2143
+ function _runChainOnComplete() {
2144
+ waiting--;
2145
+ if (waiting === 0) {
2146
+ onComplete && onComplete();
2147
+ onComplete = null;
2148
+ }
1968
2149
  }
1969
- return itemCtx;
1970
- }
1971
- function _processChannelQueue(itemCtx, processFn, onComplete) {
1972
- if (channelQueue && channelQueue.length > 0) {
1973
- var waiting_1 = channelQueue.length;
1974
- arrForEach(channelQueue, function (channels) {
2150
+ if (waiting > 0) {
2151
+ arrForEach(theChannels, function (channels) {
1975
2152
  if (channels && channels.queue.length > 0) {
1976
2153
  var channelChain = channels.chain;
1977
- var chainCtx = _getTelCtx(itemCtx).createNew(channelChain);
1978
- chainCtx.onComplete(function () {
1979
- waiting_1--;
1980
- if (waiting_1 === 0) {
1981
- onComplete && onComplete();
1982
- onComplete = null;
1983
- }
1984
- });
2154
+ var chainCtx = itemCtx.createNew(channelChain);
2155
+ chainCtx.onComplete(_runChainOnComplete);
1985
2156
  processFn(chainCtx);
1986
2157
  }
1987
2158
  else {
1988
- waiting_1--;
2159
+ waiting--;
1989
2160
  }
1990
2161
  });
1991
- if (waiting_1 === 0) {
1992
- onComplete && onComplete();
1993
- }
1994
- }
1995
- else {
1996
- onComplete && onComplete();
1997
2162
  }
2163
+ _runChainOnComplete();
1998
2164
  }
1999
- var isInitialized = false;
2000
- var channelController = {
2001
- identifier: "ChannelControllerPlugin",
2002
- priority: ChannelControllerPriority,
2003
- initialize: function (config, core, extensions, pluginChain) {
2004
- isInitialized = true;
2165
+ function _doTeardown(unloadCtx, unloadState) {
2166
+ var theUnloadState = unloadState || {
2167
+ reason: 0 ,
2168
+ isAsync: false
2169
+ };
2170
+ _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
2171
+ chainCtx[strProcessNext](theUnloadState);
2172
+ }, function () {
2173
+ unloadCtx[strProcessNext](theUnloadState);
2174
+ isInitialized = false;
2175
+ });
2176
+ return true;
2177
+ }
2178
+ function _getChannel(pluginIdentifier) {
2179
+ var thePlugin = null;
2180
+ if (channelQueue && channelQueue.length > 0) {
2005
2181
  arrForEach(channelQueue, function (channels) {
2006
2182
  if (channels && channels.queue.length > 0) {
2007
- initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2183
+ arrForEach(channels.queue, function (ext) {
2184
+ if (ext.identifier === pluginIdentifier) {
2185
+ thePlugin = ext;
2186
+ return -1;
2187
+ }
2188
+ });
2189
+ if (thePlugin) {
2190
+ return -1;
2191
+ }
2008
2192
  }
2009
2193
  });
2010
- },
2011
- isInitialized: function () { return isInitialized; },
2012
- processTelemetry: function (item, itemCtx) {
2013
- _processChannelQueue(itemCtx, function (chainCtx) {
2014
- chainCtx.processNext(item);
2015
- }, function () {
2016
- itemCtx.processNext(item);
2017
- });
2018
- },
2019
- pause: function () {
2020
- _processChannelQueue(null, function (chainCtx) {
2021
- chainCtx.iterate(function (plugin) {
2022
- plugin.pause && plugin.pause();
2194
+ }
2195
+ return thePlugin;
2196
+ }
2197
+ var isInitialized = false;
2198
+ var channelController = (_a = {
2199
+ identifier: "ChannelControllerPlugin",
2200
+ priority: ChannelControllerPriority,
2201
+ initialize: function (config, core, extensions, pluginChain) {
2202
+ isInitialized = true;
2203
+ arrForEach(channelQueue, function (channels) {
2204
+ if (channels && channels.queue.length > 0) {
2205
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2206
+ }
2023
2207
  });
2024
- });
2208
+ },
2209
+ isInitialized: function () { return isInitialized; },
2210
+ processTelemetry: function (item, itemCtx) {
2211
+ _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
2212
+ chainCtx[strProcessNext](item);
2213
+ }, function () {
2214
+ itemCtx[strProcessNext](item);
2215
+ });
2216
+ }
2025
2217
  },
2026
- resume: function () {
2027
- _processChannelQueue(null, function (chainCtx) {
2218
+ _a[strPause] = function () {
2219
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2028
2220
  chainCtx.iterate(function (plugin) {
2029
- plugin.resume && plugin.resume();
2221
+ plugin[strPause] && plugin[strPause]();
2030
2222
  });
2031
- });
2223
+ }, null);
2032
2224
  },
2033
- teardown: function () {
2034
- _processChannelQueue(null, function (chainCtx) {
2225
+ _a[strResume] = function () {
2226
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2035
2227
  chainCtx.iterate(function (plugin) {
2036
- plugin.teardown && plugin.teardown();
2228
+ plugin[strResume] && plugin[strResume]();
2037
2229
  });
2038
- });
2230
+ }, null);
2039
2231
  },
2040
- flush: function (isAsync, callBack, sendReason, cbTimeout) {
2232
+ _a[strTeardown] = _doTeardown,
2233
+ _a.getChannel = _getChannel,
2234
+ _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
2235
+ var waiting = 1;
2041
2236
  var doneIterating = false;
2042
- var waiting = 0;
2043
2237
  var cbTimer = null;
2044
2238
  cbTimeout = cbTimeout || 5000;
2045
2239
  function doCallback() {
2240
+ waiting--;
2046
2241
  if (doneIterating && waiting === 0) {
2047
2242
  if (cbTimer) {
2048
2243
  clearTimeout(cbTimer);
@@ -2052,32 +2247,38 @@
2052
2247
  callBack = null;
2053
2248
  }
2054
2249
  }
2055
- waiting = 1;
2056
- _processChannelQueue(null, function (chainCtx) {
2250
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
2057
2251
  chainCtx.iterate(function (plugin) {
2058
2252
  if (plugin.flush) {
2059
2253
  waiting++;
2254
+ var handled_1 = false;
2060
2255
  if (!plugin.flush(isAsync, function () {
2061
- waiting--;
2256
+ handled_1 = true;
2062
2257
  doCallback();
2063
2258
  }, sendReason)) {
2064
- if (cbTimer == null) {
2065
- cbTimer = setTimeout(function () {
2066
- cbTimer = null;
2067
- callBack && callBack(false);
2068
- callBack = null;
2069
- }, cbTimeout);
2259
+ if (!handled_1) {
2260
+ if (isAsync && cbTimer == null) {
2261
+ cbTimer = setTimeout(function () {
2262
+ cbTimer = null;
2263
+ doCallback();
2264
+ }, cbTimeout);
2265
+ }
2266
+ else {
2267
+ doCallback();
2268
+ }
2070
2269
  }
2071
2270
  }
2072
2271
  }
2073
2272
  });
2074
2273
  }, function () {
2075
- waiting--;
2076
2274
  doneIterating = true;
2077
2275
  doCallback();
2078
2276
  });
2079
- }
2080
- };
2277
+ },
2278
+ _a._setQueue = function (queue) {
2279
+ channelQueue = queue;
2280
+ },
2281
+ _a);
2081
2282
  return channelController;
2082
2283
  }
2083
2284
  function createChannelQueues(channels, extensions, config, core) {
@@ -2097,6 +2298,30 @@
2097
2298
  return channelQueue;
2098
2299
  }
2099
2300
 
2301
+ function createUnloadHandlerContainer() {
2302
+ var handlers = [];
2303
+ function _addHandler(handler) {
2304
+ if (handler) {
2305
+ handlers.push(handler);
2306
+ }
2307
+ }
2308
+ function _runHandlers(unloadCtx, unloadState) {
2309
+ arrForEach(handlers, function (handler) {
2310
+ try {
2311
+ handler(unloadCtx, unloadState);
2312
+ }
2313
+ catch (e) {
2314
+ unloadCtx.diagLog().throwInternal(2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
2315
+ }
2316
+ });
2317
+ handlers = [];
2318
+ }
2319
+ return {
2320
+ add: _addHandler,
2321
+ run: _runHandlers
2322
+ };
2323
+ }
2324
+
2100
2325
  var strGetPlugin = "getPlugin";
2101
2326
  var BaseTelemetryPlugin = /** @class */ (function () {
2102
2327
  function BaseTelemetryPlugin() {
@@ -2104,6 +2329,7 @@
2104
2329
  var _isinitialized;
2105
2330
  var _rootCtx;
2106
2331
  var _nextPlugin;
2332
+ var _unloadHandlerContainer;
2107
2333
  var _hooks;
2108
2334
  _initDefaults();
2109
2335
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -2111,6 +2337,39 @@
2111
2337
  _setDefaults(config, core, pluginChain);
2112
2338
  _isinitialized = true;
2113
2339
  };
2340
+ _self.teardown = function (unloadCtx, unloadState) {
2341
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
2342
+ return;
2343
+ }
2344
+ var result;
2345
+ var unloadDone = false;
2346
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
2347
+ var theUnloadState = unloadState || {
2348
+ reason: 0 ,
2349
+ isAsync: false
2350
+ };
2351
+ function _unloadCallback() {
2352
+ if (!unloadDone) {
2353
+ unloadDone = true;
2354
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
2355
+ arrForEach(_hooks, function (fn) {
2356
+ fn.rm();
2357
+ });
2358
+ _hooks = [];
2359
+ if (result === true) {
2360
+ theUnloadCtx.processNext(theUnloadState);
2361
+ }
2362
+ _initDefaults();
2363
+ }
2364
+ }
2365
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
2366
+ _unloadCallback();
2367
+ }
2368
+ else {
2369
+ result = true;
2370
+ }
2371
+ return result;
2372
+ };
2114
2373
  _self._addHook = function (hooks) {
2115
2374
  if (hooks) {
2116
2375
  if (isArray(hooks)) {
@@ -2121,17 +2380,18 @@
2121
2380
  }
2122
2381
  }
2123
2382
  };
2383
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
2124
2384
  });
2125
2385
  _self.diagLog = function (itemCtx) {
2126
2386
  return _getTelCtx(itemCtx).diagLog();
2127
2387
  };
2128
- _self.isInitialized = function () {
2388
+ _self[strIsInitialized] = function () {
2129
2389
  return _isinitialized;
2130
2390
  };
2131
2391
  _self.setInitialized = function (isInitialized) {
2132
2392
  _isinitialized = isInitialized;
2133
2393
  };
2134
- _self.setNextPlugin = function (next) {
2394
+ _self[strSetNextPlugin] = function (next) {
2135
2395
  _nextPlugin = next;
2136
2396
  };
2137
2397
  _self.processNext = function (env, itemCtx) {
@@ -2177,6 +2437,7 @@
2177
2437
  _rootCtx = null;
2178
2438
  _nextPlugin = null;
2179
2439
  _hooks = [];
2440
+ _unloadHandlerContainer = createUnloadHandlerContainer();
2180
2441
  }
2181
2442
  }
2182
2443
  return BaseTelemetryPlugin;
@@ -2223,7 +2484,7 @@
2223
2484
  }
2224
2485
  }
2225
2486
  catch (e) {
2226
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2487
+ itemCtx.diagLog().throwInternal(1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2227
2488
  }
2228
2489
  }
2229
2490
  }
@@ -2231,8 +2492,7 @@
2231
2492
  _self.processNext(item, itemCtx);
2232
2493
  }
2233
2494
  };
2234
- _self.unload = function (itemCtx, isAsync) {
2235
- _base.unload(itemCtx, isAsync);
2495
+ _self[strDoTeardown] = function () {
2236
2496
  _initDefaults();
2237
2497
  };
2238
2498
  });
@@ -2247,6 +2507,8 @@
2247
2507
 
2248
2508
  var strValidationError = "Plugins must provide initialize method";
2249
2509
  var strNotificationManager = "_notificationManager";
2510
+ var strSdkUnloadingError = "SDK is still unloading...";
2511
+ var strSdkNotInitialized = "SDK is not initialized";
2250
2512
  function _createPerfManager(core, notificationMgr) {
2251
2513
  return new PerfManager(notificationMgr);
2252
2514
  }
@@ -2276,6 +2538,26 @@
2276
2538
  core: coreExtensions
2277
2539
  };
2278
2540
  }
2541
+ function _isPluginPresent(thePlugin, plugins) {
2542
+ var exists = false;
2543
+ arrForEach(plugins, function (plugin) {
2544
+ if (plugin === thePlugin) {
2545
+ exists = true;
2546
+ return -1;
2547
+ }
2548
+ });
2549
+ return exists;
2550
+ }
2551
+ function _createDummyNotificationManager() {
2552
+ var _a;
2553
+ return objCreateFn((_a = {},
2554
+ _a[strAddNotificationListener] = function (listener) { },
2555
+ _a[strRemoveNotificationListener] = function (listener) { },
2556
+ _a[strEventsSent] = function (events) { },
2557
+ _a[strEventsDiscarded] = function (events, reason) { },
2558
+ _a[strEventsSendRequest] = function (sendReason, isAsync) { },
2559
+ _a));
2560
+ }
2279
2561
  var BaseCore = /** @class */ (function () {
2280
2562
  function BaseCore() {
2281
2563
  var _isInitialized;
@@ -2290,14 +2572,20 @@
2290
2572
  var _channelControl;
2291
2573
  var _channelConfig;
2292
2574
  var _channelQueue;
2575
+ var _isUnloading;
2293
2576
  var _telemetryInitializerPlugin;
2294
2577
  var _internalLogsEventName;
2578
+ var _evtNamespace;
2579
+ var _unloadHandlers;
2295
2580
  var _debugListener;
2296
2581
  var _internalLogPoller = 0;
2297
2582
  dynamicProto(BaseCore, this, function (_self) {
2298
2583
  _initDefaults();
2299
2584
  _self.isInitialized = function () { return _isInitialized; };
2300
2585
  _self.initialize = function (config, extensions, logger, notificationManager) {
2586
+ if (_isUnloading) {
2587
+ throwError(strSdkUnloadingError);
2588
+ }
2301
2589
  if (_self.isInitialized()) {
2302
2590
  throwError("Core should not be initialized more than once");
2303
2591
  }
@@ -2310,8 +2598,7 @@
2310
2598
  _initDebugListener(config);
2311
2599
  _initPerfManager(config);
2312
2600
  config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
2313
- var extConfig = getSetValue(config, strExtensionConfig);
2314
- extConfig.NotificationManager = notificationManager;
2601
+ _initExtConfig(config);
2315
2602
  if (logger) {
2316
2603
  _self.logger = logger;
2317
2604
  }
@@ -2336,37 +2623,29 @@
2336
2623
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
2337
2624
  setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
2338
2625
  setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
2339
- if (_self.isInitialized()) {
2340
- _self.getProcessTelContext().processNext(telemetryItem);
2626
+ if (!_isUnloading && _self.isInitialized()) {
2627
+ _createTelCtx().processNext(telemetryItem);
2341
2628
  }
2342
2629
  else {
2343
2630
  _eventQueue.push(telemetryItem);
2344
2631
  }
2345
2632
  };
2346
- _self.getProcessTelContext = function () {
2347
- return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2348
- };
2633
+ _self.getProcessTelContext = _createTelCtx;
2349
2634
  _self.getNotifyMgr = function () {
2350
2635
  if (!_notificationManager) {
2351
- _notificationManager = objCreateFn({
2352
- addNotificationListener: function (listener) { },
2353
- removeNotificationListener: function (listener) { },
2354
- eventsSent: function (events) { },
2355
- eventsDiscarded: function (events, reason) { },
2356
- eventsSendRequest: function (sendReason, isAsync) { }
2357
- });
2636
+ _notificationManager = _createDummyNotificationManager();
2358
2637
  _self[strNotificationManager] = _notificationManager;
2359
2638
  }
2360
2639
  return _notificationManager;
2361
2640
  };
2362
- _self.addNotificationListener = function (listener) {
2641
+ _self[strAddNotificationListener] = function (listener) {
2363
2642
  if (_notificationManager) {
2364
- _notificationManager.addNotificationListener(listener);
2643
+ _notificationManager[strAddNotificationListener](listener);
2365
2644
  }
2366
2645
  };
2367
- _self.removeNotificationListener = function (listener) {
2646
+ _self[strRemoveNotificationListener] = function (listener) {
2368
2647
  if (_notificationManager) {
2369
- _notificationManager.removeNotificationListener(listener);
2648
+ _notificationManager[strRemoveNotificationListener](listener);
2370
2649
  }
2371
2650
  };
2372
2651
  _self.getCookieMgr = function () {
@@ -2397,7 +2676,7 @@
2397
2676
  var eventQueue = _eventQueue;
2398
2677
  _eventQueue = [];
2399
2678
  arrForEach(eventQueue, function (event) {
2400
- _self.getProcessTelContext().processNext(event);
2679
+ _createTelCtx().processNext(event);
2401
2680
  });
2402
2681
  }
2403
2682
  };
@@ -2423,10 +2702,83 @@
2423
2702
  }
2424
2703
  };
2425
2704
  proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2705
+ _self.unload = function (isAsync, unloadComplete, cbTimeout) {
2706
+ if (isAsync === void 0) { isAsync = true; }
2707
+ if (!_isInitialized) {
2708
+ throwError(strSdkNotInitialized);
2709
+ }
2710
+ if (_isUnloading) {
2711
+ throwError(strSdkUnloadingError);
2712
+ }
2713
+ var unloadState = {
2714
+ reason: 50 ,
2715
+ isAsync: isAsync,
2716
+ flushComplete: false
2717
+ };
2718
+ var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);
2719
+ processUnloadCtx.onComplete(function () {
2720
+ _initDefaults();
2721
+ unloadComplete && unloadComplete(unloadState);
2722
+ }, _self);
2723
+ function _doUnload(flushComplete) {
2724
+ unloadState.flushComplete = flushComplete;
2725
+ _isUnloading = true;
2726
+ _unloadHandlers.run(processUnloadCtx, unloadState);
2727
+ _self.stopPollingInternalLogs();
2728
+ processUnloadCtx.processNext(unloadState);
2729
+ }
2730
+ if (_channelControl) {
2731
+ _channelControl.flush(isAsync, _doUnload, 6 , cbTimeout);
2732
+ }
2733
+ else {
2734
+ _doUnload(true);
2735
+ }
2736
+ };
2426
2737
  _self.getPlugin = _getPlugin;
2738
+ _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {
2739
+ if (isAsync === void 0) { isAsync = true; }
2740
+ if (!plugin) {
2741
+ addCb && addCb(false);
2742
+ _logOrThrowError(strValidationError);
2743
+ return;
2744
+ }
2745
+ var existingPlugin = _getPlugin(plugin.identifier);
2746
+ if (existingPlugin && !replaceExisting) {
2747
+ addCb && addCb(false);
2748
+ _logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
2749
+ return;
2750
+ }
2751
+ function _addPlugin(removed) {
2752
+ _configExtensions.push(plugin);
2753
+ _initPluginChain(_self.config);
2754
+ addCb && addCb(true);
2755
+ }
2756
+ if (existingPlugin) {
2757
+ var removedPlugins = [existingPlugin.plugin];
2758
+ var unloadState = {
2759
+ reason: 2 ,
2760
+ isAsync: isAsync
2761
+ };
2762
+ _removePlugins(removedPlugins, unloadState, function (removed) {
2763
+ if (!removed) {
2764
+ addCb && addCb(false);
2765
+ }
2766
+ else {
2767
+ _addPlugin();
2768
+ }
2769
+ });
2770
+ }
2771
+ else {
2772
+ _addPlugin();
2773
+ }
2774
+ };
2775
+ _self.evtNamespace = function () {
2776
+ return _evtNamespace;
2777
+ };
2778
+ proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
2427
2779
  function _initDefaults() {
2428
2780
  _isInitialized = false;
2429
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
2781
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 });
2430
2782
  _self.config = null;
2431
2783
  _self._extensions = [];
2432
2784
  _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
@@ -2441,7 +2793,13 @@
2441
2793
  _channelControl = null;
2442
2794
  _channelConfig = null;
2443
2795
  _channelQueue = null;
2796
+ _isUnloading = false;
2444
2797
  _internalLogsEventName = null;
2798
+ _evtNamespace = createUniqueNamespace("AIBaseCore", true);
2799
+ _unloadHandlers = createUnloadHandlerContainer();
2800
+ }
2801
+ function _createTelCtx() {
2802
+ return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2445
2803
  }
2446
2804
  function _initPluginChain(config) {
2447
2805
  var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
@@ -2449,26 +2807,63 @@
2449
2807
  _pluginChain = null;
2450
2808
  var allExtensions = theExtensions.all;
2451
2809
  _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
2452
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2810
+ if (_channelControl) {
2811
+ var idx = allExtensions.indexOf(_channelControl);
2812
+ if (idx !== -1) {
2813
+ allExtensions.splice(idx, 1);
2814
+ }
2815
+ idx = _coreExtensions.indexOf(_channelControl);
2816
+ if (idx !== -1) {
2817
+ _coreExtensions.splice(idx, 1);
2818
+ }
2819
+ _channelControl._setQueue(_channelQueue);
2820
+ }
2821
+ else {
2822
+ _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2823
+ }
2453
2824
  allExtensions.push(_channelControl);
2454
2825
  _coreExtensions.push(_channelControl);
2455
2826
  _self._extensions = sortPlugins(allExtensions);
2456
2827
  _channelControl.initialize(config, _self, allExtensions);
2457
- initializePlugins(_self.getProcessTelContext(), allExtensions);
2828
+ initializePlugins(_createTelCtx(), allExtensions);
2458
2829
  _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
2459
2830
  }
2460
2831
  function _getPlugin(pluginIdentifier) {
2461
2832
  var theExt = null;
2462
2833
  var thePlugin = null;
2463
2834
  arrForEach(_self._extensions, function (ext) {
2464
- if (ext.identifier === pluginIdentifier) {
2835
+ if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
2465
2836
  thePlugin = ext;
2466
2837
  return -1;
2467
2838
  }
2468
2839
  });
2840
+ if (!thePlugin && _channelControl) {
2841
+ thePlugin = _channelControl.getChannel(pluginIdentifier);
2842
+ }
2469
2843
  if (thePlugin) {
2470
2844
  theExt = {
2471
- plugin: thePlugin
2845
+ plugin: thePlugin,
2846
+ setEnabled: function (enabled) {
2847
+ _getPluginState(thePlugin)[strDisabled] = !enabled;
2848
+ },
2849
+ isEnabled: function () {
2850
+ var pluginState = _getPluginState(thePlugin);
2851
+ return !pluginState[strTeardown] && !pluginState[strDisabled];
2852
+ },
2853
+ remove: function (isAsync, removeCb) {
2854
+ if (isAsync === void 0) { isAsync = true; }
2855
+ var pluginsToRemove = [thePlugin];
2856
+ var unloadState = {
2857
+ reason: 1 ,
2858
+ isAsync: isAsync
2859
+ };
2860
+ _removePlugins(pluginsToRemove, unloadState, function (removed) {
2861
+ if (removed) {
2862
+ _initPluginChain(_self.config);
2863
+ }
2864
+ removeCb && removeCb(removed);
2865
+ });
2866
+ }
2472
2867
  };
2473
2868
  }
2474
2869
  return theExt;
@@ -2476,11 +2871,53 @@
2476
2871
  function _getPluginChain() {
2477
2872
  if (!_pluginChain) {
2478
2873
  var extensions = (_coreExtensions || []).slice();
2479
- extensions.push(_telemetryInitializerPlugin);
2874
+ if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {
2875
+ extensions.push(_telemetryInitializerPlugin);
2876
+ }
2480
2877
  _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
2481
2878
  }
2482
2879
  return _pluginChain;
2483
2880
  }
2881
+ function _removePlugins(thePlugins, unloadState, removeComplete) {
2882
+ if (thePlugins && thePlugins.length > 0) {
2883
+ var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
2884
+ var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);
2885
+ unloadCtx.onComplete(function () {
2886
+ var removed = false;
2887
+ var newConfigExtensions = [];
2888
+ arrForEach(_configExtensions, function (plugin, idx) {
2889
+ if (!_isPluginPresent(plugin, thePlugins)) {
2890
+ newConfigExtensions.push(plugin);
2891
+ }
2892
+ else {
2893
+ removed = true;
2894
+ }
2895
+ });
2896
+ _configExtensions = newConfigExtensions;
2897
+ var newChannelConfig = [];
2898
+ if (_channelConfig) {
2899
+ arrForEach(_channelConfig, function (queue, idx) {
2900
+ var newQueue = [];
2901
+ arrForEach(queue, function (channel) {
2902
+ if (!_isPluginPresent(channel, thePlugins)) {
2903
+ newQueue.push(channel);
2904
+ }
2905
+ else {
2906
+ removed = true;
2907
+ }
2908
+ });
2909
+ newChannelConfig.push(newQueue);
2910
+ });
2911
+ _channelConfig = newChannelConfig;
2912
+ }
2913
+ removeComplete && removeComplete(removed);
2914
+ });
2915
+ unloadCtx.processNext(unloadState);
2916
+ }
2917
+ else {
2918
+ removeComplete(false);
2919
+ }
2920
+ }
2484
2921
  function _flushInternalLogs() {
2485
2922
  var queue = _self.logger ? _self.logger.queue : [];
2486
2923
  if (queue) {
@@ -2499,12 +2936,12 @@
2499
2936
  }
2500
2937
  function _initDebugListener(config) {
2501
2938
  if (config.disableDbgExt === true && _debugListener) {
2502
- _notificationManager.removeNotificationListener(_debugListener);
2939
+ _notificationManager[strRemoveNotificationListener](_debugListener);
2503
2940
  _debugListener = null;
2504
2941
  }
2505
2942
  if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
2506
2943
  _debugListener = getDebugListener(config);
2507
- _notificationManager.addNotificationListener(_debugListener);
2944
+ _notificationManager[strAddNotificationListener](_debugListener);
2508
2945
  }
2509
2946
  }
2510
2947
  function _initPerfManager(config) {
@@ -2515,15 +2952,24 @@
2515
2952
  setValue(_self.config, "createPerfMgr", _createPerfManager);
2516
2953
  }
2517
2954
  }
2955
+ function _initExtConfig(config) {
2956
+ var extConfig = getSetValue(config, strExtensionConfig);
2957
+ extConfig.NotificationManager = _notificationManager;
2958
+ }
2959
+ function _logOrThrowError(message) {
2960
+ var logger = _self.logger;
2961
+ if (logger) {
2962
+ logger.throwInternal(2 , 73 , message);
2963
+ }
2964
+ else {
2965
+ throwError(message);
2966
+ }
2967
+ }
2518
2968
  });
2519
2969
  }
2520
2970
  return BaseCore;
2521
2971
  }());
2522
2972
 
2523
- var strEventsSent = "eventsSent";
2524
- var strEventsDiscarded = "eventsDiscarded";
2525
- var strEventsSendRequest = "eventsSendRequest";
2526
- var strPerfEvent = "perfEvent";
2527
2973
  function _runListeners(listeners, name, isAsync, callback) {
2528
2974
  arrForEach(listeners, function (listener) {
2529
2975
  if (listener && listener[name]) {
@@ -2545,32 +2991,32 @@
2545
2991
  this.listeners = [];
2546
2992
  var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
2547
2993
  dynamicProto(NotificationManager, this, function (_self) {
2548
- _self.addNotificationListener = function (listener) {
2994
+ _self[strAddNotificationListener] = function (listener) {
2549
2995
  _self.listeners.push(listener);
2550
2996
  };
2551
- _self.removeNotificationListener = function (listener) {
2997
+ _self[strRemoveNotificationListener] = function (listener) {
2552
2998
  var index = arrIndexOf(_self.listeners, listener);
2553
2999
  while (index > -1) {
2554
3000
  _self.listeners.splice(index, 1);
2555
3001
  index = arrIndexOf(_self.listeners, listener);
2556
3002
  }
2557
3003
  };
2558
- _self.eventsSent = function (events) {
3004
+ _self[strEventsSent] = function (events) {
2559
3005
  _runListeners(_self.listeners, strEventsSent, true, function (listener) {
2560
3006
  listener[strEventsSent](events);
2561
3007
  });
2562
3008
  };
2563
- _self.eventsDiscarded = function (events, reason) {
3009
+ _self[strEventsDiscarded] = function (events, reason) {
2564
3010
  _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
2565
3011
  listener[strEventsDiscarded](events, reason);
2566
3012
  });
2567
3013
  };
2568
- _self.eventsSendRequest = function (sendReason, isAsync) {
3014
+ _self[strEventsSendRequest] = function (sendReason, isAsync) {
2569
3015
  _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
2570
3016
  listener[strEventsSendRequest](sendReason, isAsync);
2571
3017
  });
2572
3018
  };
2573
- _self.perfEvent = function (perfEvent) {
3019
+ _self[strPerfEvent] = function (perfEvent) {
2574
3020
  if (perfEvent) {
2575
3021
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
2576
3022
  _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
@@ -2625,103 +3071,117 @@
2625
3071
  return AppInsightsCore;
2626
3072
  }(BaseCore));
2627
3073
 
2628
- var UInt32Mask = 0x100000000;
2629
- var MaxUInt32 = 0xffffffff;
2630
- var _mwcSeeded = false;
2631
- var _mwcW = 123456789;
2632
- var _mwcZ = 987654321;
2633
- function _mwcSeed(seedValue) {
2634
- if (seedValue < 0) {
2635
- seedValue >>>= 0;
2636
- }
2637
- _mwcW = (123456789 + seedValue) & MaxUInt32;
2638
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
2639
- _mwcSeeded = true;
2640
- }
2641
- function _autoSeedMwc() {
2642
- try {
2643
- var now = dateNow() & 0x7fffffff;
2644
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
2645
- }
2646
- catch (e) {
2647
- }
2648
- }
2649
- function randomValue(maxValue) {
2650
- if (maxValue > 0) {
2651
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
2652
- }
2653
- return 0;
2654
- }
2655
- function random32(signed) {
2656
- var value = 0;
2657
- var c = getCrypto() || getMsCrypto();
2658
- if (c && c.getRandomValues) {
2659
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
2660
- }
2661
- if (value === 0 && isIE()) {
2662
- if (!_mwcSeeded) {
2663
- _autoSeedMwc();
3074
+ var strOnPrefix = "on";
3075
+ var strAttachEvent = "attachEvent";
3076
+ var strAddEventHelper = "addEventListener";
3077
+ var strEvents = "events";
3078
+ createUniqueNamespace("aiEvtPageHide");
3079
+ createUniqueNamespace("aiEvtPageShow");
3080
+ var _guid = 1;
3081
+ var elmNodeData = createElmNodeData("events");
3082
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
3083
+ function _normalizeNamespace(name) {
3084
+ if (name && name.replace) {
3085
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
3086
+ }
3087
+ return name;
3088
+ }
3089
+ function _getEvtNamespace(eventName, namespaces) {
3090
+ if (namespaces) {
3091
+ var theNamespace_1 = "";
3092
+ if (isArray(namespaces)) {
3093
+ theNamespace_1 = "";
3094
+ arrForEach(namespaces, function (name) {
3095
+ name = _normalizeNamespace(name);
3096
+ if (name) {
3097
+ if (name[0] !== ".") {
3098
+ name = "." + name;
3099
+ }
3100
+ theNamespace_1 += name;
3101
+ }
3102
+ });
3103
+ }
3104
+ else {
3105
+ theNamespace_1 = _normalizeNamespace(namespaces);
3106
+ }
3107
+ if (theNamespace_1) {
3108
+ if (theNamespace_1[0] !== ".") {
3109
+ theNamespace_1 = "." + theNamespace_1;
3110
+ }
3111
+ eventName = (eventName || "") + theNamespace_1;
2664
3112
  }
2665
- value = mwcRandom32() & MaxUInt32;
2666
- }
2667
- if (value === 0) {
2668
- value = Math.floor((UInt32Mask * Math.random()) | 0);
2669
- }
2670
- if (!signed) {
2671
- value >>>= 0;
2672
3113
  }
2673
- return value;
3114
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
3115
+ return {
3116
+ type: parsedEvent[1],
3117
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
3118
+ };
2674
3119
  }
2675
- function mwcRandomSeed(value) {
2676
- if (!value) {
2677
- _autoSeedMwc();
2678
- }
2679
- else {
2680
- _mwcSeed(value);
3120
+ function _getRegisteredEvents(target, evtName, addDefault) {
3121
+ if (addDefault === void 0) { addDefault = true; }
3122
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
3123
+ var registeredEvents = aiEvts[evtName];
3124
+ if (!registeredEvents) {
3125
+ registeredEvents = aiEvts[evtName] = [];
2681
3126
  }
3127
+ return registeredEvents;
2682
3128
  }
2683
- function mwcRandom32(signed) {
2684
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
2685
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
2686
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
2687
- if (!signed) {
2688
- value >>>= 0;
3129
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
3130
+ var result = false;
3131
+ if (obj && evtName && evtName.type && handlerRef) {
3132
+ if (obj[strAddEventHelper]) {
3133
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
3134
+ result = true;
3135
+ }
3136
+ else if (obj[strAttachEvent]) {
3137
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
3138
+ result = true;
3139
+ }
2689
3140
  }
2690
- return value;
3141
+ return result;
2691
3142
  }
2692
- function newId(maxLength) {
2693
- if (maxLength === void 0) { maxLength = 22; }
2694
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2695
- var number = random32() >>> 0;
2696
- var chars = 0;
2697
- var result = "";
2698
- while (result.length < maxLength) {
2699
- chars++;
2700
- result += base64chars.charAt(number & 0x3F);
2701
- number >>>= 6;
2702
- if (chars === 5) {
2703
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2704
- chars = 0;
3143
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
3144
+ if (useCapture === void 0) { useCapture = false; }
3145
+ var result = false;
3146
+ if (target) {
3147
+ try {
3148
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
3149
+ result = _doAttach(target, evtName, handlerRef, useCapture);
3150
+ if (result && elmNodeData.accept(target)) {
3151
+ var registeredEvent = {
3152
+ guid: _guid++,
3153
+ evtName: evtName,
3154
+ handler: handlerRef,
3155
+ capture: useCapture
3156
+ };
3157
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
3158
+ }
3159
+ }
3160
+ catch (e) {
2705
3161
  }
2706
3162
  }
2707
3163
  return result;
2708
3164
  }
2709
-
2710
- var _cookieMgrs = null;
2711
- var _canUseCookies;
2712
- function addEventHandler(eventName, callback) {
3165
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
3166
+ if (useCapture === void 0) { useCapture = false; }
3167
+ return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
3168
+ }
3169
+ function addEventHandler(eventName, callback, evtNamespace) {
2713
3170
  var result = false;
2714
3171
  var w = getWindow();
2715
3172
  if (w) {
2716
- result = attachEvent(w, eventName, callback);
2717
- result = attachEvent(w["body"], eventName, callback) || result;
3173
+ result = eventOn(w, eventName, callback, evtNamespace);
3174
+ result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2718
3175
  }
2719
3176
  var doc = getDocument();
2720
3177
  if (doc) {
2721
- result = attachEvent(doc, eventName, callback) || result;
3178
+ result = eventOn(doc, eventName, callback, evtNamespace) || result;
2722
3179
  }
2723
3180
  return result;
2724
3181
  }
3182
+
3183
+ var _cookieMgrs = null;
3184
+ var _canUseCookies;
2725
3185
  function newGuid() {
2726
3186
  function randomHexDigit() {
2727
3187
  return randomValue(15);
@@ -2740,7 +3200,7 @@
2740
3200
  }
2741
3201
  function generateW3CId() {
2742
3202
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2743
- var oct = "", tmp;
3203
+ var oct = strEmpty$1, tmp;
2744
3204
  for (var a = 0; a < 4; a++) {
2745
3205
  tmp = random32();
2746
3206
  oct +=
@@ -2823,6 +3283,95 @@
2823
3283
  _legacyCookieMgr().setEnabled(false);
2824
3284
  }
2825
3285
 
3286
+ var LoggingSeverity = createEnumStyle({
3287
+ CRITICAL: 1 ,
3288
+ WARNING: 2
3289
+ });
3290
+ var _InternalMessageId = createEnumStyle({
3291
+ BrowserDoesNotSupportLocalStorage: 0 ,
3292
+ BrowserCannotReadLocalStorage: 1 ,
3293
+ BrowserCannotReadSessionStorage: 2 ,
3294
+ BrowserCannotWriteLocalStorage: 3 ,
3295
+ BrowserCannotWriteSessionStorage: 4 ,
3296
+ BrowserFailedRemovalFromLocalStorage: 5 ,
3297
+ BrowserFailedRemovalFromSessionStorage: 6 ,
3298
+ CannotSendEmptyTelemetry: 7 ,
3299
+ ClientPerformanceMathError: 8 ,
3300
+ ErrorParsingAISessionCookie: 9 ,
3301
+ ErrorPVCalc: 10 ,
3302
+ ExceptionWhileLoggingError: 11 ,
3303
+ FailedAddingTelemetryToBuffer: 12 ,
3304
+ FailedMonitorAjaxAbort: 13 ,
3305
+ FailedMonitorAjaxDur: 14 ,
3306
+ FailedMonitorAjaxOpen: 15 ,
3307
+ FailedMonitorAjaxRSC: 16 ,
3308
+ FailedMonitorAjaxSend: 17 ,
3309
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
3310
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
3311
+ FailedToSendQueuedTelemetry: 20 ,
3312
+ FailedToReportDataLoss: 21 ,
3313
+ FlushFailed: 22 ,
3314
+ MessageLimitPerPVExceeded: 23 ,
3315
+ MissingRequiredFieldSpecification: 24 ,
3316
+ NavigationTimingNotSupported: 25 ,
3317
+ OnError: 26 ,
3318
+ SessionRenewalDateIsZero: 27 ,
3319
+ SenderNotInitialized: 28 ,
3320
+ StartTrackEventFailed: 29 ,
3321
+ StopTrackEventFailed: 30 ,
3322
+ StartTrackFailed: 31 ,
3323
+ StopTrackFailed: 32 ,
3324
+ TelemetrySampledAndNotSent: 33 ,
3325
+ TrackEventFailed: 34 ,
3326
+ TrackExceptionFailed: 35 ,
3327
+ TrackMetricFailed: 36 ,
3328
+ TrackPVFailed: 37 ,
3329
+ TrackPVFailedCalc: 38 ,
3330
+ TrackTraceFailed: 39 ,
3331
+ TransmissionFailed: 40 ,
3332
+ FailedToSetStorageBuffer: 41 ,
3333
+ FailedToRestoreStorageBuffer: 42 ,
3334
+ InvalidBackendResponse: 43 ,
3335
+ FailedToFixDepricatedValues: 44 ,
3336
+ InvalidDurationValue: 45 ,
3337
+ TelemetryEnvelopeInvalid: 46 ,
3338
+ CreateEnvelopeError: 47 ,
3339
+ CannotSerializeObject: 48 ,
3340
+ CannotSerializeObjectNonSerializable: 49 ,
3341
+ CircularReferenceDetected: 50 ,
3342
+ ClearAuthContextFailed: 51 ,
3343
+ ExceptionTruncated: 52 ,
3344
+ IllegalCharsInName: 53 ,
3345
+ ItemNotInArray: 54 ,
3346
+ MaxAjaxPerPVExceeded: 55 ,
3347
+ MessageTruncated: 56 ,
3348
+ NameTooLong: 57 ,
3349
+ SampleRateOutOfRange: 58 ,
3350
+ SetAuthContextFailed: 59 ,
3351
+ SetAuthContextFailedAccountName: 60 ,
3352
+ StringValueTooLong: 61 ,
3353
+ StartCalledMoreThanOnce: 62 ,
3354
+ StopCalledWithoutStart: 63 ,
3355
+ TelemetryInitializerFailed: 64 ,
3356
+ TrackArgumentsNotSpecified: 65 ,
3357
+ UrlTooLong: 66 ,
3358
+ SessionStorageBufferFull: 67 ,
3359
+ CannotAccessCookie: 68 ,
3360
+ IdTooLong: 69 ,
3361
+ InvalidEvent: 70 ,
3362
+ FailedMonitorAjaxSetRequestHeader: 71 ,
3363
+ SendBrowserInfoOnUserInit: 72 ,
3364
+ PluginException: 73 ,
3365
+ NotificationException: 74 ,
3366
+ SnippetScriptLoadFailure: 99 ,
3367
+ InvalidInstrumentationKey: 100 ,
3368
+ CannotParseAiBlobValue: 101 ,
3369
+ InvalidContentBlob: 102 ,
3370
+ TrackPageActionEventFailed: 103 ,
3371
+ FailedAddingCustomDefinedRequestContext: 104 ,
3372
+ InMemoryStorageBufferFull: 105
3373
+ });
3374
+
2826
3375
  var RequestHeaders = {
2827
3376
  requestContextHeader: "Request-Context",
2828
3377
  requestContextTargetKey: "appId",
@@ -2855,7 +3404,7 @@
2855
3404
  name = strTrim(name.toString());
2856
3405
  if (name.length > 150 ) {
2857
3406
  nameTrunc = name.substring(0, 150 );
2858
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
3407
+ logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2859
3408
  }
2860
3409
  }
2861
3410
  return nameTrunc || name;
@@ -2868,7 +3417,7 @@
2868
3417
  value = strTrim(value);
2869
3418
  if (value.toString().length > maxLength) {
2870
3419
  valueTrunc = value.toString().substring(0, maxLength);
2871
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
3420
+ logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2872
3421
  }
2873
3422
  }
2874
3423
  return valueTrunc || value;
@@ -2881,7 +3430,7 @@
2881
3430
  if (message) {
2882
3431
  if (message.length > 32768 ) {
2883
3432
  messageTrunc = message.substring(0, 32768 );
2884
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
3433
+ logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2885
3434
  }
2886
3435
  }
2887
3436
  return messageTrunc || message;
@@ -2892,7 +3441,7 @@
2892
3441
  var value = "" + exception;
2893
3442
  if (value.length > 32768 ) {
2894
3443
  exceptionTrunc = value.substring(0, 32768 );
2895
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
3444
+ logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2896
3445
  }
2897
3446
  }
2898
3447
  return exceptionTrunc || exception;
@@ -2906,7 +3455,7 @@
2906
3455
  value = getJSON().stringify(value);
2907
3456
  }
2908
3457
  catch (e) {
2909
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
3458
+ logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2910
3459
  }
2911
3460
  }
2912
3461
  value = dataSanitizeString(logger, value, 8192 );
@@ -2937,7 +3486,7 @@
2937
3486
  input = strTrim(input);
2938
3487
  if (input.length > maxLength) {
2939
3488
  inputTrunc = input.substring(0, maxLength);
2940
- logger && logger.throwInternal(LoggingSeverity.WARNING, _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
3489
+ logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2941
3490
  }
2942
3491
  }
2943
3492
  return inputTrunc || input;
@@ -2947,21 +3496,22 @@
2947
3496
  return s.substr(s.length - 3);
2948
3497
  }
2949
3498
 
3499
+ var strEmpty = "";
2950
3500
  function msToTimeSpan(totalms) {
2951
3501
  if (isNaN(totalms) || totalms < 0) {
2952
3502
  totalms = 0;
2953
3503
  }
2954
3504
  totalms = Math.round(totalms);
2955
- var ms = "" + totalms % 1000;
2956
- var sec = "" + Math.floor(totalms / 1000) % 60;
2957
- var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
2958
- var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
3505
+ var ms = strEmpty + totalms % 1000;
3506
+ var sec = strEmpty + Math.floor(totalms / 1000) % 60;
3507
+ var min = strEmpty + Math.floor(totalms / (1000 * 60)) % 60;
3508
+ var hour = strEmpty + Math.floor(totalms / (1000 * 60 * 60)) % 24;
2959
3509
  var days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2960
3510
  ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
2961
3511
  sec = sec.length < 2 ? "0" + sec : sec;
2962
3512
  min = min.length < 2 ? "0" + min : min;
2963
3513
  hour = hour.length < 2 ? "0" + hour : hour;
2964
- return (days > 0 ? days + "." : "") + hour + ":" + min + ":" + sec + "." + ms;
3514
+ return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
2965
3515
  }
2966
3516
 
2967
3517
  var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
@@ -2970,17 +3520,15 @@
2970
3520
  var HttpMethod = "http.method";
2971
3521
  var strNotSpecified = "not_specified";
2972
3522
 
2973
- var StorageType;
2974
- (function (StorageType) {
2975
- StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
2976
- StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
2977
- })(StorageType || (StorageType = {}));
2978
- var DistributedTracingModes;
2979
- (function (DistributedTracingModes) {
2980
- DistributedTracingModes[DistributedTracingModes["AI"] = 0] = "AI";
2981
- DistributedTracingModes[DistributedTracingModes["AI_AND_W3C"] = 1] = "AI_AND_W3C";
2982
- DistributedTracingModes[DistributedTracingModes["W3C"] = 2] = "W3C";
2983
- })(DistributedTracingModes || (DistributedTracingModes = {}));
3523
+ var StorageType = createEnumStyle({
3524
+ LocalStorage: 0 ,
3525
+ SessionStorage: 1
3526
+ });
3527
+ createEnumStyle({
3528
+ AI: 0 ,
3529
+ AI_AND_W3C: 1 ,
3530
+ W3C: 2
3531
+ });
2984
3532
 
2985
3533
  var _canUseSessionStorage = undefined;
2986
3534
  function _getVerifiedStorageObject(storageType) {
@@ -3021,7 +3569,7 @@
3021
3569
  }
3022
3570
  catch (e) {
3023
3571
  _canUseSessionStorage = false;
3024
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3572
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3025
3573
  }
3026
3574
  }
3027
3575
  return null;
@@ -3035,7 +3583,7 @@
3035
3583
  }
3036
3584
  catch (e) {
3037
3585
  _canUseSessionStorage = false;
3038
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3586
+ logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
3039
3587
  }
3040
3588
  }
3041
3589
  return false;
@@ -4321,7 +4869,7 @@
4321
4869
  }
4322
4870
  }
4323
4871
  var EnvelopeCreator = {
4324
- Version: "2.8.0-beta.2202-07"
4872
+ Version: "2.8.0-beta.2203-03"
4325
4873
  };
4326
4874
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
4327
4875
  EnvelopeCreatorInit(logger, telemetryItem);