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