@microsoft/applicationinsights-web-basic 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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript Web SDK - Basic, 2.7.4-nightly.2202-07
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2202-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -124,11 +124,11 @@
124
124
  var DynAllowInstChkTag = DynInstChkTag;
125
125
  var DynProtoDefaultOptions = '_dfOpts';
126
126
  var UnknownValue = '_unknown_';
127
- var str__Proto = "__proto__";
127
+ var str__Proto$1 = "__proto__";
128
128
  var strUseBaseInst = 'useBaseInst';
129
129
  var strSetInstFuncs = 'setInstFuncs';
130
130
  var Obj = Object;
131
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
131
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
132
132
  var _dynamicNames = 0;
133
133
  function _hasOwnProperty(obj, prop) {
134
134
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -139,12 +139,12 @@
139
139
  function _isObjectArrayOrFunctionPrototype(target) {
140
140
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
141
141
  }
142
- function _getObjProto(target) {
142
+ function _getObjProto$1(target) {
143
143
  if (target) {
144
- if (_objGetPrototypeOf) {
145
- return _objGetPrototypeOf(target);
144
+ if (_objGetPrototypeOf$1) {
145
+ return _objGetPrototypeOf$1(target);
146
146
  }
147
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
147
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
148
148
  if (newProto) {
149
149
  return newProto;
150
150
  }
@@ -210,16 +210,16 @@
210
210
  _forEachProp(instFuncs, function (name) {
211
211
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
212
212
  });
213
- var baseProto = _getObjProto(classProto);
213
+ var baseProto = _getObjProto$1(classProto);
214
214
  var visited = [];
215
215
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
216
216
  _forEachProp(baseProto, function (name) {
217
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
217
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
218
218
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
219
219
  }
220
220
  });
221
221
  visited.push(baseProto);
222
- baseProto = _getObjProto(baseProto);
222
+ baseProto = _getObjProto$1(baseProto);
223
223
  }
224
224
  return baseFuncs;
225
225
  }
@@ -233,7 +233,7 @@
233
233
  }
234
234
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
235
235
  var canAddInst = !_hasOwnProperty(target, funcName);
236
- var objProto = _getObjProto(target);
236
+ var objProto = _getObjProto$1(target);
237
237
  var visited = [];
238
238
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
239
239
  var protoFunc = objProto[funcName];
@@ -242,7 +242,7 @@
242
242
  break;
243
243
  }
244
244
  visited.push(objProto);
245
- objProto = _getObjProto(objProto);
245
+ objProto = _getObjProto$1(objProto);
246
246
  }
247
247
  try {
248
248
  if (canAddInst) {
@@ -260,7 +260,7 @@
260
260
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
261
261
  var protoFunc = proto[funcName];
262
262
  if (protoFunc === currentDynProtoProxy) {
263
- protoFunc = _getObjProto(proto)[funcName];
263
+ protoFunc = _getObjProto$1(proto)[funcName];
264
264
  }
265
265
  if (typeof protoFunc !== strFunction) {
266
266
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -294,15 +294,15 @@
294
294
  }
295
295
  }
296
296
  function _checkPrototype(classProto, thisTarget) {
297
- if (_objGetPrototypeOf) {
297
+ if (_objGetPrototypeOf$1) {
298
298
  var visited = [];
299
- var thisProto = _getObjProto(thisTarget);
299
+ var thisProto = _getObjProto$1(thisTarget);
300
300
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
301
301
  if (thisProto === classProto) {
302
302
  return true;
303
303
  }
304
304
  visited.push(thisProto);
305
- thisProto = _getObjProto(thisProto);
305
+ thisProto = _getObjProto$1(thisProto);
306
306
  }
307
307
  }
308
308
  return false;
@@ -338,7 +338,7 @@
338
338
  var instFuncs = _getInstanceFuncs(target);
339
339
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
340
340
  delegateFunc(target, baseFuncs);
341
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
341
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
342
342
  if (setInstanceFunc && options) {
343
343
  setInstanceFunc = !!options[strSetInstFuncs];
344
344
  }
@@ -451,8 +451,10 @@
451
451
  var strReduce = "reduce";
452
452
  var cStrTrim = "trim";
453
453
  var strToString = "toString";
454
+ var str__Proto = "__proto__";
455
+ var strConstructor = "constructor";
454
456
  var _objDefineProperty = ObjDefineProperty;
455
- ObjClass.freeze;
457
+ var _objFreeze = ObjClass.freeze;
456
458
  ObjClass.seal;
457
459
  var _objKeys = ObjClass.keys;
458
460
  var StringProto = String[strShimPrototype];
@@ -464,7 +466,20 @@
464
466
  var _isArray = Array.isArray;
465
467
  var _objToString = ObjProto[strToString];
466
468
  var _fnToString = ObjHasOwnProperty[strToString];
467
- _fnToString.call(ObjClass);
469
+ var _objFunctionString = _fnToString.call(ObjClass);
470
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
471
+ function _getObjProto(target) {
472
+ if (target) {
473
+ if (_objGetPrototypeOf) {
474
+ return _objGetPrototypeOf(target);
475
+ }
476
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
477
+ if (newProto) {
478
+ return newProto;
479
+ }
480
+ }
481
+ return null;
482
+ }
468
483
  function isTypeof(value, theType) {
469
484
  return typeof value === theType;
470
485
  }
@@ -562,6 +577,22 @@
562
577
  function isBoolean(value) {
563
578
  return typeof value === "boolean";
564
579
  }
580
+ function isPlainObject(value) {
581
+ var result = false;
582
+ if (value && typeof value === "object") {
583
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
584
+ if (!proto) {
585
+ result = true;
586
+ }
587
+ else {
588
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
589
+ proto = proto[strConstructor];
590
+ }
591
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
592
+ }
593
+ }
594
+ return result;
595
+ }
565
596
  function toISOString(date) {
566
597
  if (date) {
567
598
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -727,6 +758,10 @@
727
758
  }
728
759
  return false;
729
760
  }
761
+ function _doNothing(value) {
762
+ return value;
763
+ }
764
+ var objFreeze = _objFreeze || _doNothing;
730
765
  function dateNow() {
731
766
  var dt = Date;
732
767
  return dt.now ? dt.now() : new dt().getTime();
@@ -771,6 +806,44 @@
771
806
  function throwError(message) {
772
807
  throw new Error(message);
773
808
  }
809
+ function _createProxyFunction(source, funcName) {
810
+ var srcFunc = null;
811
+ var src = null;
812
+ if (isFunction(source)) {
813
+ srcFunc = source;
814
+ }
815
+ else {
816
+ src = source;
817
+ }
818
+ return function () {
819
+ var originalArguments = arguments;
820
+ if (srcFunc) {
821
+ src = srcFunc();
822
+ }
823
+ if (src) {
824
+ return src[funcName].apply(src, originalArguments);
825
+ }
826
+ };
827
+ }
828
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
829
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
830
+ if (target && name && source) {
831
+ if (overwriteTarget || isUndefined(target[name])) {
832
+ target[name] = _createProxyFunction(source, theFunc);
833
+ }
834
+ }
835
+ }
836
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
837
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
838
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
839
+ arrForEach(functionsToProxy, function (theFuncName) {
840
+ if (isString(theFuncName)) {
841
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
842
+ }
843
+ });
844
+ }
845
+ return target;
846
+ }
774
847
  function createClassFromInterface(defaults) {
775
848
  return /** @class */ (function () {
776
849
  function class_1() {
@@ -790,6 +863,50 @@
790
863
  }
791
864
  return theObject;
792
865
  }
866
+ function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
867
+ var theArgs = arguments;
868
+ var extended = theArgs[0] || {};
869
+ var argLen = theArgs.length;
870
+ var deep = false;
871
+ var idx = 1;
872
+ if (argLen > 0 && isBoolean(extended)) {
873
+ deep = extended;
874
+ extended = theArgs[idx] || {};
875
+ idx++;
876
+ }
877
+ if (!isObject(extended)) {
878
+ extended = {};
879
+ }
880
+ for (; idx < argLen; idx++) {
881
+ var arg = theArgs[idx];
882
+ var isArgArray = isArray(arg);
883
+ var isArgObj = isObject(arg);
884
+ for (var prop in arg) {
885
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
886
+ if (!propOk) {
887
+ continue;
888
+ }
889
+ var newValue = arg[prop];
890
+ var isNewArray = void 0;
891
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
892
+ var clone = extended[prop];
893
+ if (isNewArray) {
894
+ if (!isArray(clone)) {
895
+ clone = [];
896
+ }
897
+ }
898
+ else if (!isPlainObject(clone)) {
899
+ clone = {};
900
+ }
901
+ newValue = objExtend(deep, clone, newValue);
902
+ }
903
+ if (newValue !== undefined) {
904
+ extended[prop] = newValue;
905
+ }
906
+ }
907
+ }
908
+ return extended;
909
+ }
793
910
 
