@microsoft/applicationinsights-web 2.7.4-nightly.2202-07 → 2.8.0-beta.2202-06

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 (49) hide show
  1. package/browser/{ai.2.7.4-nightly.2202-07.cjs.js → ai.2.8.0-beta.2202-06.cjs.js} +924 -524
  2. package/browser/ai.2.8.0-beta.2202-06.cjs.js.map +1 -0
  3. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js +6 -0
  4. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js.map +1 -0
  5. package/browser/{ai.2.7.4-nightly.2202-07.gbl.js → ai.2.8.0-beta.2202-06.gbl.js} +924 -524
  6. package/browser/ai.2.8.0-beta.2202-06.gbl.js.map +1 -0
  7. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js +6 -0
  8. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js.map +1 -0
  9. package/browser/ai.2.8.0-beta.2202-06.integrity.json +66 -0
  10. package/browser/{ai.2.7.4-nightly.2202-07.js → ai.2.8.0-beta.2202-06.js} +924 -524
  11. package/browser/ai.2.8.0-beta.2202-06.js.map +1 -0
  12. package/browser/ai.2.8.0-beta.2202-06.min.js +6 -0
  13. package/browser/ai.2.8.0-beta.2202-06.min.js.map +1 -0
  14. package/browser/ai.2.cjs.js +923 -523
  15. package/browser/ai.2.cjs.js.map +1 -1
  16. package/browser/ai.2.cjs.min.js +2 -2
  17. package/browser/ai.2.cjs.min.js.map +1 -1
  18. package/browser/ai.2.gbl.js +923 -523
  19. package/browser/ai.2.gbl.js.map +1 -1
  20. package/browser/ai.2.gbl.min.js +2 -2
  21. package/browser/ai.2.gbl.min.js.map +1 -1
  22. package/browser/ai.2.js +923 -523
  23. package/browser/ai.2.js.map +1 -1
  24. package/browser/ai.2.min.js +2 -2
  25. package/browser/ai.2.min.js.map +1 -1
  26. package/dist/applicationinsights-web.api.json +653 -213
  27. package/dist/applicationinsights-web.api.md +20 -6
  28. package/dist/applicationinsights-web.d.ts +158 -37
  29. package/dist/applicationinsights-web.js +923 -523
  30. package/dist/applicationinsights-web.js.map +1 -1
  31. package/dist/applicationinsights-web.min.js +2 -2
  32. package/dist/applicationinsights-web.min.js.map +1 -1
  33. package/dist/applicationinsights-web.rollup.d.ts +158 -37
  34. package/dist-esm/ApplicationInsightsContainer.js +1 -1
  35. package/dist-esm/ApplicationInsightsDeprecated.js +1 -1
  36. package/dist-esm/Init.js +1 -1
  37. package/dist-esm/Initialization.js +1 -1
  38. package/dist-esm/applicationinsights-web.js +1 -1
  39. package/package.json +8 -8
  40. package/browser/ai.2.7.4-nightly.2202-07.cjs.js.map +0 -1
  41. package/browser/ai.2.7.4-nightly.2202-07.cjs.min.js +0 -6
  42. package/browser/ai.2.7.4-nightly.2202-07.cjs.min.js.map +0 -1
  43. package/browser/ai.2.7.4-nightly.2202-07.gbl.js.map +0 -1
  44. package/browser/ai.2.7.4-nightly.2202-07.gbl.min.js +0 -6
  45. package/browser/ai.2.7.4-nightly.2202-07.gbl.min.js.map +0 -1
  46. package/browser/ai.2.7.4-nightly.2202-07.integrity.json +0 -66
  47. package/browser/ai.2.7.4-nightly.2202-07.js.map +0 -1
  48. package/browser/ai.2.7.4-nightly.2202-07.min.js +0 -6
  49. package/browser/ai.2.7.4-nightly.2202-07.min.js.map +0 -1
package/browser/ai.2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web, 2.7.4-nightly.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -453,6 +453,7 @@
453
453
  var str__Proto = "__proto__";
454
454
  var strConstructor = "constructor";
455
455
  var _objDefineProperty = ObjDefineProperty;
456
+ var _objFreeze = ObjClass.freeze;
456
457
  var _objKeys = ObjClass.keys;
457
458
  var StringProto = String[strShimPrototype];
458
459
  var _strTrim = StringProto[cStrTrim];
@@ -462,7 +463,7 @@
462
463
  var _isArray = Array.isArray;
463
464
  var _objToString = ObjProto[strToString];
464
465
  var _fnToString = ObjHasOwnProperty[strToString];
465
- _fnToString.call(ObjClass);
466
+ var _objFunctionString = _fnToString.call(ObjClass);
466
467
  var rCamelCase = /-([a-z])/g;
467
468
  var rNormalizeInvalid = /([^\w\d_$])/g;
468
469
  var rLeadingNumeric = /^(\d+[\w\d_$])/;
@@ -589,6 +590,22 @@
589
590
  function isBoolean(value) {
590
591
  return typeof value === "boolean";
591
592
  }
593
+ function isPlainObject(value) {
594
+ var result = false;
595
+ if (value && typeof value === "object") {
596
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
597
+ if (!proto) {
598
+ result = true;
599
+ }
600
+ else {
601
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
602
+ proto = proto[strConstructor];
603
+ }
604
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
605
+ }
606
+ }
607
+ return result;
608
+ }
592
609
  function toISOString(date) {
593
610
  if (date) {
594
611
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -754,6 +771,10 @@
754
771
  }
755
772
  return false;
756
773
  }
