@reservamos/browser-analytics 1.1.6 → 1.1.7-alpha.0
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/README.md +23 -10
- package/dist/browser-analytics.cjs +3 -3
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.esm.js +14 -8
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +3 -3
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +14 -12
- package/src/services/fingerprint.test.ts +147 -0
- package/src/services/fingerprint.ts +17 -13
|
@@ -4497,6 +4497,7 @@ class FpjsClient {
|
|
|
4497
4497
|
const DEFAULT_CACHE_NAME = "default_fingerprint_cache";
|
|
4498
4498
|
const DEFAULT_CACHE_TIME_IN_DAYS = 7;
|
|
4499
4499
|
const PROXY_QUERY_PARAM = "apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>";
|
|
4500
|
+
let fingerprintAgentReady = false;
|
|
4500
4501
|
const getExpirationDate = (cacheTimeInDays) => {
|
|
4501
4502
|
const currentDate = /* @__PURE__ */ new Date();
|
|
4502
4503
|
const futureDate = new Date(
|
|
@@ -4538,17 +4539,25 @@ async function initFingerprint(apiKey, proxyUrl) {
|
|
|
4538
4539
|
customEndpointArray.unshift(proxyUrl);
|
|
4539
4540
|
customScriptEndpointArray.unshift(buildProxyUrl(proxyUrl));
|
|
4540
4541
|
}
|
|
4542
|
+
fingerprintAgentReady = false;
|
|
4541
4543
|
window.fingerprintConfig = {};
|
|
4542
|
-
|
|
4544
|
+
const client = new FpjsClient({
|
|
4543
4545
|
loadOptions: {
|
|
4544
4546
|
apiKey,
|
|
4545
4547
|
endpoint: customEndpointArray,
|
|
4546
4548
|
scriptUrlPattern: customScriptEndpointArray
|
|
4547
4549
|
}
|
|
4548
4550
|
});
|
|
4551
|
+
window.fpClient = client;
|
|
4549
4552
|
try {
|
|
4550
|
-
await
|
|
4553
|
+
await client.init();
|
|
4554
|
+
if (window.fpClient === client) {
|
|
4555
|
+
fingerprintAgentReady = true;
|
|
4556
|
+
}
|
|
4551
4557
|
} catch (error) {
|
|
4558
|
+
if (window.fpClient === client) {
|
|
4559
|
+
fingerprintAgentReady = false;
|
|
4560
|
+
}
|
|
4552
4561
|
console.error("Error initializing identification service:", error);
|
|
4553
4562
|
throw error;
|
|
4554
4563
|
}
|
|
@@ -4564,12 +4573,9 @@ async function getFingerprint(cacheOnly = false) {
|
|
|
4564
4573
|
if (cachedFingerprint) {
|
|
4565
4574
|
return cachedFingerprint;
|
|
4566
4575
|
}
|
|
4567
|
-
if (cacheOnly) {
|
|
4576
|
+
if (cacheOnly || !isFingerprintReady()) {
|
|
4568
4577
|
return "";
|
|
4569
4578
|
}
|
|
4570
|
-
if (!isFingerprintReady()) {
|
|
4571
|
-
throw new Error("Identification service is not initialized.");
|
|
4572
|
-
}
|
|
4573
4579
|
try {
|
|
4574
4580
|
const fpClient = window.fpClient;
|
|
4575
4581
|
const { visitorId: fingerprint } = await fpClient.getVisitorData();
|
|
@@ -4581,7 +4587,7 @@ async function getFingerprint(cacheOnly = false) {
|
|
|
4581
4587
|
}
|
|
4582
4588
|
}
|
|
4583
4589
|
function isFingerprintReady() {
|
|
4584
|
-
return window.fpClient !== void 0;
|
|
4590
|
+
return window.fpClient !== void 0 && fingerprintAgentReady;
|
|
4585
4591
|
}
|
|
4586
4592
|
const fingerprintService = {
|
|
4587
4593
|
initFingerprint,
|
|
@@ -13407,7 +13413,7 @@ function loadNoop(_src, onload) {
|
|
|
13407
13413
|
onload();
|
|
13408
13414
|
}
|
|
13409
13415
|
var mixpanel = init_as_module(loadNoop);
|
|
13410
|
-
const version = "1.1.
|
|
13416
|
+
const version = "1.1.7-alpha.0";
|
|
13411
13417
|
const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
|
|
13412
13418
|
const EVENT_SOURCE_SUPER_PROPERTY = {
|
|
13413
13419
|
"Event Source": "sdk"
|