794
911
  var strWindow = "window";
795
912
  var strDocument = "document";
@@ -803,6 +920,7 @@
803
920
  var strMsCrypto = "msCrypto";
804
921
  var strMsie = "msie";
805
922
  var strTrident = "trident/";
923
+ var strXMLHttpRequest = "XMLHttpRequest";
806
924
  var _isTrident = null;
807
925
  var _navUserAgentCheck = null;
808
926
  var _enableMocks = false;
@@ -954,8 +1072,7 @@
954
1072
  function isFetchSupported(withKeepAlive) {
955
1073
  var isSupported = false;
956
1074
  try {
957
- var fetchApi = getGlobalInst("fetch");
958
- isSupported = !!fetchApi;
1075
+ isSupported = !!getGlobalInst("fetch");
959
1076
  var request = getGlobalInst("Request");
960
1077
  if (isSupported && withKeepAlive && request) {
961
1078
  isSupported = _hasProperty(request, "keepalive");
@@ -967,9 +1084,9 @@
967
1084
  }
968
1085
  function useXDomainRequest() {
969
1086
  if (_useXDomainRequest === null) {
970
- _useXDomainRequest = (typeof XDomainRequest !== "undefined");
1087
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
971
1088
  if (_useXDomainRequest && isXhrSupported()) {
972
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
1089
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst(strXMLHttpRequest), "withCredentials");
973
1090
  }
974
1091
  }
975
1092
  return _useXDomainRequest;
@@ -977,7 +1094,7 @@
977
1094
  function isXhrSupported() {
978
1095
  var isSupported = false;
979
1096
  try {
980
- var xmlHttpRequest = getGlobalInst("XMLHttpRequest");
1097
+ var xmlHttpRequest = getGlobalInst(strXMLHttpRequest);
981
1098
  isSupported = !!xmlHttpRequest;
982
1099
  }
983
1100
  catch (e) {
@@ -1320,253 +1437,240 @@
1320
1437
  return _defaultPerfManager;
1321
1438
  }
1322
1439
 
1323
- var TelemetryPluginChain = /** @class */ (function () {
1324
- function TelemetryPluginChain(plugin, defItemCtx) {
1325
- var _self = this;
1326
- var _nextProxy = null;
1327
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1328
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1329
- _self._hasRun = false;
1330
- _self.getPlugin = function () {
1331
- return plugin;
1332
- };
1333
- _self.getNext = function () {
1440
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1441
+ var strHasRunFlags = "_hasRun";
1442
+ var strGetTelCtx = "_getTelCtx";
1443
+ var _chainId = 0;
1444
+ function _getNextProxyStart(proxy, config, core, startAt) {
1445
+ while (proxy) {
1446
+ if (proxy.getPlugin() === startAt) {
1447
+ return proxy;
1448
+ }
1449
+ proxy = proxy.getNext();
1450
+ }
1451
+ return createTelemetryProxyChain([startAt], config, core);
1452
+ }
1453
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1454
+ var _nextProxy = null;
1455
+ var _onComplete = null;
1456
+ if (startAt) {
1457
+ _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1458
+ }
1459
+ else {
1460
+ _nextProxy = telemetryChain;
1461
+ }
1462
+ var context = {
1463
+ core: function () {
1464
+ return core;
1465
+ },
1466
+ diagLog: function () {
1467
+ return safeGetLogger(core, config);
1468
+ },
1469
+ getCfg: function () {
1470
+ return config;
1471
+ },
1472
+ getExtCfg: _getExtCfg,
1473
+ getConfig: _getConfig,
1474
+ hasNext: function () {
1475
+ return _nextProxy != null;
1476
+ },
1477
+ getNext: function () {
1334
1478
  return _nextProxy;
1335
- };
1336
- _self.setNext = function (nextPlugin) {
1479
+ },
1480
+ setNext: function (nextPlugin) {
1337
1481
  _nextProxy = nextPlugin;
1338
- };
1339
- _self.processTelemetry = function (env, itemCtx) {
1340
- if (!itemCtx) {
1341
- itemCtx = defItemCtx;
1482
+ },
1483
+ processNext: function (env) {
1484
+ _processChain(function (nextPlugin) {
1485
+ nextPlugin.processTelemetry(env, context);
1486
+ });
1487
+ },
1488
+ iterate: _iterateChain,
1489
+ createNew: function (plugins, startAt) {
1490
+ if (plugins === void 0) { plugins = null; }
1491
+ if (isArray(plugins)) {
1492
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1342
1493
  }
1343
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1344
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1345
- if (plugin && _hasProcessTelemetry) {
1346
- _self._hasRun = true;
1347
- try {
1348
- itemCtx.setNext(_nextProxy);
1349
- if (_hasSetNext) {
1350
- plugin.setNextPlugin(_nextProxy);
1351
- }
1352
- _nextProxy && (_nextProxy._hasRun = false);
1353
- plugin.processTelemetry(env, itemCtx);
1354
- }
1355
- catch (error) {
1356
- var hasRun = _nextProxy && _nextProxy._hasRun;
1357
- if (!_nextProxy || !hasRun) {
1358
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1359
- }
1360
- if (_nextProxy && !hasRun) {
1361
- _nextProxy.processTelemetry(env, itemCtx);
1494
+ return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1495
+ },
1496
+ onComplete: function (onComplete) {
1497
+ _onComplete = onComplete;
1498
+ }
1499
+ };
1500
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1501
+ if (defaultValue === void 0) { defaultValue = {}; }
1502
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1503
+ var theConfig;
1504
+ if (config) {
1505
+ var extConfig = config.extensionConfig;
1506
+ if (extConfig && identifier) {
1507
+ theConfig = extConfig[identifier];
1508
+ }
1509
+ }
1510
+ if (!theConfig) {
1511
+ theConfig = defaultValue;
1512
+ }
1513
+ else if (isObject(defaultValue)) {
1514
+ if (mergeDefault !== 0 ) {
1515
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1516
+ if (config && mergeDefault === 2 ) {
1517
+ objForEachKey(defaultValue, function (field) {
1518
+ if (isNullOrUndefined(newConfig_1[field])) {
1519
+ var cfgValue = config[field];
1520
+ if (!isNullOrUndefined(cfgValue)) {
1521
+ newConfig_1[field] = cfgValue;
1522
+ }
1362
1523
  }
1363
- }
1364
- }
1365
- else if (_nextProxy) {
1366
- _self._hasRun = true;
1367
- _nextProxy.processTelemetry(env, itemCtx);
1368
- }
1369
- }, function () { return ({ item: env }); }, !(env.sync));
1370
- };
1371
- }
1372
- return TelemetryPluginChain;
1373
- }());
1374
-
1375
- function _createProxyChain(plugins, itemCtx) {
1376
- var proxies = [];
1377
- if (plugins && plugins.length > 0) {
1378
- var lastProxy = null;
1379
- for (var idx = 0; idx < plugins.length; idx++) {
1380
- var thePlugin = plugins[idx];
1381
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1382
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1383
- proxies.push(newProxy);
1384
- if (lastProxy) {
1385
- lastProxy.setNext(newProxy);
1524
+ });
1386
1525
  }
1387
- lastProxy = newProxy;
1388
1526
  }
1389
1527
  }
1528
+ return theConfig;
1529
+ }
1530
+ function _getConfig(identifier, field, defaultValue) {
1531
+ if (defaultValue === void 0) { defaultValue = false; }
1532
+ var theValue;
1533
+ var extConfig = _getExtCfg(identifier, null);
1534
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1535
+ theValue = extConfig[field];
1536
+ }
1537
+ else if (config && !isNullOrUndefined(config[field])) {
1538
+ theValue = config[field];
1539
+ }
1540
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1390
1541
  }
1391
- return proxies.length > 0 ? proxies[0] : null;
1392
- }
1393
- function _copyProxyChain(proxy, itemCtx, startAt) {
1394
- var plugins = [];
1395
- var add = startAt ? false : true;
1396
- if (proxy) {
1397
- while (proxy) {
1398
- var thePlugin = proxy.getPlugin();
1399
- if (add || thePlugin === startAt) {
1400
- add = true;
1401
- plugins.push(thePlugin);
1542
+ function _processChain(cb) {
1543
+ var nextPlugin = _nextProxy;
1544
+ if (nextPlugin) {
1545
+ _nextProxy = nextPlugin.getNext();
1546
+ cb(nextPlugin);
1547
+ }
1548
+ else {
1549
+ if (_onComplete) {
1550
+ _onComplete();
1551
+ _onComplete = null;
1402
1552
  }
1403
- proxy = proxy.getNext();
1404
1553
  }
1405
1554
  }
1406
- if (!add) {
1407
- plugins.push(startAt);
1555
+ function _iterateChain(cb) {
1556
+ while (_nextProxy) {
1557
+ _processChain(function (nextPlugin) {
1558
+ var plugin = nextPlugin.getPlugin();
1559
+ if (plugin) {
1560
+ cb(plugin);
1561
+ }
1562
+ });
1563
+ }
1408
1564
  }
1409
- return _createProxyChain(plugins, itemCtx);
1565
+ return context;
1410
1566
  }
1411
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1412
- var plugins = srcPlugins;
1413
- var add = false;
1414
- if (startAt && srcPlugins) {
1415
- plugins = [];
1416
- arrForEach(srcPlugins, function (thePlugin) {
1417
- if (add || thePlugin === startAt) {
1567
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1568
+ var firstProxy = null;
1569
+ var add = startAt ? false : true;
1570
+ if (isArray(plugins) && plugins.length > 0) {
1571
+ var lastProxy_1 = null;
1572
+ arrForEach(plugins, function (thePlugin) {
1573
+ if (!add && startAt === thePlugin) {
1418
1574
  add = true;
1419
- plugins.push(thePlugin);
1575
+ }
1576
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1577
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1578
+ if (!firstProxy) {
1579
+ firstProxy = newProxy;
1580
+ }
1581
+ if (lastProxy_1) {
1582
+ lastProxy_1._setNext(newProxy);
1583
+ }
1584
+ lastProxy_1 = newProxy;
1420
1585
  }
1421
1586
  });
1422
1587
  }
1423
- if (startAt && !add) {
1424
- if (!plugins) {
1425
- plugins = [];
1426
- }
1427
- plugins.push(startAt);
1588
+ if (startAt && !firstProxy) {
1589
+ return createTelemetryProxyChain([startAt], config, core);
1428
1590
  }
1429
- return _createProxyChain(plugins, itemCtx);
1591
+ return firstProxy;
1430
1592
  }
1431
- var ProcessTelemetryContext = /** @class */ (function () {
1432
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1433
- var _self = this;
1434
- var _nextProxy = null;
1435
- if (startAt !== null) {
1436
- if (plugins && isFunction(plugins.getPlugin)) {
1437
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1438
- }
1439
- else {
1440
- if (startAt) {
1441
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1442
- }
1443
- else if (isUndefined(startAt)) {
1444
- _nextProxy = _createProxyChain(plugins, _self);
1445
- }
1446
- }
1447
- }
1448
- _self.core = function () {
1449
- return core;
1450
- };
1451
- _self.diagLog = function () {
1452
- return safeGetLogger(core, config);
1453
- };
1454
- _self.getCfg = function () {
1455
- return config;
1456
- };
1457
- _self.getExtCfg = function (identifier, defaultValue) {
1458
- if (defaultValue === void 0) { defaultValue = {}; }
1459
- var theConfig;
1460
- if (config) {
1461
- var extConfig = config.extensionConfig;
1462
- if (extConfig && identifier) {
1463
- theConfig = extConfig[identifier];
1464
- }
1465
- }
1466
- return (theConfig ? theConfig : defaultValue);
1467
- };
1468
- _self.getConfig = function (identifier, field, defaultValue) {
1469
- if (defaultValue === void 0) { defaultValue = false; }
1470
- var theValue;
1471
- var extConfig = _self.getExtCfg(identifier, null);
1472
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1473
- theValue = extConfig[field];
1474
- }
1475
- else if (config && !isNullOrUndefined(config[field])) {
1476
- theValue = config[field];
1477
- }
1478
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1479
- };
1480
- _self.hasNext = function () {
1481
- return _nextProxy != null;
1482
- };
1483
- _self.getNext = function () {
1484
- return _nextProxy;
1485
- };
1486
- _self.setNext = function (nextPlugin) {
1487
- _nextProxy = nextPlugin;
1488
- };
1489
- _self.processNext = function (env) {
1490
- var nextPlugin = _nextProxy;
1491
- if (nextPlugin) {
1492
- _nextProxy = nextPlugin.getNext();
1493
- nextPlugin.processTelemetry(env, _self);
1494
- }
1495
- };
1496
- _self.createNew = function (plugins, startAt) {
1497
- if (plugins === void 0) { plugins = null; }
1498
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1499
- };
1593
+ function createTelemetryPluginProxy(plugin, config, core) {
1594
+ var nextProxy = null;
1595
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1596
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1597
+ var chainId;
1598
+ if (plugin) {
1599
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1500
1600
  }
1501
- return ProcessTelemetryContext;
1502
- }());
1503
-
1504
- var strIKey = "iKey";
1505
- var strExtensionConfig = "extensionConfig";
1506
-
1507
- var strGetPlugin = "getPlugin";
1508
- var BaseTelemetryPlugin = /** @class */ (function () {
1509
- function BaseTelemetryPlugin() {
1510
- var _self = this;
1511
- var _isinitialized = false;
1512
- var _rootCtx = null;
1513
- var _nextPlugin = null;
1514
- _self.core = null;
1515
- _self.diagLog = function (itemCtx) {
1516
- return _self._getTelCtx(itemCtx).diagLog();
1517
- };
1518
- _self.isInitialized = function () {
1519
- return _isinitialized;
1520
- };
1521
- _self.setInitialized = function (isInitialized) {
1522
- _isinitialized = isInitialized;
1523
- };
1524
- _self.setNextPlugin = function (next) {
1525
- _nextPlugin = next;
1526
- };
1527
- _self.processNext = function (env, itemCtx) {
1528
- if (itemCtx) {
1529
- itemCtx.processNext(env);
1530
- }
1531
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1532
- _nextPlugin.processTelemetry(env, null);
1601
+ else {
1602
+ chainId = "Unknown-0-" + _chainId++;
1603
+ }
1604
+ var proxyChain = {
1605
+ getPlugin: function () {
1606
+ return plugin;
1607
+ },
1608
+ getNext: function () {
1609
+ return nextProxy;
1610
+ },
1611
+ processTelemetry: _processTelemetry,
1612
+ _id: chainId,
1613
+ _setNext: function (nextPlugin) {
1614
+ nextProxy = nextPlugin;
1615
+ }
1616
+ };
1617
+ function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1618
+ if (!itemCtx) {
1619
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1620
+ itemCtx = plugin[strGetTelCtx]();
1533
1621
  }
1534
- };
1535
- _self._getTelCtx = function (currentCtx) {
1536
- if (currentCtx === void 0) { currentCtx = null; }
1537
- var itemCtx = currentCtx;
1538
1622
  if (!itemCtx) {
1539
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1540
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1541
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1623
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1624
+ }
1625
+ }
1626
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1627
+ var hasRunContext = itemCtx[strHasRunFlags];
1628
+ if (!hasRunContext) {
1629
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1630
+ }
1631
+ doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1632
+ hasRunContext[chainId] = true;
1633
+ var hasRun = false;
1634
+ itemCtx.setNext(nextProxy);
1635
+ if (plugin) {
1636
+ try {
1637
+ var nextId = nextProxy ? nextProxy._id : "";
1638
+ if (nextId) {
1639
+ hasRunContext[nextId] = false;
1640
+ }
1641
+ hasRun = processPluginFn(itemCtx);
1542
1642
  }
1543
- else {
1544
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1643
+ catch (error) {
1644
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1645
+ if (hasNextRun) {
1646
+ hasRun = true;
1647
+ }
1648
+ if (!nextProxy || !hasNextRun) {
1649
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1650
+ }
1545
1651
  }
1546
1652
  }
1547
- return itemCtx;
1548
- };
1549
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1550
- if (config) {
1551
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1653
+ if (nextProxy && !hasRun) {
1654
+ processProxyFn(itemCtx);
1552
1655
  }
1553
- if (!pluginChain && core) {
1554
- pluginChain = core.getProcessTelContext().getNext();
1656
+ }, details, isAsync);
1657
+ }
1658
+ function _processTelemetry(env, itemCtx) {
1659
+ _processChain(itemCtx, function (itemCtx) {
1660
+ if (!hasProcessTelemetry) {
1661
+ return false;
1555
1662
  }
1556
- var nextPlugin = _nextPlugin;
1557
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1558
- nextPlugin = _nextPlugin[strGetPlugin]();
1663
+ if (hasSetNext) {
1664
+ plugin.setNextPlugin(nextProxy);
1559
1665
  }
1560
- _self.core = core;
1561
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1562
- _isinitialized = true;
1563
- };
1666
+ plugin.processTelemetry(env, itemCtx);
1667
+ return true;
1668
+ }, function (itemCtx) {
1669
+ nextProxy.processTelemetry(env, itemCtx);
1670
+ }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1564
1671
  }
1565
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1566
- this._baseTelInit(config, core, extensions, pluginChain);
1567
- };
1568
- return BaseTelemetryPlugin;
1569
- }());
1672
+ return objFreeze(proxyChain);
1673
+ }
1570
1674
 
1571
1675
  var processTelemetry = "processTelemetry";
1572
1676
  var priority = "priority";
@@ -1609,81 +1713,6 @@
1609
1713
  });
1610
1714
  }
1611
1715
 
1612
- var ChannelControllerPriority = 500;
1613
- var ChannelValidationMessage = "Channel has invalid priority";
1614
- var ChannelController = /** @class */ (function (_super) {
1615
- __extendsFn(ChannelController, _super);
1616
- function ChannelController() {
1617
- var _this = _super.call(this) || this;
1618
- _this.identifier = "ChannelControllerPlugin";
1619
- _this.priority = ChannelControllerPriority;
1620
- var _channelQueue;
1621
- dynamicProto(ChannelController, _this, function (_self, _base) {
1622
- _self.setNextPlugin = function (next) {
1623
- };
1624
- _self.processTelemetry = function (item, itemCtx) {
1625
- if (_channelQueue) {
1626
- arrForEach(_channelQueue, function (queues) {
1627
- if (queues.length > 0) {
1628
- var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
1629
- chainCtx.processNext(item);
1630
- }
1631
- });
1632
- }
1633
- };
1634
- _self.getChannelControls = function () {
1635
- return _channelQueue;
1636
- };
1637
- _self.initialize = function (config, core, extensions) {
1638
- if (_self.isInitialized()) {
1639
- return;
1640
- }
1641
- _base.initialize(config, core, extensions);
1642
- _createChannelQueues((config || {}).channels, extensions);
1643
- arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
1644
- };
1645
- });
1646
- function _checkQueuePriority(queue) {
1647
- arrForEach(queue, function (queueItem) {
1648
- if (queueItem.priority < ChannelControllerPriority) {
1649
- throwError(ChannelValidationMessage + queueItem.identifier);
1650
- }
1651
- });
1652
- }
1653
- function _addChannelQueue(queue) {
1654
- if (queue && queue.length > 0) {
1655
- queue = queue.sort(function (a, b) {
1656
- return a.priority - b.priority;
1657
- });
1658
- _checkQueuePriority(queue);
1659
- _channelQueue.push(queue);
1660
- }
1661
- }
1662
- function _createChannelQueues(channels, extensions) {
1663
- _channelQueue = [];
1664
- if (channels) {
1665
- arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
1666
- }
1667
- if (extensions) {
1668
- var extensionQueue_1 = [];
1669
- arrForEach(extensions, function (plugin) {
1670
- if (plugin.priority > ChannelControllerPriority) {
1671
- extensionQueue_1.push(plugin);
1672
- }
1673
- });
1674
- _addChannelQueue(extensionQueue_1);
1675
- }
1676
- }
1677
- return _this;
1678
- }
1679
- ChannelController._staticInit = (function () {
1680
- var proto = ChannelController.prototype;
1681
- objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
1682
- objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
1683
- })();
1684
- return ChannelController;
1685
- }(BaseTelemetryPlugin));
1686
-
1687
1716
  var strToGMTString = "toGMTString";
1688
1717
  var strToUTCString = "toUTCString";
1689
1718
  var strCookie = "cookie";
@@ -1848,87 +1877,425 @@
1848
1877
  if (idx === -1) {
1849
1878
  values[thePart] = null;
1850
1879
  }
1851
- else {
1852
- values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1880
+ else {
1881
+ values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1882
+ }
1883
+ }
1884
+ });
1885
+ }
1886
+ return values;
1887
+ }
1888
+ function _formatDate(theDate, func) {
1889
+ if (isFunction(theDate[func])) {
1890
+ return theDate[func]();
1891
+ }
1892
+ return null;
1893
+ }
1894
+ function _formatCookieValue(value, values) {
1895
+ var cookieValue = value || strEmpty;
1896
+ objForEachKey(values, function (name, theValue) {
1897
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1898
+ });
1899
+ return cookieValue;
1900
+ }
1901
+ function _getCookieValue(name) {
1902
+ var cookieValue = strEmpty;
1903
+ if (_doc) {
1904
+ var theCookie = _doc[strCookie] || strEmpty;
1905
+ if (_parsedCookieValue !== theCookie) {
1906
+ _cookieCache = _extractParts(theCookie);
1907
+ _parsedCookieValue = theCookie;
1908
+ }
1909
+ cookieValue = strTrim(_cookieCache[name] || strEmpty);
1910
+ }
1911
+ return cookieValue;
1912
+ }
1913
+ function _setCookieValue(name, cookieValue) {
1914
+ if (_doc) {
1915
+ _doc[strCookie] = name + "=" + cookieValue;
1916
+ }
1917
+ }
1918
+ function uaDisallowsSameSiteNone(userAgent) {
1919
+ if (!isString(userAgent)) {
1920
+ return false;
1921
+ }
1922
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
1923
+ return true;
1924
+ }
1925
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
1926
+ return true;
1927
+ }
1928
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
1929
+ return true;
1930
+ }
1931
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
1932
+ return true;
1933
+ }
1934
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
1935
+ return true;
1936
+ }
1937
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1938
+ return true;
1939
+ }
1940
+ return false;
1941
+ }
1942
+
1943
+ var strIKey = "iKey";
1944
+ var strExtensionConfig = "extensionConfig";
1945
+
1946
+ var ChannelControllerPriority = 500;
1947
+ var ChannelValidationMessage = "Channel has invalid priority - ";
1948
+ function _addChannelQueue(channelQueue, queue, config, core) {
1949
+ if (queue && isArray(queue) && queue.length > 0) {
1950
+ queue = queue.sort(function (a, b) {
1951
+ return a.priority - b.priority;
1952
+ });
1953
+ arrForEach(queue, function (queueItem) {
1954
+ if (queueItem.priority < ChannelControllerPriority) {
1955
+ throwError(ChannelValidationMessage + queueItem.identifier);
1956
+ }
1957
+ });
1958
+ channelQueue.push({
1959
+ queue: objFreeze(queue),
1960
+ chain: createTelemetryProxyChain(queue, config, core)
1961
+ });
1962
+ }
1963
+ }
1964
+ function createChannelControllerPlugin(channelQueue, core) {
1965
+ function _getTelCtx(itemCtx) {
1966
+ if (!itemCtx) {
1967
+ itemCtx = createProcessTelemetryContext(null, core.config, core, null);
1968
+ }
1969
+ return itemCtx;
1970
+ }
1971
+ function _processChannelQueue(itemCtx, processFn, onComplete) {
1972
+ if (channelQueue && channelQueue.length > 0) {
1973
+ var waiting_1 = channelQueue.length;
1974
+ arrForEach(channelQueue, function (channels) {
1975
+ if (channels && channels.queue.length > 0) {
1976
+ var channelChain = channels.chain;
1977
+ var chainCtx = _getTelCtx(itemCtx).createNew(channelChain);
1978
+ chainCtx.onComplete(function () {
1979
+ waiting_1--;
1980
+ if (waiting_1 === 0) {
1981
+ onComplete && onComplete();
1982
+ onComplete = null;
1983
+ }
1984
+ });
1985
+ processFn(chainCtx);
1986
+ }
1987
+ else {
1988
+ waiting_1--;
1989
+ }
1990
+ });
1991
+ if (waiting_1 === 0) {
1992
+ onComplete && onComplete();
1993
+ }
1994
+ }
1995
+ else {
1996
+ onComplete && onComplete();
1997
+ }
1998
+ }
1999
+ var isInitialized = false;
2000
+ var channelController = {
2001
+ identifier: "ChannelControllerPlugin",
2002
+ priority: ChannelControllerPriority,
2003
+ initialize: function (config, core, extensions, pluginChain) {
2004
+ isInitialized = true;
2005
+ arrForEach(channelQueue, function (channels) {
2006
+ if (channels && channels.queue.length > 0) {
2007
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2008
+ }
2009
+ });
2010
+ },
2011
+ isInitialized: function () { return isInitialized; },
2012
+ processTelemetry: function (item, itemCtx) {
2013
+ _processChannelQueue(itemCtx, function (chainCtx) {
2014
+ chainCtx.processNext(item);
2015
+ }, function () {
2016
+ itemCtx.processNext(item);
2017
+ });
2018
+ },
2019
+ pause: function () {
2020
+ _processChannelQueue(null, function (chainCtx) {
2021
+ chainCtx.iterate(function (plugin) {
2022
+ plugin.pause && plugin.pause();
2023
+ });
2024
+ });
2025
+ },
2026
+ resume: function () {
2027
+ _processChannelQueue(null, function (chainCtx) {
2028
+ chainCtx.iterate(function (plugin) {
2029
+ plugin.resume && plugin.resume();
2030
+ });
2031
+ });
2032
+ },
2033
+ teardown: function () {
2034
+ _processChannelQueue(null, function (chainCtx) {
2035
+ chainCtx.iterate(function (plugin) {
2036
+ plugin.teardown && plugin.teardown();
2037
+ });
2038
+ });
2039
+ },
2040
+ flush: function (isAsync, callBack, sendReason, cbTimeout) {
2041
+ var doneIterating = false;
2042
+ var waiting = 0;
2043
+ var cbTimer = null;
2044
+ cbTimeout = cbTimeout || 5000;
2045
+ function doCallback() {
2046
+ if (doneIterating && waiting === 0) {
2047
+ if (cbTimer) {
2048
+ clearTimeout(cbTimer);
2049
+ cbTimer = null;
2050
+ }
2051
+ callBack && callBack(doneIterating);
2052
+ callBack = null;
2053
+ }
2054
+ }
2055
+ waiting = 1;
2056
+ _processChannelQueue(null, function (chainCtx) {
2057
+ chainCtx.iterate(function (plugin) {
2058
+ if (plugin.flush) {
2059
+ waiting++;
2060
+ if (!plugin.flush(isAsync, function () {
2061
+ waiting--;
2062
+ doCallback();
2063
+ }, sendReason)) {
2064
+ if (cbTimer == null) {
2065
+ cbTimer = setTimeout(function () {
2066
+ cbTimer = null;
2067
+ callBack && callBack(false);
2068
+ callBack = null;
2069
+ }, cbTimeout);
2070
+ }
2071
+ }
2072
+ }
2073
+ });
2074
+ }, function () {
2075
+ waiting--;
2076
+ doneIterating = true;
2077
+ doCallback();
2078
+ });
2079
+ }
2080
+ };
2081
+ return channelController;
2082
+ }
2083
+ function createChannelQueues(channels, extensions, config, core) {
2084
+ var channelQueue = [];
2085
+ if (channels) {
2086
+ arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
2087
+ }
2088
+ if (extensions) {
2089
+ var extensionQueue_1 = [];
2090
+ arrForEach(extensions, function (plugin) {
2091
+ if (plugin.priority > ChannelControllerPriority) {
2092
+ extensionQueue_1.push(plugin);
2093
+ }
2094
+ });
2095
+ _addChannelQueue(channelQueue, extensionQueue_1, config, core);
2096
+ }
2097
+ return channelQueue;
2098
+ }
2099
+
2100
+ var strGetPlugin = "getPlugin";
2101
+ var BaseTelemetryPlugin = /** @class */ (function () {
2102
+ function BaseTelemetryPlugin() {
2103
+ var _self = this;
2104
+ var _isinitialized;
2105
+ var _rootCtx;
2106
+ var _nextPlugin;
2107
+ var _hooks;
2108
+ _initDefaults();
2109
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
2110
+ _self.initialize = function (config, core, extensions, pluginChain) {
2111
+ _setDefaults(config, core, pluginChain);
2112
+ _isinitialized = true;
2113
+ };
2114
+ _self._addHook = function (hooks) {
2115
+ if (hooks) {
2116
+ if (isArray(hooks)) {
2117
+ _hooks = _hooks.concat(hooks);
2118
+ }
2119
+ else {
2120
+ _hooks.push(hooks);
2121
+ }
2122
+ }
2123
+ };
2124
+ });
2125
+ _self.diagLog = function (itemCtx) {
2126
+ return _getTelCtx(itemCtx).diagLog();
2127
+ };
2128
+ _self.isInitialized = function () {
2129
+ return _isinitialized;
2130
+ };
2131
+ _self.setInitialized = function (isInitialized) {
2132
+ _isinitialized = isInitialized;
2133
+ };
2134
+ _self.setNextPlugin = function (next) {
2135
+ _nextPlugin = next;
2136
+ };
2137
+ _self.processNext = function (env, itemCtx) {
2138
+ if (itemCtx) {
2139
+ itemCtx.processNext(env);
2140
+ }
2141
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
2142
+ _nextPlugin.processTelemetry(env, null);
2143
+ }
2144
+ };
2145
+ _self._getTelCtx = _getTelCtx;
2146
+ function _getTelCtx(currentCtx) {
2147
+ if (currentCtx === void 0) { currentCtx = null; }
2148
+ var itemCtx = currentCtx;
2149
+ if (!itemCtx) {
2150
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
2151
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2152
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
2153
+ }
2154
+ else {
2155
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
2156
+ }
2157
+ }
2158
+ return itemCtx;
2159
+ }
2160
+ function _setDefaults(config, core, pluginChain) {
2161
+ if (config) {
2162
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
2163
+ }
2164
+ if (!pluginChain && core) {
2165
+ pluginChain = core.getProcessTelContext().getNext();
2166
+ }
2167
+ var nextPlugin = _nextPlugin;
2168
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
2169
+ nextPlugin = _nextPlugin[strGetPlugin]();
2170
+ }
2171
+ _self.core = core;
2172
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
2173
+ }
2174
+ function _initDefaults() {
2175
+ _isinitialized = false;
2176
+ _self.core = null;
2177
+ _rootCtx = null;
2178
+ _nextPlugin = null;
2179
+ _hooks = [];
2180
+ }
2181
+ }
2182
+ return BaseTelemetryPlugin;
2183
+ }());
2184
+
2185
+ var TelemetryInitializerPlugin = /** @class */ (function (_super) {
2186
+ __extendsFn(TelemetryInitializerPlugin, _super);
2187
+ function TelemetryInitializerPlugin() {
2188
+ var _this = _super.call(this) || this;
2189
+ _this.identifier = "TelemetryInitializerPlugin";
2190
+ _this.priority = 199;
2191
+ var _id;
2192
+ var _initializers;
2193
+ _initDefaults();
2194
+ dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
2195
+ _self.addTelemetryInitializer = function (telemetryInitializer) {
2196
+ var theInitializer = {
2197
+ id: _id++,
2198
+ fn: telemetryInitializer
2199
+ };
2200
+ _initializers.push(theInitializer);
2201
+ var handler = {
2202
+ remove: function () {
2203
+ arrForEach(_initializers, function (initializer, idx) {
2204
+ if (initializer.id === theInitializer.id) {
2205
+ _initializers.splice(idx, 1);
2206
+ return -1;
2207
+ }
2208
+ });
2209
+ }
2210
+ };
2211
+ return handler;
2212
+ };
2213
+ _self.processTelemetry = function (item, itemCtx) {
2214
+ var doNotSendItem = false;
2215
+ var telemetryInitializersCount = _initializers.length;
2216
+ for (var i = 0; i < telemetryInitializersCount; ++i) {
2217
+ var telemetryInitializer = _initializers[i];
2218
+ if (telemetryInitializer) {
2219
+ try {
2220
+ if (telemetryInitializer.fn.apply(null, [item]) === false) {
2221
+ doNotSendItem = true;
2222
+ break;
2223
+ }
2224
+ }
2225
+ catch (e) {
2226
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
2227
+ }
2228
+ }
2229
+ }
2230
+ if (!doNotSendItem) {
2231
+ _self.processNext(item, itemCtx);
1853
2232
  }
1854
- }
2233
+ };
2234
+ _self.unload = function (itemCtx, isAsync) {
2235
+ _base.unload(itemCtx, isAsync);
2236
+ _initDefaults();
2237
+ };
1855
2238
  });