774
+ function _doNothing(value) {
775
+ return value;
776
+ }
777
+ var objFreeze = _objFreeze || _doNothing;
757
778
  function dateNow() {
758
779
  var dt = Date;
759
780
  return dt.now ? dt.now() : new dt().getTime();
@@ -798,19 +819,33 @@
798
819
  function throwError(message) {
799
820
  throw new Error(message);
800
821
  }
822
+ function _createProxyFunction(source, funcName) {
823
+ var srcFunc = null;
824
+ var src = null;
825
+ if (isFunction(source)) {
826
+ srcFunc = source;
827
+ }
828
+ else {
829
+ src = source;
830
+ }
831
+ return function () {
832
+ var originalArguments = arguments;
833
+ if (srcFunc) {
834
+ src = srcFunc();
835
+ }
836
+ if (src) {
837
+ return src[funcName].apply(src, originalArguments);
838
+ }
839
+ };
840
+ }
801
841
  function proxyAssign(target, source, chkSet) {
802
- if (target && source && target !== source && isObject(target) && isObject(source)) {
842
+ if (target && source && isObject(target) && isObject(source)) {
803
843
  var _loop_1 = function (field) {
804
844
  if (isString(field)) {
805
845
  var value = source[field];
806
846
  if (isFunction(value)) {
807
847
  if (!chkSet || chkSet(field, true, source, target)) {
808
- target[field] = (function (funcName) {
809
- return function () {
810
- var originalArguments = arguments;
811
- return source[funcName].apply(source, originalArguments);
812
- };
813
- })(field);
848
+ target[field] = _createProxyFunction(source, field);
814
849
  }
815
850
  }
816
851
  else if (!chkSet || chkSet(field, false, source, target)) {
@@ -833,6 +868,25 @@
833
868
  }
834
869
  return target;
835
870
  }
871
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
872
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
873
+ if (target && name && source) {
874
+ if (overwriteTarget || isUndefined(target[name])) {
875
+ target[name] = _createProxyFunction(source, theFunc);
876
+ }
877
+ }
878
+ }
879
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
880
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
881
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
882
+ arrForEach(functionsToProxy, function (theFuncName) {
883
+ if (isString(theFuncName)) {
884
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
885
+ }
886
+ });
887
+ }
888
+ return target;
889
+ }
836
890
  function createClassFromInterface(defaults) {
837
891
  return /** @class */ (function () {
838
892
  function class_1() {
@@ -852,6 +906,50 @@
852
906
  }
853
907
  return theObject;
854
908
  }
909
+ function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
910
+ var theArgs = arguments;
911
+ var extended = theArgs[0] || {};
912
+ var argLen = theArgs.length;
913
+ var deep = false;
914
+ var idx = 1;
915
+ if (argLen > 0 && isBoolean(extended)) {
916
+ deep = extended;
917
+ extended = theArgs[idx] || {};
918
+ idx++;
919
+ }
920
+ if (!isObject(extended)) {
921
+ extended = {};
922
+ }
923
+ for (; idx < argLen; idx++) {
924
+ var arg = theArgs[idx];
925
+ var isArgArray = isArray(arg);
926
+ var isArgObj = isObject(arg);
927
+ for (var prop in arg) {
928
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
929
+ if (!propOk) {
930
+ continue;
931
+ }
932
+ var newValue = arg[prop];
933
+ var isNewArray = void 0;
934
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
935
+ var clone = extended[prop];
936
+ if (isNewArray) {
937
+ if (!isArray(clone)) {
938
+ clone = [];
939
+ }
940
+ }
941
+ else if (!isPlainObject(clone)) {
942
+ clone = {};
943
+ }
944
+ newValue = objExtend(deep, clone, newValue);
945
+ }
946
+ if (newValue !== undefined) {
947
+ extended[prop] = newValue;
948
+ }
949
+ }
950
+ }
951
+ return extended;
952
+ }
855
953
 
856
954
  var strWindow = "window";
857
955
  var strDocument = "document";
@@ -867,6 +965,7 @@
867
965
  var strReactNative = "ReactNative";
868
966
  var strMsie = "msie";
869
967
  var strTrident = "trident/";
968
+ var strXMLHttpRequest = "XMLHttpRequest";
870
969
  var _isTrident = null;
871
970
  var _navUserAgentCheck = null;
872
971
  var _enableMocks = false;
@@ -1034,8 +1133,7 @@
1034
1133
  function isFetchSupported(withKeepAlive) {
1035
1134
  var isSupported = false;
1036
1135
  try {
1037
- var fetchApi = getGlobalInst("fetch");
1038
- isSupported = !!fetchApi;
1136
+ isSupported = !!getGlobalInst("fetch");
1039
1137
  var request = getGlobalInst("Request");
1040
1138
  if (isSupported && withKeepAlive && request) {
1041
1139
  isSupported = _hasProperty(request, "keepalive");
@@ -1047,9 +1145,9 @@
1047
1145
  }
1048
1146
  function useXDomainRequest() {
1049
1147
  if (_useXDomainRequest === null) {
1050
- _useXDomainRequest = (typeof XDomainRequest !== "undefined");
1148
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1051
1149
  if (_useXDomainRequest && isXhrSupported()) {
1052
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
1150
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
1053
1151
  }
1054
1152
  }
1055
1153
  return _useXDomainRequest;
@@ -1057,7 +1155,7 @@
1057
1155
  function isXhrSupported() {
1058
1156
  var isSupported = false;
1059
1157
  try {
1060
- var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
1158
+ var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
1061
1159
  isSupported = !!xmlHttpRequest;
1062
1160
  }
1063
1161
  catch (e) {
@@ -1400,253 +1498,240 @@
1400
1498
  return _defaultPerfManager;
1401
1499
  }
1402
1500
 
1403
- var TelemetryPluginChain = /** @class */ (function () {
1404
- function TelemetryPluginChain(plugin, defItemCtx) {
1405
- var _self = this;
1406
- var _nextProxy = null;
1407
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1408
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1409
- _self._hasRun = false;
1410
- _self.getPlugin = function () {
1411
- return plugin;
1412
- };
1413
- _self.getNext = function () {
1501
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1502
+ var strHasRunFlags = "_hasRun";
1503
+ var strGetTelCtx = "_getTelCtx";
1504
+ var _chainId = 0;
1505
+ function _getNextProxyStart(proxy, config, core, startAt) {
1506
+ while (proxy) {
1507
+ if (proxy.getPlugin() === startAt) {
1508
+ return proxy;
1509
+ }
1510
+ proxy = proxy.getNext();
1511
+ }
1512
+ return createTelemetryProxyChain([startAt], config, core);
1513
+ }
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
+ }
1523
+ 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 () {
1414
1539
  return _nextProxy;
1415
- };
1416
- _self.setNext = function (nextPlugin) {
1540
+ },
1541
+ setNext: function (nextPlugin) {
1417
1542
  _nextProxy = nextPlugin;
1418
- };
1419
- _self.processTelemetry = function (env, itemCtx) {
1420
- if (!itemCtx) {
1421
- itemCtx = defItemCtx;
1543
+ },
1544
+ processNext: function (env) {
1545
+ _processChain(function (nextPlugin) {
1546
+ nextPlugin.processTelemetry(env, context);
1547
+ });
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);
1422
1554
  }
1423
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1424
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1425
- if (plugin && _hasProcessTelemetry) {
1426
- _self._hasRun = true;
1427
- try {
1428
- itemCtx.setNext(_nextProxy);
1429
- if (_hasSetNext) {
1430
- plugin.setNextPlugin(_nextProxy);
1431
- }
1432
- _nextProxy && (_nextProxy._hasRun = false);
1433
- plugin.processTelemetry(env, itemCtx);
1434
- }
1435
- catch (error) {
1436
- var hasRun = _nextProxy && _nextProxy._hasRun;
1437
- if (!_nextProxy || !hasRun) {
1438
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1439
- }
1440
- if (_nextProxy && !hasRun) {
1441
- _nextProxy.processTelemetry(env, itemCtx);
1555
+ return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1556
+ },
1557
+ onComplete: function (onComplete) {
1558
+ _onComplete = onComplete;
1559
+ }
1560
+ };
1561
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1562
+ if (defaultValue === void 0) { defaultValue = {}; }
1563
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1564
+ var theConfig;
1565
+ if (config) {
1566
+ var extConfig = config.extensionConfig;
1567
+ if (extConfig && identifier) {
1568
+ theConfig = extConfig[identifier];
1569
+ }
1570
+ }
1571
+ if (!theConfig) {
1572
+ theConfig = defaultValue;
1573
+ }
1574
+ else if (isObject(defaultValue)) {
1575
+ if (mergeDefault !== 0 ) {
1576
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1577
+ if (config && mergeDefault === 2 ) {
1578
+ objForEachKey(defaultValue, function (field) {
1579
+ if (isNullOrUndefined(newConfig_1[field])) {
1580
+ var cfgValue = config[field];
1581
+ if (!isNullOrUndefined(cfgValue)) {
1582
+ newConfig_1[field] = cfgValue;
1583
+ }
1442
1584
  }
1443
- }
1444
- }
1445
- else if (_nextProxy) {
1446
- _self._hasRun = true;
1447
- _nextProxy.processTelemetry(env, itemCtx);
1448
- }
1449
- }, function () { return ({ item: env }); }, !(env.sync));
1450
- };
1451
- }
1452
- return TelemetryPluginChain;
1453
- }());
1454
-
1455
- function _createProxyChain(plugins, itemCtx) {
1456
- var proxies = [];
1457
- if (plugins && plugins.length > 0) {
1458
- var lastProxy = null;
1459
- for (var idx = 0; idx < plugins.length; idx++) {
1460
- var thePlugin = plugins[idx];
1461
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1462
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1463
- proxies.push(newProxy);
1464
- if (lastProxy) {
1465
- lastProxy.setNext(newProxy);
1585
+ });
1466
1586
  }
1467
- lastProxy = newProxy;
1468
1587
  }
1469
1588
  }
1589
+ return theConfig;
1470
1590
  }
1471
- return proxies.length > 0 ? proxies[0] : null;
1472
- }
1473
- function _copyProxyChain(proxy, itemCtx, startAt) {
1474
- var plugins = [];
1475
- var add = startAt ? false : true;
1476
- if (proxy) {
1477
- while (proxy) {
1478
- var thePlugin = proxy.getPlugin();
1479
- if (add || thePlugin === startAt) {
1480
- add = true;
1481
- plugins.push(thePlugin);
1482
- }
1483
- proxy = proxy.getNext();
1591
+ function _getConfig(identifier, field, defaultValue) {
1592
+ if (defaultValue === void 0) { defaultValue = false; }
1593
+ var theValue;
1594
+ var extConfig = _getExtCfg(identifier, null);
1595
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1596
+ theValue = extConfig[field];
1484
1597
  }
1598
+ else if (config && !isNullOrUndefined(config[field])) {
1599
+ theValue = config[field];
1600
+ }
1601
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1485
1602
  }
1486
- if (!add) {
1487
- plugins.push(startAt);
1488
- }
1489
- return _createProxyChain(plugins, itemCtx);
1490
- }
1491
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1492
- var plugins = srcPlugins;
1493
- var add = false;
1494
- if (startAt && srcPlugins) {
1495
- plugins = [];
1496
- arrForEach(srcPlugins, function (thePlugin) {
1497
- if (add || thePlugin === startAt) {
1498
- add = true;
1499
- plugins.push(thePlugin);
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;
1500
1613
  }
1501
- });
1614
+ }
1502
1615
  }
1503
- if (startAt && !add) {
1504
- if (!plugins) {
1505
- plugins = [];
1616
+ function _iterateChain(cb) {
1617
+ while (_nextProxy) {
1618
+ _processChain(function (nextPlugin) {
1619
+ var plugin = nextPlugin.getPlugin();
1620
+ if (plugin) {
1621
+ cb(plugin);
1622
+ }
1623
+ });
1506
1624
  }
1507
- plugins.push(startAt);
1508
1625
  }
1509
- return _createProxyChain(plugins, itemCtx);
1626
+ return context;
1510
1627
  }
1511
- var ProcessTelemetryContext = /** @class */ (function () {
1512
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1513
- var _self = this;
1514
- var _nextProxy = null;
1515
- if (startAt !== null) {
1516
- if (plugins && isFunction(plugins.getPlugin)) {
1517
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1628
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1629
+ var firstProxy = null;
1630
+ var add = startAt ? false : true;
1631
+ if (isArray(plugins) && plugins.length > 0) {
1632
+ var lastProxy_1 = null;
1633
+ arrForEach(plugins, function (thePlugin) {
1634
+ if (!add && startAt === thePlugin) {
1635
+ add = true;
1518
1636
  }
1519
- else {
1520
- if (startAt) {
1521
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1637
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1638
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1639
+ if (!firstProxy) {
1640
+ firstProxy = newProxy;
1522
1641
  }
1523
- else if (isUndefined(startAt)) {
1524
- _nextProxy = _createProxyChain(plugins, _self);
1642
+ if (lastProxy_1) {
1643
+ lastProxy_1._setNext(newProxy);
1525
1644
  }
1645
+ lastProxy_1 = newProxy;
1526
1646
  }
1527
- }
1528
- _self.core = function () {
1529
- return core;
1530
- };
1531
- _self.diagLog = function () {
1532
- return safeGetLogger(core, config);
1533
- };
1534
- _self.getCfg = function () {
1535
- return config;
1536
- };
1537
- _self.getExtCfg = function (identifier, defaultValue) {
1538
- if (defaultValue === void 0) { defaultValue = {}; }
1539
- var theConfig;
1540
- if (config) {
1541
- var extConfig = config.extensionConfig;
1542
- if (extConfig && identifier) {
1543
- theConfig = extConfig[identifier];
1544
- }
1545
- }
1546
- return (theConfig ? theConfig : defaultValue);
1547
- };
1548
- _self.getConfig = function (identifier, field, defaultValue) {
1549
- if (defaultValue === void 0) { defaultValue = false; }
1550
- var theValue;
1551
- var extConfig = _self.getExtCfg(identifier, null);
1552
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1553
- theValue = extConfig[field];
1554
- }
1555
- else if (config && !isNullOrUndefined(config[field])) {
1556
- theValue = config[field];
1557
- }
1558
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1559
- };
1560
- _self.hasNext = function () {
1561
- return _nextProxy != null;
1562
- };
1563
- _self.getNext = function () {
1564
- return _nextProxy;
1565
- };
1566
- _self.setNext = function (nextPlugin) {
1567
- _nextProxy = nextPlugin;
1568
- };
1569
- _self.processNext = function (env) {
1570
- var nextPlugin = _nextProxy;
1571
- if (nextPlugin) {
1572
- _nextProxy = nextPlugin.getNext();
1573
- nextPlugin.processTelemetry(env, _self);
1574
- }
1575
- };
1576
- _self.createNew = function (plugins, startAt) {
1577
- if (plugins === void 0) { plugins = null; }
1578
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1579
- };
1647
+ });
1580
1648
  }
1581
- return ProcessTelemetryContext;
1582
- }());
1583
-
1584
- var strIKey = "iKey";
1585
- var strExtensionConfig = "extensionConfig";
1586
-
1587
- var strGetPlugin = "getPlugin";
1588
- var BaseTelemetryPlugin = /** @class */ (function () {
1589
- function BaseTelemetryPlugin() {
1590
- var _self = this;
1591
- var _isinitialized = false;
1592
- var _rootCtx = null;
1593
- var _nextPlugin = null;
1594
- _self.core = null;
1595
- _self.diagLog = function (itemCtx) {
1596
- return _self._getTelCtx(itemCtx).diagLog();
1597
- };
1598
- _self.isInitialized = function () {
1599
- return _isinitialized;
1600
- };
1601
- _self.setInitialized = function (isInitialized) {
1602
- _isinitialized = isInitialized;
1603
- };
1604
- _self.setNextPlugin = function (next) {
1605
- _nextPlugin = next;
1606
- };
1607
- _self.processNext = function (env, itemCtx) {
1608
- if (itemCtx) {
1609
- itemCtx.processNext(env);
1610
- }
1611
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1612
- _nextPlugin.processTelemetry(env, null);
1649
+ if (startAt && !firstProxy) {
1650
+ return createTelemetryProxyChain([startAt], config, core);
1651
+ }
1652
+ return firstProxy;
1653
+ }
1654
+ function createTelemetryPluginProxy(plugin, config, core) {
1655
+ var nextProxy = null;
1656
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1657
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1658
+ var chainId;
1659
+ if (plugin) {
1660
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1661
+ }
1662
+ else {
1663
+ chainId = "Unknown-0-" + _chainId++;
1664
+ }
1665
+ var proxyChain = {
1666
+ getPlugin: function () {
1667
+ return plugin;
1668
+ },
1669
+ getNext: function () {
1670
+ return nextProxy;
1671
+ },
1672
+ processTelemetry: _processTelemetry,
1673
+ _id: chainId,
1674
+ _setNext: function (nextPlugin) {
1675
+ nextProxy = nextPlugin;
1676
+ }
1677
+ };
1678
+ function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1679
+ if (!itemCtx) {
1680
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1681
+ itemCtx = plugin[strGetTelCtx]();
1613
1682
  }
1614
- };
1615
- _self._getTelCtx = function (currentCtx) {
1616
- if (currentCtx === void 0) { currentCtx = null; }
1617
- var itemCtx = currentCtx;
1618
1683
  if (!itemCtx) {
1619
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1620
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1621
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1684
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1685
+ }
1686
+ }
1687
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1688
+ var hasRunContext = itemCtx[strHasRunFlags];
1689
+ if (!hasRunContext) {
1690
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1691
+ }
1692
+ doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1693
+ hasRunContext[chainId] = true;
1694
+ var hasRun = false;
1695
+ itemCtx.setNext(nextProxy);
1696
+ if (plugin) {
1697
+ try {
1698
+ var nextId = nextProxy ? nextProxy._id : "";
1699
+ if (nextId) {
1700
+ hasRunContext[nextId] = false;
1701
+ }
1702
+ hasRun = processPluginFn(itemCtx);
1622
1703
  }
1623
- else {
1624
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1704
+ catch (error) {
1705
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1706
+ if (hasNextRun) {
1707
+ hasRun = true;
1708
+ }
1709
+ if (!nextProxy || !hasNextRun) {
1710
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1711
+ }
1625
1712
  }
1626
1713
  }
1627
- return itemCtx;
1628
- };
1629
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1630
- if (config) {
1631
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1714
+ if (nextProxy && !hasRun) {
1715
+ processProxyFn(itemCtx);
1632
1716
  }
1633
- if (!pluginChain && core) {
1634
- pluginChain = core.getProcessTelContext().getNext();
1717
+ }, details, isAsync);
1718
+ }
1719
+ function _processTelemetry(env, itemCtx) {
1720
+ _processChain(itemCtx, function (itemCtx) {
1721
+ if (!hasProcessTelemetry) {
1722
+ return false;
1635
1723
  }
1636
- var nextPlugin = _nextPlugin;
1637
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1638
- nextPlugin = _nextPlugin[strGetPlugin]();
1724
+ if (hasSetNext) {
1725
+ plugin.setNextPlugin(nextProxy);
1639
1726
  }
1640
- _self.core = core;
1641
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1642
- _isinitialized = true;
1643
- };
1727
+ plugin.processTelemetry(env, itemCtx);
1728
+ return true;
1729
+ }, function (itemCtx) {
1730
+ nextProxy.processTelemetry(env, itemCtx);
1731
+ }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1644
1732
  }
1645
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1646
- this._baseTelInit(config, core, extensions, pluginChain);
1647
- };
1648
- return BaseTelemetryPlugin;
1649
- }());
1733
+ return objFreeze(proxyChain);
1734
+ }
1650
1735
 
1651
1736
  var processTelemetry = "processTelemetry";
1652
1737
  var priority = "priority";
@@ -1689,81 +1774,6 @@
1689
1774
  });
1690
1775
  }
1691
1776
 
1692
- var ChannelControllerPriority = 500;
1693
- var ChannelValidationMessage = "Channel has invalid priority";
1694
- var ChannelController = /** @class */ (function (_super) {
1695
- __extendsFn(ChannelController, _super);
1696
- function ChannelController() {
1697
- var _this = _super.call(this) || this;
1698
- _this.identifier = "ChannelControllerPlugin";
1699
- _this.priority = ChannelControllerPriority;
1700
- var _channelQueue;
1701
- dynamicProto(ChannelController, _this, function (_self, _base) {
1702
- _self.setNextPlugin = function (next) {
1703
- };
1704
- _self.processTelemetry = function (item, itemCtx) {
1705
- if (_channelQueue) {
1706
- arrForEach(_channelQueue, function (queues) {
1707
- if (queues.length > 0) {
1708
- var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
1709
- chainCtx.processNext(item);
1710
- }
1711
- });
1712
- }
1713
- };
1714
- _self.getChannelControls = function () {
1715
- return _channelQueue;
1716
- };
1717
- _self.initialize = function (config, core, extensions) {
1718
- if (_self.isInitialized()) {
1719
- return;
1720
- }
1721
- _base.initialize(config, core, extensions);
1722
- _createChannelQueues((config || {}).channels, extensions);
1723
- arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
1724
- };
1725
- });
1726
- function _checkQueuePriority(queue) {
1727
- arrForEach(queue, function (queueItem) {
1728
- if (queueItem.priority < ChannelControllerPriority) {
1729
- throwError(ChannelValidationMessage + queueItem.identifier);
1730
- }
1731
- });
1732
- }
1733
- function _addChannelQueue(queue) {
1734
- if (queue && queue.length > 0) {
1735
- queue = queue.sort(function (a, b) {
1736
- return a.priority - b.priority;
1737
- });
1738
- _checkQueuePriority(queue);
1739
- _channelQueue.push(queue);
1740
- }
1741
- }
1742
- function _createChannelQueues(channels, extensions) {
1743
- _channelQueue = [];
1744
- if (channels) {
1745
- arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
1746
- }
1747
- if (extensions) {
1748
- var extensionQueue_1 = [];
1749
- arrForEach(extensions, function (plugin) {
1750
- if (plugin.priority > ChannelControllerPriority) {
1751
- extensionQueue_1.push(plugin);
1752
- }
1753
- });
1754
- _addChannelQueue(extensionQueue_1);
1755
- }
1756
- }
1757
- return _this;
1758
- }
1759
- ChannelController._staticInit = (function () {
1760
- var proto = ChannelController.prototype;
1761
- objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
1762
- objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
1763
- })();
1764
- return ChannelController;
1765
- }(BaseTelemetryPlugin));
1766
-
1767
1777
  var strToGMTString = "toGMTString";
1768
1778
  var strToUTCString = "toUTCString";
1769
1779
  var strCookie = "cookie";
@@ -1947,87 +1957,425 @@
1947
1957
  if (idx === -1) {
1948
1958
  values[thePart] = null;
1949
1959
  }
1950
- else {
1951
- values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1960
+ else {
1961
+ values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1962
+ }
1963
+ }
1964
+ });
1965
+ }
1966
+ return values;
1967
+ }
1968
+ function _formatDate(theDate, func) {
1969
+ if (isFunction(theDate[func])) {
1970
+ return theDate[func]();
1971
+ }
1972
+ return null;
1973
+ }
1974
+ function _formatCookieValue(value, values) {
1975
+ var cookieValue = value || strEmpty;
1976
+ objForEachKey(values, function (name, theValue) {
1977
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1978
+ });
1979
+ return cookieValue;
1980
+ }
1981
+ function _getCookieValue(name) {
1982
+ var cookieValue = strEmpty;
1983
+ if (_doc) {
1984
+ var theCookie = _doc[strCookie] || strEmpty;
1985
+ if (_parsedCookieValue !== theCookie) {
1986
+ _cookieCache = _extractParts(theCookie);
1987
+ _parsedCookieValue = theCookie;
1988
+ }
1989
+ cookieValue = strTrim(_cookieCache[name] || strEmpty);
1990
+ }
1991
+ return cookieValue;
1992
+ }
1993
+ function _setCookieValue(name, cookieValue) {
1994
+ if (_doc) {
1995
+ _doc[strCookie] = name + "=" + cookieValue;
1996
+ }
1997
+ }
1998
+ function uaDisallowsSameSiteNone(userAgent) {
1999
+ if (!isString(userAgent)) {
2000
+ return false;
2001
+ }
2002
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2003
+ return true;
2004
+ }
2005
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2006
+ return true;
2007
+ }
2008
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2009
+ return true;
2010
+ }
2011
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2012
+ return true;
2013
+ }
2014
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2015
+ return true;
2016
+ }
2017
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2018
+ return true;
2019
+ }
2020
+ return false;
2021
+ }
2022
+
2023
+ var strIKey = "iKey";
2024
+ var strExtensionConfig = "extensionConfig";
2025
+
2026
+ var ChannelControllerPriority = 500;
2027
+ var ChannelValidationMessage = "Channel has invalid priority - ";
2028
+ function _addChannelQueue(channelQueue, queue, config, core) {
2029
+ if (queue && isArray(queue) && queue.length > 0) {
2030
+ queue = queue.sort(function (a, b) {
2031
+ return a.priority - b.priority;
2032
+ });
2033
+ arrForEach(queue, function (queueItem) {
2034
+ if (queueItem.priority < ChannelControllerPriority) {
2035
+ throwError(ChannelValidationMessage + queueItem.identifier);
2036
+ }
2037
+ });
2038
+ channelQueue.push({
2039
+ queue: objFreeze(queue),
2040
+ chain: createTelemetryProxyChain(queue, config, core)
2041
+ });
2042
+ }
2043
+ }
2044
+ function createChannelControllerPlugin(channelQueue, core) {
2045
+ function _getTelCtx(itemCtx) {
2046
+ if (!itemCtx) {
2047
+ itemCtx = createProcessTelemetryContext(null, core.config, core, null);
2048
+ }
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) {
2055
+ if (channels && channels.queue.length > 0) {
2056
+ 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
+ });
2065
+ processFn(chainCtx);
2066
+ }
2067
+ else {
2068
+ waiting_1--;
2069
+ }
2070
+ });
2071
+ if (waiting_1 === 0) {
2072
+ onComplete && onComplete();
2073
+ }
2074
+ }
2075
+ else {
2076
+ onComplete && onComplete();
2077
+ }
2078
+ }
2079
+ var isInitialized = false;
2080
+ var channelController = {
2081
+ identifier: "ChannelControllerPlugin",
2082
+ priority: ChannelControllerPriority,
2083
+ initialize: function (config, core, extensions, pluginChain) {
2084
+ isInitialized = true;
2085
+ arrForEach(channelQueue, function (channels) {
2086
+ if (channels && channels.queue.length > 0) {
2087
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2088
+ }
2089
+ });
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();
2103
+ });
2104
+ });
2105
+ },
2106
+ resume: function () {
2107
+ _processChannelQueue(null, function (chainCtx) {
2108
+ chainCtx.iterate(function (plugin) {
2109
+ plugin.resume && plugin.resume();
2110
+ });
2111
+ });
2112
+ },
2113
+ teardown: function () {
2114
+ _processChannelQueue(null, function (chainCtx) {
2115
+ chainCtx.iterate(function (plugin) {
2116
+ plugin.teardown && plugin.teardown();
2117
+ });
2118
+ });
2119
+ },
2120
+ flush: function (isAsync, callBack, sendReason, cbTimeout) {
2121
+ var doneIterating = false;
2122
+ var waiting = 0;
2123
+ var cbTimer = null;
2124
+ cbTimeout = cbTimeout || 5000;
2125
+ function doCallback() {
2126
+ if (doneIterating && waiting === 0) {
2127
+ if (cbTimer) {
2128
+ clearTimeout(cbTimer);
2129
+ cbTimer = null;
2130
+ }
2131
+ callBack && callBack(doneIterating);
2132
+ callBack = null;
2133
+ }
2134
+ }
2135
+ waiting = 1;
2136
+ _processChannelQueue(null, function (chainCtx) {
2137
+ chainCtx.iterate(function (plugin) {
2138
+ if (plugin.flush) {
2139
+ waiting++;
2140
+ if (!plugin.flush(isAsync, function () {
2141
+ waiting--;
2142
+ doCallback();
2143
+ }, sendReason)) {
2144
+ if (cbTimer == null) {
2145
+ cbTimer = setTimeout(function () {
2146
+ cbTimer = null;
2147
+ callBack && callBack(false);
2148
+ callBack = null;
2149
+ }, cbTimeout);
2150
+ }
2151
+ }
2152
+ }
2153
+ });
2154
+ }, function () {
2155
+ waiting--;
2156
+ doneIterating = true;
2157
+ doCallback();
2158
+ });
2159
+ }
2160
+ };
2161
+ return channelController;
2162
+ }
2163
+ function createChannelQueues(channels, extensions, config, core) {
2164
+ var channelQueue = [];
2165
+ if (channels) {
2166
+ arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
2167
+ }
2168
+ if (extensions) {
2169
+ var extensionQueue_1 = [];
2170
+ arrForEach(extensions, function (plugin) {
2171
+ if (plugin.priority > ChannelControllerPriority) {
2172
+ extensionQueue_1.push(plugin);
2173
+ }
2174
+ });
2175
+ _addChannelQueue(channelQueue, extensionQueue_1, config, core);
2176
+ }
2177
+ return channelQueue;
2178
+ }
2179
+
2180
+ var strGetPlugin = "getPlugin";
2181
+ var BaseTelemetryPlugin = /** @class */ (function () {
2182
+ function BaseTelemetryPlugin() {
2183
+ var _self = this;
2184
+ var _isinitialized;
2185
+ var _rootCtx;
2186
+ var _nextPlugin;
2187
+ var _hooks;
2188
+ _initDefaults();
2189
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
2190
+ _self.initialize = function (config, core, extensions, pluginChain) {
2191
+ _setDefaults(config, core, pluginChain);
2192
+ _isinitialized = true;
2193
+ };
2194
+ _self._addHook = function (hooks) {
2195
+ if (hooks) {
2196
+ if (isArray(hooks)) {
2197
+ _hooks = _hooks.concat(hooks);
2198
+ }
2199
+ else {
2200
+ _hooks.push(hooks);
2201
+ }
2202
+ }
2203
+ };
2204
+ });
2205
+ _self.diagLog = function (itemCtx) {
2206
+ return _getTelCtx(itemCtx).diagLog();
2207
+ };
2208
+ _self.isInitialized = function () {
2209
+ return _isinitialized;
2210
+ };
2211
+ _self.setInitialized = function (isInitialized) {
2212
+ _isinitialized = isInitialized;
2213
+ };
2214
+ _self.setNextPlugin = function (next) {
2215
+ _nextPlugin = next;
2216
+ };
2217
+ _self.processNext = function (env, itemCtx) {
2218
+ if (itemCtx) {
2219
+ itemCtx.processNext(env);
2220
+ }
2221
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2222
+ _nextPlugin.processTelemetry(env, null);
2223
+ }
2224
+ };
2225
+ _self._getTelCtx = _getTelCtx;
2226
+ function _getTelCtx(currentCtx) {
2227
+ if (currentCtx === void 0) { currentCtx = null; }
2228
+ var itemCtx = currentCtx;
2229
+ if (!itemCtx) {
2230
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2231
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2232
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2233
+ }
2234
+ else {
2235
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2236
+ }
2237
+ }
2238
+ return itemCtx;
2239
+ }
2240
+ function _setDefaults(config, core, pluginChain) {
2241
+ if (config) {
2242
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2243
+ }
2244
+ if (!pluginChain && core) {
2245
+ pluginChain = core.getProcessTelContext().getNext();
2246
+ }
2247
+ var nextPlugin = _nextPlugin;
2248
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2249
+ nextPlugin = _nextPlugin[strGetPlugin]();
2250
+ }
2251
+ _self.core = core;
2252
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2253
+ }
2254
+ function _initDefaults() {
2255
+ _isinitialized = false;
2256
+ _self.core = null;
2257
+ _rootCtx = null;
2258
+ _nextPlugin = null;
2259
+ _hooks = [];
2260
+ }
2261
+ }
2262
+ return BaseTelemetryPlugin;
2263
+ }());
2264
+
2265
+ var TelemetryInitializerPlugin = /** @class */ (function (_super) {
2266
+ __extendsFn(TelemetryInitializerPlugin, _super);
2267
+ function TelemetryInitializerPlugin() {
2268
+ var _this = _super.call(this) || this;
2269
+ _this.identifier = "TelemetryInitializerPlugin";
2270
+ _this.priority = 199;
2271
+ var _id;
2272
+ var _initializers;
2273
+ _initDefaults();
2274
+ dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
2275
+ _self.addTelemetryInitializer = function (telemetryInitializer) {
2276
+ var theInitializer = {
2277
+ id: _id++,
2278
+ fn: telemetryInitializer
2279
+ };
2280
+ _initializers.push(theInitializer);
2281
+ var handler = {
2282
+ remove: function () {
2283
+ arrForEach(_initializers, function (initializer, idx) {
2284
+ if (initializer.id === theInitializer.id) {
2285
+ _initializers.splice(idx, 1);
2286
+ return -1;
2287
+ }
2288
+ });
2289
+ }
2290
+ };
2291
+ return handler;
2292
+ };
2293
+ _self.processTelemetry = function (item, itemCtx) {
2294
+ var doNotSendItem = false;
2295
+ var telemetryInitializersCount = _initializers.length;
2296
+ for (var i = 0; i < telemetryInitializersCount; ++i) {
2297
+ var telemetryInitializer = _initializers[i];
2298
+ if (telemetryInitializer) {
2299
+ try {
2300
+ if (telemetryInitializer.fn.apply(null, [item]) === false) {
2301
+ doNotSendItem = true;
2302
+ break;
2303
+ }
2304
+ }
2305
+ 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);
2307
+ }
2308
+ }
2309
+ }
2310
+ if (!doNotSendItem) {
2311
+ _self.processNext(item, itemCtx);
1952
2312
  }
1953
- }
2313
+ };
2314
+ _self.unload = function (itemCtx, isAsync) {
2315
+ _base.unload(itemCtx, isAsync);
2316
+ _initDefaults();
2317
+ };
1954
2318
  });
