@microsoft/applicationinsights-properties-js 2.8.4-nightly.2205-08 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/applicationinsights-properties-js.integrity.json +9 -9
- package/browser/applicationinsights-properties-js.js +571 -499
- package/browser/applicationinsights-properties-js.js.map +1 -1
- package/browser/applicationinsights-properties-js.min.js +2 -2
- package/browser/applicationinsights-properties-js.min.js.map +1 -1
- package/dist/applicationinsights-properties-js.api.json +45 -1
- package/dist/applicationinsights-properties-js.api.md +4 -1
- package/dist/applicationinsights-properties-js.d.ts +4 -2
- package/dist/applicationinsights-properties-js.js +571 -499
- package/dist/applicationinsights-properties-js.js.map +1 -1
- package/dist/applicationinsights-properties-js.min.js +2 -2
- package/dist/applicationinsights-properties-js.min.js.map +1 -1
- package/dist/applicationinsights-properties-js.rollup.d.ts +4 -2
- package/dist-esm/Context/Application.js +1 -1
- package/dist-esm/Context/Device.js +1 -1
- package/dist-esm/Context/Internal.js +2 -2
- package/dist-esm/Context/Internal.js.map +1 -1
- package/dist-esm/Context/Location.js +1 -1
- package/dist-esm/Context/Session.js +5 -5
- package/dist-esm/Context/Session.js.map +1 -1
- package/dist-esm/Context/TelemetryTrace.js +3 -4
- package/dist-esm/Context/TelemetryTrace.js.map +1 -1
- package/dist-esm/Context/User.js +2 -2
- package/dist-esm/Context/User.js.map +1 -1
- package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
- package/dist-esm/Interfaces/ITelemetryConfig.js +1 -1
- package/dist-esm/PropertiesPlugin.js +30 -8
- package/dist-esm/PropertiesPlugin.js.map +1 -1
- package/dist-esm/TelemetryContext.js +11 -3
- package/dist-esm/TelemetryContext.js.map +1 -1
- package/dist-esm/applicationinsights-properties-js.js +1 -1
- package/package.json +58 -61
- package/src/Context/Internal.ts +1 -1
- package/src/Context/TelemetryTrace.ts +3 -3
- package/src/PropertiesPlugin.ts +33 -7
- package/src/TelemetryContext.ts +12 -3
- package/types/Context/TelemetryTrace.d.ts +1 -0
- package/types/TelemetryContext.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - Properties Plugin, 2.8.4
|
|
2
|
+
* Application Insights JavaScript SDK - Properties Plugin, 2.8.4
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -1172,7 +1172,7 @@
|
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
1174
|
var _objDefineProperty = ObjDefineProperty;
|
|
1175
|
-
var version = "2.8.4
|
|
1175
|
+
var version = "2.8.4";
|
|
1176
1176
|
var instanceName = "." + newId(6);
|
|
1177
1177
|
var _dataUid = 0;
|
|
1178
1178
|
function _createAccessor(target, prop, value) {
|
|
@@ -1243,6 +1243,285 @@
|
|
|
1243
1243
|
return data;
|
|
1244
1244
|
}
|
|
1245
1245
|
|
|
1246
|
+
var strToGMTString = "toGMTString";
|
|
1247
|
+
var strToUTCString = "toUTCString";
|
|
1248
|
+
var strCookie = "cookie";
|
|
1249
|
+
var strExpires = "expires";
|
|
1250
|
+
var strEnabled = "enabled";
|
|
1251
|
+
var strIsCookieUseDisabled = "isCookieUseDisabled";
|
|
1252
|
+
var strDisableCookiesUsage = "disableCookiesUsage";
|
|
1253
|
+
var strConfigCookieMgr = "_ckMgr";
|
|
1254
|
+
var _supportsCookies = null;
|
|
1255
|
+
var _allowUaSameSite = null;
|
|
1256
|
+
var _parsedCookieValue = null;
|
|
1257
|
+
var _doc = getDocument();
|
|
1258
|
+
var _cookieCache = {};
|
|
1259
|
+
var _globalCookieConfig = {};
|
|
1260
|
+
function _gblCookieMgr(config, logger) {
|
|
1261
|
+
var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
|
|
1262
|
+
if (!inst) {
|
|
1263
|
+
inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
|
|
1264
|
+
_globalCookieConfig[strConfigCookieMgr] = inst;
|
|
1265
|
+
}
|
|
1266
|
+
return inst;
|
|
1267
|
+
}
|
|
1268
|
+
function _isMgrEnabled(cookieMgr) {
|
|
1269
|
+
if (cookieMgr) {
|
|
1270
|
+
return cookieMgr.isEnabled();
|
|
1271
|
+
}
|
|
1272
|
+
return true;
|
|
1273
|
+
}
|
|
1274
|
+
function _createCookieMgrConfig(rootConfig) {
|
|
1275
|
+
var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};
|
|
1276
|
+
setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
|
|
1277
|
+
setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
|
|
1278
|
+
if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {
|
|
1279
|
+
var cookieEnabled = void 0;
|
|
1280
|
+
if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
|
|
1281
|
+
cookieEnabled = !rootConfig[strIsCookieUseDisabled];
|
|
1282
|
+
}
|
|
1283
|
+
if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
|
|
1284
|
+
cookieEnabled = !rootConfig[strDisableCookiesUsage];
|
|
1285
|
+
}
|
|
1286
|
+
cookieMgrCfg[strEnabled] = cookieEnabled;
|
|
1287
|
+
}
|
|
1288
|
+
return cookieMgrCfg;
|
|
1289
|
+
}
|
|
1290
|
+
function safeGetCookieMgr(core, config) {
|
|
1291
|
+
var cookieMgr;
|
|
1292
|
+
if (core) {
|
|
1293
|
+
cookieMgr = core.getCookieMgr();
|
|
1294
|
+
}
|
|
1295
|
+
else if (config) {
|
|
1296
|
+
var cookieCfg = config.cookieCfg;
|
|
1297
|
+
if (cookieCfg[strConfigCookieMgr]) {
|
|
1298
|
+
cookieMgr = cookieCfg[strConfigCookieMgr];
|
|
1299
|
+
}
|
|
1300
|
+
else {
|
|
1301
|
+
cookieMgr = createCookieMgr(config);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
if (!cookieMgr) {
|
|
1305
|
+
cookieMgr = _gblCookieMgr(config, (core || {}).logger);
|
|
1306
|
+
}
|
|
1307
|
+
return cookieMgr;
|
|
1308
|
+
}
|
|
1309
|
+
function createCookieMgr(rootConfig, logger) {
|
|
1310
|
+
var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
|
|
1311
|
+
var _path = cookieMgrConfig.path || "/";
|
|
1312
|
+
var _domain = cookieMgrConfig.domain;
|
|
1313
|
+
var _enabled = cookieMgrConfig[strEnabled] !== false;
|
|
1314
|
+
var cookieMgr = {
|
|
1315
|
+
isEnabled: function () {
|
|
1316
|
+
var enabled = _enabled && areCookiesSupported(logger);
|
|
1317
|
+
var gblManager = _globalCookieConfig[strConfigCookieMgr];
|
|
1318
|
+
if (enabled && gblManager && cookieMgr !== gblManager) {
|
|
1319
|
+
enabled = _isMgrEnabled(gblManager);
|
|
1320
|
+
}
|
|
1321
|
+
return enabled;
|
|
1322
|
+
},
|
|
1323
|
+
setEnabled: function (value) {
|
|
1324
|
+
_enabled = value !== false;
|
|
1325
|
+
},
|
|
1326
|
+
set: function (name, value, maxAgeSec, domain, path) {
|
|
1327
|
+
var result = false;
|
|
1328
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1329
|
+
var values = {};
|
|
1330
|
+
var theValue = strTrim(value || strEmpty$1);
|
|
1331
|
+
var idx = theValue.indexOf(";");
|
|
1332
|
+
if (idx !== -1) {
|
|
1333
|
+
theValue = strTrim(value.substring(0, idx));
|
|
1334
|
+
values = _extractParts(value.substring(idx + 1));
|
|
1335
|
+
}
|
|
1336
|
+
setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
|
|
1337
|
+
if (!isNullOrUndefined(maxAgeSec)) {
|
|
1338
|
+
var _isIE = isIE();
|
|
1339
|
+
if (isUndefined(values[strExpires])) {
|
|
1340
|
+
var nowMs = dateNow();
|
|
1341
|
+
var expireMs = nowMs + (maxAgeSec * 1000);
|
|
1342
|
+
if (expireMs > 0) {
|
|
1343
|
+
var expiry = new Date();
|
|
1344
|
+
expiry.setTime(expireMs);
|
|
1345
|
+
setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (!_isIE) {
|
|
1349
|
+
setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
var location_1 = getLocation();
|
|
1353
|
+
if (location_1 && location_1.protocol === "https:") {
|
|
1354
|
+
setValue(values, "secure", null, null, isUndefined);
|
|
1355
|
+
if (_allowUaSameSite === null) {
|
|
1356
|
+
_allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
|
|
1357
|
+
}
|
|
1358
|
+
if (_allowUaSameSite) {
|
|
1359
|
+
setValue(values, "SameSite", "None", null, isUndefined);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
setValue(values, "path", path || _path, null, isUndefined);
|
|
1363
|
+
var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
|
|
1364
|
+
setCookieFn(name, _formatCookieValue(theValue, values));
|
|
1365
|
+
result = true;
|
|
1366
|
+
}
|
|
1367
|
+
return result;
|
|
1368
|
+
},
|
|
1369
|
+
get: function (name) {
|
|
1370
|
+
var value = strEmpty$1;
|
|
1371
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1372
|
+
value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
|
|
1373
|
+
}
|
|
1374
|
+
return value;
|
|
1375
|
+
},
|
|
1376
|
+
del: function (name, path) {
|
|
1377
|
+
var result = false;
|
|
1378
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1379
|
+
result = cookieMgr.purge(name, path);
|
|
1380
|
+
}
|
|
1381
|
+
return result;
|
|
1382
|
+
},
|
|
1383
|
+
purge: function (name, path) {
|
|
1384
|
+
var _a;
|
|
1385
|
+
var result = false;
|
|
1386
|
+
if (areCookiesSupported(logger)) {
|
|
1387
|
+
var values = (_a = {},
|
|
1388
|
+
_a["path"] = path ? path : "/",
|
|
1389
|
+
_a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
|
|
1390
|
+
_a);
|
|
1391
|
+
if (!isIE()) {
|
|
1392
|
+
values["max-age"] = "0";
|
|
1393
|
+
}
|
|
1394
|
+
var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
|
|
1395
|
+
delCookie(name, _formatCookieValue(strEmpty$1, values));
|
|
1396
|
+
result = true;
|
|
1397
|
+
}
|
|
1398
|
+
return result;
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
cookieMgr[strConfigCookieMgr] = cookieMgr;
|
|
1402
|
+
return cookieMgr;
|
|
1403
|
+
}
|
|
1404
|
+
function areCookiesSupported(logger) {
|
|
1405
|
+
if (_supportsCookies === null) {
|
|
1406
|
+
_supportsCookies = false;
|
|
1407
|
+
try {
|
|
1408
|
+
var doc = _doc || {};
|
|
1409
|
+
_supportsCookies = doc[strCookie] !== undefined;
|
|
1410
|
+
}
|
|
1411
|
+
catch (e) {
|
|
1412
|
+
_throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
return _supportsCookies;
|
|
1416
|
+
}
|
|
1417
|
+
function _extractParts(theValue) {
|
|
1418
|
+
var values = {};
|
|
1419
|
+
if (theValue && theValue.length) {
|
|
1420
|
+
var parts = strTrim(theValue).split(";");
|
|
1421
|
+
arrForEach(parts, function (thePart) {
|
|
1422
|
+
thePart = strTrim(thePart || strEmpty$1);
|
|
1423
|
+
if (thePart) {
|
|
1424
|
+
var idx = thePart.indexOf("=");
|
|
1425
|
+
if (idx === -1) {
|
|
1426
|
+
values[thePart] = null;
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
return values;
|
|
1435
|
+
}
|
|
1436
|
+
function _formatDate(theDate, func) {
|
|
1437
|
+
if (isFunction(theDate[func])) {
|
|
1438
|
+
return theDate[func]();
|
|
1439
|
+
}
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
function _formatCookieValue(value, values) {
|
|
1443
|
+
var cookieValue = value || strEmpty$1;
|
|
1444
|
+
objForEachKey(values, function (name, theValue) {
|
|
1445
|
+
cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
|
|
1446
|
+
});
|
|
1447
|
+
return cookieValue;
|
|
1448
|
+
}
|
|
1449
|
+
function _getCookieValue(name) {
|
|
1450
|
+
var cookieValue = strEmpty$1;
|
|
1451
|
+
if (_doc) {
|
|
1452
|
+
var theCookie = _doc[strCookie] || strEmpty$1;
|
|
1453
|
+
if (_parsedCookieValue !== theCookie) {
|
|
1454
|
+
_cookieCache = _extractParts(theCookie);
|
|
1455
|
+
_parsedCookieValue = theCookie;
|
|
1456
|
+
}
|
|
1457
|
+
cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
|
|
1458
|
+
}
|
|
1459
|
+
return cookieValue;
|
|
1460
|
+
}
|
|
1461
|
+
function _setCookieValue(name, cookieValue) {
|
|
1462
|
+
if (_doc) {
|
|
1463
|
+
_doc[strCookie] = name + "=" + cookieValue;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function uaDisallowsSameSiteNone(userAgent) {
|
|
1467
|
+
if (!isString(userAgent)) {
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
|
|
1471
|
+
return true;
|
|
1472
|
+
}
|
|
1473
|
+
if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
|
|
1474
|
+
return true;
|
|
1475
|
+
}
|
|
1476
|
+
if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
|
|
1477
|
+
return true;
|
|
1478
|
+
}
|
|
1479
|
+
if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
|
|
1480
|
+
return true;
|
|
1481
|
+
}
|
|
1482
|
+
if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
|
|
1483
|
+
return true;
|
|
1484
|
+
}
|
|
1485
|
+
if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
function generateW3CId() {
|
|
1492
|
+
var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
|
1493
|
+
var oct = strEmpty$1, tmp;
|
|
1494
|
+
for (var a = 0; a < 4; a++) {
|
|
1495
|
+
tmp = random32();
|
|
1496
|
+
oct +=
|
|
1497
|
+
hexValues[tmp & 0xF] +
|
|
1498
|
+
hexValues[tmp >> 4 & 0xF] +
|
|
1499
|
+
hexValues[tmp >> 8 & 0xF] +
|
|
1500
|
+
hexValues[tmp >> 12 & 0xF] +
|
|
1501
|
+
hexValues[tmp >> 16 & 0xF] +
|
|
1502
|
+
hexValues[tmp >> 20 & 0xF] +
|
|
1503
|
+
hexValues[tmp >> 24 & 0xF] +
|
|
1504
|
+
hexValues[tmp >> 28 & 0xF];
|
|
1505
|
+
}
|
|
1506
|
+
var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
|
|
1507
|
+
return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
var INVALID_TRACE_ID = "00000000000000000000000000000000";
|
|
1511
|
+
var INVALID_SPAN_ID = "0000000000000000";
|
|
1512
|
+
function _isValid(value, len, invalidValue) {
|
|
1513
|
+
if (value && value.length === len && value !== invalidValue) {
|
|
1514
|
+
return !!value.match(/^[\da-f]*$/);
|
|
1515
|
+
}
|
|
1516
|
+
return false;
|
|
1517
|
+
}
|
|
1518
|
+
function isValidTraceId(value) {
|
|
1519
|
+
return _isValid(value, 32, INVALID_TRACE_ID);
|
|
1520
|
+
}
|
|
1521
|
+
function isValidSpanId(value) {
|
|
1522
|
+
return _isValid(value, 16, INVALID_SPAN_ID);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1246
1525
|
var pluginStateData = createElmNodeData("plugin");
|
|
1247
1526
|
function _getPluginState(plugin) {
|
|
1248
1527
|
return pluginStateData.get(plugin, "state", {}, true);
|
|
@@ -1345,500 +1624,255 @@
|
|
|
1345
1624
|
if (config && mergeDefault === 2 ) {
|
|
1346
1625
|
objForEachKey(defaultValue, function (field) {
|
|
1347
1626
|
if (isNullOrUndefined(newConfig_1[field])) {
|
|
1348
|
-
var cfgValue = config[field];
|
|
1349
|
-
if (!isNullOrUndefined(cfgValue)) {
|
|
1350
|
-
newConfig_1[field] = cfgValue;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
});
|
|
1354
|
-
}
|
|
1355
|
-
theConfig = newConfig_1;
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
return theConfig;
|
|
1359
|
-
}
|
|
1360
|
-
function _getConfig(identifier, field, defaultValue) {
|
|
1361
|
-
if (defaultValue === void 0) { defaultValue = false; }
|
|
1362
|
-
var theValue;
|
|
1363
|
-
var extConfig = _getExtCfg(identifier, null);
|
|
1364
|
-
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
1365
|
-
theValue = extConfig[field];
|
|
1366
|
-
}
|
|
1367
|
-
else if (config && !isNullOrUndefined(config[field])) {
|
|
1368
|
-
theValue = config[field];
|
|
1369
|
-
}
|
|
1370
|
-
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
|
|
1371
|
-
}
|
|
1372
|
-
function _iterateChain(cb) {
|
|
1373
|
-
var nextPlugin;
|
|
1374
|
-
while (!!(nextPlugin = context._next())) {
|
|
1375
|
-
var plugin = nextPlugin.getPlugin();
|
|
1376
|
-
if (plugin) {
|
|
1377
|
-
cb(plugin);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
return context;
|
|
1382
|
-
}
|
|
1383
|
-
function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
|
|
1384
|
-
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1385
|
-
var context = internalContext.ctx;
|
|
1386
|
-
function _processNext(env) {
|
|
1387
|
-
var nextPlugin = internalContext._next();
|
|
1388
|
-
nextPlugin && nextPlugin.processTelemetry(env, context);
|
|
1389
|
-
return !nextPlugin;
|
|
1390
|
-
}
|
|
1391
|
-
function _createNew(plugins, startAt) {
|
|
1392
|
-
if (plugins === void 0) { plugins = null; }
|
|
1393
|
-
if (isArray(plugins)) {
|
|
1394
|
-
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1395
|
-
}
|
|
1396
|
-
return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
|
|
1397
|
-
}
|
|
1398
|
-
context.processNext = _processNext;
|
|
1399
|
-
context.createNew = _createNew;
|
|
1400
|
-
return context;
|
|
1401
|
-
}
|
|
1402
|
-
function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
|
|
1403
|
-
var config = core.config || {};
|
|
1404
|
-
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1405
|
-
var context = internalContext.ctx;
|
|
1406
|
-
function _processNext(unloadState) {
|
|
1407
|
-
var nextPlugin = internalContext._next();
|
|
1408
|
-
nextPlugin && nextPlugin.unload(context, unloadState);
|
|
1409
|
-
return !nextPlugin;
|
|
1410
|
-
}
|
|
1411
|
-
function _createNew(plugins, startAt) {
|
|
1412
|
-
if (plugins === void 0) { plugins = null; }
|
|
1413
|
-
if (isArray(plugins)) {
|
|
1414
|
-
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1415
|
-
}
|
|
1416
|
-
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
|
|
1417
|
-
}
|
|
1418
|
-
context.processNext = _processNext;
|
|
1419
|
-
context.createNew = _createNew;
|
|
1420
|
-
return context;
|
|
1421
|
-
}
|
|
1422
|
-
function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
|
|
1423
|
-
var config = core.config || {};
|
|
1424
|
-
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1425
|
-
var context = internalContext.ctx;
|
|
1426
|
-
function _processNext(updateState) {
|
|
1427
|
-
return context.iterate(function (plugin) {
|
|
1428
|
-
if (isFunction(plugin.update)) {
|
|
1429
|
-
plugin.update(context, updateState);
|
|
1430
|
-
}
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
function _createNew(plugins, startAt) {
|
|
1434
|
-
if (plugins === void 0) { plugins = null; }
|
|
1435
|
-
if (isArray(plugins)) {
|
|
1436
|
-
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1437
|
-
}
|
|
1438
|
-
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
|
|
1439
|
-
}
|
|
1440
|
-
context.processNext = _processNext;
|
|
1441
|
-
context.createNew = _createNew;
|
|
1442
|
-
return context;
|
|
1443
|
-
}
|
|
1444
|
-
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1445
|
-
var firstProxy = null;
|
|
1446
|
-
var add = startAt ? false : true;
|
|
1447
|
-
if (isArray(plugins) && plugins.length > 0) {
|
|
1448
|
-
var lastProxy_1 = null;
|
|
1449
|
-
arrForEach(plugins, function (thePlugin) {
|
|
1450
|
-
if (!add && startAt === thePlugin) {
|
|
1451
|
-
add = true;
|
|
1452
|
-
}
|
|
1453
|
-
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
1454
|
-
var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
1455
|
-
if (!firstProxy) {
|
|
1456
|
-
firstProxy = newProxy;
|
|
1457
|
-
}
|
|
1458
|
-
if (lastProxy_1) {
|
|
1459
|
-
lastProxy_1._setNext(newProxy);
|
|
1460
|
-
}
|
|
1461
|
-
lastProxy_1 = newProxy;
|
|
1462
|
-
}
|
|
1463
|
-
});
|
|
1464
|
-
}
|
|
1465
|
-
if (startAt && !firstProxy) {
|
|
1466
|
-
return createTelemetryProxyChain([startAt], config, core);
|
|
1467
|
-
}
|
|
1468
|
-
return firstProxy;
|
|
1469
|
-
}
|
|
1470
|
-
function createTelemetryPluginProxy(plugin, config, core) {
|
|
1471
|
-
var nextProxy = null;
|
|
1472
|
-
var hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
1473
|
-
var hasSetNext = isFunction(plugin.setNextPlugin);
|
|
1474
|
-
var chainId;
|
|
1475
|
-
if (plugin) {
|
|
1476
|
-
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
1477
|
-
}
|
|
1478
|
-
else {
|
|
1479
|
-
chainId = "Unknown-0-" + _chainId++;
|
|
1480
|
-
}
|
|
1481
|
-
var proxyChain = {
|
|
1482
|
-
getPlugin: function () {
|
|
1483
|
-
return plugin;
|
|
1484
|
-
},
|
|
1485
|
-
getNext: function () {
|
|
1486
|
-
return nextProxy;
|
|
1487
|
-
},
|
|
1488
|
-
processTelemetry: _processTelemetry,
|
|
1489
|
-
unload: _unloadPlugin,
|
|
1490
|
-
update: _updatePlugin,
|
|
1491
|
-
_id: chainId,
|
|
1492
|
-
_setNext: function (nextPlugin) {
|
|
1493
|
-
nextProxy = nextPlugin;
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
function _getTelCtx() {
|
|
1497
|
-
var itemCtx;
|
|
1498
|
-
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
1499
|
-
itemCtx = plugin[strGetTelCtx]();
|
|
1500
|
-
}
|
|
1501
|
-
if (!itemCtx) {
|
|
1502
|
-
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
1503
|
-
}
|
|
1504
|
-
return itemCtx;
|
|
1505
|
-
}
|
|
1506
|
-
function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
|
|
1507
|
-
var hasRun = false;
|
|
1508
|
-
var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
|
|
1509
|
-
var hasRunContext = itemCtx[strHasRunFlags];
|
|
1510
|
-
if (!hasRunContext) {
|
|
1511
|
-
hasRunContext = itemCtx[strHasRunFlags] = {};
|
|
1512
|
-
}
|
|
1513
|
-
itemCtx.setNext(nextProxy);
|
|
1514
|
-
if (plugin) {
|
|
1515
|
-
doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
|
|
1516
|
-
hasRunContext[chainId] = true;
|
|
1517
|
-
try {
|
|
1518
|
-
var nextId = nextProxy ? nextProxy._id : strEmpty$1;
|
|
1519
|
-
if (nextId) {
|
|
1520
|
-
hasRunContext[nextId] = false;
|
|
1521
|
-
}
|
|
1522
|
-
hasRun = processPluginFn(itemCtx);
|
|
1523
|
-
}
|
|
1524
|
-
catch (error) {
|
|
1525
|
-
var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
|
|
1526
|
-
if (hasNextRun) {
|
|
1527
|
-
hasRun = true;
|
|
1528
|
-
}
|
|
1529
|
-
if (!nextProxy || !hasNextRun) {
|
|
1530
|
-
_throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}, details, isAsync);
|
|
1534
|
-
}
|
|
1535
|
-
return hasRun;
|
|
1536
|
-
}
|
|
1537
|
-
function _processTelemetry(env, itemCtx) {
|
|
1538
|
-
itemCtx = itemCtx || _getTelCtx();
|
|
1539
|
-
function _callProcessTelemetry(itemCtx) {
|
|
1540
|
-
if (!plugin || !hasProcessTelemetry) {
|
|
1541
|
-
return false;
|
|
1542
|
-
}
|
|
1543
|
-
var pluginState = _getPluginState(plugin);
|
|
1544
|
-
if (pluginState.teardown || pluginState[strDisabled]) {
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
if (hasSetNext) {
|
|
1548
|
-
plugin.setNextPlugin(nextProxy);
|
|
1627
|
+
var cfgValue = config[field];
|
|
1628
|
+
if (!isNullOrUndefined(cfgValue)) {
|
|
1629
|
+
newConfig_1[field] = cfgValue;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
theConfig = newConfig_1;
|
|
1549
1635
|
}
|
|
1550
|
-
plugin.processTelemetry(env, itemCtx);
|
|
1551
|
-
return true;
|
|
1552
|
-
}
|
|
1553
|
-
if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
|
|
1554
|
-
itemCtx.processNext(env);
|
|
1555
1636
|
}
|
|
1637
|
+
return theConfig;
|
|
1556
1638
|
}
|
|
1557
|
-
function
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1564
|
-
pluginState[strCore] = null;
|
|
1565
|
-
pluginState[strTeardown] = true;
|
|
1566
|
-
pluginState[strIsInitialized] = false;
|
|
1567
|
-
if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
|
|
1568
|
-
hasRun = true;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return hasRun;
|
|
1639
|
+
function _getConfig(identifier, field, defaultValue) {
|
|
1640
|
+
if (defaultValue === void 0) { defaultValue = false; }
|
|
1641
|
+
var theValue;
|
|
1642
|
+
var extConfig = _getExtCfg(identifier, null);
|
|
1643
|
+
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
1644
|
+
theValue = extConfig[field];
|
|
1573
1645
|
}
|
|
1574
|
-
if (
|
|
1575
|
-
|
|
1646
|
+
else if (config && !isNullOrUndefined(config[field])) {
|
|
1647
|
+
theValue = config[field];
|
|
1576
1648
|
}
|
|
1649
|
+
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
|
|
1577
1650
|
}
|
|
1578
|
-
function
|
|
1579
|
-
|
|
1580
|
-
|
|
1651
|
+
function _iterateChain(cb) {
|
|
1652
|
+
var nextPlugin;
|
|
1653
|
+
while (!!(nextPlugin = context._next())) {
|
|
1654
|
+
var plugin = nextPlugin.getPlugin();
|
|
1581
1655
|
if (plugin) {
|
|
1582
|
-
|
|
1583
|
-
var pluginCore = plugin[strCore] || pluginState.core;
|
|
1584
|
-
if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1585
|
-
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
1586
|
-
hasRun = true;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1656
|
+
cb(plugin);
|
|
1589
1657
|
}
|
|
1590
|
-
return hasRun;
|
|
1591
|
-
}
|
|
1592
|
-
if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
|
|
1593
|
-
updateCtx.processNext(updateState);
|
|
1594
1658
|
}
|
|
1595
1659
|
}
|
|
1596
|
-
return
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
var strToGMTString = "toGMTString";
|
|
1600
|
-
var strToUTCString = "toUTCString";
|
|
1601
|
-
var strCookie = "cookie";
|
|
1602
|
-
var strExpires = "expires";
|
|
1603
|
-
var strEnabled = "enabled";
|
|
1604
|
-
var strIsCookieUseDisabled = "isCookieUseDisabled";
|
|
1605
|
-
var strDisableCookiesUsage = "disableCookiesUsage";
|
|
1606
|
-
var strConfigCookieMgr = "_ckMgr";
|
|
1607
|
-
var _supportsCookies = null;
|
|
1608
|
-
var _allowUaSameSite = null;
|
|
1609
|
-
var _parsedCookieValue = null;
|
|
1610
|
-
var _doc = getDocument();
|
|
1611
|
-
var _cookieCache = {};
|
|
1612
|
-
var _globalCookieConfig = {};
|
|
1613
|
-
function _gblCookieMgr(config, logger) {
|
|
1614
|
-
var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
|
|
1615
|
-
if (!inst) {
|
|
1616
|
-
inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
|
|
1617
|
-
_globalCookieConfig[strConfigCookieMgr] = inst;
|
|
1618
|
-
}
|
|
1619
|
-
return inst;
|
|
1660
|
+
return context;
|
|
1620
1661
|
}
|
|
1621
|
-
function
|
|
1622
|
-
|
|
1623
|
-
|
|
1662
|
+
function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
|
|
1663
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1664
|
+
var context = internalContext.ctx;
|
|
1665
|
+
function _processNext(env) {
|
|
1666
|
+
var nextPlugin = internalContext._next();
|
|
1667
|
+
nextPlugin && nextPlugin.processTelemetry(env, context);
|
|
1668
|
+
return !nextPlugin;
|
|
1624
1669
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
|
|
1630
|
-
setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
|
|
1631
|
-
if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {
|
|
1632
|
-
var cookieEnabled = void 0;
|
|
1633
|
-
if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
|
|
1634
|
-
cookieEnabled = !rootConfig[strIsCookieUseDisabled];
|
|
1635
|
-
}
|
|
1636
|
-
if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
|
|
1637
|
-
cookieEnabled = !rootConfig[strDisableCookiesUsage];
|
|
1670
|
+
function _createNew(plugins, startAt) {
|
|
1671
|
+
if (plugins === void 0) { plugins = null; }
|
|
1672
|
+
if (isArray(plugins)) {
|
|
1673
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1638
1674
|
}
|
|
1639
|
-
|
|
1675
|
+
return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
|
|
1640
1676
|
}
|
|
1641
|
-
|
|
1677
|
+
context.processNext = _processNext;
|
|
1678
|
+
context.createNew = _createNew;
|
|
1679
|
+
return context;
|
|
1642
1680
|
}
|
|
1643
|
-
function
|
|
1644
|
-
var
|
|
1645
|
-
|
|
1646
|
-
|
|
1681
|
+
function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
|
|
1682
|
+
var config = core.config || {};
|
|
1683
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1684
|
+
var context = internalContext.ctx;
|
|
1685
|
+
function _processNext(unloadState) {
|
|
1686
|
+
var nextPlugin = internalContext._next();
|
|
1687
|
+
nextPlugin && nextPlugin.unload(context, unloadState);
|
|
1688
|
+
return !nextPlugin;
|
|
1647
1689
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
if (
|
|
1651
|
-
|
|
1652
|
-
}
|
|
1653
|
-
else {
|
|
1654
|
-
cookieMgr = createCookieMgr(config);
|
|
1690
|
+
function _createNew(plugins, startAt) {
|
|
1691
|
+
if (plugins === void 0) { plugins = null; }
|
|
1692
|
+
if (isArray(plugins)) {
|
|
1693
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1655
1694
|
}
|
|
1695
|
+
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
|
|
1656
1696
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
return cookieMgr;
|
|
1661
|
-
}
|
|
1662
|
-
function createCookieMgr(rootConfig, logger) {
|
|
1663
|
-
var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
|
|
1664
|
-
var _path = cookieMgrConfig.path || "/";
|
|
1665
|
-
var _domain = cookieMgrConfig.domain;
|
|
1666
|
-
var _enabled = cookieMgrConfig[strEnabled] !== false;
|
|
1667
|
-
var cookieMgr = {
|
|
1668
|
-
isEnabled: function () {
|
|
1669
|
-
var enabled = _enabled && areCookiesSupported(logger);
|
|
1670
|
-
var gblManager = _globalCookieConfig[strConfigCookieMgr];
|
|
1671
|
-
if (enabled && gblManager && cookieMgr !== gblManager) {
|
|
1672
|
-
enabled = _isMgrEnabled(gblManager);
|
|
1673
|
-
}
|
|
1674
|
-
return enabled;
|
|
1675
|
-
},
|
|
1676
|
-
setEnabled: function (value) {
|
|
1677
|
-
_enabled = value !== false;
|
|
1678
|
-
},
|
|
1679
|
-
set: function (name, value, maxAgeSec, domain, path) {
|
|
1680
|
-
var result = false;
|
|
1681
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
1682
|
-
var values = {};
|
|
1683
|
-
var theValue = strTrim(value || strEmpty$1);
|
|
1684
|
-
var idx = theValue.indexOf(";");
|
|
1685
|
-
if (idx !== -1) {
|
|
1686
|
-
theValue = strTrim(value.substring(0, idx));
|
|
1687
|
-
values = _extractParts(value.substring(idx + 1));
|
|
1688
|
-
}
|
|
1689
|
-
setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
|
|
1690
|
-
if (!isNullOrUndefined(maxAgeSec)) {
|
|
1691
|
-
var _isIE = isIE();
|
|
1692
|
-
if (isUndefined(values[strExpires])) {
|
|
1693
|
-
var nowMs = dateNow();
|
|
1694
|
-
var expireMs = nowMs + (maxAgeSec * 1000);
|
|
1695
|
-
if (expireMs > 0) {
|
|
1696
|
-
var expiry = new Date();
|
|
1697
|
-
expiry.setTime(expireMs);
|
|
1698
|
-
setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty$1, isTruthy);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
if (!_isIE) {
|
|
1702
|
-
setValue(values, "max-age", strEmpty$1 + maxAgeSec, null, isUndefined);
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
var location_1 = getLocation();
|
|
1706
|
-
if (location_1 && location_1.protocol === "https:") {
|
|
1707
|
-
setValue(values, "secure", null, null, isUndefined);
|
|
1708
|
-
if (_allowUaSameSite === null) {
|
|
1709
|
-
_allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
|
|
1710
|
-
}
|
|
1711
|
-
if (_allowUaSameSite) {
|
|
1712
|
-
setValue(values, "SameSite", "None", null, isUndefined);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
setValue(values, "path", path || _path, null, isUndefined);
|
|
1716
|
-
var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
|
|
1717
|
-
setCookieFn(name, _formatCookieValue(theValue, values));
|
|
1718
|
-
result = true;
|
|
1719
|
-
}
|
|
1720
|
-
return result;
|
|
1721
|
-
},
|
|
1722
|
-
get: function (name) {
|
|
1723
|
-
var value = strEmpty$1;
|
|
1724
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
1725
|
-
value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
|
|
1726
|
-
}
|
|
1727
|
-
return value;
|
|
1728
|
-
},
|
|
1729
|
-
del: function (name, path) {
|
|
1730
|
-
var result = false;
|
|
1731
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
1732
|
-
result = cookieMgr.purge(name, path);
|
|
1733
|
-
}
|
|
1734
|
-
return result;
|
|
1735
|
-
},
|
|
1736
|
-
purge: function (name, path) {
|
|
1737
|
-
var _a;
|
|
1738
|
-
var result = false;
|
|
1739
|
-
if (areCookiesSupported(logger)) {
|
|
1740
|
-
var values = (_a = {},
|
|
1741
|
-
_a["path"] = path ? path : "/",
|
|
1742
|
-
_a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
|
|
1743
|
-
_a);
|
|
1744
|
-
if (!isIE()) {
|
|
1745
|
-
values["max-age"] = "0";
|
|
1746
|
-
}
|
|
1747
|
-
var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
|
|
1748
|
-
delCookie(name, _formatCookieValue(strEmpty$1, values));
|
|
1749
|
-
result = true;
|
|
1750
|
-
}
|
|
1751
|
-
return result;
|
|
1752
|
-
}
|
|
1753
|
-
};
|
|
1754
|
-
cookieMgr[strConfigCookieMgr] = cookieMgr;
|
|
1755
|
-
return cookieMgr;
|
|
1697
|
+
context.processNext = _processNext;
|
|
1698
|
+
context.createNew = _createNew;
|
|
1699
|
+
return context;
|
|
1756
1700
|
}
|
|
1757
|
-
function
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1701
|
+
function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
|
|
1702
|
+
var config = core.config || {};
|
|
1703
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1704
|
+
var context = internalContext.ctx;
|
|
1705
|
+
function _processNext(updateState) {
|
|
1706
|
+
return context.iterate(function (plugin) {
|
|
1707
|
+
if (isFunction(plugin.update)) {
|
|
1708
|
+
plugin.update(context, updateState);
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
function _createNew(plugins, startAt) {
|
|
1713
|
+
if (plugins === void 0) { plugins = null; }
|
|
1714
|
+
if (isArray(plugins)) {
|
|
1715
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1766
1716
|
}
|
|
1717
|
+
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
|
|
1767
1718
|
}
|
|
1768
|
-
|
|
1719
|
+
context.processNext = _processNext;
|
|
1720
|
+
context.createNew = _createNew;
|
|
1721
|
+
return context;
|
|
1769
1722
|
}
|
|
1770
|
-
function
|
|
1771
|
-
var
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1723
|
+
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1724
|
+
var firstProxy = null;
|
|
1725
|
+
var add = startAt ? false : true;
|
|
1726
|
+
if (isArray(plugins) && plugins.length > 0) {
|
|
1727
|
+
var lastProxy_1 = null;
|
|
1728
|
+
arrForEach(plugins, function (thePlugin) {
|
|
1729
|
+
if (!add && startAt === thePlugin) {
|
|
1730
|
+
add = true;
|
|
1731
|
+
}
|
|
1732
|
+
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
1733
|
+
var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
1734
|
+
if (!firstProxy) {
|
|
1735
|
+
firstProxy = newProxy;
|
|
1780
1736
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1737
|
+
if (lastProxy_1) {
|
|
1738
|
+
lastProxy_1._setNext(newProxy);
|
|
1783
1739
|
}
|
|
1740
|
+
lastProxy_1 = newProxy;
|
|
1784
1741
|
}
|
|
1785
1742
|
});
|
|
1786
1743
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
function _formatDate(theDate, func) {
|
|
1790
|
-
if (isFunction(theDate[func])) {
|
|
1791
|
-
return theDate[func]();
|
|
1792
|
-
}
|
|
1793
|
-
return null;
|
|
1794
|
-
}
|
|
1795
|
-
function _formatCookieValue(value, values) {
|
|
1796
|
-
var cookieValue = value || strEmpty$1;
|
|
1797
|
-
objForEachKey(values, function (name, theValue) {
|
|
1798
|
-
cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty$1);
|
|
1799
|
-
});
|
|
1800
|
-
return cookieValue;
|
|
1801
|
-
}
|
|
1802
|
-
function _getCookieValue(name) {
|
|
1803
|
-
var cookieValue = strEmpty$1;
|
|
1804
|
-
if (_doc) {
|
|
1805
|
-
var theCookie = _doc[strCookie] || strEmpty$1;
|
|
1806
|
-
if (_parsedCookieValue !== theCookie) {
|
|
1807
|
-
_cookieCache = _extractParts(theCookie);
|
|
1808
|
-
_parsedCookieValue = theCookie;
|
|
1809
|
-
}
|
|
1810
|
-
cookieValue = strTrim(_cookieCache[name] || strEmpty$1);
|
|
1811
|
-
}
|
|
1812
|
-
return cookieValue;
|
|
1813
|
-
}
|
|
1814
|
-
function _setCookieValue(name, cookieValue) {
|
|
1815
|
-
if (_doc) {
|
|
1816
|
-
_doc[strCookie] = name + "=" + cookieValue;
|
|
1744
|
+
if (startAt && !firstProxy) {
|
|
1745
|
+
return createTelemetryProxyChain([startAt], config, core);
|
|
1817
1746
|
}
|
|
1747
|
+
return firstProxy;
|
|
1818
1748
|
}
|
|
1819
|
-
function
|
|
1820
|
-
|
|
1821
|
-
|
|
1749
|
+
function createTelemetryPluginProxy(plugin, config, core) {
|
|
1750
|
+
var nextProxy = null;
|
|
1751
|
+
var hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
1752
|
+
var hasSetNext = isFunction(plugin.setNextPlugin);
|
|
1753
|
+
var chainId;
|
|
1754
|
+
if (plugin) {
|
|
1755
|
+
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
1822
1756
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1757
|
+
else {
|
|
1758
|
+
chainId = "Unknown-0-" + _chainId++;
|
|
1825
1759
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1760
|
+
var proxyChain = {
|
|
1761
|
+
getPlugin: function () {
|
|
1762
|
+
return plugin;
|
|
1763
|
+
},
|
|
1764
|
+
getNext: function () {
|
|
1765
|
+
return nextProxy;
|
|
1766
|
+
},
|
|
1767
|
+
processTelemetry: _processTelemetry,
|
|
1768
|
+
unload: _unloadPlugin,
|
|
1769
|
+
update: _updatePlugin,
|
|
1770
|
+
_id: chainId,
|
|
1771
|
+
_setNext: function (nextPlugin) {
|
|
1772
|
+
nextProxy = nextPlugin;
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
function _getTelCtx() {
|
|
1776
|
+
var itemCtx;
|
|
1777
|
+
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
1778
|
+
itemCtx = plugin[strGetTelCtx]();
|
|
1779
|
+
}
|
|
1780
|
+
if (!itemCtx) {
|
|
1781
|
+
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
1782
|
+
}
|
|
1783
|
+
return itemCtx;
|
|
1828
1784
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1785
|
+
function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
|
|
1786
|
+
var hasRun = false;
|
|
1787
|
+
var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
|
|
1788
|
+
var hasRunContext = itemCtx[strHasRunFlags];
|
|
1789
|
+
if (!hasRunContext) {
|
|
1790
|
+
hasRunContext = itemCtx[strHasRunFlags] = {};
|
|
1791
|
+
}
|
|
1792
|
+
itemCtx.setNext(nextProxy);
|
|
1793
|
+
if (plugin) {
|
|
1794
|
+
doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
|
|
1795
|
+
hasRunContext[chainId] = true;
|
|
1796
|
+
try {
|
|
1797
|
+
var nextId = nextProxy ? nextProxy._id : strEmpty$1;
|
|
1798
|
+
if (nextId) {
|
|
1799
|
+
hasRunContext[nextId] = false;
|
|
1800
|
+
}
|
|
1801
|
+
hasRun = processPluginFn(itemCtx);
|
|
1802
|
+
}
|
|
1803
|
+
catch (error) {
|
|
1804
|
+
var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
|
|
1805
|
+
if (hasNextRun) {
|
|
1806
|
+
hasRun = true;
|
|
1807
|
+
}
|
|
1808
|
+
if (!nextProxy || !hasNextRun) {
|
|
1809
|
+
_throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}, details, isAsync);
|
|
1813
|
+
}
|
|
1814
|
+
return hasRun;
|
|
1831
1815
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1816
|
+
function _processTelemetry(env, itemCtx) {
|
|
1817
|
+
itemCtx = itemCtx || _getTelCtx();
|
|
1818
|
+
function _callProcessTelemetry(itemCtx) {
|
|
1819
|
+
if (!plugin || !hasProcessTelemetry) {
|
|
1820
|
+
return false;
|
|
1821
|
+
}
|
|
1822
|
+
var pluginState = _getPluginState(plugin);
|
|
1823
|
+
if (pluginState.teardown || pluginState[strDisabled]) {
|
|
1824
|
+
return false;
|
|
1825
|
+
}
|
|
1826
|
+
if (hasSetNext) {
|
|
1827
|
+
plugin.setNextPlugin(nextProxy);
|
|
1828
|
+
}
|
|
1829
|
+
plugin.processTelemetry(env, itemCtx);
|
|
1830
|
+
return true;
|
|
1831
|
+
}
|
|
1832
|
+
if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
|
|
1833
|
+
itemCtx.processNext(env);
|
|
1834
|
+
}
|
|
1834
1835
|
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1836
|
+
function _unloadPlugin(unloadCtx, unloadState) {
|
|
1837
|
+
function _callTeardown() {
|
|
1838
|
+
var hasRun = false;
|
|
1839
|
+
if (plugin) {
|
|
1840
|
+
var pluginState = _getPluginState(plugin);
|
|
1841
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
1842
|
+
if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1843
|
+
pluginState[strCore] = null;
|
|
1844
|
+
pluginState[strTeardown] = true;
|
|
1845
|
+
pluginState[strIsInitialized] = false;
|
|
1846
|
+
if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
|
|
1847
|
+
hasRun = true;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
return hasRun;
|
|
1852
|
+
}
|
|
1853
|
+
if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
|
|
1854
|
+
unloadCtx.processNext(unloadState);
|
|
1855
|
+
}
|
|
1837
1856
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1857
|
+
function _updatePlugin(updateCtx, updateState) {
|
|
1858
|
+
function _callUpdate() {
|
|
1859
|
+
var hasRun = false;
|
|
1860
|
+
if (plugin) {
|
|
1861
|
+
var pluginState = _getPluginState(plugin);
|
|
1862
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
1863
|
+
if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1864
|
+
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
1865
|
+
hasRun = true;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
return hasRun;
|
|
1870
|
+
}
|
|
1871
|
+
if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
|
|
1872
|
+
updateCtx.processNext(updateState);
|
|
1873
|
+
}
|
|
1840
1874
|
}
|
|
1841
|
-
return
|
|
1875
|
+
return objFreeze(proxyChain);
|
|
1842
1876
|
}
|
|
1843
1877
|
|
|
1844
1878
|
var strExtensionConfig = "extensionConfig";
|
|
@@ -2014,25 +2048,6 @@
|
|
|
2014
2048
|
return BaseTelemetryPlugin;
|
|
2015
2049
|
}());
|
|
2016
2050
|
|
|
2017
|
-
function generateW3CId() {
|
|
2018
|
-
var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
|
2019
|
-
var oct = strEmpty$1, tmp;
|
|
2020
|
-
for (var a = 0; a < 4; a++) {
|
|
2021
|
-
tmp = random32();
|
|
2022
|
-
oct +=
|
|
2023
|
-
hexValues[tmp & 0xF] +
|
|
2024
|
-
hexValues[tmp >> 4 & 0xF] +
|
|
2025
|
-
hexValues[tmp >> 8 & 0xF] +
|
|
2026
|
-
hexValues[tmp >> 12 & 0xF] +
|
|
2027
|
-
hexValues[tmp >> 16 & 0xF] +
|
|
2028
|
-
hexValues[tmp >> 20 & 0xF] +
|
|
2029
|
-
hexValues[tmp >> 24 & 0xF] +
|
|
2030
|
-
hexValues[tmp >> 28 & 0xF];
|
|
2031
|
-
}
|
|
2032
|
-
var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
|
|
2033
|
-
return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
2051
|
function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
|
|
2037
2052
|
var origLength = key.length;
|
|
2038
2053
|
var field = dataSanitizeKey(logger, key);
|
|
@@ -2141,16 +2156,6 @@
|
|
|
2141
2156
|
hour = hour.length < 2 ? "0" + hour : hour;
|
|
2142
2157
|
return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms;
|
|
2143
2158
|
}
|
|
2144
|
-
function getExtensionByName(extensions, identifier) {
|
|
2145
|
-
var extension = null;
|
|
2146
|
-
arrForEach(extensions, function (value) {
|
|
2147
|
-
if (value.identifier === identifier) {
|
|
2148
|
-
extension = value;
|
|
2149
|
-
return -1;
|
|
2150
|
-
}
|
|
2151
|
-
});
|
|
2152
|
-
return extension;
|
|
2153
|
-
}
|
|
2154
2159
|
|
|
2155
2160
|
var strNotSpecified = "not_specified";
|
|
2156
2161
|
|
|
@@ -2237,6 +2242,44 @@
|
|
|
2237
2242
|
return false;
|
|
2238
2243
|
}
|
|
2239
2244
|
|
|
2245
|
+
function createDistributedTraceContextFromTrace(telemetryTrace, parentCtx) {
|
|
2246
|
+
var trace = telemetryTrace || {};
|
|
2247
|
+
return {
|
|
2248
|
+
getName: function () {
|
|
2249
|
+
return trace.name;
|
|
2250
|
+
},
|
|
2251
|
+
setName: function (newValue) {
|
|
2252
|
+
parentCtx && parentCtx.setName(newValue);
|
|
2253
|
+
trace.name = newValue;
|
|
2254
|
+
},
|
|
2255
|
+
getTraceId: function () {
|
|
2256
|
+
return trace.traceID;
|
|
2257
|
+
},
|
|
2258
|
+
setTraceId: function (newValue) {
|
|
2259
|
+
parentCtx && parentCtx.setTraceId(newValue);
|
|
2260
|
+
if (isValidTraceId(newValue)) {
|
|
2261
|
+
trace.traceID = newValue;
|
|
2262
|
+
}
|
|
2263
|
+
},
|
|
2264
|
+
getSpanId: function () {
|
|
2265
|
+
return trace.parentID;
|
|
2266
|
+
},
|
|
2267
|
+
setSpanId: function (newValue) {
|
|
2268
|
+
parentCtx && parentCtx.setSpanId(newValue);
|
|
2269
|
+
if (isValidSpanId(newValue)) {
|
|
2270
|
+
trace.parentID = newValue;
|
|
2271
|
+
}
|
|
2272
|
+
},
|
|
2273
|
+
getTraceFlags: function () {
|
|
2274
|
+
return trace.traceFlags;
|
|
2275
|
+
},
|
|
2276
|
+
setTraceFlags: function (newTraceFlags) {
|
|
2277
|
+
parentCtx && parentCtx.setTraceFlags(newTraceFlags);
|
|
2278
|
+
trace.traceFlags = newTraceFlags;
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2240
2283
|
var PageView = /** @class */ (function () {
|
|
2241
2284
|
function PageView(logger, name, url, durationMs, properties, measurements, id) {
|
|
2242
2285
|
this.aiDataContract = {
|
|
@@ -2511,7 +2554,7 @@
|
|
|
2511
2554
|
return Device;
|
|
2512
2555
|
}());
|
|
2513
2556
|
|
|
2514
|
-
var Version = "2.8.4
|
|
2557
|
+
var Version = "2.8.4";
|
|
2515
2558
|
var Internal = /** @class */ (function () {
|
|
2516
2559
|
function Internal(config) {
|
|
2517
2560
|
this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;
|
|
@@ -2632,12 +2675,11 @@
|
|
|
2632
2675
|
var _self = this;
|
|
2633
2676
|
_self.traceID = id || generateW3CId();
|
|
2634
2677
|
_self.parentID = parentId;
|
|
2635
|
-
_self.name = name;
|
|
2636
2678
|
var location = getLocation();
|
|
2637
2679
|
if (!name && location && location.pathname) {
|
|
2638
|
-
|
|
2680
|
+
name = location.pathname;
|
|
2639
2681
|
}
|
|
2640
|
-
_self.name = dataSanitizeString(logger,
|
|
2682
|
+
_self.name = dataSanitizeString(logger, name);
|
|
2641
2683
|
}
|
|
2642
2684
|
return TelemetryTrace;
|
|
2643
2685
|
}());
|
|
@@ -2650,7 +2692,7 @@
|
|
|
2650
2692
|
}
|
|
2651
2693
|
}
|
|
2652
2694
|
var TelemetryContext = /** @class */ (function () {
|
|
2653
|
-
function TelemetryContext(core, defaultConfig) {
|
|
2695
|
+
function TelemetryContext(core, defaultConfig, previousTraceCtx) {
|
|
2654
2696
|
var _this = this;
|
|
2655
2697
|
var logger = core.logger;
|
|
2656
2698
|
this.appId = function () { return null; };
|
|
@@ -2663,7 +2705,15 @@
|
|
|
2663
2705
|
_self.device = new Device();
|
|
2664
2706
|
_self.location = new Location();
|
|
2665
2707
|
_self.user = new User(defaultConfig, core);
|
|
2666
|
-
|
|
2708
|
+
var traceId = void 0;
|
|
2709
|
+
var parentId = void 0;
|
|
2710
|
+
var name_1;
|
|
2711
|
+
if (previousTraceCtx) {
|
|
2712
|
+
traceId = previousTraceCtx.getTraceId();
|
|
2713
|
+
parentId = previousTraceCtx.getSpanId();
|
|
2714
|
+
name_1 = previousTraceCtx.getName();
|
|
2715
|
+
}
|
|
2716
|
+
_self.telemetryTrace = new TelemetryTrace(traceId, parentId, name_1, logger);
|
|
2667
2717
|
_self.session = new Session();
|
|
2668
2718
|
}
|
|
2669
2719
|
_self.getSessionId = function () {
|
|
@@ -2767,9 +2817,11 @@
|
|
|
2767
2817
|
var _this = _super.call(this) || this;
|
|
2768
2818
|
_this.priority = 110;
|
|
2769
2819
|
_this.identifier = PropertiesPluginIdentifier;
|
|
2770
|
-
var _breezeChannel;
|
|
2771
2820
|
var _extensionConfig;
|
|
2821
|
+
var _distributedTraceCtx;
|
|
2822
|
+
var _previousTraceCtx;
|
|
2772
2823
|
dynamicProto(PropertiesPlugin, _this, function (_self, _base) {
|
|
2824
|
+
_initDefaults();
|
|
2773
2825
|
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
2774
2826
|
_base.initialize(config, core, extensions, pluginChain);
|
|
2775
2827
|
var ctx = _self._getTelCtx();
|
|
@@ -2779,9 +2831,14 @@
|
|
|
2779
2831
|
objForEachKey(defaultConfig, function (field, value) {
|
|
2780
2832
|
_extensionConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };
|
|
2781
2833
|
});
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
_self.context.
|
|
2834
|
+
_previousTraceCtx = core.getTraceCtx(false);
|
|
2835
|
+
_self.context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
|
|
2836
|
+
_distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
|
|
2837
|
+
core.setTraceCtx(_distributedTraceCtx);
|
|
2838
|
+
_self.context.appId = function () {
|
|
2839
|
+
var breezeChannel = core.getPlugin(BreezeChannelIdentifier);
|
|
2840
|
+
return breezeChannel ? breezeChannel.plugin["_appId"] : null;
|
|
2841
|
+
};
|
|
2785
2842
|
_self["_extConfig"] = _extensionConfig;
|
|
2786
2843
|
};
|
|
2787
2844
|
_self.processTelemetry = function (event, itemCtx) {
|
|
@@ -2810,6 +2867,21 @@
|
|
|
2810
2867
|
_self.processNext(event, itemCtx);
|
|
2811
2868
|
}
|
|
2812
2869
|
};
|
|
2870
|
+
_self._doTeardown = function (unloadCtx, unloadState) {
|
|
2871
|
+
var core = (unloadCtx || {}).core();
|
|
2872
|
+
if (core && core.getTraceCtx) {
|
|
2873
|
+
var traceCtx = core.getTraceCtx(false);
|
|
2874
|
+
if (traceCtx === _distributedTraceCtx) {
|
|
2875
|
+
core.setTraceCtx(_previousTraceCtx);
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
_initDefaults();
|
|
2879
|
+
};
|
|
2880
|
+
function _initDefaults() {
|
|
2881
|
+
_extensionConfig = null;
|
|
2882
|
+
_distributedTraceCtx = null;
|
|
2883
|
+
_previousTraceCtx = null;
|
|
2884
|
+
}
|
|
2813
2885
|
function _processTelemetryInternal(evt, itemCtx) {
|
|
2814
2886
|
getSetValue(evt, "tags", []);
|
|
2815
2887
|
getSetValue(evt, "ext", {});
|