1856
- }
1857
- return values;
1858
- }
1859
- function _formatDate(theDate, func) {
1860
- if (isFunction(theDate[func])) {
1861
- return theDate[func]();
1862
- }
1863
- return null;
1864
- }
1865
- function _formatCookieValue(value, values) {
1866
- var cookieValue = value || strEmpty;
1867
- objForEachKey(values, function (name, theValue) {
1868
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
1869
- });
1870
- return cookieValue;
1871
- }
1872
- function _getCookieValue(name) {
1873
- var cookieValue = strEmpty;
1874
- if (_doc) {
1875
- var theCookie = _doc[strCookie] || strEmpty;
1876
- if (_parsedCookieValue !== theCookie) {
1877
- _cookieCache = _extractParts(theCookie);
1878
- _parsedCookieValue = theCookie;
2239
+ function _initDefaults() {
2240
+ _id = 0;
2241
+ _initializers = [];
1879
2242
  }
1880
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
1881
- }
1882
- return cookieValue;
1883
- }
1884
- function _setCookieValue(name, cookieValue) {
1885
- if (_doc) {
1886
- _doc[strCookie] = name + "=" + cookieValue;
1887
- }
1888
- }
1889
- function uaDisallowsSameSiteNone(userAgent) {
1890
- if (!isString(userAgent)) {
1891
- return false;
1892
- }
1893
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
1894
- return true;
1895
- }
1896
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
1897
- return true;
1898
- }
1899
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
1900
- return true;
1901
- }
1902
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
1903
- return true;
1904
- }
1905
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
1906
- return true;
1907
- }
1908
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1909
- return true;
2243
+ return _this;
1910
2244
  }