1955
- }
1956
- return values;
1957
- }
1958
- function _formatDate(theDate, func) {
1959
- if (isFunction(theDate[func])) {
1960
- return theDate[func]();
1961
- }
1962
- return null;
1963
- }
1964
- function _formatCookieValue(value, values) {
1965
- var cookieValue = value || strEmpty;
1966
- objForEachKey(values, function (name, theValue) {
1967
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1968
- });
1969
- return cookieValue;
1970
- }
1971
- function _getCookieValue(name) {
1972
- var cookieValue = strEmpty;
1973
- if (_doc) {
1974
- var theCookie = _doc[strCookie] || strEmpty;
1975
- if (_parsedCookieValue !== theCookie) {
1976
- _cookieCache = _extractParts(theCookie);
1977
- _parsedCookieValue = theCookie;
2319
+ function _initDefaults() {
2320
+ _id = 0;
2321
+ _initializers = [];
1978
2322
  }
1979
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1980
- }
1981
- return cookieValue;
1982
- }
1983
- function _setCookieValue(name, cookieValue) {
1984
- if (_doc) {
1985
- _doc[strCookie] = name + "=" + cookieValue;
1986
- }
1987
- }
1988
- function uaDisallowsSameSiteNone(userAgent) {
1989
- if (!isString(userAgent)) {
1990
- return false;
1991
- }
1992
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
1993
- return true;
1994
- }
1995
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
1996
- return true;
1997
- }
1998
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
1999
- return true;
2000
- }
2001
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2002
- return true;
2003
- }
2004
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2005
- return true;
2006
- }
2007
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2008
- return true;
2323
+ return _this;
2009
2324
  }
