countly-sdk-web 26.1.0 → 26.1.2
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/CHANGELOG.md +8 -0
- package/cypress/e2e/bridged_utils.cy.js +1 -1
- package/cypress/e2e/device_id_change.cy.js +45 -0
- package/cypress/e2e/sdk_info.cy.js +1 -1
- package/examples/example_quick_async.html +63 -0
- package/examples/quick_loader/quick_async_loader.js +152 -0
- package/examples/quick_loader/quick_async_loader.min.js +4 -0
- package/lib/countly.js +330 -2
- package/lib/countly.min.js +251 -241
- package/package.json +3 -2
package/lib/countly.js
CHANGED
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
backoffCount: "cly_hc_backoff_count",
|
|
351
351
|
consecutiveBackoffCount: "cly_hc_consecutive_backoff_count"
|
|
352
352
|
});
|
|
353
|
-
var SDK_VERSION = "26.1.
|
|
353
|
+
var SDK_VERSION = "26.1.2";
|
|
354
354
|
var SDK_NAME = "javascript_native_web";
|
|
355
355
|
|
|
356
356
|
// Using this on document.referrer would return an array with 17 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
|
|
@@ -759,6 +759,109 @@
|
|
|
759
759
|
return ua;
|
|
760
760
|
}
|
|
761
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Parse Windows version from UA-CH platformVersion
|
|
764
|
+
* Chromium based browsers use platformVersion major >= 13 for Windows 11 and lower values for Windows 10.
|
|
765
|
+
*
|
|
766
|
+
* @param {string} platformVersion - platformVersion value from userAgentData.getHighEntropyValues
|
|
767
|
+
* @returns {string|null} "11", "10" or null if not parsable
|
|
768
|
+
*/
|
|
769
|
+
function parseWindowsVersionFromPlatformVersion(platformVersion) {
|
|
770
|
+
if (typeof platformVersion !== "string" || !platformVersion) {
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
var major = parseInt(platformVersion.split(".")[0], 10);
|
|
774
|
+
if (isNaN(major)) {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
return major >= 13 ? "11" : "10";
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Retrieve User-Agent Client Hints (high entropy values) when available.
|
|
782
|
+
*
|
|
783
|
+
* @param {Object} uaDataOverride - optional userAgentData override for testing
|
|
784
|
+
* @returns {Promise<Object|null>} resolved hints object or null
|
|
785
|
+
*/
|
|
786
|
+
function getUserAgentClientHintsInternal(uaData) {
|
|
787
|
+
if (!uaData || typeof uaData.getHighEntropyValues !== "function") {
|
|
788
|
+
return Promise.resolve(null);
|
|
789
|
+
}
|
|
790
|
+
return uaData.getHighEntropyValues(["platform", "platformVersion", "architecture", "bitness", "model", "uaFullVersion", "fullVersionList"]).then(function (values) {
|
|
791
|
+
if (!values || _typeof(values) !== "object") {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
var browserName = null;
|
|
795
|
+
var browserVersion = null;
|
|
796
|
+
var versionList = Array.isArray(values.fullVersionList) ? values.fullVersionList : [];
|
|
797
|
+
var fallbackList = Array.isArray(uaData.brands) ? uaData.brands : [];
|
|
798
|
+
var normalizeBrand = function normalizeBrand(brand) {
|
|
799
|
+
return typeof brand === "string" ? brand.toLowerCase().replace(/[^a-z0-9]/g, "") : "";
|
|
800
|
+
};
|
|
801
|
+
var isGreaseBrand = function isGreaseBrand(brand) {
|
|
802
|
+
var normalized = normalizeBrand(brand);
|
|
803
|
+
return normalized === "notabrand" || normalized === "notabrand99" || normalized.indexOf("notabrand") === 0;
|
|
804
|
+
};
|
|
805
|
+
var isChromiumBrand = function isChromiumBrand(brand) {
|
|
806
|
+
return normalizeBrand(brand) === "chromium";
|
|
807
|
+
};
|
|
808
|
+
var pickEntry = function pickEntry(list, allowChromiumFallback) {
|
|
809
|
+
return list.find(function (entry) {
|
|
810
|
+
if (!entry || !entry.brand) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
if (isGreaseBrand(entry.brand)) {
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
if (!allowChromiumFallback && isChromiumBrand(entry.brand)) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
return true;
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
var browserEntry = pickEntry(versionList, false) || pickEntry(fallbackList, false) || pickEntry(versionList, true) || pickEntry(fallbackList, true);
|
|
823
|
+
if (browserEntry) {
|
|
824
|
+
browserName = browserEntry.brand || null;
|
|
825
|
+
browserVersion = browserEntry.version || null;
|
|
826
|
+
}
|
|
827
|
+
var parsed = {
|
|
828
|
+
platform: values.platform || uaData.platform || null,
|
|
829
|
+
platformVersion: values.platformVersion || null,
|
|
830
|
+
architecture: values.architecture || null,
|
|
831
|
+
bitness: values.bitness || null,
|
|
832
|
+
model: values.model || null,
|
|
833
|
+
uaFullVersion: values.uaFullVersion || null,
|
|
834
|
+
fullVersionList: values.fullVersionList || null,
|
|
835
|
+
browserName: browserName,
|
|
836
|
+
browserVersion: browserVersion,
|
|
837
|
+
windowsVersion: null
|
|
838
|
+
};
|
|
839
|
+
if (parsed.platform && parsed.platform.toLowerCase() === "windows") {
|
|
840
|
+
parsed.windowsVersion = parseWindowsVersionFromPlatformVersion(parsed.platformVersion);
|
|
841
|
+
}
|
|
842
|
+
return parsed;
|
|
843
|
+
})["catch"](function () {
|
|
844
|
+
return null;
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
var prefetchedUserAgentClientHintsPromise = null;
|
|
848
|
+
if (isBrowser && typeof navigator !== "undefined" && navigator.userAgentData && typeof navigator.userAgentData.getHighEntropyValues === "function") {
|
|
849
|
+
prefetchedUserAgentClientHintsPromise = getUserAgentClientHintsInternal(navigator.userAgentData);
|
|
850
|
+
}
|
|
851
|
+
function getUserAgentClientHints(uaDataOverride) {
|
|
852
|
+
if (uaDataOverride) {
|
|
853
|
+
return getUserAgentClientHintsInternal(uaDataOverride);
|
|
854
|
+
}
|
|
855
|
+
if (prefetchedUserAgentClientHintsPromise) {
|
|
856
|
+
return prefetchedUserAgentClientHintsPromise;
|
|
857
|
+
}
|
|
858
|
+
if (isBrowser && typeof navigator !== "undefined" && navigator.userAgentData && typeof navigator.userAgentData.getHighEntropyValues === "function") {
|
|
859
|
+
prefetchedUserAgentClientHintsPromise = getUserAgentClientHintsInternal(navigator.userAgentData);
|
|
860
|
+
return prefetchedUserAgentClientHintsPromise;
|
|
861
|
+
}
|
|
862
|
+
return Promise.resolve(null);
|
|
863
|
+
}
|
|
864
|
+
|
|
762
865
|
/**
|
|
763
866
|
* Returns device type information according to user agent string
|
|
764
867
|
* @memberof Countly._internals
|
|
@@ -1092,6 +1195,14 @@
|
|
|
1092
1195
|
var _journeyTriggerPending = /*#__PURE__*/new WeakMap();
|
|
1093
1196
|
var _journeyPendingEventIds = /*#__PURE__*/new WeakMap();
|
|
1094
1197
|
var _fakeRequestHandler = /*#__PURE__*/new WeakMap();
|
|
1198
|
+
var _uaClientHints = /*#__PURE__*/new WeakMap();
|
|
1199
|
+
var _uaClientHintsStatus = /*#__PURE__*/new WeakMap();
|
|
1200
|
+
var _clientHintsPromise = /*#__PURE__*/new WeakMap();
|
|
1201
|
+
var _pendingRequestBuffer = /*#__PURE__*/new WeakMap();
|
|
1202
|
+
var _clientHintsBufferTimeoutId = /*#__PURE__*/new WeakMap();
|
|
1203
|
+
var _changeIdRemoteConfigTimeoutId = /*#__PURE__*/new WeakMap();
|
|
1204
|
+
var _initializeClientHints = /*#__PURE__*/new WeakMap();
|
|
1205
|
+
var _flushPendingRequestBuffer = /*#__PURE__*/new WeakMap();
|
|
1095
1206
|
var _getAndSetServerConfig = /*#__PURE__*/new WeakMap();
|
|
1096
1207
|
var _populateServerConfig = /*#__PURE__*/new WeakMap();
|
|
1097
1208
|
var _initialize = /*#__PURE__*/new WeakMap();
|
|
@@ -1141,6 +1252,7 @@
|
|
|
1141
1252
|
var _getStoredIdOrGenerateId = /*#__PURE__*/new WeakMap();
|
|
1142
1253
|
var _isUUID = /*#__PURE__*/new WeakMap();
|
|
1143
1254
|
var _getUA = /*#__PURE__*/new WeakMap();
|
|
1255
|
+
var _getBrowserInfoFromUA = /*#__PURE__*/new WeakMap();
|
|
1144
1256
|
var _getMetrics = /*#__PURE__*/new WeakMap();
|
|
1145
1257
|
var _getResolution = /*#__PURE__*/new WeakMap();
|
|
1146
1258
|
var _isReferrerUsable = /*#__PURE__*/new WeakMap();
|
|
@@ -1280,6 +1392,90 @@
|
|
|
1280
1392
|
_classPrivateFieldInitSpec(this, _journeyTriggerPending, void 0);
|
|
1281
1393
|
_classPrivateFieldInitSpec(this, _journeyPendingEventIds, void 0);
|
|
1282
1394
|
_classPrivateFieldInitSpec(this, _fakeRequestHandler, void 0);
|
|
1395
|
+
_classPrivateFieldInitSpec(this, _uaClientHints, void 0);
|
|
1396
|
+
_classPrivateFieldInitSpec(this, _uaClientHintsStatus, void 0);
|
|
1397
|
+
_classPrivateFieldInitSpec(this, _clientHintsPromise, void 0);
|
|
1398
|
+
_classPrivateFieldInitSpec(this, _pendingRequestBuffer, void 0);
|
|
1399
|
+
_classPrivateFieldInitSpec(this, _clientHintsBufferTimeoutId, void 0);
|
|
1400
|
+
_classPrivateFieldInitSpec(this, _changeIdRemoteConfigTimeoutId, void 0);
|
|
1401
|
+
/**
|
|
1402
|
+
* Fetch User-Agent Client Hints and cache values for metrics enrichment.
|
|
1403
|
+
* @private
|
|
1404
|
+
*/
|
|
1405
|
+
_classPrivateFieldInitSpec(this, _initializeClientHints, function () {
|
|
1406
|
+
if (!isBrowser) {
|
|
1407
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "unavailable");
|
|
1408
|
+
_classPrivateFieldSet2(_pendingRequestBuffer, _this, null); // no buffering needed
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
var uaRaw = currentUserAgentString();
|
|
1412
|
+
var uaDataAvailable = typeof navigator !== "undefined" && !!navigator.userAgentData;
|
|
1413
|
+
var getHighEntropyValuesAvailable = uaDataAvailable && typeof navigator.userAgentData.getHighEntropyValues === "function";
|
|
1414
|
+
var uaDataPlatform = uaDataAvailable ? navigator.userAgentData.platform : undefined;
|
|
1415
|
+
var uaDataBrands = uaDataAvailable ? navigator.userAgentData.brands : undefined;
|
|
1416
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, raw ua string:[" + uaRaw + "]");
|
|
1417
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, userAgentData available:[" + uaDataAvailable + "], getHighEntropyValues available:[" + getHighEntropyValuesAvailable + "]");
|
|
1418
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, userAgentData low-entropy platform:[" + uaDataPlatform + "], brands:[" + JSON.stringify(uaDataBrands) + "]");
|
|
1419
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "pending");
|
|
1420
|
+
_classPrivateFieldSet2(_pendingRequestBuffer, _this, []); // enable request buffering until hints resolve
|
|
1421
|
+
|
|
1422
|
+
// Safety timeout: flush buffer even if hints never resolve (e.g. API blocked)
|
|
1423
|
+
_classPrivateFieldSet2(_clientHintsBufferTimeoutId, _this, setTimeout(function () {
|
|
1424
|
+
if (_classPrivateFieldGet2(_pendingRequestBuffer, _this) !== null) {
|
|
1425
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.WARNING, "ua_logic, client hints resolution timed out after 5s, flushing pending requests with available metrics");
|
|
1426
|
+
_classPrivateFieldGet2(_flushPendingRequestBuffer, _this).call(_this);
|
|
1427
|
+
}
|
|
1428
|
+
}, 1000));
|
|
1429
|
+
_classPrivateFieldSet2(_clientHintsPromise, _this, getUserAgentClientHints().then(function (clientHints) {
|
|
1430
|
+
if (clientHints && _typeof(clientHints) === "object") {
|
|
1431
|
+
_classPrivateFieldSet2(_uaClientHints, _this, clientHints);
|
|
1432
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "resolved");
|
|
1433
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, high-entropy hints resolved:[" + JSON.stringify(clientHints) + "]");
|
|
1434
|
+
} else {
|
|
1435
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "unavailable");
|
|
1436
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, high-entropy hints unavailable or not returned");
|
|
1437
|
+
}
|
|
1438
|
+
})["catch"](function (err) {
|
|
1439
|
+
_classPrivateFieldSet2(_uaClientHints, _this, null);
|
|
1440
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "failed");
|
|
1441
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, high-entropy hints fetch failed:[" + err + "]");
|
|
1442
|
+
})["finally"](function () {
|
|
1443
|
+
_classPrivateFieldGet2(_flushPendingRequestBuffer, _this).call(_this);
|
|
1444
|
+
}));
|
|
1445
|
+
});
|
|
1446
|
+
/**
|
|
1447
|
+
* Flush pending request buffer after client hints resolution.
|
|
1448
|
+
* Re-computes metrics for any buffered begin_session request so that
|
|
1449
|
+
* high-entropy Client Hints values are included. All other buffered
|
|
1450
|
+
* requests are pushed to the queue unchanged, preserving order.
|
|
1451
|
+
* @private
|
|
1452
|
+
*/
|
|
1453
|
+
_classPrivateFieldInitSpec(this, _flushPendingRequestBuffer, function () {
|
|
1454
|
+
// Clear safety timeout
|
|
1455
|
+
if (_classPrivateFieldGet2(_clientHintsBufferTimeoutId, _this)) {
|
|
1456
|
+
clearTimeout(_classPrivateFieldGet2(_clientHintsBufferTimeoutId, _this));
|
|
1457
|
+
_classPrivateFieldSet2(_clientHintsBufferTimeoutId, _this, null);
|
|
1458
|
+
}
|
|
1459
|
+
var buffer = _classPrivateFieldGet2(_pendingRequestBuffer, _this);
|
|
1460
|
+
_classPrivateFieldSet2(_pendingRequestBuffer, _this, null); // disable buffering — subsequent calls go directly to queue
|
|
1461
|
+
|
|
1462
|
+
if (!buffer || buffer.length === 0) {
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, flushing [" + buffer.length + "] pending request(s) after client hints resolution");
|
|
1466
|
+
for (var i = 0; i < buffer.length; i++) {
|
|
1467
|
+
var request = buffer[i];
|
|
1468
|
+
// Re-compute metrics for begin_session requests with now-resolved hints
|
|
1469
|
+
if (request.begin_session) {
|
|
1470
|
+
request.metrics = JSON.stringify(_classPrivateFieldGet2(_getMetrics, _this).call(_this));
|
|
1471
|
+
}
|
|
1472
|
+
if (_classPrivateFieldGet2(_requestQueue, _this).length > _classPrivateFieldGet2(_SCSizeReqQueue, _this)) {
|
|
1473
|
+
_classPrivateFieldGet2(_requestQueue, _this).shift();
|
|
1474
|
+
}
|
|
1475
|
+
_classPrivateFieldGet2(_requestQueue, _this).push(request);
|
|
1476
|
+
}
|
|
1477
|
+
_classPrivateFieldGet2(_setValueInStorage, _this).call(_this, "cly_queue", _classPrivateFieldGet2(_requestQueue, _this), true);
|
|
1478
|
+
});
|
|
1283
1479
|
/**
|
|
1284
1480
|
* Fetch and set server configuration
|
|
1285
1481
|
* Retrieves server-side settings and behavior configurations
|
|
@@ -2003,6 +2199,18 @@
|
|
|
2003
2199
|
_classPrivateFieldSet2(_journeyTriggerInProgress, _this, undefined);
|
|
2004
2200
|
_classPrivateFieldSet2(_journeyTriggerPending, _this, undefined);
|
|
2005
2201
|
_classPrivateFieldSet2(_journeyPendingEventIds, _this, undefined);
|
|
2202
|
+
if (_classPrivateFieldGet2(_clientHintsBufferTimeoutId, _this)) {
|
|
2203
|
+
clearTimeout(_classPrivateFieldGet2(_clientHintsBufferTimeoutId, _this));
|
|
2204
|
+
_classPrivateFieldSet2(_clientHintsBufferTimeoutId, _this, null);
|
|
2205
|
+
}
|
|
2206
|
+
if (_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this)) {
|
|
2207
|
+
clearTimeout(_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this));
|
|
2208
|
+
_classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, null);
|
|
2209
|
+
}
|
|
2210
|
+
_classPrivateFieldSet2(_pendingRequestBuffer, _this, null);
|
|
2211
|
+
_classPrivateFieldSet2(_clientHintsPromise, _this, null);
|
|
2212
|
+
_classPrivateFieldSet2(_uaClientHints, _this, null);
|
|
2213
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, _this, "not_started");
|
|
2006
2214
|
});
|
|
2007
2215
|
/**
|
|
2008
2216
|
* Returns the SDK version string currently in use
|
|
@@ -2433,7 +2641,17 @@
|
|
|
2433
2641
|
if (_this.remote_config) {
|
|
2434
2642
|
_classPrivateFieldSet2(_remoteConfigs, _this, {});
|
|
2435
2643
|
_classPrivateFieldGet2(_setValueInStorage, _this).call(_this, "cly_remote_configs", _classPrivateFieldGet2(_remoteConfigs, _this));
|
|
2436
|
-
|
|
2644
|
+
if (merge) {
|
|
2645
|
+
if (_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this)) {
|
|
2646
|
+
clearTimeout(_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this));
|
|
2647
|
+
}
|
|
2648
|
+
_classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, setTimeout(function () {
|
|
2649
|
+
_classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, null);
|
|
2650
|
+
_this.fetch_remote_config(_this.remote_config);
|
|
2651
|
+
}, 1000));
|
|
2652
|
+
} else {
|
|
2653
|
+
_this.fetch_remote_config(_this.remote_config);
|
|
2654
|
+
}
|
|
2437
2655
|
}
|
|
2438
2656
|
});
|
|
2439
2657
|
/**
|
|
@@ -2731,6 +2949,11 @@
|
|
|
2731
2949
|
return _regenerator().w(function (_context2) {
|
|
2732
2950
|
while (1) switch (_context2.n) {
|
|
2733
2951
|
case 0:
|
|
2952
|
+
// Flush any buffered requests (e.g. held while client hints were resolving)
|
|
2953
|
+
// into the real request queue so they can be sent before the content request.
|
|
2954
|
+
if (_classPrivateFieldGet2(_pendingRequestBuffer, _this) !== null) {
|
|
2955
|
+
_classPrivateFieldGet2(_flushPendingRequestBuffer, _this).call(_this);
|
|
2956
|
+
}
|
|
2734
2957
|
initialQueueLength = _classPrivateFieldGet2(_requestQueue, _this).length;
|
|
2735
2958
|
if (!(initialQueueLength === 0)) {
|
|
2736
2959
|
_context2.n = 1;
|
|
@@ -5836,6 +6059,12 @@
|
|
|
5836
6059
|
return;
|
|
5837
6060
|
}
|
|
5838
6061
|
_classPrivateFieldGet2(_prepareRequest, _this).call(_this, request);
|
|
6062
|
+
|
|
6063
|
+
// Buffer requests while client hints are still resolving
|
|
6064
|
+
if (_classPrivateFieldGet2(_pendingRequestBuffer, _this) !== null) {
|
|
6065
|
+
_classPrivateFieldGet2(_pendingRequestBuffer, _this).push(request);
|
|
6066
|
+
return;
|
|
6067
|
+
}
|
|
5839
6068
|
if (_classPrivateFieldGet2(_requestQueue, _this).length > _classPrivateFieldGet2(_SCSizeReqQueue, _this)) {
|
|
5840
6069
|
_classPrivateFieldGet2(_requestQueue, _this).shift();
|
|
5841
6070
|
}
|
|
@@ -6089,6 +6318,49 @@
|
|
|
6089
6318
|
}
|
|
6090
6319
|
return currentUserAgentString();
|
|
6091
6320
|
});
|
|
6321
|
+
/**
|
|
6322
|
+
* Basic browser name/version parsing fallback from UA string.
|
|
6323
|
+
* @private
|
|
6324
|
+
* @param {string} ua - raw user agent string
|
|
6325
|
+
* @returns {{name: string|null, version: string|null}}
|
|
6326
|
+
*/
|
|
6327
|
+
_classPrivateFieldInitSpec(this, _getBrowserInfoFromUA, function (ua) {
|
|
6328
|
+
if (!ua || typeof ua !== "string") {
|
|
6329
|
+
return {
|
|
6330
|
+
name: null,
|
|
6331
|
+
version: null
|
|
6332
|
+
};
|
|
6333
|
+
}
|
|
6334
|
+
var patterns = [{
|
|
6335
|
+
name: "Edge",
|
|
6336
|
+
regex: /Edg\/([\d\.]+)/
|
|
6337
|
+
}, {
|
|
6338
|
+
name: "Opera",
|
|
6339
|
+
regex: /OPR\/([\d\.]+)/
|
|
6340
|
+
}, {
|
|
6341
|
+
name: "Chrome",
|
|
6342
|
+
regex: /Chrome\/([\d\.]+)/
|
|
6343
|
+
}, {
|
|
6344
|
+
name: "Firefox",
|
|
6345
|
+
regex: /Firefox\/([\d\.]+)/
|
|
6346
|
+
}, {
|
|
6347
|
+
name: "Safari",
|
|
6348
|
+
regex: /Version\/([\d\.]+).*Safari/
|
|
6349
|
+
}];
|
|
6350
|
+
for (var i = 0; i < patterns.length; i++) {
|
|
6351
|
+
var match = ua.match(patterns[i].regex);
|
|
6352
|
+
if (match && match[1]) {
|
|
6353
|
+
return {
|
|
6354
|
+
name: patterns[i].name,
|
|
6355
|
+
version: match[1]
|
|
6356
|
+
};
|
|
6357
|
+
}
|
|
6358
|
+
}
|
|
6359
|
+
return {
|
|
6360
|
+
name: null,
|
|
6361
|
+
version: null
|
|
6362
|
+
};
|
|
6363
|
+
});
|
|
6092
6364
|
/**
|
|
6093
6365
|
* Get metrics of the browser or config object
|
|
6094
6366
|
* @memberof Countly._internals
|
|
@@ -6118,6 +6390,55 @@
|
|
|
6118
6390
|
if (typeof locale !== "undefined") {
|
|
6119
6391
|
metrics._locale = metrics._locale || locale;
|
|
6120
6392
|
}
|
|
6393
|
+
if (isBrowser && navigator.userAgentData && navigator.userAgentData.platform) {
|
|
6394
|
+
metrics._os = metrics._os || navigator.userAgentData.platform;
|
|
6395
|
+
}
|
|
6396
|
+
var detectedDeviceType = userAgentDeviceDetection();
|
|
6397
|
+
if (detectedDeviceType === "phone") {
|
|
6398
|
+
detectedDeviceType = "mobile";
|
|
6399
|
+
}
|
|
6400
|
+
metrics._device_type = metrics._device_type || detectedDeviceType;
|
|
6401
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this) && _typeof(_classPrivateFieldGet2(_uaClientHints, _this)) === "object") {
|
|
6402
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this).platform) {
|
|
6403
|
+
metrics._os = metrics._os || _classPrivateFieldGet2(_uaClientHints, _this).platform;
|
|
6404
|
+
}
|
|
6405
|
+
var osVersionFromHints = _classPrivateFieldGet2(_uaClientHints, _this).windowsVersion || _classPrivateFieldGet2(_uaClientHints, _this).platformVersion;
|
|
6406
|
+
if (osVersionFromHints) {
|
|
6407
|
+
metrics._os_version = metrics._os_version || osVersionFromHints;
|
|
6408
|
+
}
|
|
6409
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this).model) {
|
|
6410
|
+
metrics._device = metrics._device || _classPrivateFieldGet2(_uaClientHints, _this).model;
|
|
6411
|
+
}
|
|
6412
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this).browserName) {
|
|
6413
|
+
metrics._browser = metrics._browser || _classPrivateFieldGet2(_uaClientHints, _this).browserName;
|
|
6414
|
+
}
|
|
6415
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this).browserVersion) {
|
|
6416
|
+
metrics._browser_version = metrics._browser_version || _classPrivateFieldGet2(_uaClientHints, _this).browserVersion;
|
|
6417
|
+
}
|
|
6418
|
+
if (_classPrivateFieldGet2(_uaClientHints, _this).windowsVersion) {
|
|
6419
|
+
metrics._os = metrics._os || "Windows";
|
|
6420
|
+
metrics._os_version = metrics._os_version || _classPrivateFieldGet2(_uaClientHints, _this).windowsVersion;
|
|
6421
|
+
}
|
|
6422
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, metrics enriched from hints:[" + JSON.stringify({
|
|
6423
|
+
_os: metrics._os,
|
|
6424
|
+
_os_version: metrics._os_version,
|
|
6425
|
+
_device: metrics._device,
|
|
6426
|
+
_device_type: metrics._device_type,
|
|
6427
|
+
_browser: metrics._browser,
|
|
6428
|
+
_browser_version: metrics._browser_version
|
|
6429
|
+
}) + "]");
|
|
6430
|
+
} else {
|
|
6431
|
+
if (_classPrivateFieldGet2(_uaClientHintsStatus, _this) === "pending") {
|
|
6432
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, high-entropy hints are still pending, using fallback metrics for now");
|
|
6433
|
+
} else {
|
|
6434
|
+
_classPrivateFieldGet2(_log, _this).call(_this, logLevelEnums.DEBUG, "ua_logic, no high-entropy hints available, using UA fallback parsing");
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
if (!metrics._browser || !metrics._browser_version) {
|
|
6438
|
+
var browserInfo = _classPrivateFieldGet2(_getBrowserInfoFromUA, _this).call(_this, metrics._ua);
|
|
6439
|
+
metrics._browser = metrics._browser || browserInfo.name;
|
|
6440
|
+
metrics._browser_version = metrics._browser_version || browserInfo.version;
|
|
6441
|
+
}
|
|
6121
6442
|
if (_classPrivateFieldGet2(_isReferrerUsable, _this).call(_this)) {
|
|
6122
6443
|
metrics._store = metrics._store || document.referrer;
|
|
6123
6444
|
}
|
|
@@ -7332,6 +7653,12 @@
|
|
|
7332
7653
|
_classPrivateFieldSet2(_journeyTriggerPending, this, false);
|
|
7333
7654
|
_classPrivateFieldSet2(_journeyPendingEventIds, this, new Set());
|
|
7334
7655
|
_classPrivateFieldSet2(_fakeRequestHandler, this, getConfig("fake_request_handler", _ob, null));
|
|
7656
|
+
_classPrivateFieldSet2(_uaClientHints, this, null);
|
|
7657
|
+
_classPrivateFieldSet2(_uaClientHintsStatus, this, "not_started");
|
|
7658
|
+
_classPrivateFieldSet2(_clientHintsPromise, this, null);
|
|
7659
|
+
_classPrivateFieldSet2(_pendingRequestBuffer, this, null);
|
|
7660
|
+
_classPrivateFieldSet2(_clientHintsBufferTimeoutId, this, null);
|
|
7661
|
+
_classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, this, null);
|
|
7335
7662
|
this.app_key = getConfig("app_key", _ob, null);
|
|
7336
7663
|
this.url = stripTrailingSlash(getConfig("url", _ob, ""));
|
|
7337
7664
|
this.serialize = getConfig("serialize", _ob, Countly.serialize);
|
|
@@ -7359,6 +7686,7 @@
|
|
|
7359
7686
|
for (var it = 0; it < Countly.features.length; it++) {
|
|
7360
7687
|
_classPrivateFieldGet2(_consents, this)[Countly.features[it]] = {};
|
|
7361
7688
|
}
|
|
7689
|
+
_classPrivateFieldGet2(_initializeClientHints, this).call(this);
|
|
7362
7690
|
_classPrivateFieldGet2(_initialize, this).call(this, _ob);
|
|
7363
7691
|
|
|
7364
7692
|
// start SDK
|