@microsoft/applicationinsights-analytics-js 2.8.4-nightly.2205-07 → 2.8.4-nightly.2205-10

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 (26) hide show
  1. package/browser/applicationinsights-analytics-js.integrity.json +9 -9
  2. package/browser/applicationinsights-analytics-js.js +769 -704
  3. package/browser/applicationinsights-analytics-js.js.map +1 -1
  4. package/browser/applicationinsights-analytics-js.min.js +2 -2
  5. package/browser/applicationinsights-analytics-js.min.js.map +1 -1
  6. package/dist/applicationinsights-analytics-js.api.json +1 -1
  7. package/dist/applicationinsights-analytics-js.d.ts +1 -1
  8. package/dist/applicationinsights-analytics-js.js +769 -704
  9. package/dist/applicationinsights-analytics-js.js.map +1 -1
  10. package/dist/applicationinsights-analytics-js.min.js +2 -2
  11. package/dist/applicationinsights-analytics-js.min.js.map +1 -1
  12. package/dist/applicationinsights-analytics-js.rollup.d.ts +1 -1
  13. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +40 -26
  14. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -1
  15. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +3 -3
  16. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +4 -4
  18. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +1 -1
  20. package/dist-esm/JavaScriptSDK/Timing.js +3 -3
  21. package/dist-esm/JavaScriptSDK/Timing.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
  23. package/dist-esm/applicationinsights-analytics-js.js +1 -1
  24. package/package.json +6 -6
  25. package/src/JavaScriptSDK/AnalyticsPlugin.ts +32 -16
  26. package/types/tsdoc-metadata.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -1206,7 +1206,7 @@
1206
1206
  }
1207
1207
 
1208
1208
  var _objDefineProperty = ObjDefineProperty;
1209
- var version = "2.8.4-nightly.2205-07";
1209
+ var version = "2.8.4-nightly.2205-10";
1210
1210
  var instanceName = "." + newId(6);
1211
1211
  var _dataUid = 0;
1212
1212
  function _createAccessor(target, prop, value) {
@@ -1277,602 +1277,807 @@
1277
1277
  return data;
1278
1278
  }
1279
1279
 
