cryptique-sdk 1.2.9 → 1.2.11
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/lib/cjs/index.js +71 -188
- package/lib/esm/index.js +71 -188
- package/lib/umd/index.js +71 -188
- package/package.json +1 -1
package/lib/esm/index.js
CHANGED
|
@@ -40,25 +40,17 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
40
40
|
// - Single place to change environment (dev/prod)
|
|
41
41
|
// ============================================================================
|
|
42
42
|
|
|
43
|
+
// Single SDK API base — change manually for local vs production.
|
|
44
|
+
const SDK_API_BASE = "https://sdkapi.cryptique.io";
|
|
45
|
+
|
|
43
46
|
const CONFIG = {
|
|
44
|
-
// API Endpoints
|
|
47
|
+
// API Endpoints — all SDK writes go to SDK_API_BASE.
|
|
45
48
|
API: {
|
|
46
|
-
TRACK: "
|
|
47
|
-
UTM_EVENTS: "
|
|
48
|
-
EVENTS: "
|
|
49
|
+
TRACK: SDK_API_BASE + "/api/sdk/track",
|
|
50
|
+
UTM_EVENTS: SDK_API_BASE + "/api/utm-events",
|
|
51
|
+
EVENTS: SDK_API_BASE + "/api/events"
|
|
49
52
|
},
|
|
50
53
|
|
|
51
|
-
// Development API (uncomment for local testing)
|
|
52
|
-
|
|
53
|
-
/*API: {
|
|
54
|
-
TRACK: "http://localhost:3002/api/sdk/track", // Main session tracking
|
|
55
|
-
UTM_EVENTS: "http://localhost:3002/api/utm-events", // UTM campaign tracking
|
|
56
|
-
EVENTS: "http://localhost:3002/api/events" // Comprehensive events API
|
|
57
|
-
},*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
54
|
|
|
63
55
|
// SDK Version
|
|
64
56
|
VERSION: "v0.11.24",
|
|
@@ -286,7 +278,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
286
278
|
|
|
287
279
|
return null;
|
|
288
280
|
} catch (err) {
|
|
289
|
-
console.warn('Failed to load session, clearing corrupted data:', err);
|
|
290
281
|
// Clean up corrupted data
|
|
291
282
|
try {
|
|
292
283
|
sessionStorage.removeItem(CONFIG.STORAGE_KEYS.SESSION);
|
|
@@ -314,15 +305,13 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
314
305
|
this.updateBackup(session);
|
|
315
306
|
}
|
|
316
307
|
} catch (err) {
|
|
317
|
-
console.warn('Failed to save session:', err);
|
|
318
308
|
// Try to save at least the backup
|
|
319
309
|
try {
|
|
320
310
|
if (session && session.id) {
|
|
321
311
|
this.updateBackup(session);
|
|
322
312
|
}
|
|
323
313
|
} catch (backupErr) {
|
|
324
|
-
|
|
325
|
-
}
|
|
314
|
+
}
|
|
326
315
|
}
|
|
327
316
|
},
|
|
328
317
|
|
|
@@ -586,7 +575,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
586
575
|
const result = await response.json();
|
|
587
576
|
return result;
|
|
588
577
|
} catch (error) {
|
|
589
|
-
console.error('Error calling migration endpoint:', error);
|
|
590
578
|
throw error;
|
|
591
579
|
}
|
|
592
580
|
},
|
|
@@ -643,18 +631,14 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
643
631
|
}
|
|
644
632
|
})
|
|
645
633
|
.catch((err) => {
|
|
646
|
-
console.warn('⚠️ Failed to migrate userId on backend:', err.message);
|
|
647
634
|
// UUID already stored in localStorage, migration can happen later
|
|
648
635
|
});
|
|
649
|
-
} else {
|
|
650
|
-
console.warn('⚠️ SITE_ID not available, cannot migrate on backend');
|
|
651
636
|
}
|
|
652
637
|
|
|
653
638
|
// Return new UUID immediately (already stored in localStorage)
|
|
654
639
|
userId = newUserId;
|
|
655
640
|
} else if (!uuidRegex.test(userId)) {
|
|
656
641
|
// Invalid format - regenerate
|
|
657
|
-
console.warn('⚠️ Invalid userId format detected. Regenerating as UUID v4...');
|
|
658
642
|
userId = this.generateUUIDv4();
|
|
659
643
|
localStorage.setItem(CONFIG.STORAGE_KEYS.USER_ID, userId);
|
|
660
644
|
}
|
|
@@ -663,7 +647,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
663
647
|
return userId;
|
|
664
648
|
} catch (err) {
|
|
665
649
|
// Fallback: generate temporary UUID (won't persist)
|
|
666
|
-
console.warn('Failed to access localStorage for userId:', err);
|
|
667
650
|
return this.generateUUIDv4(); // Still use UUID even for temp
|
|
668
651
|
}
|
|
669
652
|
},
|
|
@@ -830,8 +813,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
830
813
|
try {
|
|
831
814
|
localStorage.setItem(CONFIG.STORAGE_KEYS.CONSENT, consent ? "true" : "false");
|
|
832
815
|
} catch (err) {
|
|
833
|
-
|
|
834
|
-
}
|
|
816
|
+
}
|
|
835
817
|
},
|
|
836
818
|
|
|
837
819
|
/**
|
|
@@ -918,8 +900,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
918
900
|
try {
|
|
919
901
|
localStorage.setItem(CONFIG.STORAGE_KEYS.LAST_SESSION, JSON.stringify(sessionData));
|
|
920
902
|
} catch (err) {
|
|
921
|
-
|
|
922
|
-
}
|
|
903
|
+
}
|
|
923
904
|
},
|
|
924
905
|
|
|
925
906
|
/**
|
|
@@ -944,8 +925,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
944
925
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.LAST_SESSION);
|
|
945
926
|
// Note: We don't clear USER_ID or CONSENT as they're persistent preferences
|
|
946
927
|
} catch (err) {
|
|
947
|
-
|
|
948
|
-
}
|
|
928
|
+
}
|
|
949
929
|
},
|
|
950
930
|
|
|
951
931
|
/**
|
|
@@ -1332,7 +1312,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1332
1312
|
// Verify it was saved correctly
|
|
1333
1313
|
const verify = StorageManager.loadSession();
|
|
1334
1314
|
if (!verify || verify.id !== newSessionId) {
|
|
1335
|
-
console.error("⚠️ SessionStorage write verification failed! Session may not persist across page navigation.");
|
|
1336
1315
|
// Try to recover from localStorage backup
|
|
1337
1316
|
try {
|
|
1338
1317
|
const backup = localStorage.getItem(CONFIG.STORAGE_KEYS.SESSION_BACKUP);
|
|
@@ -1348,7 +1327,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1348
1327
|
|
|
1349
1328
|
return newSessionId;
|
|
1350
1329
|
} catch (error) {
|
|
1351
|
-
console.error("Error in getOrCreateSessionId:", error);
|
|
1352
1330
|
// Even on error, ensure we have a valid userId
|
|
1353
1331
|
sessionData.userId = StorageManager.getUserId();
|
|
1354
1332
|
userSession.userId = sessionData.userId;
|
|
@@ -1396,7 +1374,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1396
1374
|
|
|
1397
1375
|
// Ensure sessionId is never null/undefined
|
|
1398
1376
|
if (!sessionData.sessionId) {
|
|
1399
|
-
console.error("❌ sessionData.sessionId is null/undefined after initialization!");
|
|
1400
1377
|
// Try to get from storage first
|
|
1401
1378
|
const session = StorageManager.loadSession();
|
|
1402
1379
|
if (session && session.id) {
|
|
@@ -1408,7 +1385,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1408
1385
|
}
|
|
1409
1386
|
}
|
|
1410
1387
|
} catch (error) {
|
|
1411
|
-
console.error("Error initializing session data:", error);
|
|
1412
1388
|
// Try to get from storage first, then fallback
|
|
1413
1389
|
try {
|
|
1414
1390
|
const session = StorageManager.loadSession();
|
|
@@ -1596,8 +1572,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1596
1572
|
} else {
|
|
1597
1573
|
// No timestamp available - use minimum duration
|
|
1598
1574
|
calculatedDuration = 1; // Minimum 1 second
|
|
1599
|
-
|
|
1600
|
-
}
|
|
1575
|
+
}
|
|
1601
1576
|
}
|
|
1602
1577
|
|
|
1603
1578
|
// Ensure duration is not negative
|
|
@@ -1816,8 +1791,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1816
1791
|
resolve(locationData);
|
|
1817
1792
|
})
|
|
1818
1793
|
.catch((err) => {
|
|
1819
|
-
console.error("Primary geolocation error:", err);
|
|
1820
|
-
|
|
1821
1794
|
// Fall back to backup URL
|
|
1822
1795
|
fetch(CONFIG.GEOLOCATION.BACKUP_URL, fetchOptions)
|
|
1823
1796
|
.then((res) => {
|
|
@@ -1856,7 +1829,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1856
1829
|
resolve(locationData);
|
|
1857
1830
|
})
|
|
1858
1831
|
.catch((backupErr) => {
|
|
1859
|
-
console.error("Backup geolocation error:", backupErr);
|
|
1860
1832
|
// Set fallback values
|
|
1861
1833
|
this.storeLocationData(locationData);
|
|
1862
1834
|
resolve(locationData);
|
|
@@ -1923,7 +1895,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1923
1895
|
const locationData = await this.fetchLocationData();
|
|
1924
1896
|
return locationData.country;
|
|
1925
1897
|
} catch (err) {
|
|
1926
|
-
console.error("Error fetching country name:", err);
|
|
1927
1898
|
return "Unknown";
|
|
1928
1899
|
}
|
|
1929
1900
|
},
|
|
@@ -1978,7 +1949,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1978
1949
|
initialize() {
|
|
1979
1950
|
// Fetch location data in background (non-blocking)
|
|
1980
1951
|
this.fetchLocationData().catch((err) => {
|
|
1981
|
-
console.warn("Background location fetch failed:", err);
|
|
1982
1952
|
// Continue with default values
|
|
1983
1953
|
});
|
|
1984
1954
|
}
|
|
@@ -2738,8 +2708,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2738
2708
|
return `0x${chainId.toString(16)}`;
|
|
2739
2709
|
}
|
|
2740
2710
|
} catch (err) {
|
|
2741
|
-
|
|
2742
|
-
}
|
|
2711
|
+
}
|
|
2743
2712
|
|
|
2744
2713
|
return null;
|
|
2745
2714
|
},
|
|
@@ -2773,7 +2742,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2773
2742
|
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
2774
2743
|
return accounts && accounts.length > 0;
|
|
2775
2744
|
} catch (error) {
|
|
2776
|
-
console.warn('Error checking wallet connection:', error);
|
|
2777
2745
|
return false;
|
|
2778
2746
|
}
|
|
2779
2747
|
},
|
|
@@ -2792,7 +2760,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2792
2760
|
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
2793
2761
|
return accounts && accounts.length > 0 ? accounts[0] : null;
|
|
2794
2762
|
} catch (error) {
|
|
2795
|
-
console.warn('Error getting wallet address:', error);
|
|
2796
2763
|
return null;
|
|
2797
2764
|
}
|
|
2798
2765
|
},
|
|
@@ -2821,7 +2788,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2821
2788
|
try {
|
|
2822
2789
|
chainName = await this.detectChainName();
|
|
2823
2790
|
} catch (chainError) {
|
|
2824
|
-
console.warn('Error detecting chain name:', chainError);
|
|
2825
2791
|
chainName = "Unknown Chain";
|
|
2826
2792
|
}
|
|
2827
2793
|
}
|
|
@@ -2965,13 +2931,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2965
2931
|
retries: 1
|
|
2966
2932
|
});
|
|
2967
2933
|
} catch (error) {
|
|
2968
|
-
console.warn('Error sending wallet update:', error);
|
|
2969
2934
|
// Don't throw - wallet connection succeeded, just failed to send update
|
|
2970
2935
|
}
|
|
2971
2936
|
|
|
2972
2937
|
return accounts[0];
|
|
2973
2938
|
} catch (error) {
|
|
2974
|
-
console.error('Error connecting with selected provider:', error);
|
|
2975
2939
|
throw error;
|
|
2976
2940
|
}
|
|
2977
2941
|
},
|
|
@@ -3068,9 +3032,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3068
3032
|
return await this.connectWithProvider(selectedProvider);
|
|
3069
3033
|
} catch (error) {
|
|
3070
3034
|
// Only log if it's not a cancellation
|
|
3071
|
-
if (!error.message || !error.message.includes('cancelled'))
|
|
3072
|
-
console.error('Error connecting wallet:', error);
|
|
3073
|
-
}
|
|
3035
|
+
if (!error.message || !error.message.includes('cancelled')) ;
|
|
3074
3036
|
return null; // Return null instead of throwing
|
|
3075
3037
|
}
|
|
3076
3038
|
},
|
|
@@ -3102,8 +3064,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3102
3064
|
|
|
3103
3065
|
// Update UTM event with newly connected wallet
|
|
3104
3066
|
APIClient.updateUTMEventWithWallet().catch((error) => {
|
|
3105
|
-
|
|
3106
|
-
});
|
|
3067
|
+
});
|
|
3107
3068
|
} catch (error) {
|
|
3108
3069
|
// Only log actual errors (not user cancellations or missing wallets)
|
|
3109
3070
|
if (error && error.message && !error.message.includes('No wallet provider found')) {
|
|
@@ -3186,8 +3147,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3186
3147
|
async initialize() {
|
|
3187
3148
|
// Initial wallet detection (non-blocking)
|
|
3188
3149
|
this.updateWalletInfo().catch((err) => {
|
|
3189
|
-
|
|
3190
|
-
});
|
|
3150
|
+
});
|
|
3191
3151
|
|
|
3192
3152
|
// Setup event listeners
|
|
3193
3153
|
this.setupEventListeners();
|
|
@@ -3312,7 +3272,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3312
3272
|
|
|
3313
3273
|
// Validate category
|
|
3314
3274
|
if (!this.CATEGORIES.includes(category)) {
|
|
3315
|
-
console.warn(`Invalid interaction category: ${category}`);
|
|
3316
3275
|
return;
|
|
3317
3276
|
}
|
|
3318
3277
|
|
|
@@ -3367,8 +3326,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3367
3326
|
StorageManager.saveSession(storedSession);
|
|
3368
3327
|
}
|
|
3369
3328
|
} catch (error) {
|
|
3370
|
-
|
|
3371
|
-
}
|
|
3329
|
+
}
|
|
3372
3330
|
},
|
|
3373
3331
|
|
|
3374
3332
|
/**
|
|
@@ -3502,7 +3460,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3502
3460
|
}
|
|
3503
3461
|
|
|
3504
3462
|
if (!this.CATEGORIES.includes(category)) {
|
|
3505
|
-
console.warn(`Invalid interaction category: ${category}`);
|
|
3506
3463
|
return [];
|
|
3507
3464
|
}
|
|
3508
3465
|
|
|
@@ -3793,8 +3750,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3793
3750
|
// Save updated session
|
|
3794
3751
|
StorageManager.saveSession(session);
|
|
3795
3752
|
} catch (error) {
|
|
3796
|
-
|
|
3797
|
-
}
|
|
3753
|
+
}
|
|
3798
3754
|
},
|
|
3799
3755
|
|
|
3800
3756
|
/**
|
|
@@ -3807,7 +3763,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3807
3763
|
try {
|
|
3808
3764
|
const session = StorageManager.loadSession();
|
|
3809
3765
|
if (!session || !session.sessionData || !session.sessionData.pageVisits) {
|
|
3810
|
-
console.warn('trackBrowserClose: No session data found');
|
|
3811
3766
|
return;
|
|
3812
3767
|
}
|
|
3813
3768
|
|
|
@@ -3849,11 +3804,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3849
3804
|
// Save updated session
|
|
3850
3805
|
StorageManager.saveSession(session);
|
|
3851
3806
|
} else {
|
|
3852
|
-
|
|
3853
|
-
}
|
|
3807
|
+
}
|
|
3854
3808
|
} catch (error) {
|
|
3855
|
-
|
|
3856
|
-
}
|
|
3809
|
+
}
|
|
3857
3810
|
},
|
|
3858
3811
|
|
|
3859
3812
|
/**
|
|
@@ -4333,8 +4286,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4333
4286
|
return referrerHostname;
|
|
4334
4287
|
}
|
|
4335
4288
|
} catch (error) {
|
|
4336
|
-
|
|
4337
|
-
}
|
|
4289
|
+
}
|
|
4338
4290
|
}
|
|
4339
4291
|
|
|
4340
4292
|
// Step 3: Default to direct traffic
|
|
@@ -4392,11 +4344,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4392
4344
|
if (success) {
|
|
4393
4345
|
return Promise.resolve();
|
|
4394
4346
|
} else {
|
|
4395
|
-
|
|
4396
|
-
}
|
|
4347
|
+
}
|
|
4397
4348
|
} catch (error) {
|
|
4398
|
-
|
|
4399
|
-
}
|
|
4349
|
+
}
|
|
4400
4350
|
}
|
|
4401
4351
|
|
|
4402
4352
|
// Use fetch for regular sends or as fallback
|
|
@@ -4437,32 +4387,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4437
4387
|
|
|
4438
4388
|
if (!response.ok) {
|
|
4439
4389
|
// Log detailed error information
|
|
4440
|
-
console.error(`❌ API Error (${response.status} ${response.statusText}):`, {
|
|
4441
|
-
endpoint: endpoint,
|
|
4442
|
-
status: response.status,
|
|
4443
|
-
statusText: response.statusText,
|
|
4444
|
-
errorResponse: responseData
|
|
4445
|
-
});
|
|
4446
|
-
|
|
4447
4390
|
// Log specific error reasons
|
|
4448
4391
|
if (response.status === 400) {
|
|
4449
|
-
console.error('❌ REASON: Bad Request - Validation error');
|
|
4450
4392
|
if (responseData && responseData.error) {
|
|
4451
|
-
|
|
4452
|
-
}
|
|
4393
|
+
}
|
|
4453
4394
|
if (responseData && responseData.details) {
|
|
4454
|
-
|
|
4455
|
-
}
|
|
4395
|
+
}
|
|
4456
4396
|
if (responseData && responseData.message) {
|
|
4457
|
-
|
|
4458
|
-
}
|
|
4397
|
+
}
|
|
4459
4398
|
// Log the payload that failed (for debugging)
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
} else if (response.status === 500) {
|
|
4464
|
-
console.error('❌ REASON: Server Error - Check backend logs for details');
|
|
4465
|
-
}
|
|
4399
|
+
} else if (response.status === 404) {
|
|
4400
|
+
} else if (response.status === 500) {
|
|
4401
|
+
}
|
|
4466
4402
|
|
|
4467
4403
|
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(responseData)}`);
|
|
4468
4404
|
}
|
|
@@ -4540,8 +4476,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4540
4476
|
timeout: 15000
|
|
4541
4477
|
});
|
|
4542
4478
|
} catch (error) {
|
|
4543
|
-
|
|
4544
|
-
}
|
|
4479
|
+
}
|
|
4545
4480
|
},
|
|
4546
4481
|
|
|
4547
4482
|
|
|
@@ -4587,8 +4522,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4587
4522
|
retries: 1
|
|
4588
4523
|
});
|
|
4589
4524
|
} catch (error) {
|
|
4590
|
-
|
|
4591
|
-
}
|
|
4525
|
+
}
|
|
4592
4526
|
},
|
|
4593
4527
|
|
|
4594
4528
|
/**
|
|
@@ -4698,8 +4632,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4698
4632
|
}
|
|
4699
4633
|
});
|
|
4700
4634
|
} catch (error) {
|
|
4701
|
-
|
|
4702
|
-
}
|
|
4635
|
+
}
|
|
4703
4636
|
},
|
|
4704
4637
|
|
|
4705
4638
|
/**
|
|
@@ -4799,8 +4732,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4799
4732
|
}
|
|
4800
4733
|
}, true);
|
|
4801
4734
|
} catch (error) {
|
|
4802
|
-
|
|
4803
|
-
}
|
|
4735
|
+
}
|
|
4804
4736
|
},
|
|
4805
4737
|
|
|
4806
4738
|
/**
|
|
@@ -4869,8 +4801,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4869
4801
|
}
|
|
4870
4802
|
});
|
|
4871
4803
|
} catch (error) {
|
|
4872
|
-
|
|
4873
|
-
}
|
|
4804
|
+
}
|
|
4874
4805
|
},
|
|
4875
4806
|
|
|
4876
4807
|
/**
|
|
@@ -4907,8 +4838,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4907
4838
|
}, 150); // Debounce scroll events
|
|
4908
4839
|
});
|
|
4909
4840
|
} catch (error) {
|
|
4910
|
-
|
|
4911
|
-
}
|
|
4841
|
+
}
|
|
4912
4842
|
},
|
|
4913
4843
|
|
|
4914
4844
|
/**
|
|
@@ -4977,8 +4907,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4977
4907
|
}
|
|
4978
4908
|
});
|
|
4979
4909
|
} catch (error) {
|
|
4980
|
-
|
|
4981
|
-
}
|
|
4910
|
+
}
|
|
4982
4911
|
},
|
|
4983
4912
|
|
|
4984
4913
|
/**
|
|
@@ -5017,8 +4946,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5017
4946
|
}
|
|
5018
4947
|
});
|
|
5019
4948
|
} catch (error) {
|
|
5020
|
-
|
|
5021
|
-
}
|
|
4949
|
+
}
|
|
5022
4950
|
},
|
|
5023
4951
|
|
|
5024
4952
|
/**
|
|
@@ -5053,8 +4981,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5053
4981
|
InteractionManager.add('copyPasteEvents', pasteData);
|
|
5054
4982
|
});
|
|
5055
4983
|
} catch (error) {
|
|
5056
|
-
|
|
5057
|
-
}
|
|
4984
|
+
}
|
|
5058
4985
|
},
|
|
5059
4986
|
|
|
5060
4987
|
/**
|
|
@@ -5080,8 +5007,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5080
5007
|
InteractionManager.add('contextMenuEvents', contextData);
|
|
5081
5008
|
});
|
|
5082
5009
|
} catch (error) {
|
|
5083
|
-
|
|
5084
|
-
}
|
|
5010
|
+
}
|
|
5085
5011
|
},
|
|
5086
5012
|
|
|
5087
5013
|
/**
|
|
@@ -5125,8 +5051,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5125
5051
|
InteractionManager.add('dragDropEvents', dropData);
|
|
5126
5052
|
});
|
|
5127
5053
|
} catch (error) {
|
|
5128
|
-
|
|
5129
|
-
}
|
|
5054
|
+
}
|
|
5130
5055
|
},
|
|
5131
5056
|
|
|
5132
5057
|
/**
|
|
@@ -5173,8 +5098,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5173
5098
|
InteractionManager.add('touchEvents', touchData);
|
|
5174
5099
|
});
|
|
5175
5100
|
} catch (error) {
|
|
5176
|
-
|
|
5177
|
-
}
|
|
5101
|
+
}
|
|
5178
5102
|
},
|
|
5179
5103
|
|
|
5180
5104
|
/**
|
|
@@ -5251,8 +5175,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5251
5175
|
InteractionManager.add('windowEvents', blurData);
|
|
5252
5176
|
});
|
|
5253
5177
|
} catch (error) {
|
|
5254
|
-
|
|
5255
|
-
}
|
|
5178
|
+
}
|
|
5256
5179
|
},
|
|
5257
5180
|
|
|
5258
5181
|
/**
|
|
@@ -5279,8 +5202,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5279
5202
|
}, 1000);
|
|
5280
5203
|
});
|
|
5281
5204
|
} catch (error) {
|
|
5282
|
-
|
|
5283
|
-
}
|
|
5205
|
+
}
|
|
5284
5206
|
},
|
|
5285
5207
|
|
|
5286
5208
|
/**
|
|
@@ -5321,8 +5243,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5321
5243
|
InteractionManager.add('errorEvents', errorData);
|
|
5322
5244
|
});
|
|
5323
5245
|
} catch (error) {
|
|
5324
|
-
|
|
5325
|
-
}
|
|
5246
|
+
}
|
|
5326
5247
|
},
|
|
5327
5248
|
|
|
5328
5249
|
/**
|
|
@@ -5331,8 +5252,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5331
5252
|
* NOTE:
|
|
5332
5253
|
* We intentionally do NOT wrap window.fetch here, to avoid confusing
|
|
5333
5254
|
* browser DevTools attribution for third‑party requests. All SDK
|
|
5334
|
-
* fetch-based calls to backend.cryptique.io are already
|
|
5335
|
-
* inside APIClient.send(), so fetch wrapping is redundant.
|
|
5255
|
+
* fetch-based calls to the SDK API backend (sdkapi.cryptique.io) are already
|
|
5256
|
+
* error-handled inside APIClient.send(), so fetch wrapping is redundant.
|
|
5336
5257
|
*/
|
|
5337
5258
|
startNetworkTracking() {
|
|
5338
5259
|
try {
|
|
@@ -5351,7 +5272,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5351
5272
|
const xhr = this;
|
|
5352
5273
|
|
|
5353
5274
|
// Pass third-party XHR requests through completely untouched
|
|
5354
|
-
if (!xhr._cryptiqueUrl || !xhr._cryptiqueUrl.includes('
|
|
5275
|
+
if (!xhr._cryptiqueUrl || !xhr._cryptiqueUrl.includes('sdkapi.cryptique.io')) {
|
|
5355
5276
|
return originalXHRSend.apply(this, args);
|
|
5356
5277
|
}
|
|
5357
5278
|
|
|
@@ -5388,8 +5309,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5388
5309
|
return originalXHRSend.apply(this, args);
|
|
5389
5310
|
};
|
|
5390
5311
|
} catch (error) {
|
|
5391
|
-
|
|
5392
|
-
}
|
|
5312
|
+
}
|
|
5393
5313
|
},
|
|
5394
5314
|
|
|
5395
5315
|
/**
|
|
@@ -5427,8 +5347,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5427
5347
|
}
|
|
5428
5348
|
});
|
|
5429
5349
|
} catch (error) {
|
|
5430
|
-
|
|
5431
|
-
}
|
|
5350
|
+
}
|
|
5432
5351
|
},
|
|
5433
5352
|
|
|
5434
5353
|
/**
|
|
@@ -5504,8 +5423,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5504
5423
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.LAST_SESSION);
|
|
5505
5424
|
}
|
|
5506
5425
|
} catch (error) {
|
|
5507
|
-
|
|
5508
|
-
}
|
|
5426
|
+
}
|
|
5509
5427
|
},
|
|
5510
5428
|
|
|
5511
5429
|
/**
|
|
@@ -5530,8 +5448,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5530
5448
|
// Initialize page visits
|
|
5531
5449
|
PageVisitManager.initialize();
|
|
5532
5450
|
} catch (error) {
|
|
5533
|
-
|
|
5534
|
-
}
|
|
5451
|
+
}
|
|
5535
5452
|
},
|
|
5536
5453
|
|
|
5537
5454
|
/**
|
|
@@ -5543,11 +5460,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5543
5460
|
try {
|
|
5544
5461
|
// Start location fetch (non-blocking)
|
|
5545
5462
|
LocationManager.getLocationData().catch(error => {
|
|
5546
|
-
|
|
5547
|
-
});
|
|
5463
|
+
});
|
|
5548
5464
|
} catch (error) {
|
|
5549
|
-
|
|
5550
|
-
}
|
|
5465
|
+
}
|
|
5551
5466
|
},
|
|
5552
5467
|
|
|
5553
5468
|
/**
|
|
@@ -5558,8 +5473,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5558
5473
|
// FIX: Call initialize() which both detects AND stores the data
|
|
5559
5474
|
await BrowserDeviceManager.initialize();
|
|
5560
5475
|
} catch (error) {
|
|
5561
|
-
|
|
5562
|
-
}
|
|
5476
|
+
}
|
|
5563
5477
|
},
|
|
5564
5478
|
|
|
5565
5479
|
/**
|
|
@@ -5569,8 +5483,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5569
5483
|
try {
|
|
5570
5484
|
UTMManager.initialize();
|
|
5571
5485
|
} catch (error) {
|
|
5572
|
-
|
|
5573
|
-
}
|
|
5486
|
+
}
|
|
5574
5487
|
},
|
|
5575
5488
|
|
|
5576
5489
|
/**
|
|
@@ -5580,8 +5493,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5580
5493
|
try {
|
|
5581
5494
|
WalletManager.initialize();
|
|
5582
5495
|
} catch (error) {
|
|
5583
|
-
|
|
5584
|
-
}
|
|
5496
|
+
}
|
|
5585
5497
|
},
|
|
5586
5498
|
|
|
5587
5499
|
/**
|
|
@@ -5591,8 +5503,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5591
5503
|
try {
|
|
5592
5504
|
PageVisitManager.track();
|
|
5593
5505
|
} catch (error) {
|
|
5594
|
-
|
|
5595
|
-
}
|
|
5506
|
+
}
|
|
5596
5507
|
},
|
|
5597
5508
|
|
|
5598
5509
|
/**
|
|
@@ -5678,12 +5589,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5678
5589
|
// Send session data
|
|
5679
5590
|
await APIClient.sendSessionData();
|
|
5680
5591
|
} catch (error) {
|
|
5681
|
-
|
|
5682
|
-
}
|
|
5592
|
+
}
|
|
5683
5593
|
}, CONFIG.INTERVALS.SESSION_TRACKING_MS);
|
|
5684
5594
|
} catch (error) {
|
|
5685
|
-
|
|
5686
|
-
}
|
|
5595
|
+
}
|
|
5687
5596
|
},
|
|
5688
5597
|
|
|
5689
5598
|
/**
|
|
@@ -5769,8 +5678,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5769
5678
|
JSON.stringify(transformedData)
|
|
5770
5679
|
);
|
|
5771
5680
|
} catch (storageError) {
|
|
5772
|
-
|
|
5773
|
-
}
|
|
5681
|
+
}
|
|
5774
5682
|
});
|
|
5775
5683
|
|
|
5776
5684
|
// Clear tracking interval
|
|
@@ -5779,12 +5687,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5779
5687
|
runtimeState.timer = null;
|
|
5780
5688
|
}
|
|
5781
5689
|
} catch (error) {
|
|
5782
|
-
|
|
5783
|
-
}
|
|
5690
|
+
}
|
|
5784
5691
|
});
|
|
5785
5692
|
} catch (error) {
|
|
5786
|
-
|
|
5787
|
-
}
|
|
5693
|
+
}
|
|
5788
5694
|
},
|
|
5789
5695
|
|
|
5790
5696
|
/**
|
|
@@ -5803,11 +5709,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5803
5709
|
// Send UTM event if UTM parameters are present (non-blocking)
|
|
5804
5710
|
// This should happen after session data is sent so we have sessionId and userId
|
|
5805
5711
|
APIClient.sendUTMEvent().catch((error) => {
|
|
5806
|
-
|
|
5807
|
-
});
|
|
5712
|
+
});
|
|
5808
5713
|
} catch (error) {
|
|
5809
|
-
|
|
5810
|
-
}
|
|
5714
|
+
}
|
|
5811
5715
|
},
|
|
5812
5716
|
|
|
5813
5717
|
/**
|
|
@@ -5819,7 +5723,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5819
5723
|
try {
|
|
5820
5724
|
// Check for sessionStorage availability
|
|
5821
5725
|
if (!window.sessionStorage) {
|
|
5822
|
-
console.error('SessionStorage is not available in this browser');
|
|
5823
5726
|
return;
|
|
5824
5727
|
}
|
|
5825
5728
|
|
|
@@ -5901,8 +5804,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5901
5804
|
}
|
|
5902
5805
|
}
|
|
5903
5806
|
} catch (error) {
|
|
5904
|
-
|
|
5905
|
-
}
|
|
5807
|
+
}
|
|
5906
5808
|
}
|
|
5907
5809
|
|
|
5908
5810
|
/**
|
|
@@ -5927,8 +5829,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5927
5829
|
try {
|
|
5928
5830
|
await WalletManager.updateWalletInfo();
|
|
5929
5831
|
} catch (walletError) {
|
|
5930
|
-
|
|
5931
|
-
}
|
|
5832
|
+
}
|
|
5932
5833
|
|
|
5933
5834
|
// Update session data from storage
|
|
5934
5835
|
const storedSession = StorageManager.loadSession();
|
|
@@ -5957,8 +5858,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5957
5858
|
// This function is primarily for internal SDK events
|
|
5958
5859
|
// Custom events should use trackEvent instead
|
|
5959
5860
|
} catch (error) {
|
|
5960
|
-
|
|
5961
|
-
}
|
|
5861
|
+
}
|
|
5962
5862
|
}
|
|
5963
5863
|
|
|
5964
5864
|
// ============================================================================
|
|
@@ -5979,14 +5879,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5979
5879
|
async trackEvent(eventName, properties = {}, options = {}) {
|
|
5980
5880
|
try {
|
|
5981
5881
|
if (!runtimeState.isInitialized) {
|
|
5982
|
-
console.warn('⚠️ [Events] SDK not initialized, queuing event:', eventName);
|
|
5983
5882
|
return;
|
|
5984
5883
|
}
|
|
5985
5884
|
|
|
5986
5885
|
// Get session from storage - it returns { id, userId, ... }
|
|
5987
5886
|
const storedSession = StorageManager.loadSession();
|
|
5988
5887
|
if (!storedSession || !storedSession.id) {
|
|
5989
|
-
console.error('❌ [Events] No session ID available for custom event tracking');
|
|
5990
5888
|
return;
|
|
5991
5889
|
}
|
|
5992
5890
|
|
|
@@ -5995,7 +5893,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5995
5893
|
const sessionId = storedSession.id || sessionData.sessionId || sessionData.session_id;
|
|
5996
5894
|
|
|
5997
5895
|
if (!sessionId) {
|
|
5998
|
-
console.error('❌ [Events] Session ID is missing');
|
|
5999
5896
|
return;
|
|
6000
5897
|
}
|
|
6001
5898
|
|
|
@@ -6125,8 +6022,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6125
6022
|
// Get session from storage - it returns { id, userId, ... }
|
|
6126
6023
|
const storedSession = StorageManager.loadSession();
|
|
6127
6024
|
if (!storedSession || !storedSession.id) {
|
|
6128
|
-
console.error('❌ [Events] No session ID available for auto event tracking');
|
|
6129
|
-
console.error('❌ [Events] Stored session:', storedSession);
|
|
6130
6025
|
return;
|
|
6131
6026
|
}
|
|
6132
6027
|
|
|
@@ -6135,7 +6030,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6135
6030
|
const sessionId = storedSession.id || sessionData.sessionId || sessionData.session_id;
|
|
6136
6031
|
|
|
6137
6032
|
if (!sessionId) {
|
|
6138
|
-
console.error('❌ [Events] Session ID is missing');
|
|
6139
6033
|
return;
|
|
6140
6034
|
}
|
|
6141
6035
|
|
|
@@ -6208,11 +6102,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6208
6102
|
|
|
6209
6103
|
if (!response.ok) {
|
|
6210
6104
|
const errorData = await response.text();
|
|
6211
|
-
console.error('❌ [Events SDK] API error:', {
|
|
6212
|
-
status: response.status,
|
|
6213
|
-
statusText: response.statusText,
|
|
6214
|
-
error: errorData
|
|
6215
|
-
});
|
|
6216
6105
|
throw new Error(`Events API error: ${response.status} ${response.statusText} - ${errorData}`);
|
|
6217
6106
|
}
|
|
6218
6107
|
|
|
@@ -6220,7 +6109,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6220
6109
|
return result;
|
|
6221
6110
|
|
|
6222
6111
|
} catch (error) {
|
|
6223
|
-
console.error('❌ [Events SDK] Error sending event to API:', error);
|
|
6224
6112
|
throw error;
|
|
6225
6113
|
}
|
|
6226
6114
|
},
|
|
@@ -6746,8 +6634,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6746
6634
|
page_load_time: performance.now(),
|
|
6747
6635
|
scroll_position: 0
|
|
6748
6636
|
}).catch(err => {
|
|
6749
|
-
|
|
6750
|
-
});
|
|
6637
|
+
});
|
|
6751
6638
|
}, 1000); // Wait 1 second for session to be created
|
|
6752
6639
|
},
|
|
6753
6640
|
|
|
@@ -6870,8 +6757,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6870
6757
|
element_area: element.offsetWidth * element.offsetHeight,
|
|
6871
6758
|
element_category: elementCategory
|
|
6872
6759
|
}, elementData).catch(err => {
|
|
6873
|
-
|
|
6874
|
-
});
|
|
6760
|
+
});
|
|
6875
6761
|
}
|
|
6876
6762
|
} else {
|
|
6877
6763
|
clickCount = 1;
|
|
@@ -6956,8 +6842,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6956
6842
|
double_click: event.detail === 2,
|
|
6957
6843
|
element_category: elementCategory
|
|
6958
6844
|
}, elementData).catch(err => {
|
|
6959
|
-
|
|
6960
|
-
});
|
|
6845
|
+
});
|
|
6961
6846
|
|
|
6962
6847
|
lastClickTime = now;
|
|
6963
6848
|
lastClickElement = element;
|
|
@@ -6994,8 +6879,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6994
6879
|
document_height: docHeight,
|
|
6995
6880
|
document_width: docWidth
|
|
6996
6881
|
}).catch(err => {
|
|
6997
|
-
|
|
6998
|
-
});
|
|
6882
|
+
});
|
|
6999
6883
|
}
|
|
7000
6884
|
}, 250);
|
|
7001
6885
|
});
|
|
@@ -8020,7 +7904,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
8020
7904
|
* The script.js file is inlined during the build process by Rollup.
|
|
8021
7905
|
*/
|
|
8022
7906
|
|
|
8023
|
-
|
|
8024
7907
|
// Create a wrapper that provides programmatic initialization
|
|
8025
7908
|
const CryptiqueSDK = {
|
|
8026
7909
|
/**
|