cryptique-sdk 1.2.9 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +68 -185
- package/lib/esm/index.js +68 -185
- package/lib/umd/index.js +68 -185
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -42,25 +42,17 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
42
42
|
// - Single place to change environment (dev/prod)
|
|
43
43
|
// ============================================================================
|
|
44
44
|
|
|
45
|
+
// Single SDK API base — change manually for local vs production.
|
|
46
|
+
const SDK_API_BASE = "https://sdkapi.cryptique.io";
|
|
47
|
+
|
|
45
48
|
const CONFIG = {
|
|
46
|
-
// API Endpoints
|
|
49
|
+
// API Endpoints — all SDK writes go to SDK_API_BASE.
|
|
47
50
|
API: {
|
|
48
|
-
TRACK: "
|
|
49
|
-
UTM_EVENTS: "
|
|
50
|
-
EVENTS: "
|
|
51
|
+
TRACK: SDK_API_BASE + "/api/sdk/track",
|
|
52
|
+
UTM_EVENTS: SDK_API_BASE + "/api/utm-events",
|
|
53
|
+
EVENTS: SDK_API_BASE + "/api/events"
|
|
51
54
|
},
|
|
52
55
|
|
|
53
|
-
// Development API (uncomment for local testing)
|
|
54
|
-
|
|
55
|
-
/*API: {
|
|
56
|
-
TRACK: "http://localhost:3002/api/sdk/track", // Main session tracking
|
|
57
|
-
UTM_EVENTS: "http://localhost:3002/api/utm-events", // UTM campaign tracking
|
|
58
|
-
EVENTS: "http://localhost:3002/api/events" // Comprehensive events API
|
|
59
|
-
},*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
56
|
|
|
65
57
|
// SDK Version
|
|
66
58
|
VERSION: "v0.11.24",
|
|
@@ -288,7 +280,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
288
280
|
|
|
289
281
|
return null;
|
|
290
282
|
} catch (err) {
|
|
291
|
-
console.warn('Failed to load session, clearing corrupted data:', err);
|
|
292
283
|
// Clean up corrupted data
|
|
293
284
|
try {
|
|
294
285
|
sessionStorage.removeItem(CONFIG.STORAGE_KEYS.SESSION);
|
|
@@ -316,15 +307,13 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
316
307
|
this.updateBackup(session);
|
|
317
308
|
}
|
|
318
309
|
} catch (err) {
|
|
319
|
-
console.warn('Failed to save session:', err);
|
|
320
310
|
// Try to save at least the backup
|
|
321
311
|
try {
|
|
322
312
|
if (session && session.id) {
|
|
323
313
|
this.updateBackup(session);
|
|
324
314
|
}
|
|
325
315
|
} catch (backupErr) {
|
|
326
|
-
|
|
327
|
-
}
|
|
316
|
+
}
|
|
328
317
|
}
|
|
329
318
|
},
|
|
330
319
|
|
|
@@ -588,7 +577,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
588
577
|
const result = await response.json();
|
|
589
578
|
return result;
|
|
590
579
|
} catch (error) {
|
|
591
|
-
console.error('Error calling migration endpoint:', error);
|
|
592
580
|
throw error;
|
|
593
581
|
}
|
|
594
582
|
},
|
|
@@ -645,18 +633,14 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
645
633
|
}
|
|
646
634
|
})
|
|
647
635
|
.catch((err) => {
|
|
648
|
-
console.warn('⚠️ Failed to migrate userId on backend:', err.message);
|
|
649
636
|
// UUID already stored in localStorage, migration can happen later
|
|
650
637
|
});
|
|
651
|
-
} else {
|
|
652
|
-
console.warn('⚠️ SITE_ID not available, cannot migrate on backend');
|
|
653
638
|
}
|
|
654
639
|
|
|
655
640
|
// Return new UUID immediately (already stored in localStorage)
|
|
656
641
|
userId = newUserId;
|
|
657
642
|
} else if (!uuidRegex.test(userId)) {
|
|
658
643
|
// Invalid format - regenerate
|
|
659
|
-
console.warn('⚠️ Invalid userId format detected. Regenerating as UUID v4...');
|
|
660
644
|
userId = this.generateUUIDv4();
|
|
661
645
|
localStorage.setItem(CONFIG.STORAGE_KEYS.USER_ID, userId);
|
|
662
646
|
}
|
|
@@ -665,7 +649,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
665
649
|
return userId;
|
|
666
650
|
} catch (err) {
|
|
667
651
|
// Fallback: generate temporary UUID (won't persist)
|
|
668
|
-
console.warn('Failed to access localStorage for userId:', err);
|
|
669
652
|
return this.generateUUIDv4(); // Still use UUID even for temp
|
|
670
653
|
}
|
|
671
654
|
},
|
|
@@ -832,8 +815,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
832
815
|
try {
|
|
833
816
|
localStorage.setItem(CONFIG.STORAGE_KEYS.CONSENT, consent ? "true" : "false");
|
|
834
817
|
} catch (err) {
|
|
835
|
-
|
|
836
|
-
}
|
|
818
|
+
}
|
|
837
819
|
},
|
|
838
820
|
|
|
839
821
|
/**
|
|
@@ -920,8 +902,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
920
902
|
try {
|
|
921
903
|
localStorage.setItem(CONFIG.STORAGE_KEYS.LAST_SESSION, JSON.stringify(sessionData));
|
|
922
904
|
} catch (err) {
|
|
923
|
-
|
|
924
|
-
}
|
|
905
|
+
}
|
|
925
906
|
},
|
|
926
907
|
|
|
927
908
|
/**
|
|
@@ -946,8 +927,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
946
927
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.LAST_SESSION);
|
|
947
928
|
// Note: We don't clear USER_ID or CONSENT as they're persistent preferences
|
|
948
929
|
} catch (err) {
|
|
949
|
-
|
|
950
|
-
}
|
|
930
|
+
}
|
|
951
931
|
},
|
|
952
932
|
|
|
953
933
|
/**
|
|
@@ -1334,7 +1314,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1334
1314
|
// Verify it was saved correctly
|
|
1335
1315
|
const verify = StorageManager.loadSession();
|
|
1336
1316
|
if (!verify || verify.id !== newSessionId) {
|
|
1337
|
-
console.error("⚠️ SessionStorage write verification failed! Session may not persist across page navigation.");
|
|
1338
1317
|
// Try to recover from localStorage backup
|
|
1339
1318
|
try {
|
|
1340
1319
|
const backup = localStorage.getItem(CONFIG.STORAGE_KEYS.SESSION_BACKUP);
|
|
@@ -1350,7 +1329,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1350
1329
|
|
|
1351
1330
|
return newSessionId;
|
|
1352
1331
|
} catch (error) {
|
|
1353
|
-
console.error("Error in getOrCreateSessionId:", error);
|
|
1354
1332
|
// Even on error, ensure we have a valid userId
|
|
1355
1333
|
sessionData.userId = StorageManager.getUserId();
|
|
1356
1334
|
userSession.userId = sessionData.userId;
|
|
@@ -1398,7 +1376,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1398
1376
|
|
|
1399
1377
|
// Ensure sessionId is never null/undefined
|
|
1400
1378
|
if (!sessionData.sessionId) {
|
|
1401
|
-
console.error("❌ sessionData.sessionId is null/undefined after initialization!");
|
|
1402
1379
|
// Try to get from storage first
|
|
1403
1380
|
const session = StorageManager.loadSession();
|
|
1404
1381
|
if (session && session.id) {
|
|
@@ -1410,7 +1387,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1410
1387
|
}
|
|
1411
1388
|
}
|
|
1412
1389
|
} catch (error) {
|
|
1413
|
-
console.error("Error initializing session data:", error);
|
|
1414
1390
|
// Try to get from storage first, then fallback
|
|
1415
1391
|
try {
|
|
1416
1392
|
const session = StorageManager.loadSession();
|
|
@@ -1598,8 +1574,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1598
1574
|
} else {
|
|
1599
1575
|
// No timestamp available - use minimum duration
|
|
1600
1576
|
calculatedDuration = 1; // Minimum 1 second
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1577
|
+
}
|
|
1603
1578
|
}
|
|
1604
1579
|
|
|
1605
1580
|
// Ensure duration is not negative
|
|
@@ -1818,8 +1793,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1818
1793
|
resolve(locationData);
|
|
1819
1794
|
})
|
|
1820
1795
|
.catch((err) => {
|
|
1821
|
-
console.error("Primary geolocation error:", err);
|
|
1822
|
-
|
|
1823
1796
|
// Fall back to backup URL
|
|
1824
1797
|
fetch(CONFIG.GEOLOCATION.BACKUP_URL, fetchOptions)
|
|
1825
1798
|
.then((res) => {
|
|
@@ -1858,7 +1831,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1858
1831
|
resolve(locationData);
|
|
1859
1832
|
})
|
|
1860
1833
|
.catch((backupErr) => {
|
|
1861
|
-
console.error("Backup geolocation error:", backupErr);
|
|
1862
1834
|
// Set fallback values
|
|
1863
1835
|
this.storeLocationData(locationData);
|
|
1864
1836
|
resolve(locationData);
|
|
@@ -1925,7 +1897,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1925
1897
|
const locationData = await this.fetchLocationData();
|
|
1926
1898
|
return locationData.country;
|
|
1927
1899
|
} catch (err) {
|
|
1928
|
-
console.error("Error fetching country name:", err);
|
|
1929
1900
|
return "Unknown";
|
|
1930
1901
|
}
|
|
1931
1902
|
},
|
|
@@ -1980,7 +1951,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
1980
1951
|
initialize() {
|
|
1981
1952
|
// Fetch location data in background (non-blocking)
|
|
1982
1953
|
this.fetchLocationData().catch((err) => {
|
|
1983
|
-
console.warn("Background location fetch failed:", err);
|
|
1984
1954
|
// Continue with default values
|
|
1985
1955
|
});
|
|
1986
1956
|
}
|
|
@@ -2740,8 +2710,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2740
2710
|
return `0x${chainId.toString(16)}`;
|
|
2741
2711
|
}
|
|
2742
2712
|
} catch (err) {
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2713
|
+
}
|
|
2745
2714
|
|
|
2746
2715
|
return null;
|
|
2747
2716
|
},
|
|
@@ -2775,7 +2744,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2775
2744
|
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
2776
2745
|
return accounts && accounts.length > 0;
|
|
2777
2746
|
} catch (error) {
|
|
2778
|
-
console.warn('Error checking wallet connection:', error);
|
|
2779
2747
|
return false;
|
|
2780
2748
|
}
|
|
2781
2749
|
},
|
|
@@ -2794,7 +2762,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2794
2762
|
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
2795
2763
|
return accounts && accounts.length > 0 ? accounts[0] : null;
|
|
2796
2764
|
} catch (error) {
|
|
2797
|
-
console.warn('Error getting wallet address:', error);
|
|
2798
2765
|
return null;
|
|
2799
2766
|
}
|
|
2800
2767
|
},
|
|
@@ -2823,7 +2790,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2823
2790
|
try {
|
|
2824
2791
|
chainName = await this.detectChainName();
|
|
2825
2792
|
} catch (chainError) {
|
|
2826
|
-
console.warn('Error detecting chain name:', chainError);
|
|
2827
2793
|
chainName = "Unknown Chain";
|
|
2828
2794
|
}
|
|
2829
2795
|
}
|
|
@@ -2967,13 +2933,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2967
2933
|
retries: 1
|
|
2968
2934
|
});
|
|
2969
2935
|
} catch (error) {
|
|
2970
|
-
console.warn('Error sending wallet update:', error);
|
|
2971
2936
|
// Don't throw - wallet connection succeeded, just failed to send update
|
|
2972
2937
|
}
|
|
2973
2938
|
|
|
2974
2939
|
return accounts[0];
|
|
2975
2940
|
} catch (error) {
|
|
2976
|
-
console.error('Error connecting with selected provider:', error);
|
|
2977
2941
|
throw error;
|
|
2978
2942
|
}
|
|
2979
2943
|
},
|
|
@@ -3070,9 +3034,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3070
3034
|
return await this.connectWithProvider(selectedProvider);
|
|
3071
3035
|
} catch (error) {
|
|
3072
3036
|
// Only log if it's not a cancellation
|
|
3073
|
-
if (!error.message || !error.message.includes('cancelled'))
|
|
3074
|
-
console.error('Error connecting wallet:', error);
|
|
3075
|
-
}
|
|
3037
|
+
if (!error.message || !error.message.includes('cancelled')) ;
|
|
3076
3038
|
return null; // Return null instead of throwing
|
|
3077
3039
|
}
|
|
3078
3040
|
},
|
|
@@ -3104,8 +3066,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3104
3066
|
|
|
3105
3067
|
// Update UTM event with newly connected wallet
|
|
3106
3068
|
APIClient.updateUTMEventWithWallet().catch((error) => {
|
|
3107
|
-
|
|
3108
|
-
});
|
|
3069
|
+
});
|
|
3109
3070
|
} catch (error) {
|
|
3110
3071
|
// Only log actual errors (not user cancellations or missing wallets)
|
|
3111
3072
|
if (error && error.message && !error.message.includes('No wallet provider found')) {
|
|
@@ -3188,8 +3149,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3188
3149
|
async initialize() {
|
|
3189
3150
|
// Initial wallet detection (non-blocking)
|
|
3190
3151
|
this.updateWalletInfo().catch((err) => {
|
|
3191
|
-
|
|
3192
|
-
});
|
|
3152
|
+
});
|
|
3193
3153
|
|
|
3194
3154
|
// Setup event listeners
|
|
3195
3155
|
this.setupEventListeners();
|
|
@@ -3314,7 +3274,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3314
3274
|
|
|
3315
3275
|
// Validate category
|
|
3316
3276
|
if (!this.CATEGORIES.includes(category)) {
|
|
3317
|
-
console.warn(`Invalid interaction category: ${category}`);
|
|
3318
3277
|
return;
|
|
3319
3278
|
}
|
|
3320
3279
|
|
|
@@ -3369,8 +3328,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3369
3328
|
StorageManager.saveSession(storedSession);
|
|
3370
3329
|
}
|
|
3371
3330
|
} catch (error) {
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3331
|
+
}
|
|
3374
3332
|
},
|
|
3375
3333
|
|
|
3376
3334
|
/**
|
|
@@ -3504,7 +3462,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3504
3462
|
}
|
|
3505
3463
|
|
|
3506
3464
|
if (!this.CATEGORIES.includes(category)) {
|
|
3507
|
-
console.warn(`Invalid interaction category: ${category}`);
|
|
3508
3465
|
return [];
|
|
3509
3466
|
}
|
|
3510
3467
|
|
|
@@ -3795,8 +3752,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3795
3752
|
// Save updated session
|
|
3796
3753
|
StorageManager.saveSession(session);
|
|
3797
3754
|
} catch (error) {
|
|
3798
|
-
|
|
3799
|
-
}
|
|
3755
|
+
}
|
|
3800
3756
|
},
|
|
3801
3757
|
|
|
3802
3758
|
/**
|
|
@@ -3809,7 +3765,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3809
3765
|
try {
|
|
3810
3766
|
const session = StorageManager.loadSession();
|
|
3811
3767
|
if (!session || !session.sessionData || !session.sessionData.pageVisits) {
|
|
3812
|
-
console.warn('trackBrowserClose: No session data found');
|
|
3813
3768
|
return;
|
|
3814
3769
|
}
|
|
3815
3770
|
|
|
@@ -3851,11 +3806,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3851
3806
|
// Save updated session
|
|
3852
3807
|
StorageManager.saveSession(session);
|
|
3853
3808
|
} else {
|
|
3854
|
-
|
|
3855
|
-
}
|
|
3809
|
+
}
|
|
3856
3810
|
} catch (error) {
|
|
3857
|
-
|
|
3858
|
-
}
|
|
3811
|
+
}
|
|
3859
3812
|
},
|
|
3860
3813
|
|
|
3861
3814
|
/**
|
|
@@ -4335,8 +4288,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4335
4288
|
return referrerHostname;
|
|
4336
4289
|
}
|
|
4337
4290
|
} catch (error) {
|
|
4338
|
-
|
|
4339
|
-
}
|
|
4291
|
+
}
|
|
4340
4292
|
}
|
|
4341
4293
|
|
|
4342
4294
|
// Step 3: Default to direct traffic
|
|
@@ -4394,11 +4346,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4394
4346
|
if (success) {
|
|
4395
4347
|
return Promise.resolve();
|
|
4396
4348
|
} else {
|
|
4397
|
-
|
|
4398
|
-
}
|
|
4349
|
+
}
|
|
4399
4350
|
} catch (error) {
|
|
4400
|
-
|
|
4401
|
-
}
|
|
4351
|
+
}
|
|
4402
4352
|
}
|
|
4403
4353
|
|
|
4404
4354
|
// Use fetch for regular sends or as fallback
|
|
@@ -4439,32 +4389,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4439
4389
|
|
|
4440
4390
|
if (!response.ok) {
|
|
4441
4391
|
// Log detailed error information
|
|
4442
|
-
console.error(`❌ API Error (${response.status} ${response.statusText}):`, {
|
|
4443
|
-
endpoint: endpoint,
|
|
4444
|
-
status: response.status,
|
|
4445
|
-
statusText: response.statusText,
|
|
4446
|
-
errorResponse: responseData
|
|
4447
|
-
});
|
|
4448
|
-
|
|
4449
4392
|
// Log specific error reasons
|
|
4450
4393
|
if (response.status === 400) {
|
|
4451
|
-
console.error('❌ REASON: Bad Request - Validation error');
|
|
4452
4394
|
if (responseData && responseData.error) {
|
|
4453
|
-
|
|
4454
|
-
}
|
|
4395
|
+
}
|
|
4455
4396
|
if (responseData && responseData.details) {
|
|
4456
|
-
|
|
4457
|
-
}
|
|
4397
|
+
}
|
|
4458
4398
|
if (responseData && responseData.message) {
|
|
4459
|
-
|
|
4460
|
-
}
|
|
4399
|
+
}
|
|
4461
4400
|
// Log the payload that failed (for debugging)
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
} else if (response.status === 500) {
|
|
4466
|
-
console.error('❌ REASON: Server Error - Check backend logs for details');
|
|
4467
|
-
}
|
|
4401
|
+
} else if (response.status === 404) {
|
|
4402
|
+
} else if (response.status === 500) {
|
|
4403
|
+
}
|
|
4468
4404
|
|
|
4469
4405
|
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(responseData)}`);
|
|
4470
4406
|
}
|
|
@@ -4542,8 +4478,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4542
4478
|
timeout: 15000
|
|
4543
4479
|
});
|
|
4544
4480
|
} catch (error) {
|
|
4545
|
-
|
|
4546
|
-
}
|
|
4481
|
+
}
|
|
4547
4482
|
},
|
|
4548
4483
|
|
|
4549
4484
|
|
|
@@ -4589,8 +4524,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4589
4524
|
retries: 1
|
|
4590
4525
|
});
|
|
4591
4526
|
} catch (error) {
|
|
4592
|
-
|
|
4593
|
-
}
|
|
4527
|
+
}
|
|
4594
4528
|
},
|
|
4595
4529
|
|
|
4596
4530
|
/**
|
|
@@ -4700,8 +4634,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4700
4634
|
}
|
|
4701
4635
|
});
|
|
4702
4636
|
} catch (error) {
|
|
4703
|
-
|
|
4704
|
-
}
|
|
4637
|
+
}
|
|
4705
4638
|
},
|
|
4706
4639
|
|
|
4707
4640
|
/**
|
|
@@ -4801,8 +4734,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4801
4734
|
}
|
|
4802
4735
|
}, true);
|
|
4803
4736
|
} catch (error) {
|
|
4804
|
-
|
|
4805
|
-
}
|
|
4737
|
+
}
|
|
4806
4738
|
},
|
|
4807
4739
|
|
|
4808
4740
|
/**
|
|
@@ -4871,8 +4803,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4871
4803
|
}
|
|
4872
4804
|
});
|
|
4873
4805
|
} catch (error) {
|
|
4874
|
-
|
|
4875
|
-
}
|
|
4806
|
+
}
|
|
4876
4807
|
},
|
|
4877
4808
|
|
|
4878
4809
|
/**
|
|
@@ -4909,8 +4840,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4909
4840
|
}, 150); // Debounce scroll events
|
|
4910
4841
|
});
|
|
4911
4842
|
} catch (error) {
|
|
4912
|
-
|
|
4913
|
-
}
|
|
4843
|
+
}
|
|
4914
4844
|
},
|
|
4915
4845
|
|
|
4916
4846
|
/**
|
|
@@ -4979,8 +4909,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4979
4909
|
}
|
|
4980
4910
|
});
|
|
4981
4911
|
} catch (error) {
|
|
4982
|
-
|
|
4983
|
-
}
|
|
4912
|
+
}
|
|
4984
4913
|
},
|
|
4985
4914
|
|
|
4986
4915
|
/**
|
|
@@ -5019,8 +4948,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5019
4948
|
}
|
|
5020
4949
|
});
|
|
5021
4950
|
} catch (error) {
|
|
5022
|
-
|
|
5023
|
-
}
|
|
4951
|
+
}
|
|
5024
4952
|
},
|
|
5025
4953
|
|
|
5026
4954
|
/**
|
|
@@ -5055,8 +4983,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5055
4983
|
InteractionManager.add('copyPasteEvents', pasteData);
|
|
5056
4984
|
});
|
|
5057
4985
|
} catch (error) {
|
|
5058
|
-
|
|
5059
|
-
}
|
|
4986
|
+
}
|
|
5060
4987
|
},
|
|
5061
4988
|
|
|
5062
4989
|
/**
|
|
@@ -5082,8 +5009,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5082
5009
|
InteractionManager.add('contextMenuEvents', contextData);
|
|
5083
5010
|
});
|
|
5084
5011
|
} catch (error) {
|
|
5085
|
-
|
|
5086
|
-
}
|
|
5012
|
+
}
|
|
5087
5013
|
},
|
|
5088
5014
|
|
|
5089
5015
|
/**
|
|
@@ -5127,8 +5053,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5127
5053
|
InteractionManager.add('dragDropEvents', dropData);
|
|
5128
5054
|
});
|
|
5129
5055
|
} catch (error) {
|
|
5130
|
-
|
|
5131
|
-
}
|
|
5056
|
+
}
|
|
5132
5057
|
},
|
|
5133
5058
|
|
|
5134
5059
|
/**
|
|
@@ -5175,8 +5100,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5175
5100
|
InteractionManager.add('touchEvents', touchData);
|
|
5176
5101
|
});
|
|
5177
5102
|
} catch (error) {
|
|
5178
|
-
|
|
5179
|
-
}
|
|
5103
|
+
}
|
|
5180
5104
|
},
|
|
5181
5105
|
|
|
5182
5106
|
/**
|
|
@@ -5253,8 +5177,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5253
5177
|
InteractionManager.add('windowEvents', blurData);
|
|
5254
5178
|
});
|
|
5255
5179
|
} catch (error) {
|
|
5256
|
-
|
|
5257
|
-
}
|
|
5180
|
+
}
|
|
5258
5181
|
},
|
|
5259
5182
|
|
|
5260
5183
|
/**
|
|
@@ -5281,8 +5204,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5281
5204
|
}, 1000);
|
|
5282
5205
|
});
|
|
5283
5206
|
} catch (error) {
|
|
5284
|
-
|
|
5285
|
-
}
|
|
5207
|
+
}
|
|
5286
5208
|
},
|
|
5287
5209
|
|
|
5288
5210
|
/**
|
|
@@ -5323,8 +5245,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5323
5245
|
InteractionManager.add('errorEvents', errorData);
|
|
5324
5246
|
});
|
|
5325
5247
|
} catch (error) {
|
|
5326
|
-
|
|
5327
|
-
}
|
|
5248
|
+
}
|
|
5328
5249
|
},
|
|
5329
5250
|
|
|
5330
5251
|
/**
|
|
@@ -5390,8 +5311,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5390
5311
|
return originalXHRSend.apply(this, args);
|
|
5391
5312
|
};
|
|
5392
5313
|
} catch (error) {
|
|
5393
|
-
|
|
5394
|
-
}
|
|
5314
|
+
}
|
|
5395
5315
|
},
|
|
5396
5316
|
|
|
5397
5317
|
/**
|
|
@@ -5429,8 +5349,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5429
5349
|
}
|
|
5430
5350
|
});
|
|
5431
5351
|
} catch (error) {
|
|
5432
|
-
|
|
5433
|
-
}
|
|
5352
|
+
}
|
|
5434
5353
|
},
|
|
5435
5354
|
|
|
5436
5355
|
/**
|
|
@@ -5506,8 +5425,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5506
5425
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.LAST_SESSION);
|
|
5507
5426
|
}
|
|
5508
5427
|
} catch (error) {
|
|
5509
|
-
|
|
5510
|
-
}
|
|
5428
|
+
}
|
|
5511
5429
|
},
|
|
5512
5430
|
|
|
5513
5431
|
/**
|
|
@@ -5532,8 +5450,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5532
5450
|
// Initialize page visits
|
|
5533
5451
|
PageVisitManager.initialize();
|
|
5534
5452
|
} catch (error) {
|
|
5535
|
-
|
|
5536
|
-
}
|
|
5453
|
+
}
|
|
5537
5454
|
},
|
|
5538
5455
|
|
|
5539
5456
|
/**
|
|
@@ -5545,11 +5462,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5545
5462
|
try {
|
|
5546
5463
|
// Start location fetch (non-blocking)
|
|
5547
5464
|
LocationManager.getLocationData().catch(error => {
|
|
5548
|
-
|
|
5549
|
-
});
|
|
5465
|
+
});
|
|
5550
5466
|
} catch (error) {
|
|
5551
|
-
|
|
5552
|
-
}
|
|
5467
|
+
}
|
|
5553
5468
|
},
|
|
5554
5469
|
|
|
5555
5470
|
/**
|
|
@@ -5560,8 +5475,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5560
5475
|
// FIX: Call initialize() which both detects AND stores the data
|
|
5561
5476
|
await BrowserDeviceManager.initialize();
|
|
5562
5477
|
} catch (error) {
|
|
5563
|
-
|
|
5564
|
-
}
|
|
5478
|
+
}
|
|
5565
5479
|
},
|
|
5566
5480
|
|
|
5567
5481
|
/**
|
|
@@ -5571,8 +5485,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5571
5485
|
try {
|
|
5572
5486
|
UTMManager.initialize();
|
|
5573
5487
|
} catch (error) {
|
|
5574
|
-
|
|
5575
|
-
}
|
|
5488
|
+
}
|
|
5576
5489
|
},
|
|
5577
5490
|
|
|
5578
5491
|
/**
|
|
@@ -5582,8 +5495,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5582
5495
|
try {
|
|
5583
5496
|
WalletManager.initialize();
|
|
5584
5497
|
} catch (error) {
|
|
5585
|
-
|
|
5586
|
-
}
|
|
5498
|
+
}
|
|
5587
5499
|
},
|
|
5588
5500
|
|
|
5589
5501
|
/**
|
|
@@ -5593,8 +5505,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5593
5505
|
try {
|
|
5594
5506
|
PageVisitManager.track();
|
|
5595
5507
|
} catch (error) {
|
|
5596
|
-
|
|
5597
|
-
}
|
|
5508
|
+
}
|
|
5598
5509
|
},
|
|
5599
5510
|
|
|
5600
5511
|
/**
|
|
@@ -5680,12 +5591,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5680
5591
|
// Send session data
|
|
5681
5592
|
await APIClient.sendSessionData();
|
|
5682
5593
|
} catch (error) {
|
|
5683
|
-
|
|
5684
|
-
}
|
|
5594
|
+
}
|
|
5685
5595
|
}, CONFIG.INTERVALS.SESSION_TRACKING_MS);
|
|
5686
5596
|
} catch (error) {
|
|
5687
|
-
|
|
5688
|
-
}
|
|
5597
|
+
}
|
|
5689
5598
|
},
|
|
5690
5599
|
|
|
5691
5600
|
/**
|
|
@@ -5771,8 +5680,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5771
5680
|
JSON.stringify(transformedData)
|
|
5772
5681
|
);
|
|
5773
5682
|
} catch (storageError) {
|
|
5774
|
-
|
|
5775
|
-
}
|
|
5683
|
+
}
|
|
5776
5684
|
});
|
|
5777
5685
|
|
|
5778
5686
|
// Clear tracking interval
|
|
@@ -5781,12 +5689,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5781
5689
|
runtimeState.timer = null;
|
|
5782
5690
|
}
|
|
5783
5691
|
} catch (error) {
|
|
5784
|
-
|
|
5785
|
-
}
|
|
5692
|
+
}
|
|
5786
5693
|
});
|
|
5787
5694
|
} catch (error) {
|
|
5788
|
-
|
|
5789
|
-
}
|
|
5695
|
+
}
|
|
5790
5696
|
},
|
|
5791
5697
|
|
|
5792
5698
|
/**
|
|
@@ -5805,11 +5711,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5805
5711
|
// Send UTM event if UTM parameters are present (non-blocking)
|
|
5806
5712
|
// This should happen after session data is sent so we have sessionId and userId
|
|
5807
5713
|
APIClient.sendUTMEvent().catch((error) => {
|
|
5808
|
-
|
|
5809
|
-
});
|
|
5714
|
+
});
|
|
5810
5715
|
} catch (error) {
|
|
5811
|
-
|
|
5812
|
-
}
|
|
5716
|
+
}
|
|
5813
5717
|
},
|
|
5814
5718
|
|
|
5815
5719
|
/**
|
|
@@ -5821,7 +5725,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5821
5725
|
try {
|
|
5822
5726
|
// Check for sessionStorage availability
|
|
5823
5727
|
if (!window.sessionStorage) {
|
|
5824
|
-
console.error('SessionStorage is not available in this browser');
|
|
5825
5728
|
return;
|
|
5826
5729
|
}
|
|
5827
5730
|
|
|
@@ -5903,8 +5806,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5903
5806
|
}
|
|
5904
5807
|
}
|
|
5905
5808
|
} catch (error) {
|
|
5906
|
-
|
|
5907
|
-
}
|
|
5809
|
+
}
|
|
5908
5810
|
}
|
|
5909
5811
|
|
|
5910
5812
|
/**
|
|
@@ -5929,8 +5831,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5929
5831
|
try {
|
|
5930
5832
|
await WalletManager.updateWalletInfo();
|
|
5931
5833
|
} catch (walletError) {
|
|
5932
|
-
|
|
5933
|
-
}
|
|
5834
|
+
}
|
|
5934
5835
|
|
|
5935
5836
|
// Update session data from storage
|
|
5936
5837
|
const storedSession = StorageManager.loadSession();
|
|
@@ -5959,8 +5860,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5959
5860
|
// This function is primarily for internal SDK events
|
|
5960
5861
|
// Custom events should use trackEvent instead
|
|
5961
5862
|
} catch (error) {
|
|
5962
|
-
|
|
5963
|
-
}
|
|
5863
|
+
}
|
|
5964
5864
|
}
|
|
5965
5865
|
|
|
5966
5866
|
// ============================================================================
|
|
@@ -5981,14 +5881,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5981
5881
|
async trackEvent(eventName, properties = {}, options = {}) {
|
|
5982
5882
|
try {
|
|
5983
5883
|
if (!runtimeState.isInitialized) {
|
|
5984
|
-
console.warn('⚠️ [Events] SDK not initialized, queuing event:', eventName);
|
|
5985
5884
|
return;
|
|
5986
5885
|
}
|
|
5987
5886
|
|
|
5988
5887
|
// Get session from storage - it returns { id, userId, ... }
|
|
5989
5888
|
const storedSession = StorageManager.loadSession();
|
|
5990
5889
|
if (!storedSession || !storedSession.id) {
|
|
5991
|
-
console.error('❌ [Events] No session ID available for custom event tracking');
|
|
5992
5890
|
return;
|
|
5993
5891
|
}
|
|
5994
5892
|
|
|
@@ -5997,7 +5895,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5997
5895
|
const sessionId = storedSession.id || sessionData.sessionId || sessionData.session_id;
|
|
5998
5896
|
|
|
5999
5897
|
if (!sessionId) {
|
|
6000
|
-
console.error('❌ [Events] Session ID is missing');
|
|
6001
5898
|
return;
|
|
6002
5899
|
}
|
|
6003
5900
|
|
|
@@ -6127,8 +6024,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6127
6024
|
// Get session from storage - it returns { id, userId, ... }
|
|
6128
6025
|
const storedSession = StorageManager.loadSession();
|
|
6129
6026
|
if (!storedSession || !storedSession.id) {
|
|
6130
|
-
console.error('❌ [Events] No session ID available for auto event tracking');
|
|
6131
|
-
console.error('❌ [Events] Stored session:', storedSession);
|
|
6132
6027
|
return;
|
|
6133
6028
|
}
|
|
6134
6029
|
|
|
@@ -6137,7 +6032,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6137
6032
|
const sessionId = storedSession.id || sessionData.sessionId || sessionData.session_id;
|
|
6138
6033
|
|
|
6139
6034
|
if (!sessionId) {
|
|
6140
|
-
console.error('❌ [Events] Session ID is missing');
|
|
6141
6035
|
return;
|
|
6142
6036
|
}
|
|
6143
6037
|
|
|
@@ -6210,11 +6104,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6210
6104
|
|
|
6211
6105
|
if (!response.ok) {
|
|
6212
6106
|
const errorData = await response.text();
|
|
6213
|
-
console.error('❌ [Events SDK] API error:', {
|
|
6214
|
-
status: response.status,
|
|
6215
|
-
statusText: response.statusText,
|
|
6216
|
-
error: errorData
|
|
6217
|
-
});
|
|
6218
6107
|
throw new Error(`Events API error: ${response.status} ${response.statusText} - ${errorData}`);
|
|
6219
6108
|
}
|
|
6220
6109
|
|
|
@@ -6222,7 +6111,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6222
6111
|
return result;
|
|
6223
6112
|
|
|
6224
6113
|
} catch (error) {
|
|
6225
|
-
console.error('❌ [Events SDK] Error sending event to API:', error);
|
|
6226
6114
|
throw error;
|
|
6227
6115
|
}
|
|
6228
6116
|
},
|
|
@@ -6748,8 +6636,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6748
6636
|
page_load_time: performance.now(),
|
|
6749
6637
|
scroll_position: 0
|
|
6750
6638
|
}).catch(err => {
|
|
6751
|
-
|
|
6752
|
-
});
|
|
6639
|
+
});
|
|
6753
6640
|
}, 1000); // Wait 1 second for session to be created
|
|
6754
6641
|
},
|
|
6755
6642
|
|
|
@@ -6872,8 +6759,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6872
6759
|
element_area: element.offsetWidth * element.offsetHeight,
|
|
6873
6760
|
element_category: elementCategory
|
|
6874
6761
|
}, elementData).catch(err => {
|
|
6875
|
-
|
|
6876
|
-
});
|
|
6762
|
+
});
|
|
6877
6763
|
}
|
|
6878
6764
|
} else {
|
|
6879
6765
|
clickCount = 1;
|
|
@@ -6958,8 +6844,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6958
6844
|
double_click: event.detail === 2,
|
|
6959
6845
|
element_category: elementCategory
|
|
6960
6846
|
}, elementData).catch(err => {
|
|
6961
|
-
|
|
6962
|
-
});
|
|
6847
|
+
});
|
|
6963
6848
|
|
|
6964
6849
|
lastClickTime = now;
|
|
6965
6850
|
lastClickElement = element;
|
|
@@ -6996,8 +6881,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6996
6881
|
document_height: docHeight,
|
|
6997
6882
|
document_width: docWidth
|
|
6998
6883
|
}).catch(err => {
|
|
6999
|
-
|
|
7000
|
-
});
|
|
6884
|
+
});
|
|
7001
6885
|
}
|
|
7002
6886
|
}, 250);
|
|
7003
6887
|
});
|
|
@@ -8022,7 +7906,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
8022
7906
|
* The script.js file is inlined during the build process by Rollup.
|
|
8023
7907
|
*/
|
|
8024
7908
|
|
|
8025
|
-
|
|
8026
7909
|
// Create a wrapper that provides programmatic initialization
|
|
8027
7910
|
const CryptiqueSDK = {
|
|
8028
7911
|
/**
|