1280
- var pluginStateData = createElmNodeData("plugin");
1281
- function _getPluginState(plugin) {
1282
- return pluginStateData.get(plugin, "state", {}, true);
1280
+ var strToGMTString = "toGMTString";
1281
+ var strToUTCString = "toUTCString";
1282
+ var strCookie = "cookie";
1283
+ var strExpires = "expires";
1284
+ var strEnabled = "enabled";
1285
+ var strIsCookieUseDisabled = "isCookieUseDisabled";
1286
+ var strDisableCookiesUsage = "disableCookiesUsage";
1287
+ var strConfigCookieMgr = "_ckMgr";
1288
+ var _supportsCookies = null;
1289
+ var _allowUaSameSite = null;
1290
+ var _parsedCookieValue = null;
1291
+ var _doc = getDocument();
1292
+ var _cookieCache = {};
1293
+ var _globalCookieConfig = {};
1294
+ function _gblCookieMgr(config, logger) {
1295
+ var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
1296
+ if (!inst) {
1297
+ inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
1298
+ _globalCookieConfig[strConfigCookieMgr] = inst;
1299
+ }
1300
+ return inst;
1283
1301
  }
1284
-
1285
- var strTelemetryPluginChain = "TelemetryPluginChain";
1286
- var strHasRunFlags = "_hasRun";
1287
- var strGetTelCtx = "_getTelCtx";
1288
- var _chainId = 0;
1289
- function _getNextProxyStart(proxy, core, startAt) {
1290
- while (proxy) {
1291
- if (proxy.getPlugin() === startAt) {
1292
- return proxy;
1302
+ function _isMgrEnabled(cookieMgr) {
1303
+ if (cookieMgr) {
1304
+ return cookieMgr.isEnabled();
1305
+ }
1306
+ return true;
1307
+ }
1308
+ function _createCookieMgrConfig(rootConfig) {
1309
+ var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};
1310
+ setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
1311
+ setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
1312
+ if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {
1313
+ var cookieEnabled = void 0;
1314
+ if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
1315
+ cookieEnabled = !rootConfig[strIsCookieUseDisabled];
1293
1316
  }
1294
- proxy = proxy.getNext();
1317
+ if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
1318
+ cookieEnabled = !rootConfig[strDisableCookiesUsage];
1319
+ }
1320
+ cookieMgrCfg[strEnabled] = cookieEnabled;
1295
1321
  }
1296
- return createTelemetryProxyChain([startAt], core.config || {}, core);
1322
+ return cookieMgrCfg;
1297
1323
  }
1298
- function _createInternalContext(telemetryChain, config, core, startAt) {
1299
- var _nextProxy = null;
1300
- var _onComplete = [];
1301
- if (startAt !== null) {
1302
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1324
+ function safeGetCookieMgr(core, config) {
1325
+ var cookieMgr;
1326
+ if (core) {
1327
+ cookieMgr = core.getCookieMgr();
1303
1328
  }
1304
- var context = {
1305
- _next: _moveNext,
1306
- ctx: {
1307
- core: function () {
1308
- return core;
1309
- },
1310
- diagLog: function () {
1311
- return safeGetLogger(core, config);
1312
- },
1313
- getCfg: function () {
1314
- return config;
1315
- },
1316
- getExtCfg: _getExtCfg,
1317
- getConfig: _getConfig,
1318
- hasNext: function () {
1319
- return !!_nextProxy;
1320
- },
1321
- getNext: function () {
1322
- return _nextProxy;
1323
- },
1324
- setNext: function (nextPlugin) {
1325
- _nextProxy = nextPlugin;
1326
- },
1327
- iterate: _iterateChain,
1328
- onComplete: _addOnComplete
1329
- }
1330
- };
1331
- function _addOnComplete(onComplete, that) {
1332
- var args = [];
1333
- for (var _i = 2; _i < arguments.length; _i++) {
1334
- args[_i - 2] = arguments[_i];
1329
+ else if (config) {
1330
+ var cookieCfg = config.cookieCfg;
1331
+ if (cookieCfg[strConfigCookieMgr]) {
1332
+ cookieMgr = cookieCfg[strConfigCookieMgr];
1335
1333
  }
1336
- if (onComplete) {
1337
- _onComplete.push({
1338
- func: onComplete,
1339
- self: !isUndefined(that) ? that : context.ctx,
1340
- args: args
1341
- });
1334
+ else {
1335
+ cookieMgr = createCookieMgr(config);
1342
1336
  }
1343
1337
  }
1344
- function _moveNext() {
1345
- var nextProxy = _nextProxy;
1346
- _nextProxy = nextProxy ? nextProxy.getNext() : null;
1347
- if (!nextProxy) {
1348
- var onComplete = _onComplete;
1349
- if (onComplete && onComplete.length > 0) {
1350
- arrForEach(onComplete, function (completeDetails) {
1351
- try {
1352
- completeDetails.func.call(completeDetails.self, completeDetails.args);
1338
+ if (!cookieMgr) {
1339
+ cookieMgr = _gblCookieMgr(config, (core || {}).logger);
1340
+ }
1341
+ return cookieMgr;
1342
+ }
1343
+ function createCookieMgr(rootConfig, logger) {
1344
+ var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
1345
+ var _path = cookieMgrConfig.path || "/";
1346
+ var _domain = cookieMgrConfig.domain;
1347
+ var _enabled = cookieMgrConfig[strEnabled] !== false;
1348
+ var cookieMgr = {
1349
+ isEnabled: function () {
1350
+ var enabled = _enabled && areCookiesSupported(logger);
1351
+ var gblManager = _globalCookieConfig[strConfigCookieMgr];
1352
+ if (enabled && gblManager && cookieMgr !== gblManager) {
1353
+ enabled = _isMgrEnabled(gblManager);
1354
+ }
1355
+ return enabled;
1356
+ },
1357
+ setEnabled: function (value) {
1358
+ _enabled = value !== false;
1359
+ },
1360
+ set: function (name, value, maxAgeSec, domain, path) {
1361
+ var result = false;
1362
+ if (_isMgrEnabled(cookieMgr)) {
1363
+ var values = {};
1364
+ var theValue = strTrim(value || strEmpty$1);
1365
+ var idx = theValue.indexOf(";");
1366
+ if (idx !== -1) {
1367
+ theValue = strTrim(value.substring(0, idx));
1368
+ values = _extractParts(value.substring(idx + 1));
1369
+ }
1370
+ setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
1371
+ if (!isNullOrUndefined(maxAgeSec)) {
1372
+ var _isIE = isIE();
1373
+ if (isUndefined(values[strExpires])) {
1374
+ var nowMs = dateNow();
1375
+ var expireMs = nowMs + (maxAgeSec * 1000);
1376
+ if (expireMs > 0) {
1377
+ var expiry = new Date();
1378
+ expiry.setTime(expireMs);
1379
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1380
+ }
1353
1381
  }
1354
- catch (e) {
1355
- _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1382
+ if (!_isIE) {
1383
+ setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1356
1384
  }
1357
- });
1358
- _onComplete = [];
1385
+ }
1386
+ var location_1 = getLocation();
1387
+ if (location_1 && location_1.protocol === "https:") {
1388
+ setValue(values, "secure", null, null, isUndefined);
1389
+ if (_allowUaSameSite === null) {
1390
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
1391
+ }
1392
+ if (_allowUaSameSite) {
1393
+ setValue(values, "SameSite", "None", null, isUndefined);
1394
+ }
1395
+ }
1396
+ setValue(values, "path", path || _path, null, isUndefined);
1397
+ var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
1398
+ setCookieFn(name, _formatCookieValue(theValue, values));
1399
+ result = true;
1359
1400
  }
1360
- }
1361
- return nextProxy;
1362
- }
1363
- function _getExtCfg(identifier, defaultValue, mergeDefault) {
1364
- if (defaultValue === void 0) { defaultValue = {}; }
1365
- if (mergeDefault === void 0) { mergeDefault = 0 ; }
1366
- var theConfig;
1367
- if (config) {
1368
- var extConfig = config.extensionConfig;
1369
- if (extConfig && identifier) {
1370
- theConfig = extConfig[identifier];
1401
+ return result;
1402
+ },
1403
+ get: function (name) {
1404
+ var value = strEmpty$1;
1405
+ if (_isMgrEnabled(cookieMgr)) {
1406
+ value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1371
1407
  }
1372
- }
1373
- if (!theConfig) {
1374
- theConfig = defaultValue;
1375
- }
1376
- else if (isObject(defaultValue)) {
1377
- if (mergeDefault !== 0 ) {
1378
- var newConfig_1 = objExtend(true, defaultValue, theConfig);
1379
- if (config && mergeDefault === 2 ) {
1380
- objForEachKey(defaultValue, function (field) {
1381
- if (isNullOrUndefined(newConfig_1[field])) {
1382
- var cfgValue = config[field];
1383
- if (!isNullOrUndefined(cfgValue)) {
1384
- newConfig_1[field] = cfgValue;
1385
- }
1386
- }
1387
- });
1408
+ return value;
1409
+ },
1410
+ del: function (name, path) {
1411
+ var result = false;
1412
+ if (_isMgrEnabled(cookieMgr)) {
1413
+ result = cookieMgr.purge(name, path);
1414
+ }
1415
+ return result;
1416
+ },
1417
+ purge: function (name, path) {
1418
+ var _a;
1419
+ var result = false;
1420
+ if (areCookiesSupported(logger)) {
1421
+ var values = (_a = {},
1422
+ _a["path"] = path ? path : "/",
1423
+ _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
1424
+ _a);
1425
+ if (!isIE()) {
1426
+ values["max-age"] = "0";
1388
1427
  }
1389
- theConfig = newConfig_1;
1428
+ var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1429
+ delCookie(name, _formatCookieValue(strEmpty$1, values));
1430
+ result = true;
1390
1431
  }
1432
+ return result;
1391
1433
  }
1392
- return theConfig;
1393
- }
1394
- function _getConfig(identifier, field, defaultValue) {
1395
- if (defaultValue === void 0) { defaultValue = false; }
1396
- var theValue;
1397
- var extConfig = _getExtCfg(identifier, null);
1398
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1399
- theValue = extConfig[field];
1434
+ };
1435
+ cookieMgr[strConfigCookieMgr] = cookieMgr;
1436
+ return cookieMgr;
1437
+ }
1438
+ function areCookiesSupported(logger) {
1439
+ if (_supportsCookies === null) {
1440
+ _supportsCookies = false;
1441
+ try {
1442
+ var doc = _doc || {};
1443
+ _supportsCookies = doc[strCookie] !== undefined;
1400
1444
  }
1401
- else if (config && !isNullOrUndefined(config[field])) {
1402
- theValue = config[field];
1445
+ catch (e) {
1446
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1403
1447
  }
1404
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1405
1448
  }
1406
- function _iterateChain(cb) {
1407
- var nextPlugin;
1408
- while (!!(nextPlugin = context._next())) {
1409
- var plugin = nextPlugin.getPlugin();
1410
- if (plugin) {
1411
- cb(plugin);
1449
+ return _supportsCookies;
1450
+ }
1451
+ function _extractParts(theValue) {
1452
+ var values = {};
1453
+ if (theValue && theValue.length) {
1454
+ var parts = strTrim(theValue).split(";");
1455
+ arrForEach(parts, function (thePart) {
1456
+ thePart = strTrim(thePart || strEmpty$1);
1457
+ if (thePart) {
1458
+ var idx = thePart.indexOf("=");
1459
+ if (idx === -1) {
1460
+ values[thePart] = null;
1461
+ }
1462
+ else {
1463
+ values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1464
+ }
1412
1465
  }
1466
+ });
1467
+ }
1468
+ return values;
1469
+ }
1470
+ function _formatDate(theDate, func) {
1471
+ if (isFunction(theDate[func])) {
1472
+ return theDate[func]();
1473
+ }
1474
+ return null;
1475
+ }
1476
+ function _formatCookieValue(value, values) {
1477
+ var cookieValue = value || strEmpty$1;
1478
+ objForEachKey(values, function (name, theValue) {
1479
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1480
+ });
1481
+ return cookieValue;
1482
+ }
1483
+ function _getCookieValue(name) {
1484
+ var cookieValue = strEmpty$1;
1485
+ if (_doc) {
1486
+ var theCookie = _doc[strCookie] || strEmpty$1;
1487
+ if (_parsedCookieValue !== theCookie) {
1488
+ _cookieCache = _extractParts(theCookie);
1489
+ _parsedCookieValue = theCookie;
1413
1490
  }
1491
+ cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1414
1492
  }
1415
- return context;
1493
+ return cookieValue;
1416
1494
  }
1417
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1418
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1419
- var context = internalContext.ctx;
1420
- function _processNext(env) {
1421
- var nextPlugin = internalContext._next();
1422
- nextPlugin && nextPlugin.processTelemetry(env, context);
1423
- return !nextPlugin;
1495
+ function _setCookieValue(name, cookieValue) {
1496
+ if (_doc) {
1497
+ _doc[strCookie] = name + "=" + cookieValue;
1424
1498
  }
1425
- function _createNew(plugins, startAt) {
1426
- if (plugins === void 0) { plugins = null; }
1427
- if (isArray(plugins)) {
1428
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1499
+ }
1500
+ function uaDisallowsSameSiteNone(userAgent) {
1501
+ if (!isString(userAgent)) {
1502
+ return false;
1503
+ }
1504
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
1505
+ return true;
1506
+ }
1507
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
1508
+ return true;
1509
+ }
1510
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
1511
+ return true;
1512
+ }
1513
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
1514
+ return true;
1515
+ }
1516
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
1517
+ return true;
1518
+ }
1519
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1520
+ return true;
1521
+ }
1522
+ return false;
1523
+ }
1524
+
1525
+ var strOnPrefix = "on";
1526
+ var strAttachEvent = "attachEvent";
1527
+ var strAddEventHelper = "addEventListener";
1528
+ var strDetachEvent = "detachEvent";
1529
+ var strRemoveEventListener = "removeEventListener";
1530
+ var strEvents = "events";
1531
+ createUniqueNamespace("aiEvtPageHide");
1532
+ createUniqueNamespace("aiEvtPageShow");
1533
+ var rRemoveEmptyNs = /\.[\.]+/g;
1534
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
1535
+ var _guid = 1;
1536
+ var elmNodeData = createElmNodeData("events");
1537
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1538
+ function _normalizeNamespace(name) {
1539
+ if (name && name.replace) {
1540
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1541
+ }
1542
+ return name;
1543
+ }
1544
+ function _getEvtNamespace(eventName, evtNamespace) {
1545
+ if (evtNamespace) {
1546
+ var theNamespace_1 = "";
1547
+ if (isArray(evtNamespace)) {
1548
+ theNamespace_1 = "";
1549
+ arrForEach(evtNamespace, function (name) {
1550
+ name = _normalizeNamespace(name);
1551
+ if (name) {
1552
+ if (name[0] !== ".") {
1553
+ name = "." + name;
1554
+ }
1555
+ theNamespace_1 += name;
1556
+ }
1557
+ });
1558
+ }
1559
+ else {
1560
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
1561
+ }
1562
+ if (theNamespace_1) {
1563
+ if (theNamespace_1[0] !== ".") {
1564
+ theNamespace_1 = "." + theNamespace_1;
1565
+ }
1566
+ eventName = (eventName || "") + theNamespace_1;
1429
1567
  }
1430
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1431
1568
  }
1432
- context.processNext = _processNext;
1433
- context.createNew = _createNew;
1434
- return context;
1569
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
1570
+ return {
1571
+ type: parsedEvent[1],
1572
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
1573
+ };
1435
1574
  }
1436
- function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
1437
- var config = core.config || {};
1438
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1439
- var context = internalContext.ctx;
1440
- function _processNext(unloadState) {
1441
- var nextPlugin = internalContext._next();
1442
- nextPlugin && nextPlugin.unload(context, unloadState);
1443
- return !nextPlugin;
1575
+ function _getRegisteredEvents(target, evtName, addDefault) {
1576
+ if (addDefault === void 0) { addDefault = true; }
1577
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1578
+ var registeredEvents = aiEvts[evtName];
1579
+ if (!registeredEvents) {
1580
+ registeredEvents = aiEvts[evtName] = [];
1444
1581
  }
1445
- function _createNew(plugins, startAt) {
1446
- if (plugins === void 0) { plugins = null; }
1447
- if (isArray(plugins)) {
1448
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1582
+ return registeredEvents;
1583
+ }
1584
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
1585
+ if (obj && evtName && evtName.type) {
1586
+ if (obj[strRemoveEventListener]) {
1587
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
1588
+ }
1589
+ else if (obj[strDetachEvent]) {
1590
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
1449
1591
  }
1450
- return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
1451
1592
  }
1452
- context.processNext = _processNext;
1453
- context.createNew = _createNew;
1454
- return context;
1455
1593
  }
1456
- function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
1457
- var config = core.config || {};
1458
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1459
- var context = internalContext.ctx;
1460
- function _processNext(updateState) {
1461
- return context.iterate(function (plugin) {
1462
- if (isFunction(plugin.update)) {
1463
- plugin.update(context, updateState);
1464
- }
1465
- });
1466
- }
1467
- function _createNew(plugins, startAt) {
1468
- if (plugins === void 0) { plugins = null; }
1469
- if (isArray(plugins)) {
1470
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1594
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
1595
+ var result = false;
1596
+ if (obj && evtName && evtName.type && handlerRef) {
1597
+ if (obj[strAddEventHelper]) {
1598
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1599
+ result = true;
1600
+ }
1601
+ else if (obj[strAttachEvent]) {
1602
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1603
+ result = true;
1471
1604
  }
1472
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
1473
1605
  }
1474
- context.processNext = _processNext;
1475
- context.createNew = _createNew;
1476
- return context;
1606
+ return result;
1477
1607
  }
1478
- function createTelemetryProxyChain(plugins, config, core, startAt) {
1479
- var firstProxy = null;
1480
- var add = startAt ? false : true;
1481
- if (isArray(plugins) && plugins.length > 0) {
1482
- var lastProxy_1 = null;
1483
- arrForEach(plugins, function (thePlugin) {
1484
- if (!add && startAt === thePlugin) {
1485
- add = true;
1486
- }
1487
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1488
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1489
- if (!firstProxy) {
1490
- firstProxy = newProxy;
1491
- }
1492
- if (lastProxy_1) {
1493
- lastProxy_1._setNext(newProxy);
1608
+ function _doUnregister(target, events, evtName, unRegFn) {
1609
+ var idx = events.length;
1610
+ while (idx--) {
1611
+ var theEvent = events[idx];
1612
+ if (theEvent) {
1613
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
1614
+ if (!unRegFn || unRegFn(theEvent)) {
1615
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
1616
+ events.splice(idx, 1);
1494
1617
  }
1495
- lastProxy_1 = newProxy;
1496
1618
  }
1497
- });
1498
- }
1499
- if (startAt && !firstProxy) {
1500
- return createTelemetryProxyChain([startAt], config, core);
1619
+ }
1501
1620
  }
1502
- return firstProxy;
1503
1621
  }
1504
- function createTelemetryPluginProxy(plugin, config, core) {
1505
- var nextProxy = null;
1506
- var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1507
- var hasSetNext = isFunction(plugin.setNextPlugin);
1508
- var chainId;
1509
- if (plugin) {
1510
- chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1622
+ function _unregisterEvents(target, evtName, unRegFn) {
1623
+ if (evtName.type) {
1624
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1511
1625
  }
1512
1626
  else {
1513
- chainId = "Unknown-0-" + _chainId++;
1514
- }
1515
- var proxyChain = {
1516
- getPlugin: function () {
1517
- return plugin;
1518
- },
1519
- getNext: function () {
1520
- return nextProxy;
1521
- },
1522
- processTelemetry: _processTelemetry,
1523
- unload: _unloadPlugin,
1524
- update: _updatePlugin,
1525
- _id: chainId,
1526
- _setNext: function (nextPlugin) {
1527
- nextProxy = nextPlugin;
1528
- }
1529
- };
1530
- function _getTelCtx() {
1531
- var itemCtx;
1532
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1533
- itemCtx = plugin[strGetTelCtx]();
1534
- }
1535
- if (!itemCtx) {
1536
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1627
+ var eventCache = elmNodeData.get(target, strEvents, {});
1628
+ objForEachKey(eventCache, function (evtType, events) {
1629
+ _doUnregister(target, events, evtName, unRegFn);
1630
+ });
1631
+ if (objKeys(eventCache).length === 0) {
1632
+ elmNodeData.kill(target, strEvents);
1537
1633
  }
1538
- return itemCtx;
1539
1634
  }
1540
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1541
- var hasRun = false;
1542
- var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1543
- var hasRunContext = itemCtx[strHasRunFlags];
1544
- if (!hasRunContext) {
1545
- hasRunContext = itemCtx[strHasRunFlags] = {};
1635
+ }
1636
+ function mergeEvtNamespace(theNamespace, namespaces) {
1637
+ var newNamespaces;
1638
+ if (namespaces) {
1639
+ if (isArray(namespaces)) {
1640
+ newNamespaces = [theNamespace].concat(namespaces);
1546
1641
  }
1547
- itemCtx.setNext(nextProxy);
1548
- if (plugin) {
1549
- doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1550
- hasRunContext[chainId] = true;
1551
- try {
1552
- var nextId = nextProxy ? nextProxy._id : strEmpty$1;
1553
- if (nextId) {
1554
- hasRunContext[nextId] = false;
1555
- }
1556
- hasRun = processPluginFn(itemCtx);
1557
- }
1558
- catch (error) {
1559
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1560
- if (hasNextRun) {
1561
- hasRun = true;
1562
- }
1563
- if (!nextProxy || !hasNextRun) {
1564
- _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1565
- }
1566
- }
1567
- }, details, isAsync);
1642
+ else {
1643
+ newNamespaces = [theNamespace, namespaces];
1568
1644
  }
1569
- return hasRun;
1645
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1570
1646
  }
1571
- function _processTelemetry(env, itemCtx) {
1572
- itemCtx = itemCtx || _getTelCtx();
1573
- function _callProcessTelemetry(itemCtx) {
1574
- if (!plugin || !hasProcessTelemetry) {
1575
- return false;
1576
- }
1577
- var pluginState = _getPluginState(plugin);
1578
- if (pluginState.teardown || pluginState[strDisabled]) {
1579
- return false;
1580
- }
1581
- if (hasSetNext) {
1582
- plugin.setNextPlugin(nextProxy);
1583
- }
1584
- plugin.processTelemetry(env, itemCtx);
1585
- return true;
1586
- }
1587
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1588
- itemCtx.processNext(env);
1589
- }
1647
+ else {
1648
+ newNamespaces = theNamespace;
1590
1649
  }
1591
- function _unloadPlugin(unloadCtx, unloadState) {
1592
- function _callTeardown() {
1593
- var hasRun = false;
1594
- if (plugin) {
1595
- var pluginState = _getPluginState(plugin);
1596
- var pluginCore = plugin[strCore] || pluginState.core;
1597
- if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1598
- pluginState[strCore] = null;
1599
- pluginState[strTeardown] = true;
1600
- pluginState[strIsInitialized] = false;
1601
- if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1602
- hasRun = true;
1603
- }
1604
- }
1650
+ return newNamespaces;
1651
+ }
1652
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1653
+ if (useCapture === void 0) { useCapture = false; }
1654
+ var result = false;
1655
+ if (target) {
1656
+ try {
1657
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
1658
+ result = _doAttach(target, evtName, handlerRef, useCapture);
1659
+ if (result && elmNodeData.accept(target)) {
1660
+ var registeredEvent = {
1661
+ guid: _guid++,
1662
+ evtName: evtName,
1663
+ handler: handlerRef,
1664
+ capture: useCapture
1665
+ };
1666
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1605
1667
  }
1606
- return hasRun;
1607
1668
  }
1608
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1609
- unloadCtx.processNext(unloadState);
1669
+ catch (e) {
1610
1670
  }
1611
1671
  }
1612
- function _updatePlugin(updateCtx, updateState) {
1613
- function _callUpdate() {
1614
- var hasRun = false;
1615
- if (plugin) {
1616
- var pluginState = _getPluginState(plugin);
1617
- var pluginCore = plugin[strCore] || pluginState.core;
1618
- if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1619
- if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1620
- hasRun = true;
1621
- }
1672
+ return result;
1673
+ }
1674
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
1675
+ if (useCapture === void 0) { useCapture = false; }
1676
+ if (target) {
1677
+ try {
1678
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
1679
+ var found_1 = false;
1680
+ _unregisterEvents(target, evtName_1, function (regEvent) {
1681
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
1682
+ found_1 = true;
1683
+ return true;
1622
1684
  }
1685
+ return false;
1686
+ });
1687
+ if (!found_1) {
1688
+ _doDetach(target, evtName_1, handlerRef, useCapture);
1623
1689
  }
1624
- return hasRun;
1625
1690
  }
1626
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1627
- updateCtx.processNext(updateState);
1691
+ catch (e) {
1628
1692
  }
1629
1693
  }
1630
- return objFreeze(proxyChain);
1631
1694
  }
1632
1695
 
1633
- var strToGMTString = "toGMTString";
1634
- var strToUTCString = "toUTCString";
1635
- var strCookie = "cookie";
1636
- var strExpires = "expires";
1637
- var strEnabled = "enabled";
1638
- var strIsCookieUseDisabled = "isCookieUseDisabled";
1639
- var strDisableCookiesUsage = "disableCookiesUsage";
1640
- var strConfigCookieMgr = "_ckMgr";
1641
- var _supportsCookies = null;
1642
- var _allowUaSameSite = null;
1643
- var _parsedCookieValue = null;
1644
- var _doc = getDocument();
1645
- var _cookieCache = {};
1646
- var _globalCookieConfig = {};
1647
- function _gblCookieMgr(config, logger) {
1648
- var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
1649
- if (!inst) {
1650
- inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
1651
- _globalCookieConfig[strConfigCookieMgr] = inst;
1696
+ function generateW3CId() {
1697
+ var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1698
+ var oct = strEmpty$1, tmp;
1699
+ for (var a = 0; a < 4; a++) {
1700
+ tmp = random32();
1701
+ oct +=
1702
+ hexValues[tmp & 0xF] +
1703
+ hexValues[tmp >> 4 & 0xF] +
1704
+ hexValues[tmp >> 8 & 0xF] +
1705
+ hexValues[tmp >> 12 & 0xF] +
1706
+ hexValues[tmp >> 16 & 0xF] +
1707
+ hexValues[tmp >> 20 & 0xF] +
1708
+ hexValues[tmp >> 24 & 0xF] +
1709
+ hexValues[tmp >> 28 & 0xF];
1652
1710
  }
1653
- return inst;
1711
+ var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
1712
+ return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
1654
1713
  }
1655
- function _isMgrEnabled(cookieMgr) {
1656
- if (cookieMgr) {
1657
- return cookieMgr.isEnabled();
1714
+
1715
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
1716
+ var INVALID_SPAN_ID = "0000000000000000";
1717
+ function _isValid(value, len, invalidValue) {
1718
+ if (value && value.length === len && value !== invalidValue) {
1719
+ return !!value.match(/^[\da-f]*$/);
1658
1720
  }
1659
- return true;
1721
+ return false;
1660
1722
  }
1661
- function _createCookieMgrConfig(rootConfig) {
1662
- var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};
1663
- setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
1664
- setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
1665
- if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {
1666
- var cookieEnabled = void 0;
1667
- if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
1668
- cookieEnabled = !rootConfig[strIsCookieUseDisabled];
1669
- }
1670
- if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
1671
- cookieEnabled = !rootConfig[strDisableCookiesUsage];
1723
+ function isValidTraceId(value) {
1724
+ return _isValid(value, 32, INVALID_TRACE_ID);
1725
+ }
1726
+ function isValidSpanId(value) {
1727
+ return _isValid(value, 16, INVALID_SPAN_ID);
1728
+ }
1729
+
1730
+ var pluginStateData = createElmNodeData("plugin");
1731
+ function _getPluginState(plugin) {
1732
+ return pluginStateData.get(plugin, "state", {}, true);
1733
+ }
1734
+
1735
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1736
+ var strHasRunFlags = "_hasRun";
1737
+ var strGetTelCtx = "_getTelCtx";
1738
+ var _chainId = 0;
1739
+ function _getNextProxyStart(proxy, core, startAt) {
1740
+ while (proxy) {
1741
+ if (proxy.getPlugin() === startAt) {
1742
+ return proxy;
1672
1743
  }
1673
- cookieMgrCfg[strEnabled] = cookieEnabled;
1744
+ proxy = proxy.getNext();
1674
1745
  }
1675
- return cookieMgrCfg;
1746
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
1676
1747
  }
1677
- function safeGetCookieMgr(core, config) {
1678
- var cookieMgr;
1679
- if (core) {
1680
- cookieMgr = core.getCookieMgr();
1748
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1749
+ var _nextProxy = null;
1750
+ var _onComplete = [];
1751
+ if (startAt !== null) {
1752
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1681
1753
  }
1682
- else if (config) {
1683
- var cookieCfg = config.cookieCfg;
1684
- if (cookieCfg[strConfigCookieMgr]) {
1685
- cookieMgr = cookieCfg[strConfigCookieMgr];
1754
+ var context = {
1755
+ _next: _moveNext,
1756
+ ctx: {
1757
+ core: function () {
1758
+ return core;
1759
+ },
1760
+ diagLog: function () {
1761
+ return safeGetLogger(core, config);
1762
+ },
1763
+ getCfg: function () {
1764
+ return config;
1765
+ },
1766
+ getExtCfg: _getExtCfg,
1767
+ getConfig: _getConfig,
1768
+ hasNext: function () {
1769
+ return !!_nextProxy;
1770
+ },
1771
+ getNext: function () {
1772
+ return _nextProxy;
1773
+ },
1774
+ setNext: function (nextPlugin) {
1775
+ _nextProxy = nextPlugin;
1776
+ },
1777
+ iterate: _iterateChain,
1778
+ onComplete: _addOnComplete
1686
1779
  }
1687
- else {
1688
- cookieMgr = createCookieMgr(config);
1780
+ };
1781
+ function _addOnComplete(onComplete, that) {
1782
+ var args = [];
1783
+ for (var _i = 2; _i < arguments.length; _i++) {
1784
+ args[_i - 2] = arguments[_i];
1785
+ }
1786
+ if (onComplete) {
1787
+ _onComplete.push({
1788
+ func: onComplete,
1789
+ self: !isUndefined(that) ? that : context.ctx,
1790
+ args: args
1791
+ });
1689
1792
  }
1690
1793
  }
1691
- if (!cookieMgr) {
1692
- cookieMgr = _gblCookieMgr(config, (core || {}).logger);
1693
- }
1694
- return cookieMgr;
1695
- }
1696
- function createCookieMgr(rootConfig, logger) {
1697
- var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
1698
- var _path = cookieMgrConfig.path || "/";
1699
- var _domain = cookieMgrConfig.domain;
1700
- var _enabled = cookieMgrConfig[strEnabled] !== false;
1701
- var cookieMgr = {
1702
- isEnabled: function () {
1703
- var enabled = _enabled && areCookiesSupported(logger);
1704
- var gblManager = _globalCookieConfig[strConfigCookieMgr];
1705
- if (enabled && gblManager && cookieMgr !== gblManager) {
1706
- enabled = _isMgrEnabled(gblManager);
1707
- }
1708
- return enabled;
1709
- },
1710
- setEnabled: function (value) {
1711
- _enabled = value !== false;
1712
- },
1713
- set: function (name, value, maxAgeSec, domain, path) {
1714
- var result = false;
1715
- if (_isMgrEnabled(cookieMgr)) {
1716
- var values = {};
1717
- var theValue = strTrim(value || strEmpty$1);
1718
- var idx = theValue.indexOf(";");
1719
- if (idx !== -1) {
1720
- theValue = strTrim(value.substring(0, idx));
1721
- values = _extractParts(value.substring(idx + 1));
1722
- }
1723
- setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
1724
- if (!isNullOrUndefined(maxAgeSec)) {
1725
- var _isIE = isIE();
1726
- if (isUndefined(values[strExpires])) {
1727
- var nowMs = dateNow();
1728
- var expireMs = nowMs + (maxAgeSec * 1000);
1729
- if (expireMs > 0) {
1730
- var expiry = new Date();
1731
- expiry.setTime(expireMs);
1732
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
1733
- }
1734
- }
1735
- if (!_isIE) {
1736
- setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
1737
- }
1738
- }
1739
- var location_1 = getLocation();
1740
- if (location_1 && location_1.protocol === "https:") {
1741
- setValue(values, "secure", null, null, isUndefined);
1742
- if (_allowUaSameSite === null) {
1743
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
1794
+ function _moveNext() {
1795
+ var nextProxy = _nextProxy;
1796
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1797
+ if (!nextProxy) {
1798
+ var onComplete = _onComplete;
1799
+ if (onComplete && onComplete.length > 0) {
1800
+ arrForEach(onComplete, function (completeDetails) {
1801
+ try {
1802
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1744
1803
  }
1745
- if (_allowUaSameSite) {
1746
- setValue(values, "SameSite", "None", null, isUndefined);
1804
+ catch (e) {
1805
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1747
1806
  }
1748
- }
1749
- setValue(values, "path", path || _path, null, isUndefined);
1750
- var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
1751
- setCookieFn(name, _formatCookieValue(theValue, values));
1752
- result = true;
1753
- }
1754
- return result;
1755
- },
1756
- get: function (name) {
1757
- var value = strEmpty$1;
1758
- if (_isMgrEnabled(cookieMgr)) {
1759
- value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
1807
+ });
1808
+ _onComplete = [];
1760
1809
  }
1761
- return value;
1762
- },
1763
- del: function (name, path) {
1764
- var result = false;
1765
- if (_isMgrEnabled(cookieMgr)) {
1766
- result = cookieMgr.purge(name, path);
1810
+ }
1811
+ return nextProxy;
1812
+ }
1813
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1814
+ if (defaultValue === void 0) { defaultValue = {}; }
1815
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1816
+ var theConfig;
1817
+ if (config) {
1818
+ var extConfig = config.extensionConfig;
1819
+ if (extConfig && identifier) {
1820
+ theConfig = extConfig[identifier];
1767
1821
  }
1768
- return result;
1769
- },
1770
- purge: function (name, path) {
1771
- var _a;
1772
- var result = false;
1773
- if (areCookiesSupported(logger)) {
1774
- var values = (_a = {},
1775
- _a["path"] = path ? path : "/",
1776
- _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
1777
- _a);
1778
- if (!isIE()) {
1779
- values["max-age"] = "0";
1822
+ }
1823
+ if (!theConfig) {
1824
+ theConfig = defaultValue;
1825
+ }
1826
+ else if (isObject(defaultValue)) {
1827
+ if (mergeDefault !== 0 ) {
1828
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1829
+ if (config && mergeDefault === 2 ) {
1830
+ objForEachKey(defaultValue, function (field) {
1831
+ if (isNullOrUndefined(newConfig_1[field])) {
1832
+ var cfgValue = config[field];
1833
+ if (!isNullOrUndefined(cfgValue)) {
1834
+ newConfig_1[field] = cfgValue;
1835
+ }
1836
+ }
1837
+ });
1780
1838
  }
1781
- var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
1782
- delCookie(name, _formatCookieValue(strEmpty$1, values));
1783
- result = true;
1839
+ theConfig = newConfig_1;
1784
1840
  }
1785
- return result;
1786
1841
  }
1787
- };
1788
- cookieMgr[strConfigCookieMgr] = cookieMgr;
1789
- return cookieMgr;
1790
- }
1791
- function areCookiesSupported(logger) {
1792
- if (_supportsCookies === null) {
1793
- _supportsCookies = false;
1794
- try {
1795
- var doc = _doc || {};
1796
- _supportsCookies = doc[strCookie] !== undefined;
1842
+ return theConfig;
1843
+ }
1844
+ function _getConfig(identifier, field, defaultValue) {
1845
+ if (defaultValue === void 0) { defaultValue = false; }
1846
+ var theValue;
1847
+ var extConfig = _getExtCfg(identifier, null);
1848
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1849
+ theValue = extConfig[field];
1797
1850
  }
1798
- catch (e) {
1799
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1851
+ else if (config && !isNullOrUndefined(config[field])) {
1852
+ theValue = config[field];
1800
1853
  }
1854
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1801
1855
  }
1802
- return _supportsCookies;
1803
- }
1804
- function _extractParts(theValue) {
1805
- var values = {};
1806
- if (theValue && theValue.length) {
1807
- var parts = strTrim(theValue).split(";");
1808
- arrForEach(parts, function (thePart) {
1809
- thePart = strTrim(thePart || strEmpty$1);
1810
- if (thePart) {
1811
- var idx = thePart.indexOf("=");
1812
- if (idx === -1) {
1813
- values[thePart] = null;
1814
- }
1815
- else {
1816
- values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
1817
- }
1856
+ function _iterateChain(cb) {
1857
+ var nextPlugin;
1858
+ while (!!(nextPlugin = context._next())) {
1859
+ var plugin = nextPlugin.getPlugin();
1860
+ if (plugin) {
1861
+ cb(plugin);
1818
1862
  }
1819
- });
1863
+ }
1820
1864
  }
1821
- return values;
1865
+ return context;
1822
1866
  }
1823
- function _formatDate(theDate, func) {
1824
- if (isFunction(theDate[func])) {
1825
- return theDate[func]();
1867
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1868
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1869
+ var context = internalContext.ctx;
1870
+ function _processNext(env) {
1871
+ var nextPlugin = internalContext._next();
1872
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1873
+ return !nextPlugin;
1826
1874
  }
1827
- return null;
1875
+ function _createNew(plugins, startAt) {
1876
+ if (plugins === void 0) { plugins = null; }
1877
+ if (isArray(plugins)) {
1878
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1879
+ }
1880
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1881
+ }
1882
+ context.processNext = _processNext;
1883
+ context.createNew = _createNew;
1884
+ return context;
1828
1885
  }
1829
- function _formatCookieValue(value, values) {
1830
- var cookieValue = value || strEmpty$1;
1831
- objForEachKey(values, function (name, theValue) {
1832
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
1833
- });
1834
- return cookieValue;
1886
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
1887
+ var config = core.config || {};
1888
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1889
+ var context = internalContext.ctx;
1890
+ function _processNext(unloadState) {
1891
+ var nextPlugin = internalContext._next();
1892
+ nextPlugin && nextPlugin.unload(context, unloadState);
1893
+ return !nextPlugin;
1894
+ }
1895
+ function _createNew(plugins, startAt) {
1896
+ if (plugins === void 0) { plugins = null; }
1897
+ if (isArray(plugins)) {
1898
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1899
+ }
1900
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
1901
+ }
1902
+ context.processNext = _processNext;
1903
+ context.createNew = _createNew;
1904
+ return context;
1835
1905
  }
1836
- function _getCookieValue(name) {
1837
- var cookieValue = strEmpty$1;
1838
- if (_doc) {
1839
- var theCookie = _doc[strCookie] || strEmpty$1;
1840
- if (_parsedCookieValue !== theCookie) {
1841
- _cookieCache = _extractParts(theCookie);
1842
- _parsedCookieValue = theCookie;
1906
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
1907
+ var config = core.config || {};
1908
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1909
+ var context = internalContext.ctx;
1910
+ function _processNext(updateState) {
1911
+ return context.iterate(function (plugin) {
1912
+ if (isFunction(plugin.update)) {
1913
+ plugin.update(context, updateState);
1914
+ }
1915
+ });
1916
+ }
1917
+ function _createNew(plugins, startAt) {
1918
+ if (plugins === void 0) { plugins = null; }
1919
+ if (isArray(plugins)) {
1920
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1843
1921
  }
1844
- cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
1922
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
1845
1923
  }
1846
- return cookieValue;
1924
+ context.processNext = _processNext;
1925
+ context.createNew = _createNew;
1926
+ return context;
1847
1927
  }
1848
- function _setCookieValue(name, cookieValue) {
1849
- if (_doc) {
1850
- _doc[strCookie] = name + "=" + cookieValue;
1928
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1929
+ var firstProxy = null;
1930
+ var add = startAt ? false : true;
1931
+ if (isArray(plugins) && plugins.length > 0) {
1932
+ var lastProxy_1 = null;
1933
+ arrForEach(plugins, function (thePlugin) {
1934
+ if (!add && startAt === thePlugin) {
1935
+ add = true;
1936
+ }
1937
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1938
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1939
+ if (!firstProxy) {
1940
+ firstProxy = newProxy;
1941
+ }
1942
+ if (lastProxy_1) {
1943
+ lastProxy_1._setNext(newProxy);
1944
+ }
1945
+ lastProxy_1 = newProxy;
1946
+ }
1947
+ });
1948
+ }
1949
+ if (startAt && !firstProxy) {
1950
+ return createTelemetryProxyChain([startAt], config, core);
1851
1951
  }
1952
+ return firstProxy;
1852
1953
  }
1853
- function uaDisallowsSameSiteNone(userAgent) {
1854
- if (!isString(userAgent)) {
1855
- return false;
1954
+ function createTelemetryPluginProxy(plugin, config, core) {
1955
+ var nextProxy = null;
1956
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1957
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1958
+ var chainId;
1959
+ if (plugin) {
1960
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1856
1961
  }
1857
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
1858
- return true;
1962
+ else {
1963
+ chainId = "Unknown-0-" + _chainId++;
1859
1964
  }
1860
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
1861
- return true;
1965
+ var proxyChain = {
1966
+ getPlugin: function () {
1967
+ return plugin;
1968
+ },
1969
+ getNext: function () {
1970
+ return nextProxy;
1971
+ },
1972
+ processTelemetry: _processTelemetry,
1973
+ unload: _unloadPlugin,
1974
+ update: _updatePlugin,
1975
+ _id: chainId,
1976
+ _setNext: function (nextPlugin) {
1977
+ nextProxy = nextPlugin;
1978
+ }
1979
+ };
1980
+ function _getTelCtx() {
1981
+ var itemCtx;
1982
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1983
+ itemCtx = plugin[strGetTelCtx]();
1984
+ }
1985
+ if (!itemCtx) {
1986
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1987
+ }
1988
+ return itemCtx;
1862
1989
  }
1863
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
1864
- return true;
1990
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1991
+ var hasRun = false;
1992
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1993
+ var hasRunContext = itemCtx[strHasRunFlags];
1994
+ if (!hasRunContext) {
1995
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1996
+ }
1997
+ itemCtx.setNext(nextProxy);
1998
+ if (plugin) {
1999
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
2000
+ hasRunContext[chainId] = true;
2001
+ try {
2002
+ var nextId = nextProxy ? nextProxy._id : strEmpty$1;
2003
+ if (nextId) {
2004
+ hasRunContext[nextId] = false;
2005
+ }
2006
+ hasRun = processPluginFn(itemCtx);
2007
+ }
2008
+ catch (error) {
2009
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2010
+ if (hasNextRun) {
2011
+ hasRun = true;
2012
+ }
2013
+ if (!nextProxy || !hasNextRun) {
2014
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2015
+ }
2016
+ }
2017
+ }, details, isAsync);
2018
+ }
2019
+ return hasRun;
1865
2020
  }
1866
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
1867
- return true;
2021
+ function _processTelemetry(env, itemCtx) {
2022
+ itemCtx = itemCtx || _getTelCtx();
2023
+ function _callProcessTelemetry(itemCtx) {
2024
+ if (!plugin || !hasProcessTelemetry) {
2025
+ return false;
2026
+ }
2027
+ var pluginState = _getPluginState(plugin);
2028
+ if (pluginState.teardown || pluginState[strDisabled]) {
2029
+ return false;
2030
+ }
2031
+ if (hasSetNext) {
2032
+ plugin.setNextPlugin(nextProxy);
2033
+ }
2034
+ plugin.processTelemetry(env, itemCtx);
2035
+ return true;
2036
+ }
2037
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2038
+ itemCtx.processNext(env);
2039
+ }
1868
2040
  }
1869
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
1870
- return true;
2041
+ function _unloadPlugin(unloadCtx, unloadState) {
2042
+ function _callTeardown() {
2043
+ var hasRun = false;
2044
+ if (plugin) {
2045
+ var pluginState = _getPluginState(plugin);
2046
+ var pluginCore = plugin[strCore] || pluginState.core;
2047
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
2048
+ pluginState[strCore] = null;
2049
+ pluginState[strTeardown] = true;
2050
+ pluginState[strIsInitialized] = false;
2051
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
2052
+ hasRun = true;
2053
+ }
2054
+ }
2055
+ }
2056
+ return hasRun;
2057
+ }
2058
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
2059
+ unloadCtx.processNext(unloadState);
2060
+ }
1871
2061
  }
1872
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
1873
- return true;
2062
+ function _updatePlugin(updateCtx, updateState) {
2063
+ function _callUpdate() {
2064
+ var hasRun = false;
2065
+ if (plugin) {
2066
+ var pluginState = _getPluginState(plugin);
2067
+ var pluginCore = plugin[strCore] || pluginState.core;
2068
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
2069
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
2070
+ hasRun = true;
2071
+ }
2072
+ }
2073
+ }
2074
+ return hasRun;
2075
+ }
2076
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2077
+ updateCtx.processNext(updateState);
2078
+ }
1874
2079
  }
1875
- return false;
2080
+ return objFreeze(proxyChain);
1876
2081
  }
1877
2082
 
1878
2083
  var strExtensionConfig = "extensionConfig";
@@ -2048,196 +2253,6 @@
2048
2253
  return BaseTelemetryPlugin;
2049
2254
  }());
2050
2255
 
2051
- var strOnPrefix = "on";
2052
- var strAttachEvent = "attachEvent";
2053
- var strAddEventHelper = "addEventListener";
2054
- var strDetachEvent = "detachEvent";
2055
- var strRemoveEventListener = "removeEventListener";
2056
- var strEvents = "events";
2057
- createUniqueNamespace("aiEvtPageHide");
2058
- createUniqueNamespace("aiEvtPageShow");
2059
- var rRemoveEmptyNs = /\.[\.]+/g;
2060
- var rRemoveTrailingEmptyNs = /[\.]+$/;
2061
- var _guid = 1;
2062
- var elmNodeData = createElmNodeData("events");
2063
- var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2064
- function _normalizeNamespace(name) {
2065
- if (name && name.replace) {
2066
- return name.replace(/^\s*\.*|\.*\s*$/g, "");
2067
- }
2068
- return name;
2069
- }
2070
- function _getEvtNamespace(eventName, evtNamespace) {
2071
- if (evtNamespace) {
2072
- var theNamespace_1 = "";
2073
- if (isArray(evtNamespace)) {
2074
- theNamespace_1 = "";
2075
- arrForEach(evtNamespace, function (name) {
2076
- name = _normalizeNamespace(name);
2077
- if (name) {
2078
- if (name[0] !== ".") {
2079
- name = "." + name;
2080
- }
2081
- theNamespace_1 += name;
2082
- }
2083
- });
2084
- }
2085
- else {
2086
- theNamespace_1 = _normalizeNamespace(evtNamespace);
2087
- }
2088
- if (theNamespace_1) {
2089
- if (theNamespace_1[0] !== ".") {
2090
- theNamespace_1 = "." + theNamespace_1;
2091
- }
2092
- eventName = (eventName || "") + theNamespace_1;
2093
- }
2094
- }
2095
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2096
- return {
2097
- type: parsedEvent[1],
2098
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2099
- };
2100
- }
2101
- function _getRegisteredEvents(target, evtName, addDefault) {
2102
- if (addDefault === void 0) { addDefault = true; }
2103
- var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2104
- var registeredEvents = aiEvts[evtName];
2105
- if (!registeredEvents) {
2106
- registeredEvents = aiEvts[evtName] = [];
2107
- }
2108
- return registeredEvents;
2109
- }
2110
- function _doDetach(obj, evtName, handlerRef, useCapture) {
2111
- if (obj && evtName && evtName.type) {
2112
- if (obj[strRemoveEventListener]) {
2113
- obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
2114
- }
2115
- else if (obj[strDetachEvent]) {
2116
- obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
2117
- }
2118
- }
2119
- }
2120
- function _doAttach(obj, evtName, handlerRef, useCapture) {
2121
- var result = false;
2122
- if (obj && evtName && evtName.type && handlerRef) {
2123
- if (obj[strAddEventHelper]) {
2124
- obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2125
- result = true;
2126
- }
2127
- else if (obj[strAttachEvent]) {
2128
- obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2129
- result = true;
2130
- }
2131
- }
2132
- return result;
2133
- }
2134
- function _doUnregister(target, events, evtName, unRegFn) {
2135
- var idx = events.length;
2136
- while (idx--) {
2137
- var theEvent = events[idx];
2138
- if (theEvent) {
2139
- if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
2140
- if (!unRegFn || unRegFn(theEvent)) {
2141
- _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
2142
- events.splice(idx, 1);
2143
- }
2144
- }
2145
- }
2146
- }
2147
- }
2148
- function _unregisterEvents(target, evtName, unRegFn) {
2149
- if (evtName.type) {
2150
- _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
2151
- }
2152
- else {
2153
- var eventCache = elmNodeData.get(target, strEvents, {});
2154
- objForEachKey(eventCache, function (evtType, events) {
2155
- _doUnregister(target, events, evtName, unRegFn);
2156
- });
2157
- if (objKeys(eventCache).length === 0) {
2158
- elmNodeData.kill(target, strEvents);
2159
- }
2160
- }
2161
- }
2162
- function mergeEvtNamespace(theNamespace, namespaces) {
2163
- var newNamespaces;
2164
- if (namespaces) {
2165
- if (isArray(namespaces)) {
2166
- newNamespaces = [theNamespace].concat(namespaces);
2167
- }
2168
- else {
2169
- newNamespaces = [theNamespace, namespaces];
2170
- }
2171
- newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
2172
- }
2173
- else {
2174
- newNamespaces = theNamespace;
2175
- }
2176
- return newNamespaces;
2177
- }
2178
- function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2179
- if (useCapture === void 0) { useCapture = false; }
2180
- var result = false;
2181
- if (target) {
2182
- try {
2183
- var evtName = _getEvtNamespace(eventName, evtNamespace);
2184
- result = _doAttach(target, evtName, handlerRef, useCapture);
2185
- if (result && elmNodeData.accept(target)) {
2186
- var registeredEvent = {
2187
- guid: _guid++,
2188
- evtName: evtName,
2189
- handler: handlerRef,
2190
- capture: useCapture
2191
- };
2192
- _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2193
- }
2194
- }
2195
- catch (e) {
2196
- }
2197
- }
2198
- return result;
2199
- }
2200
- function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
2201
- if (useCapture === void 0) { useCapture = false; }
2202
- if (target) {
2203
- try {
2204
- var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
2205
- var found_1 = false;
2206
- _unregisterEvents(target, evtName_1, function (regEvent) {
2207
- if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
2208
- found_1 = true;
2209
- return true;
2210
- }
2211
- return false;
2212
- });
2213
- if (!found_1) {
2214
- _doDetach(target, evtName_1, handlerRef, useCapture);
2215
- }
2216
- }
2217
- catch (e) {
2218
- }
2219
- }
2220
- }
2221
-
2222
- function generateW3CId() {
2223
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2224
- var oct = strEmpty$1, tmp;
2225
- for (var a = 0; a < 4; a++) {
2226
- tmp = random32();
2227
- oct +=
2228
- hexValues[tmp & 0xF] +
2229
- hexValues[tmp >> 4 & 0xF] +
2230
- hexValues[tmp >> 8 & 0xF] +
2231
- hexValues[tmp >> 12 & 0xF] +
2232
- hexValues[tmp >> 16 & 0xF] +
2233
- hexValues[tmp >> 20 & 0xF] +
2234
- hexValues[tmp >> 24 & 0xF] +
2235
- hexValues[tmp >> 28 & 0xF];
2236
- }
2237
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2238
- return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2239
- }
2240
-
2241
2256
  var aiInstrumentHooks = "_aiHooks";
2242
2257
  var cbNames = [
2243
2258
  "req", "rsp", "hkErr", "fnErr"
@@ -2721,6 +2736,43 @@
2721
2736
  }
2722
2737
  return result;
2723
2738
  }
2739
+ function createDistributedTraceContextFromTrace(telemetryTrace, parentCtx) {
2740
+ var trace = telemetryTrace || {};
2741
+ return {
2742
+ getName: function () {
2743
+ return trace.name;
2744
+ },
2745
+ setName: function (newValue) {
2746
+ parentCtx && parentCtx.setName(newValue);
2747
+ trace.name = newValue;
2748
+ },
2749
+ getTraceId: function () {
2750
+ return trace.traceID;
2751
+ },
2752
+ setTraceId: function (newValue) {
2753
+ parentCtx && parentCtx.setTraceId(newValue);
2754
+ if (isValidTraceId(newValue)) {
2755
+ trace.traceID = newValue;
2756
+ }
2757
+ },
2758
+ getSpanId: function () {
2759
+ return trace.parentID;
2760
+ },
2761
+ setSpanId: function (newValue) {
2762
+ parentCtx && parentCtx.setSpanId(newValue);
2763
+ if (isValidSpanId(newValue)) {
2764
+ trace.parentID = newValue;
2765
+ }
2766
+ },
2767
+ getTraceFlags: function () {
2768
+ return trace.traceFlags;
2769
+ },
2770
+ setTraceFlags: function (newTraceFlags) {
2771
+ parentCtx && parentCtx.setTraceFlags(newTraceFlags);
2772
+ trace.traceFlags = newTraceFlags;
2773
+ }
2774
+ };
2775
+ }
2724
2776
 
2725
2777
  var Event$1 = /** @class */ (function () {
2726
2778
  function Event(logger, name, properties, measurements) {
@@ -4161,6 +4213,22 @@
4161
4213
  }
4162
4214
  }
4163
4215
  }
4216
+ function _getDistributedTraceCtx() {
4217
+ var distributedTraceCtx = null;
4218
+ if (_self.core && _self.core.getTraceCtx) {
4219
+ distributedTraceCtx = _self.core.getTraceCtx(false);
4220
+ }
4221
+ if (!distributedTraceCtx) {
4222
+ var properties = _self.core.getPlugin(PropertiesPluginIdentifier);
4223
+ if (properties) {
4224
+ var context = properties.plugin.context;
4225
+ if (context) {
4226
+ distributedTraceCtx = createDistributedTraceContextFromTrace(context.telemetryTrace);
4227
+ }
4228
+ }
4229
+ }
4230
+ return distributedTraceCtx;
4231
+ }
4164
4232
  function _addHistoryListener(extConfig, win, history, locn) {
4165
4233
  function _popstateHandler() {
4166
4234
  if (_enableAutoRouteTracking) {
@@ -4176,17 +4244,14 @@
4176
4244
  _currUri = locn && locn.href || "";
4177
4245
  }
4178
4246
  if (_enableAutoRouteTracking) {
4179
- var properties = _self.core.getPlugin(PropertiesPluginIdentifier);
4180
- if (properties) {
4181
- var context = properties.plugin.context;
4182
- if (context && context.telemetryTrace) {
4183
- context.telemetryTrace.traceID = generateW3CId();
4184
- var traceLocationName = "_unknown_";
4185
- if (locn && locn.pathname) {
4186
- traceLocationName = locn.pathname + (locn.hash || "");
4187
- }
4188
- context.telemetryTrace.name = dataSanitizeString(_self.diagLog(), traceLocationName);
4247
+ var distributedTraceCtx = _getDistributedTraceCtx();
4248
+ if (distributedTraceCtx) {
4249
+ distributedTraceCtx.setTraceId(generateW3CId());
4250
+ var traceLocationName = "_unknown_";
4251
+ if (locn && locn.pathname) {
4252
+ traceLocationName = locn.pathname + (locn.hash || "");
4189
4253
  }
4254
+ distributedTraceCtx.setName(dataSanitizeString(_self.diagLog(), traceLocationName));
4190
4255
  }
4191
4256
  setTimeout((function (uri) {
4192
4257
  _self.trackPageView({ refUri: uri, properties: { duration: 0 } });
@@ -4262,7 +4327,7 @@
4262
4327
  });
4263
4328
  return _this;
4264
4329
  }
4265
- AnalyticsPlugin.Version = "2.8.4-nightly.2205-07";
4330
+ AnalyticsPlugin.Version = "2.8.4-nightly.2205-10";
4266
4331
  AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
4267
4332
  return AnalyticsPlugin;
4268
4333
  }(BaseTelemetryPlugin));