1911
- return false;
1912
- }
2245
+ return TelemetryInitializerPlugin;
2246
+ }(BaseTelemetryPlugin));
1913
2247
 
1914
- var validationError = "Extensions must provide callback to initialize";
2248
+ var strValidationError = "Plugins must provide initialize method";
1915
2249
  var strNotificationManager = "_notificationManager";
1916
2250
  function _createPerfManager(core, notificationMgr) {
1917
2251
  return new PerfManager(notificationMgr);
1918
2252
  }
2253
+ function _validateExtensions(logger, channelPriority, allExtensions) {
2254
+ var coreExtensions = [];
2255
+ var extPriorities = {};
2256
+ arrForEach(allExtensions, function (ext) {
2257
+ if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
2258
+ throwError(strValidationError);
2259
+ }
2260
+ var extPriority = ext.priority;
2261
+ var identifier = ext.identifier;
2262
+ if (ext && extPriority) {
2263
+ if (!isNullOrUndefined(extPriorities[extPriority])) {
2264
+ logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
2265
+ }
2266
+ else {
2267
+ extPriorities[extPriority] = identifier;
2268
+ }
2269
+ }
2270
+ if (!extPriority || extPriority < channelPriority) {
2271
+ coreExtensions.push(ext);
2272
+ }
2273
+ });
2274
+ return {
2275
+ all: allExtensions,
2276
+ core: coreExtensions
2277
+ };
2278
+ }
1919
2279
  var BaseCore = /** @class */ (function () {
1920
2280
  function BaseCore() {
1921
- var _isInitialized = false;
2281
+ var _isInitialized;
1922
2282
  var _eventQueue;
1923
- var _channelController;
1924
2283
  var _notificationManager;
1925
2284
  var _perfManager;
2285
+ var _cfgPerfManager;
1926
2286
  var _cookieManager;
2287
+ var _pluginChain;
2288
+ var _configExtensions;
2289
+ var _coreExtensions;
2290
+ var _channelControl;
2291
+ var _channelConfig;
2292
+ var _channelQueue;
2293
+ var _telemetryInitializerPlugin;
2294
+ var _internalLogsEventName;
2295
+ var _debugListener;
2296
+ var _internalLogPoller = 0;
1927
2297
  dynamicProto(BaseCore, this, function (_self) {
1928
- _self._extensions = new Array();
1929
- _channelController = new ChannelController();
1930
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
1931
- _eventQueue = [];
2298
+ _initDefaults();
1932
2299
  _self.isInitialized = function () { return _isInitialized; };
1933
2300
  _self.initialize = function (config, extensions, logger, notificationManager) {
1934
2301
  if (_self.isInitialized()) {
@@ -1940,48 +2307,18 @@
1940
2307
  _notificationManager = notificationManager;
1941
2308
  _self[strNotificationManager] = notificationManager;
1942
2309
  _self.config = config || {};
1943
- if (notificationManager && _self.config.disableDbgExt !== true) {
1944
- notificationManager.addNotificationListener(getDebugListener(config));
1945
- }
1946
- if (_self.config.enablePerfMgr) {
1947
- setValue(_self.config, "createPerfMgr", _createPerfManager);
1948
- }
2310
+ _initDebugListener(config);
2311
+ _initPerfManager(config);
1949
2312
  config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
1950
2313
  var extConfig = getSetValue(config, strExtensionConfig);
1951
2314
  extConfig.NotificationManager = notificationManager;
1952
2315
  if (logger) {
1953
2316
  _self.logger = logger;
1954
2317
  }
1955
- var allExtensions = [];
1956
- allExtensions.push.apply(allExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
1957
- allExtensions = sortPlugins(allExtensions);
1958
- var coreExtensions = [];
1959
- var extPriorities = {};
1960
- arrForEach(allExtensions, function (ext) {
1961
- if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
1962
- throwError(validationError);
1963
- }
1964
- var extPriority = ext.priority;
1965
- var identifier = ext.identifier;
1966
- if (ext && extPriority) {
1967
- if (!isNullOrUndefined(extPriorities[extPriority])) {
1968
- logger.warnToConsole("Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
1969
- }
1970
- else {
1971
- extPriorities[extPriority] = identifier;
1972
- }
1973
- }
1974
- if (!extPriority || extPriority < _channelController.priority) {
1975
- coreExtensions.push(ext);
1976
- }
1977
- });
1978
- allExtensions.push(_channelController);
1979
- coreExtensions.push(_channelController);
1980
- allExtensions = sortPlugins(allExtensions);
1981
- _self._extensions = allExtensions;
1982
- initializePlugins(new ProcessTelemetryContext([_channelController], config, _self), allExtensions);
1983
- initializePlugins(new ProcessTelemetryContext(coreExtensions, config, _self), allExtensions);
1984
- _self._extensions = coreExtensions;
2318
+ _configExtensions = [];
2319
+ _configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
2320
+ _channelConfig = (config || {}).channels;
2321
+ _initPluginChain(config);
1985
2322
  if (_self.getTransmissionControls().length === 0) {
1986
2323
  throwError("No channels available");
1987
2324
  }
@@ -1989,7 +2326,11 @@
1989
2326
  _self.releaseQueue();
1990
2327
  };
1991
2328
  _self.getTransmissionControls = function () {
1992
- return _channelController.getChannelControls();
2329
+ var controls = [];
2330
+ arrForEach(_channelQueue, function (channels) {
2331
+ controls.push(channels.queue);
2332
+ });
2333
+ return objFreeze(controls);
1993
2334
  };
1994
2335
  _self.track = function (telemetryItem) {
1995
2336
  setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
@@ -2003,12 +2344,7 @@
2003
2344
  }
2004
2345
  };
2005
2346
  _self.getProcessTelContext = function () {
2006
- var extensions = _self._extensions;
2007
- var thePlugins = extensions;
2008
- if (!extensions || extensions.length === 0) {
2009
- thePlugins = [_channelController];
2010
- }
2011
- return new ProcessTelemetryContext(thePlugins, _self.config, _self);
2347
+ return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
2012
2348
  };
2013
2349
  _self.getNotifyMgr = function () {
2014
2350
  if (!_notificationManager) {
@@ -2023,6 +2359,16 @@
2023
2359
  }
2024
2360
  return _notificationManager;
2025
2361
  };
2362
+ _self.addNotificationListener = function (listener) {
2363
+ if (_notificationManager) {
2364
+ _notificationManager.addNotificationListener(listener);
2365
+ }
2366
+ };
2367
+ _self.removeNotificationListener = function (listener) {
2368
+ if (_notificationManager) {
2369
+ _notificationManager.removeNotificationListener(listener);
2370
+ }
2371
+ };
2026
2372
  _self.getCookieMgr = function () {
2027
2373
  if (!_cookieManager) {
2028
2374
  _cookieManager = createCookieMgr(_self.config, _self.logger);
@@ -2033,12 +2379,12 @@
2033
2379
  _cookieManager = cookieMgr;
2034
2380
  };
2035
2381
  _self.getPerfMgr = function () {
2036
- if (!_perfManager) {
2382
+ if (!_perfManager && !_cfgPerfManager) {
2037
2383
  if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
2038
- _perfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2384
+ _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
2039
2385
  }
2040
2386
  }
2041
- return _perfManager || getGblPerfMgr();
2387
+ return _perfManager || _cfgPerfManager || getGblPerfMgr();
2042
2388
  };
2043
2389
  _self.setPerfMgr = function (perfMgr) {
2044
2390
  _perfManager = perfMgr;
@@ -2047,18 +2393,153 @@
2047
2393
  return _eventQueue.length;
2048
2394
  };
2049
2395
  _self.releaseQueue = function () {
2050
- if (_eventQueue.length > 0) {
2051
- arrForEach(_eventQueue, function (event) {
2396
+ if (_isInitialized && _eventQueue.length > 0) {
2397
+ var eventQueue = _eventQueue;
2398
+ _eventQueue = [];
2399
+ arrForEach(eventQueue, function (event) {
2052
2400
  _self.getProcessTelContext().processNext(event);
2053
2401
  });
2054
- _eventQueue = [];
2055
2402
  }
2056
2403
  };
2404
+ _self.pollInternalLogs = function (eventName) {
2405
+ _internalLogsEventName = eventName;
2406
+ var interval = _self.config.diagnosticLogInterval;
2407
+ if (!interval || !(interval > 0)) {
2408
+ interval = 10000;
2409
+ }
2410
+ if (_internalLogPoller) {
2411
+ clearInterval(_internalLogPoller);
2412
+ }
2413
+ _internalLogPoller = setInterval(function () {
2414
+ _flushInternalLogs();
2415
+ }, interval);
2416
+ return _internalLogPoller;
2417
+ };
2418
+ _self.stopPollingInternalLogs = function () {
2419
+ if (_internalLogPoller) {
2420
+ clearInterval(_internalLogPoller);
2421
+ _internalLogPoller = 0;
2422
+ _flushInternalLogs();
2423
+ }
2424
+ };
2425
+ proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
2426
+ _self.getPlugin = _getPlugin;
2427
+ function _initDefaults() {
2428
+ _isInitialized = false;
2429
+ _self.logger = new DiagnosticLogger({ loggingLevelConsole: LoggingSeverity.CRITICAL });
2430
+ _self.config = null;
2431
+ _self._extensions = [];
2432
+ _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
2433
+ _eventQueue = [];
2434
+ _notificationManager = null;
2435
+ _perfManager = null;
2436
+ _cfgPerfManager = null;
2437
+ _cookieManager = null;
2438
+ _pluginChain = null;
2439
+ _coreExtensions = null;
2440
+ _configExtensions = null;
2441
+ _channelControl = null;
2442
+ _channelConfig = null;
2443
+ _channelQueue = null;
2444
+ _internalLogsEventName = null;
2445
+ }
2446
+ function _initPluginChain(config) {
2447
+ var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
2448
+ _coreExtensions = theExtensions.core;
2449
+ _pluginChain = null;
2450
+ var allExtensions = theExtensions.all;
2451
+ _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
2452
+ _channelControl = createChannelControllerPlugin(_channelQueue, _self);
2453
+ allExtensions.push(_channelControl);
2454
+ _coreExtensions.push(_channelControl);
2455
+ _self._extensions = sortPlugins(allExtensions);
2456
+ _channelControl.initialize(config, _self, allExtensions);
2457
+ initializePlugins(_self.getProcessTelContext(), allExtensions);
2458
+ _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
2459
+ }
2460
+ function _getPlugin(pluginIdentifier) {
2461
+ var theExt = null;
2462
+ var thePlugin = null;
2463
+ arrForEach(_self._extensions, function (ext) {
2464
+ if (ext.identifier === pluginIdentifier) {
2465
+ thePlugin = ext;
2466
+ return -1;
2467
+ }
2468
+ });
2469
+ if (thePlugin) {
2470
+ theExt = {
2471
+ plugin: thePlugin
2472
+ };
2473
+ }
2474
+ return theExt;
2475
+ }
2476
+ function _getPluginChain() {
2477
+ if (!_pluginChain) {
2478
+ var extensions = (_coreExtensions || []).slice();
2479
+ extensions.push(_telemetryInitializerPlugin);
2480
+ _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
2481
+ }
2482
+ return _pluginChain;
2483
+ }
2484
+ function _flushInternalLogs() {
2485
+ var queue = _self.logger ? _self.logger.queue : [];
2486
+ if (queue) {
2487
+ arrForEach(queue, function (logMessage) {
2488
+ var item = {
2489
+ name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
2490
+ iKey: _self.config.instrumentationKey,
2491
+ time: toISOString(new Date()),
2492
+ baseType: _InternalLogMessage.dataType,
2493
+ baseData: { message: logMessage.message }
2494
+ };
2495
+ _self.track(item);
2496
+ });
2497
+ queue.length = 0;
2498
+ }
2499
+ }
2500
+ function _initDebugListener(config) {
2501
+ if (config.disableDbgExt === true && _debugListener) {
2502
+ _notificationManager.removeNotificationListener(_debugListener);
2503
+ _debugListener = null;
2504
+ }
2505
+ if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
2506
+ _debugListener = getDebugListener(config);
2507
+ _notificationManager.addNotificationListener(_debugListener);
2508
+ }
2509
+ }
2510
+ function _initPerfManager(config) {
2511
+ if (!config.enablePerfMgr && _cfgPerfManager) {
2512
+ _cfgPerfManager = null;
2513
+ }
2514
+ if (config.enablePerfMgr) {
2515
+ setValue(_self.config, "createPerfMgr", _createPerfManager);
2516
+ }
2517
+ }
2057
2518
  });
2058
2519
  }
2059
2520
  return BaseCore;
2060
2521
  }());
2061
2522
 
2523
+ var strEventsSent = "eventsSent";
2524
+ var strEventsDiscarded = "eventsDiscarded";
2525
+ var strEventsSendRequest = "eventsSendRequest";
2526
+ var strPerfEvent = "perfEvent";
2527
+ function _runListeners(listeners, name, isAsync, callback) {
2528
+ arrForEach(listeners, function (listener) {
2529
+ if (listener && listener[name]) {
2530
+ if (isAsync) {
2531
+ setTimeout(function () { return callback(listener); }, 0);
2532
+ }
2533
+ else {
2534
+ try {
2535
+ callback(listener);
2536
+ }
2537
+ catch (e) {
2538
+ }
2539
+ }
2540
+ }
2541
+ });
2542
+ }
2062
2543
  var NotificationManager = /** @class */ (function () {
2063
2544
  function NotificationManager(config) {
2064
2545
  this.listeners = [];
@@ -2075,50 +2556,29 @@
2075
2556
  }
2076
2557
  };
2077
2558
  _self.eventsSent = function (events) {
2078
- arrForEach(_self.listeners, function (listener) {
2079
- if (listener && listener.eventsSent) {
2080
- setTimeout(function () { return listener.eventsSent(events); }, 0);
2081
- }
2559
+ _runListeners(_self.listeners, strEventsSent, true, function (listener) {
2560
+ listener[strEventsSent](events);
2082
2561
  });
2083
2562
  };
2084
2563
  _self.eventsDiscarded = function (events, reason) {
2085
- arrForEach(_self.listeners, function (listener) {
2086
- if (listener && listener.eventsDiscarded) {
2087
- setTimeout(function () { return listener.eventsDiscarded(events, reason); }, 0);
2088
- }
2564
+ _runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
2565
+ listener[strEventsDiscarded](events, reason);
2089
2566
  });
2090
2567
  };
2091
2568
  _self.eventsSendRequest = function (sendReason, isAsync) {
2092
- arrForEach(_self.listeners, function (listener) {
2093
- if (listener && listener.eventsSendRequest) {
2094
- if (isAsync) {
2095
- setTimeout(function () { return listener.eventsSendRequest(sendReason, isAsync); }, 0);
2096
- }
2097
- else {
2098
- try {
2099
- listener.eventsSendRequest(sendReason, isAsync);
2100
- }
2101
- catch (e) {
2102
- }
2103
- }
2104
- }
2569
+ _runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
2570
+ listener[strEventsSendRequest](sendReason, isAsync);
2105
2571
  });
2106
2572
  };
2107
2573
  _self.perfEvent = function (perfEvent) {
2108
2574
  if (perfEvent) {
2109
2575
  if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
2110
- arrForEach(_self.listeners, function (listener) {
2111
- if (listener && listener.perfEvent) {
2112
- if (perfEvent.isAsync) {
2113
- setTimeout(function () { return listener.perfEvent(perfEvent); }, 0);
2114
- }
2115
- else {
2116
- try {
2117
- listener.perfEvent(perfEvent);
2118
- }
2119
- catch (e) {
2120
- }
2121
- }
2576
+ _runListeners(_self.listeners, strPerfEvent, false, function (listener) {
2577
+ if (perfEvent.isAsync) {
2578
+ setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
2579
+ }
2580
+ else {
2581
+ listener[strPerfEvent](perfEvent);
2122
2582
  }
2123
2583
  });
2124
2584
  }
@@ -2133,7 +2593,6 @@
2133
2593
  __extendsFn(AppInsightsCore, _super);
2134
2594
  function AppInsightsCore() {
2135
2595
  var _this = _super.call(this) || this;
2136
- var _internalLogPoller = 0;
2137
2596
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
2138
2597
  _self.initialize = function (config, extensions, logger, notificationManager) {
2139
2598
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -2148,48 +2607,6 @@
2148
2607
  _base.track(telemetryItem);
2149
2608
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
2150
2609
  };
2151
- _self.addNotificationListener = function (listener) {
2152
- var manager = _self.getNotifyMgr();
2153
- if (manager) {
2154
- manager.addNotificationListener(listener);
2155
- }
2156
- };
2157
- _self.removeNotificationListener = function (listener) {
2158
- var manager = _self.getNotifyMgr();
2159
- if (manager) {
2160
- manager.removeNotificationListener(listener);
2161
- }
2162
- };
2163
- _self.pollInternalLogs = function (eventName) {
2164
- var interval = _self.config.diagnosticLogInterval;
2165
- if (!interval || !(interval > 0)) {
2166
- interval = 10000;
2167
- }
2168
- if (_internalLogPoller) {
2169
- _self.stopPollingInternalLogs();
2170
- }
2171
- _internalLogPoller = setInterval(function () {
2172
- var queue = _self.logger ? _self.logger.queue : [];
2173
- arrForEach(queue, function (logMessage) {
2174
- var item = {
2175
- name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
2176
- iKey: _self.config.instrumentationKey,
2177
- time: toISOString(new Date()),
2178
- baseType: _InternalLogMessage.dataType,
2179
- baseData: { message: logMessage.message }
2180
- };
2181
- _self.track(item);
2182
- });
2183
- queue.length = 0;
2184
- }, interval);
2185
- return _internalLogPoller;
2186
- };
2187
- _self.stopPollingInternalLogs = function () {
2188
- if (!_internalLogPoller)
2189
- return;
2190
- clearInterval(_internalLogPoller);
2191
- _internalLogPoller = 0;
2192
- };
2193
2610
  function _validateTelemetryItem(telemetryItem) {
2194
2611
  if (isNullOrUndefined(telemetryItem.name)) {
2195
2612
  _notifyInvalidEvent(telemetryItem);
@@ -2236,18 +2653,18 @@
2236
2653
  return 0;
2237
2654
  }
2238
2655
  function random32(signed) {
2239
- var value;
2656
+ var value = 0;
2240
2657
  var c = getCrypto() || getMsCrypto();
2241
2658
  if (c && c.getRandomValues) {
2242
2659
  value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
2243
2660
  }
2244
- else if (isIE()) {
2661
+ if (value === 0 && isIE()) {
2245
2662
  if (!_mwcSeeded) {
2246
2663
  _autoSeedMwc();
2247
2664
  }
2248
2665
  value = mwcRandom32() & MaxUInt32;
2249
2666
  }
2250
- else {
2667
+ if (value === 0) {
2251
2668
  value = Math.floor((UInt32Mask * Math.random()) | 0);
2252
2669
  }
2253
2670
  if (!signed) {
@@ -2272,6 +2689,23 @@
2272
2689
  }
2273
2690
  return value;
2274
2691
  }
2692
+ function newId(maxLength) {
2693
+ if (maxLength === void 0) { maxLength = 22; }
2694
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2695
+ var number = random32() >>> 0;
2696
+ var chars = 0;
2697
+ var result = "";
2698
+ while (result.length < maxLength) {
2699
+ chars++;
2700
+ result += base64chars.charAt(number & 0x3F);
2701
+ number >>>= 6;
2702
+ if (chars === 5) {
2703
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2704
+ chars = 0;
2705
+ }
2706
+ }
2707
+ return result;
2708
+ }
2275
2709
 
2276
2710
  var _cookieMgrs = null;
2277
2711
  var _canUseCookies;
@@ -2304,23 +2738,6 @@
2304
2738
  }
2305
2739
  return dateNow();
2306
2740
  }
2307
- function newId(maxLength) {
2308
- if (maxLength === void 0) { maxLength = 22; }
2309
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2310
- var number = random32() >>> 0;
2311
- var chars = 0;
2312
- var result = "";
2313
- while (result.length < maxLength) {
2314
- chars++;
2315
- result += base64chars.charAt(number & 0x3F);
2316
- number >>>= 6;
2317
- if (chars === 5) {
2318
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
2319
- chars = 0;
2320
- }
2321
- }
2322
- return result;
2323
- }
2324
2741
  function generateW3CId() {
2325
2742
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2326
2743
  var oct = "", tmp;
@@ -3904,7 +4321,7 @@
3904
4321
  }
3905
4322
  }
3906
4323
  var EnvelopeCreator = {
3907
- Version: "2.7.4-nightly.2202-07"
4324
+ Version: "2.8.0-beta.2202-06"
3908
4325
  };
3909
4326
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
3910
4327
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -4415,11 +4832,12 @@
4415
4832
  _setupTimer();
4416
4833
  }
4417
4834
  };
4418
- _self.flush = function () {
4835
+ _self.flush = function (isAsync, callBack, sendReason) {
4836
+ if (isAsync === void 0) { isAsync = true; }
4419
4837
  if (!_paused) {
4420
4838
  _clearScheduledTimer();
4421
4839
  try {
4422
- _self.triggerSend(true, null, 1 );
4840
+ _self.triggerSend(isAsync, null, sendReason || 1 );
4423
4841
  }
4424
4842
  catch (e) {
4425
4843
  _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
@@ -5073,4 +5491,4 @@
5073
5491
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
5074
5492
 
5075
5493
  }));
5076
- //# sourceMappingURL=aib.2.7.4-nightly.2202-07.js.map
5494
+ //# sourceMappingURL=aib.2.8.0-beta.2202-06.js.map