2010
- return false;
2011
- }
2325
+ return TelemetryInitializerPlugin;
2326
+ }(BaseTelemetryPlugin));
2012
2327
 
2013
- var validationError = "Extensions must provide callback to initialize";
2328
+ var strValidationError = "Plugins must provide initialize method";
2014
2329
  var strNotificationManager = "_notificationManager";
2015
2330
  function _createPerfManager(core, notificationMgr) {
2016
2331
  return new PerfManager(notificationMgr);
2017
2332
  }
2333
+ function _validateExtensions(logger, channelPriority, allExtensions) {
2334
+ var coreExtensions = [];
2335
+ var extPriorities = {};
2336
+ arrForEach(allExtensions, function (ext) {
2337
+ if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2338
+ throwError(strValidationError);
2339
+ }
2340
+ var extPriority = ext.priority;
2341
+ var identifier = ext.identifier;
2342
+ if (ext && extPriority) {
2343
+ if (!isNullOrUndefined(extPriorities[extPriority])) {
2344
+ logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2345
+ }
2346
+ else {
2347
+ extPriorities[extPriority] = identifier;
2348
+ }
2349
+ }
2350
+ if (!extPriority || extPriority < channelPriority) {
2351
+ coreExtensions.push(ext);
2352
+ }
2353
+ });
2354
+ return {
2355
+ all: allExtensions,
2356
+ core: coreExtensions
2357
+ };
2358
+ }
2018
2359
  var BaseCore = /** @class */ (function () {
2019
2360
  function BaseCore() {
2020
- var _isInitialized = false;
2361
+ var _isInitialized;
2021
2362
  var _eventQueue;
2022
- var _channelController;
2023
2363
  var _notificationManager;
2024
2364
  var _perfManager;
2365
+ var _cfgPerfManager;
2025
2366
  var _cookieManager;
2367
+ var _pluginChain;
2368
+ var _configExtensions;
2369
+ var _coreExtensions;
2370
+ var _channelControl;
2371
+ var _channelConfig;
2372
+ var _channelQueue;
2373
+ var _telemetryInitializerPlugin;
2374
+ var _internalLogsEventName;
2375
+ var _debugListener;
2376
+ var _internalLogPoller = 0;
2026
2377
  dynamicProto(BaseCore, this, function (_self) {
2027
- _self._extensions = new Array();
2028
- _channelController = new ChannelController();
2029
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
2030
- _eventQueue = [];
2378
+ _initDefaults();
2031
2379
  _self.isInitialized = function () { return _isInitialized; };
2032
2380
  _self.initialize = function (config, extensions, logger, notificationManager) {
2033
2381
  if (_self.isInitialized()) {
@@ -2039,48 +2387,18 @@
2039
2387
  _notificationManager = notificationManager;
2040
2388
  _self[strNotificationManager] = notificationManager;
2041
2389
  _self.config = config || {};
2042
- if (notificationManager && _self.config.disableDbgExt !== true) {
2043
- notificationManager.addNotificationListener(getDebugListener(config));
2044
- }
2045
- if (_self.config.enablePerfMgr) {
2046
- setValue(_self.config, "createPerfMgr", _createPerfManager);
2047
- }
2390
+ _initDebugListener(config);
2391
+ _initPerfManager(config);
2048
2392
  config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
2049
2393
  var extConfig = getSetValue(config, strExtensionConfig);
2050
2394
  extConfig.NotificationManager = notificationManager;
2051
2395
  if (logger) {
2052
2396
  _self.logger = logger;
2053
2397
  }
2054
- var allExtensions = [];
2055
- allExtensions.push.apply(allExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2056
- allExtensions = sortPlugins(allExtensions);
2057
- var coreExtensions = [];
2058
- var extPriorities = {};
2059
- arrForEach(allExtensions, function (ext) {
2060
- if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2061
- throwError(validationError);
2062
- }
2063
- var extPriority = ext.priority;
2064
- var identifier = ext.identifier;
2065
- if (ext && extPriority) {
2066
- if (!isNullOrUndefined(extPriorities[extPriority])) {
2067
- logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2068
- }
2069
- else {
2070
- extPriorities[extPriority] = identifier;
2071
- }
2072
- }
2073
- if (!extPriority || extPriority < _channelController.priority) {
2074
- coreExtensions.push(ext);
2075
- }
2076
- });
2077
- allExtensions.push(_channelController);
2078
- coreExtensions.push(_channelController);
2079
- allExtensions = sortPlugins(allExtensions);
2080
- _self._extensions = allExtensions;
2081
- initializePlugins(new ProcessTelemetryContext([_channelController], config, _self), allExtensions);
2082
- initializePlugins(new ProcessTelemetryContext(coreExtensions, config, _self), allExtensions);
2083
- _self._extensions = coreExtensions;
2398
+ _configExtensions = [];
2399
+ _configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2400
+ _channelConfig = (config || {}).channels;
2401
+ _initPluginChain(config);
2084
2402
  if (_self.getTransmissionControls().length === 0) {
2085
2403
  throwError("No channels available");
2086
2404
  }
@@ -2088,7 +2406,11 @@
2088
2406
  _self.releaseQueue();
2089
2407
  };
2090
2408
  _self.getTransmissionControls = function () {
2091
- return _channelController.getChannelControls();
2409
+ var controls = [];
2410
+ arrForEach(_channelQueue, function (channels) {
2411
+ controls.push(channels.queue);
2412
+ });
2413
+ return objFreeze(controls);
2092
2414
  };
2093
2415
  _self.track = function (telemetryItem) {
2094
2416
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
@@ -2102,12 +2424,7 @@
2102
2424
  }
2103
2425
  };
2104
2426
  _self.getProcessTelContext = function () {
2105
- var extensions = _self._extensions;
2106
- var thePlugins = extensions;
2107
- if (!extensions || extensions.length === 0) {
2108
- thePlugins = [_channelController];
2109
- }
2110
- return new ProcessTelemetryContext(thePlugins, _self.config, _self);
2427
+ return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2111
2428
  };
2112
2429
  _self.getNotifyMgr = function () {
2113
2430
  if (!_notificationManager) {
@@ -2122,6 +2439,16 @@
2122
2439
  }
2123
2440
  return _notificationManager;
2124
2441
  };
2442
+ _self.addNotificationListener = function (listener) {
2443
+ if (_notificationManager) {
2444
+ _notificationManager.addNotificationListener(listener);
2445
+ }
2446
+ };
2447
+ _self.removeNotificationListener = function (listener) {
2448
+ if (_notificationManager) {
2449
+ _notificationManager.removeNotificationListener(listener);
2450
+ }
2451
+ };
2125
2452
  _self.getCookieMgr = function () {
2126
2453
  if (!_cookieManager) {
2127
2454
  _cookieManager = createCookieMgr(_self.config, _self.logger);
@@ -2132,12 +2459,12 @@
2132
2459
  _cookieManager = cookieMgr;
2133
2460
  };
2134
2461
  _self.getPerfMgr = function () {
2135
- if (!_perfManager) {
2462
+ if (!_perfManager && !_cfgPerfManager) {
2136
2463
  if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2137
- _perfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2464
+ _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2138
2465
  }
2139
2466
  }
2140
- return _perfManager || getGblPerfMgr();
2467
+ return _perfManager || _cfgPerfManager || getGblPerfMgr();
2141
2468
  };
2142
2469
  _self.setPerfMgr = function (perfMgr) {
2143
2470
  _perfManager = perfMgr;
@@ -2146,18 +2473,153 @@
2146
2473
  return _eventQueue.length;
2147
2474
  };
2148
2475
  _self.releaseQueue = function () {
2149
- if (_eventQueue.length > 0) {
2150
- arrForEach(_eventQueue, function (event) {
2476
+ if (_isInitialized && _eventQueue.length > 0) {
2477
+ var eventQueue = _eventQueue;
2478
+ _eventQueue = [];
2479
+ arrForEach(eventQueue, function (event) {
2151
2480
  _self.getProcessTelContext().processNext(event);
2152
2481
  });
2153
- _eventQueue = [];
2154
2482
  }
2155
2483
  };
2484
+ _self.pollInternalLogs = function (eventName) {
2485
+ _internalLogsEventName = eventName;
2486
+ var interval = _self.config.diagnosticLogInterval;
2487
+ if (!interval || !(interval > 0)) {
2488
+ interval = 10000;
2489
+ }
2490
+ if (_internalLogPoller) {
2491
+ clearInterval(_internalLogPoller);
2492
+ }
2493
+ _internalLogPoller = setInterval(function () {
2494
+ _flushInternalLogs();
2495
+ }, interval);
2496
+ return _internalLogPoller;
2497
+ };
2498
+ _self.stopPollingInternalLogs = function () {
2499
+ if (_internalLogPoller) {
2500
+ clearInterval(_internalLogPoller);
2501
+ _internalLogPoller = 0;
2502
+ _flushInternalLogs();
2503
+ }
2504
+ };
2505
+ proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2506
+ _self.getPlugin = _getPlugin;
2507
+ function _initDefaults() {
2508
+ _isInitialized = false;
2509
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
2510
+ _self.config = null;
2511
+ _self._extensions = [];
2512
+ _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
2513
+ _eventQueue = [];
2514
+ _notificationManager = null;
2515
+ _perfManager = null;
2516
+ _cfgPerfManager = null;
2517
+ _cookieManager = null;
2518
+ _pluginChain = null;
2519
+ _coreExtensions = null;
2520
+ _configExtensions = null;
2521
+ _channelControl = null;
2522
+ _channelConfig = null;
2523
+ _channelQueue = null;
2524
+ _internalLogsEventName = null;
2525
+ }
2526
+ function _initPluginChain(config) {
2527
+ var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
2528
+ _coreExtensions = theExtensions.core;
2529
+ _pluginChain = null;
2530
+ var allExtensions = theExtensions.all;
2531
+ _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
2532
+ _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2533
+ allExtensions.push(_channelControl);
2534
+ _coreExtensions.push(_channelControl);
2535
+ _self._extensions = sortPlugins(allExtensions);
2536
+ _channelControl.initialize(config, _self, allExtensions);
2537
+ initializePlugins(_self.getProcessTelContext(), allExtensions);
2538
+ _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
2539
+ }
2540
+ function _getPlugin(pluginIdentifier) {
2541
+ var theExt = null;
2542
+ var thePlugin = null;
2543
+ arrForEach(_self._extensions, function (ext) {
2544
+ if (ext.identifier === pluginIdentifier) {
2545
+ thePlugin = ext;
2546
+ return -1;
2547
+ }
2548
+ });
2549
+ if (thePlugin) {
2550
+ theExt = {
2551
+ plugin: thePlugin
2552
+ };
2553
+ }
2554
+ return theExt;
2555
+ }
2556
+ function _getPluginChain() {
2557
+ if (!_pluginChain) {
2558
+ var extensions = (_coreExtensions || []).slice();
2559
+ extensions.push(_telemetryInitializerPlugin);
2560
+ _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
2561
+ }
2562
+ return _pluginChain;
2563
+ }
2564
+ function _flushInternalLogs() {
2565
+ var queue = _self.logger ? _self.logger.queue : [];
2566
+ if (queue) {
2567
+ arrForEach(queue, function (logMessage) {
2568
+ var item = {
2569
+ name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
2570
+ iKey: _self.config.instrumentationKey,
2571
+ time: toISOString(new Date()),
2572
+ baseType: _InternalLogMessage.dataType,
2573
+ baseData: { message: logMessage.message }
2574
+ };
2575
+ _self.track(item);
2576
+ });
2577
+ queue.length = 0;
2578
+ }
2579
+ }
2580
+ function _initDebugListener(config) {
2581
+ if (config.disableDbgExt === true && _debugListener) {
2582
+ _notificationManager.removeNotificationListener(_debugListener);
2583
+ _debugListener = null;
2584
+ }
2585
+ if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
2586
+ _debugListener = getDebugListener(config);
2587
+ _notificationManager.addNotificationListener(_debugListener);
2588
+ }
2589
+ }
2590
+ function _initPerfManager(config) {
2591
+ if (!config.enablePerfMgr && _cfgPerfManager) {
2592
+ _cfgPerfManager = null;
2593
+ }
2594
+ if (config.enablePerfMgr) {
2595
+ setValue(_self.config, "createPerfMgr", _createPerfManager);
2596
+ }
2597
+ }
2156
2598
  });
2157
2599
  }
2158
2600
  return BaseCore;
2159
2601
  }());
2160
2602
 
2603
+ var strEventsSent = "eventsSent";
2604
+ var strEventsDiscarded = "eventsDiscarded";
2605
+ var strEventsSendRequest = "eventsSendRequest";
2606
+ var strPerfEvent = "perfEvent";
2607
+ function _runListeners(listeners, name, isAsync, callback) {
2608
+ arrForEach(listeners, function (listener) {
2609
+ if (listener && listener[name]) {
2610
+ if (isAsync) {
2611
+ setTimeout(function () { return callback(listener); }, 0);
2612
+ }
2613
+ else {
2614
+ try {
2615
+ callback(listener);
2616
+ }
2617
+ catch (e) {
2618
+ }
2619
+ }
2620
+ }
2621
+ });
2622
+ }
2161
2623
  var NotificationManager = /** @class */ (function () {
2162
2624
  function NotificationManager(config) {
2163
2625
  this.listeners = [];
@@ -2174,50 +2636,29 @@
2174
2636
  }
2175
2637
  };
2176
2638
  _self.eventsSent = function (events) {
2177
- arrForEach(_self.listeners, function (listener) {
2178
- if (listener && listener.eventsSent) {
2179
- setTimeout(function () { return listener.eventsSent(events); }, 0);
2180
- }
2639
+ _runListeners(_self.listeners, strEventsSent, true, function (listener) {
2640
+ listener[strEventsSent](events);
2181
2641
  });
2182
2642
  };
2183
2643
  _self.eventsDiscarded = function (events, reason) {
2184
- arrForEach(_self.listeners, function (listener) {
2185
- if (listener && listener.eventsDiscarded) {
2186
- setTimeout(function () { return listener.eventsDiscarded(events, reason); }, 0);
2187
- }
2644
+ _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
2645
+ listener[strEventsDiscarded](events, reason);
2188
2646
  });
2189
2647
  };
2190
2648
  _self.eventsSendRequest = function (sendReason, isAsync) {
2191
- arrForEach(_self.listeners, function (listener) {
2192
- if (listener && listener.eventsSendRequest) {
2193
- if (isAsync) {
2194
- setTimeout(function () { return listener.eventsSendRequest(sendReason, isAsync); }, 0);
2195
- }
2196
- else {
2197
- try {
2198
- listener.eventsSendRequest(sendReason, isAsync);
2199
- }
2200
- catch (e) {
2201
- }
2202
- }
2203
- }
2649
+ _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
2650
+ listener[strEventsSendRequest](sendReason, isAsync);
2204
2651
  });
2205
2652
  };
2206
2653
  _self.perfEvent = function (perfEvent) {
2207
2654
  if (perfEvent) {
2208
2655
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
2209
- arrForEach(_self.listeners, function (listener) {
2210
- if (listener && listener.perfEvent) {
2211
- if (perfEvent.isAsync) {
2212
- setTimeout(function () { return listener.perfEvent(perfEvent); }, 0);
2213
- }
2214
- else {
2215
- try {
2216
- listener.perfEvent(perfEvent);
2217
- }
2218
- catch (e) {
2219
- }
2220
- }
2656
+ _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
2657
+ if (perfEvent.isAsync) {
2658
+ setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
2659
+ }
2660
+ else {
2661
+ listener[strPerfEvent](perfEvent);
2221
2662
  }
2222
2663
  });
2223
2664
  }
@@ -2232,7 +2673,6 @@
2232
2673
  __extendsFn(AppInsightsCore, _super);
2233
2674
  function AppInsightsCore() {
2234
2675
  var _this = _super.call(this) || this;
2235
- var _internalLogPoller = 0;
2236
2676
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
2237
2677
  _self.initialize = function (config, extensions, logger, notificationManager) {
2238
2678
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -2247,48 +2687,6 @@
2247
2687
  _base.track(telemetryItem);
2248
2688
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
2249
2689
  };
2250
- _self.addNotificationListener = function (listener) {
2251
- var manager = _self.getNotifyMgr();
2252
- if (manager) {
2253
- manager.addNotificationListener(listener);
2254
- }
2255
- };
2256
- _self.removeNotificationListener = function (listener) {
2257
- var manager = _self.getNotifyMgr();
2258
- if (manager) {
2259
- manager.removeNotificationListener(listener);
2260
- }
2261
- };
2262
- _self.pollInternalLogs = function (eventName) {
2263
- var interval = _self.config.diagnosticLogInterval;
2264
- if (!interval || !(interval > 0)) {
2265
- interval = 10000;
2266
- }
2267
- if (_internalLogPoller) {
2268
- _self.stopPollingInternalLogs();
2269
- }
2270
- _internalLogPoller = setInterval(function () {
2271
- var queue = _self.logger ? _self.logger.queue : [];
2272
- arrForEach(queue, function (logMessage) {
2273
- var item = {
2274
- name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
2275
- iKey: _self.config.instrumentationKey,
2276
- time: toISOString(new Date()),
2277
- baseType: _InternalLogMessage.dataType,
2278
- baseData: { message: logMessage.message }
2279
- };
2280
- _self.track(item);
2281
- });
2282
- queue.length = 0;
2283
- }, interval);
2284
- return _internalLogPoller;
2285
- };
2286
- _self.stopPollingInternalLogs = function () {
2287
- if (!_internalLogPoller)
2288
- return;
2289
- clearInterval(_internalLogPoller);
2290
- _internalLogPoller = 0;
2291
- };
2292
2690
  function _validateTelemetryItem(telemetryItem) {
2293
2691
  if (isNullOrUndefined(telemetryItem.name)) {
2294
2692
  _notifyInvalidEvent(telemetryItem);
@@ -2335,18 +2733,18 @@
2335
2733
  return 0;
2336
2734
  }
2337
2735
  function random32(signed) {
2338
- var value;
2736
+ var value = 0;
2339
2737
  var c = getCrypto() || getMsCrypto();
2340
2738
  if (c && c.getRandomValues) {
2341
2739
  value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
2342
2740
  }
2343
- else if (isIE()) {
2741
+ if (value === 0 && isIE()) {
2344
2742
  if (!_mwcSeeded) {
2345
2743
  _autoSeedMwc();
2346
2744
  }
2347
2745
  value = mwcRandom32() & MaxUInt32;
2348
2746
  }
2349
- else {
2747
+ if (value === 0) {
2350
2748
  value = Math.floor((UInt32Mask * Math.random()) | 0);
2351
2749
  }
2352
2750
  if (!signed) {
@@ -2371,6 +2769,23 @@
2371
2769
  }
2372
2770
  return value;
2373
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;
2785
+ }
2786
+ }
2787
+ return result;
2788
+ }
2374
2789
 
2375
2790
  var strVisibilityChangeEvt = "visibilitychange";
2376
2791
  var strPageHide = "pagehide";
@@ -2447,23 +2862,6 @@
2447
2862
  }
2448
2863
  return dateNow();
2449
2864
  }
2450
- function newId(maxLength) {
2451
- if (maxLength === void 0) { maxLength = 22; }
2452
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2453
- var number = random32() >>> 0;
2454
- var chars = 0;
2455
- var result = "";
2456
- while (result.length < maxLength) {
2457
- chars++;
2458
- result += base64chars.charAt(number & 0x3F);
2459
- number >>>= 6;
2460
- if (chars === 5) {
2461
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2462
- chars = 0;
2463
- }
2464
- }
2465
- return result;
2466
- }
2467
2865
  function generateW3CId() {
2468
2866
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2469
2867
  var oct = "", tmp;
@@ -2619,6 +3017,7 @@
2619
3017
  };
2620
3018
  var hookCtx = [];
2621
3019
  var cbArgs = _createArgs([funcArgs], orgArgs);
3020
+ funcArgs.evt = getGlobalInst("event");
2622
3021
  function _createArgs(target, theArgs) {
2623
3022
  _arrLoop(theArgs, function (arg) {
2624
3023
  target.push(arg);
@@ -4481,7 +4880,7 @@
4481
4880
  function _flushChannels() {
4482
4881
  if (core) {
4483
4882
  arrForEach(core.getTransmissionControls(), function (queues) {
4484
- arrForEach(queues, function (q) { return q.flush(true); });
4883
+ arrForEach(queues, function (q) { q.flush(true); });
4485
4884
  });
4486
4885
  }
4487
4886
  }
@@ -5213,7 +5612,7 @@
5213
5612
  config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
5214
5613
  return config;
5215
5614
  };
5216
- ApplicationInsights.Version = "2.7.4-nightly.2202-07";
5615
+ ApplicationInsights.Version = "2.8.0-beta.2202-06";
5217
5616
  return ApplicationInsights;
5218
5617
  }(BaseTelemetryPlugin));
5219
5618
  var Timing = /** @class */ (function () {
@@ -5520,7 +5919,7 @@
5520
5919
  }
5521
5920
  }
5522
5921
  var EnvelopeCreator = {
5523
- Version: "2.7.4-nightly.2202-07"
5922
+ Version: "2.8.0-beta.2202-06"
5524
5923
  };
5525
5924
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
5526
5925
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -6031,11 +6430,12 @@
6031
6430
  _setupTimer();
6032
6431
  }
6033
6432
  };
6034
- _self.flush = function () {
6433
+ _self.flush = function (isAsync, callBack, sendReason) {
6434
+ if (isAsync === void 0) { isAsync = true; }
6035
6435
  if (!_paused) {
6036
6436
  _clearScheduledTimer();
6037
6437
  try {
6038
- _self.triggerSend(true, null, 1 );
6438
+ _self.triggerSend(isAsync, null, sendReason || 1 );
6039
6439
  }
6040
6440
  catch (e) {
6041
6441
  _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
@@ -6788,7 +7188,7 @@
6788
7188
  return Device;
6789
7189
  }());
6790
7190
 
6791
- var Version = "2.7.4-nightly.2202-07";
7191
+ var Version = "2.8.0-beta.2202-06";
6792
7192
  var Internal = /** @class */ (function () {
6793
7193
  function Internal(config) {
6794
7194
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;