cryptique-sdk 1.1.9 → 1.2.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/lib/cjs/index.js +2 -53
- package/lib/esm/index.js +2 -53
- package/lib/umd/index.js +2 -53
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -431,12 +431,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
431
431
|
sessionData.utm_id = persistentData.utm_id;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
|
|
435
|
-
wallet_address: sessionData.wallet_address,
|
|
436
|
-
is_web3_user: sessionData.is_web3_user,
|
|
437
|
-
referrer: sessionData.referrer,
|
|
438
|
-
utm_source: sessionData.utm_source
|
|
439
|
-
});
|
|
434
|
+
// Session-specific persistent data restored successfully (wallet, web3 status, referrer, UTM source)
|
|
440
435
|
|
|
441
436
|
} catch (err) {
|
|
442
437
|
console.warn('Failed to restore session-specific persistent data:', err);
|
|
@@ -460,11 +455,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
460
455
|
if (currentSessionId) {
|
|
461
456
|
const sessionKey = `${CONFIG.STORAGE_KEYS.PERSISTENT_DATA}_${currentSessionId}`;
|
|
462
457
|
localStorage.removeItem(sessionKey);
|
|
463
|
-
console.log(`✅ Cleared session-specific persistent data for session ${currentSessionId}`);
|
|
464
458
|
} else {
|
|
465
459
|
// Fallback: clear old global persistent data if session ID not available
|
|
466
460
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.PERSISTENT_DATA);
|
|
467
|
-
console.log('✅ Cleared global persistent data from localStorage');
|
|
468
461
|
}
|
|
469
462
|
} catch (err) {
|
|
470
463
|
console.warn('Failed to clear persistent data:', err);
|
|
@@ -495,8 +488,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
495
488
|
keysToRemove.forEach(key => {
|
|
496
489
|
localStorage.removeItem(key);
|
|
497
490
|
});
|
|
498
|
-
|
|
499
|
-
console.log(`✅ Cleared all persistent data (${keysToRemove.length} keys removed)`);
|
|
500
491
|
} catch (err) {
|
|
501
492
|
console.warn('Failed to clear all persistent data:', err);
|
|
502
493
|
}
|
|
@@ -803,7 +794,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
803
794
|
_cachedDistinctId = distinctId;
|
|
804
795
|
|
|
805
796
|
const type = distinctId.startsWith('anon_') ? 'anonymous' : 'identified';
|
|
806
|
-
console.log(`✅ [Storage] Stored ${type} distinct_id in localStorage and sessionStorage: ${distinctId}`);
|
|
807
797
|
} catch (err) {
|
|
808
798
|
console.warn('Failed to set distinct_id:', err);
|
|
809
799
|
}
|
|
@@ -2319,7 +2309,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2319
2309
|
}
|
|
2320
2310
|
} catch (error) {
|
|
2321
2311
|
// API may not be available or user denied permission
|
|
2322
|
-
console.debug('User-Agent Client Hints API not available:', error);
|
|
2323
2312
|
}
|
|
2324
2313
|
} else {
|
|
2325
2314
|
// Fallback: parse from user agent string
|
|
@@ -2547,16 +2536,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2547
2536
|
// Current address is valid - only update to another valid address
|
|
2548
2537
|
if (newIsValid) {
|
|
2549
2538
|
sessionData.wallet_address = newAddress;
|
|
2550
|
-
console.log(`🔄 Wallet address updated: ${currentAddress} → ${newAddress}`);
|
|
2551
|
-
} else {
|
|
2552
|
-
console.log(`🔒 Wallet address protected: keeping ${currentAddress} (cannot set to ${newAddress})`);
|
|
2553
2539
|
}
|
|
2554
2540
|
} else {
|
|
2555
2541
|
// Current address is not valid - can set to any value
|
|
2556
2542
|
sessionData.wallet_address = newAddress;
|
|
2557
|
-
if (newIsValid) {
|
|
2558
|
-
console.log(`✅ Wallet address set: ${newAddress}`);
|
|
2559
|
-
}
|
|
2560
2543
|
}
|
|
2561
2544
|
},
|
|
2562
2545
|
|
|
@@ -2855,8 +2838,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2855
2838
|
// Invalid wallet type - only set if wallet_type is not already set to a valid value
|
|
2856
2839
|
if (!sessionData.wallet_type || sessionData.wallet_type === "No Wallet Detected") {
|
|
2857
2840
|
sessionData.wallet_type = walletType;
|
|
2858
|
-
} else {
|
|
2859
|
-
console.log(`🔒 Wallet type protected: keeping ${sessionData.wallet_type} (cannot set to ${walletType})`);
|
|
2860
2841
|
}
|
|
2861
2842
|
}
|
|
2862
2843
|
// Update chain_name with immutability protection
|
|
@@ -2868,8 +2849,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2868
2849
|
// Invalid chain name - only set if chain_name is not already set to a valid value
|
|
2869
2850
|
if (!sessionData.chain_name || sessionData.chain_name === "Not Connected") {
|
|
2870
2851
|
sessionData.chain_name = chainName;
|
|
2871
|
-
} else {
|
|
2872
|
-
console.log(`🔒 Chain name protected: keeping ${sessionData.chain_name} (cannot set to ${chainName})`);
|
|
2873
2852
|
}
|
|
2874
2853
|
}
|
|
2875
2854
|
// Keep is_web3_user as true if it's already true or if we detect a wallet
|
|
@@ -3156,7 +3135,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3156
3135
|
} else {
|
|
3157
3136
|
// Wallet disconnected - but protect wallet_address, chain_name, and wallet_type from becoming null/placeholder
|
|
3158
3137
|
// Keep the last known values for session consistency
|
|
3159
|
-
console.log('🔒 Wallet disconnected but keeping wallet data for session consistency');
|
|
3160
3138
|
sessionData.wallet_connected = false;
|
|
3161
3139
|
// Do NOT set wallet_address, chain_name, or wallet_type to null/placeholder - keep them for session attribution
|
|
3162
3140
|
// The updateWalletInfo() method already has immutability protection, so we don't need to call it here
|
|
@@ -5712,15 +5690,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5712
5690
|
// Save session to storage
|
|
5713
5691
|
StorageManager.saveSession(sessionData);
|
|
5714
5692
|
|
|
5715
|
-
// Always sync distinctId from storage before
|
|
5693
|
+
// Always sync distinctId from storage before sending to ensure consistency
|
|
5716
5694
|
sessionData.distinctId = StorageManager.getDistinctId();
|
|
5717
5695
|
|
|
5718
|
-
// Console log raw session data intermittently
|
|
5719
|
-
console.log('📊 [Session] Raw Session Data:', {
|
|
5720
|
-
sessionData: sessionData,
|
|
5721
|
-
storedSession: storedSession
|
|
5722
|
-
});
|
|
5723
|
-
|
|
5724
5696
|
// Send session data
|
|
5725
5697
|
await APIClient.sendSessionData();
|
|
5726
5698
|
} catch (error) {
|
|
@@ -6441,8 +6413,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6441
6413
|
session.identified = true;
|
|
6442
6414
|
StorageManager.saveSession(session);
|
|
6443
6415
|
}
|
|
6444
|
-
|
|
6445
|
-
console.log(`✅ [Identity] Distinct ID updated: ${currentDistinctId} → ${result.distinctId}`);
|
|
6446
6416
|
} else if (result.merged && result.newDistinctId) {
|
|
6447
6417
|
// Fallback: use newDistinctId if distinctId not present
|
|
6448
6418
|
StorageManager.setDistinctId(result.newDistinctId);
|
|
@@ -6462,8 +6432,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6462
6432
|
session.identified = true;
|
|
6463
6433
|
StorageManager.saveSession(session);
|
|
6464
6434
|
}
|
|
6465
|
-
|
|
6466
|
-
console.log(`✅ [Identity] Distinct ID merged: ${currentDistinctId} → ${result.newDistinctId}`);
|
|
6467
6435
|
} else {
|
|
6468
6436
|
console.warn('⚠️ [Identity] No distinctId or newDistinctId in response:', result);
|
|
6469
6437
|
}
|
|
@@ -6562,8 +6530,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6562
6530
|
// Ignore errors
|
|
6563
6531
|
}
|
|
6564
6532
|
|
|
6565
|
-
console.log(`🔄 [Identity] Reset to anonymous: ${newDistinctId}`);
|
|
6566
|
-
|
|
6567
6533
|
return { success: true, distinctId: newDistinctId };
|
|
6568
6534
|
} catch (error) {
|
|
6569
6535
|
console.error('❌ [Identity] Error in reset():', error);
|
|
@@ -6619,8 +6585,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6619
6585
|
StorageManager.updateBackup({ id: sessionData.sessionId, userId: sessionData.userId });
|
|
6620
6586
|
// That's it - session sync will pick it up automatically, just like automatic detection
|
|
6621
6587
|
|
|
6622
|
-
console.log(`✅ [Identity] Wallet address set in sessionData: ${trimmedWalletAddress}`);
|
|
6623
|
-
|
|
6624
6588
|
// Get current distinct_id
|
|
6625
6589
|
const currentDistinctId = StorageManager.getDistinctId();
|
|
6626
6590
|
|
|
@@ -6667,12 +6631,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6667
6631
|
|
|
6668
6632
|
// Update userSession
|
|
6669
6633
|
userSession.userId = result.newUserId;
|
|
6670
|
-
|
|
6671
|
-
console.log(`✅ [Identity] User merged via wallet: ${currentUserId} → ${result.newUserId}`);
|
|
6672
6634
|
}
|
|
6673
6635
|
|
|
6674
|
-
console.log(`✅ [Identity] Wallet address set: ${trimmedWalletAddress}`);
|
|
6675
|
-
|
|
6676
6636
|
return result;
|
|
6677
6637
|
} catch (error) {
|
|
6678
6638
|
console.error('❌ [Identity] Error in walletAddress():', error);
|
|
@@ -7385,7 +7345,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7385
7345
|
return { success: false, error: result.message || 'Set failed' };
|
|
7386
7346
|
}
|
|
7387
7347
|
|
|
7388
|
-
console.log('✅ [People] Properties set successfully');
|
|
7389
7348
|
return result;
|
|
7390
7349
|
|
|
7391
7350
|
} catch (error) {
|
|
@@ -7435,7 +7394,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7435
7394
|
return { success: false, error: result.message || 'SetOnce failed' };
|
|
7436
7395
|
}
|
|
7437
7396
|
|
|
7438
|
-
console.log('✅ [People] Properties set once successfully');
|
|
7439
7397
|
return result;
|
|
7440
7398
|
|
|
7441
7399
|
} catch (error) {
|
|
@@ -7485,7 +7443,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7485
7443
|
return { success: false, error: result.message || 'Unset failed' };
|
|
7486
7444
|
}
|
|
7487
7445
|
|
|
7488
|
-
console.log('✅ [People] Properties unset successfully');
|
|
7489
7446
|
return result;
|
|
7490
7447
|
|
|
7491
7448
|
} catch (error) {
|
|
@@ -7542,7 +7499,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7542
7499
|
return { success: false, error: result.message || 'Increment failed' };
|
|
7543
7500
|
}
|
|
7544
7501
|
|
|
7545
|
-
console.log('✅ [People] Property incremented successfully');
|
|
7546
7502
|
return result;
|
|
7547
7503
|
|
|
7548
7504
|
} catch (error) {
|
|
@@ -7599,7 +7555,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7599
7555
|
return { success: false, error: result.message || 'Append failed' };
|
|
7600
7556
|
}
|
|
7601
7557
|
|
|
7602
|
-
console.log('✅ [People] Values appended successfully');
|
|
7603
7558
|
return result;
|
|
7604
7559
|
|
|
7605
7560
|
} catch (error) {
|
|
@@ -7656,7 +7611,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7656
7611
|
return { success: false, error: result.message || 'Union failed' };
|
|
7657
7612
|
}
|
|
7658
7613
|
|
|
7659
|
-
console.log('✅ [People] Values unioned successfully');
|
|
7660
7614
|
return result;
|
|
7661
7615
|
|
|
7662
7616
|
} catch (error) {
|
|
@@ -7713,7 +7667,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7713
7667
|
return { success: false, error: result.message || 'Remove failed' };
|
|
7714
7668
|
}
|
|
7715
7669
|
|
|
7716
|
-
console.log('✅ [People] Values removed successfully');
|
|
7717
7670
|
return result;
|
|
7718
7671
|
|
|
7719
7672
|
} catch (error) {
|
|
@@ -7765,7 +7718,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7765
7718
|
return { success: false, error: result.message || 'TrackCharge failed' };
|
|
7766
7719
|
}
|
|
7767
7720
|
|
|
7768
|
-
console.log('✅ [People] Charge tracked successfully');
|
|
7769
7721
|
return result;
|
|
7770
7722
|
|
|
7771
7723
|
} catch (error) {
|
|
@@ -7808,7 +7760,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7808
7760
|
return { success: false, error: result.message || 'ClearCharges failed' };
|
|
7809
7761
|
}
|
|
7810
7762
|
|
|
7811
|
-
console.log('✅ [People] Charges cleared successfully');
|
|
7812
7763
|
return result;
|
|
7813
7764
|
|
|
7814
7765
|
} catch (error) {
|
|
@@ -7851,8 +7802,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7851
7802
|
return { success: false, error: result.message || 'DeleteUser failed' };
|
|
7852
7803
|
}
|
|
7853
7804
|
|
|
7854
|
-
console.log('✅ [People] User deleted successfully');
|
|
7855
|
-
|
|
7856
7805
|
// Clear local storage after successful deletion
|
|
7857
7806
|
StorageManager.clearSession();
|
|
7858
7807
|
StorageManager.clearUserId();
|
package/lib/esm/index.js
CHANGED
|
@@ -429,12 +429,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
429
429
|
sessionData.utm_id = persistentData.utm_id;
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
|
|
433
|
-
wallet_address: sessionData.wallet_address,
|
|
434
|
-
is_web3_user: sessionData.is_web3_user,
|
|
435
|
-
referrer: sessionData.referrer,
|
|
436
|
-
utm_source: sessionData.utm_source
|
|
437
|
-
});
|
|
432
|
+
// Session-specific persistent data restored successfully (wallet, web3 status, referrer, UTM source)
|
|
438
433
|
|
|
439
434
|
} catch (err) {
|
|
440
435
|
console.warn('Failed to restore session-specific persistent data:', err);
|
|
@@ -458,11 +453,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
458
453
|
if (currentSessionId) {
|
|
459
454
|
const sessionKey = `${CONFIG.STORAGE_KEYS.PERSISTENT_DATA}_${currentSessionId}`;
|
|
460
455
|
localStorage.removeItem(sessionKey);
|
|
461
|
-
console.log(`✅ Cleared session-specific persistent data for session ${currentSessionId}`);
|
|
462
456
|
} else {
|
|
463
457
|
// Fallback: clear old global persistent data if session ID not available
|
|
464
458
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.PERSISTENT_DATA);
|
|
465
|
-
console.log('✅ Cleared global persistent data from localStorage');
|
|
466
459
|
}
|
|
467
460
|
} catch (err) {
|
|
468
461
|
console.warn('Failed to clear persistent data:', err);
|
|
@@ -493,8 +486,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
493
486
|
keysToRemove.forEach(key => {
|
|
494
487
|
localStorage.removeItem(key);
|
|
495
488
|
});
|
|
496
|
-
|
|
497
|
-
console.log(`✅ Cleared all persistent data (${keysToRemove.length} keys removed)`);
|
|
498
489
|
} catch (err) {
|
|
499
490
|
console.warn('Failed to clear all persistent data:', err);
|
|
500
491
|
}
|
|
@@ -801,7 +792,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
801
792
|
_cachedDistinctId = distinctId;
|
|
802
793
|
|
|
803
794
|
const type = distinctId.startsWith('anon_') ? 'anonymous' : 'identified';
|
|
804
|
-
console.log(`✅ [Storage] Stored ${type} distinct_id in localStorage and sessionStorage: ${distinctId}`);
|
|
805
795
|
} catch (err) {
|
|
806
796
|
console.warn('Failed to set distinct_id:', err);
|
|
807
797
|
}
|
|
@@ -2317,7 +2307,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2317
2307
|
}
|
|
2318
2308
|
} catch (error) {
|
|
2319
2309
|
// API may not be available or user denied permission
|
|
2320
|
-
console.debug('User-Agent Client Hints API not available:', error);
|
|
2321
2310
|
}
|
|
2322
2311
|
} else {
|
|
2323
2312
|
// Fallback: parse from user agent string
|
|
@@ -2545,16 +2534,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2545
2534
|
// Current address is valid - only update to another valid address
|
|
2546
2535
|
if (newIsValid) {
|
|
2547
2536
|
sessionData.wallet_address = newAddress;
|
|
2548
|
-
console.log(`🔄 Wallet address updated: ${currentAddress} → ${newAddress}`);
|
|
2549
|
-
} else {
|
|
2550
|
-
console.log(`🔒 Wallet address protected: keeping ${currentAddress} (cannot set to ${newAddress})`);
|
|
2551
2537
|
}
|
|
2552
2538
|
} else {
|
|
2553
2539
|
// Current address is not valid - can set to any value
|
|
2554
2540
|
sessionData.wallet_address = newAddress;
|
|
2555
|
-
if (newIsValid) {
|
|
2556
|
-
console.log(`✅ Wallet address set: ${newAddress}`);
|
|
2557
|
-
}
|
|
2558
2541
|
}
|
|
2559
2542
|
},
|
|
2560
2543
|
|
|
@@ -2853,8 +2836,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2853
2836
|
// Invalid wallet type - only set if wallet_type is not already set to a valid value
|
|
2854
2837
|
if (!sessionData.wallet_type || sessionData.wallet_type === "No Wallet Detected") {
|
|
2855
2838
|
sessionData.wallet_type = walletType;
|
|
2856
|
-
} else {
|
|
2857
|
-
console.log(`🔒 Wallet type protected: keeping ${sessionData.wallet_type} (cannot set to ${walletType})`);
|
|
2858
2839
|
}
|
|
2859
2840
|
}
|
|
2860
2841
|
// Update chain_name with immutability protection
|
|
@@ -2866,8 +2847,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2866
2847
|
// Invalid chain name - only set if chain_name is not already set to a valid value
|
|
2867
2848
|
if (!sessionData.chain_name || sessionData.chain_name === "Not Connected") {
|
|
2868
2849
|
sessionData.chain_name = chainName;
|
|
2869
|
-
} else {
|
|
2870
|
-
console.log(`🔒 Chain name protected: keeping ${sessionData.chain_name} (cannot set to ${chainName})`);
|
|
2871
2850
|
}
|
|
2872
2851
|
}
|
|
2873
2852
|
// Keep is_web3_user as true if it's already true or if we detect a wallet
|
|
@@ -3154,7 +3133,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
3154
3133
|
} else {
|
|
3155
3134
|
// Wallet disconnected - but protect wallet_address, chain_name, and wallet_type from becoming null/placeholder
|
|
3156
3135
|
// Keep the last known values for session consistency
|
|
3157
|
-
console.log('🔒 Wallet disconnected but keeping wallet data for session consistency');
|
|
3158
3136
|
sessionData.wallet_connected = false;
|
|
3159
3137
|
// Do NOT set wallet_address, chain_name, or wallet_type to null/placeholder - keep them for session attribution
|
|
3160
3138
|
// The updateWalletInfo() method already has immutability protection, so we don't need to call it here
|
|
@@ -5710,15 +5688,9 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5710
5688
|
// Save session to storage
|
|
5711
5689
|
StorageManager.saveSession(sessionData);
|
|
5712
5690
|
|
|
5713
|
-
// Always sync distinctId from storage before
|
|
5691
|
+
// Always sync distinctId from storage before sending to ensure consistency
|
|
5714
5692
|
sessionData.distinctId = StorageManager.getDistinctId();
|
|
5715
5693
|
|
|
5716
|
-
// Console log raw session data intermittently
|
|
5717
|
-
console.log('📊 [Session] Raw Session Data:', {
|
|
5718
|
-
sessionData: sessionData,
|
|
5719
|
-
storedSession: storedSession
|
|
5720
|
-
});
|
|
5721
|
-
|
|
5722
5694
|
// Send session data
|
|
5723
5695
|
await APIClient.sendSessionData();
|
|
5724
5696
|
} catch (error) {
|
|
@@ -6439,8 +6411,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6439
6411
|
session.identified = true;
|
|
6440
6412
|
StorageManager.saveSession(session);
|
|
6441
6413
|
}
|
|
6442
|
-
|
|
6443
|
-
console.log(`✅ [Identity] Distinct ID updated: ${currentDistinctId} → ${result.distinctId}`);
|
|
6444
6414
|
} else if (result.merged && result.newDistinctId) {
|
|
6445
6415
|
// Fallback: use newDistinctId if distinctId not present
|
|
6446
6416
|
StorageManager.setDistinctId(result.newDistinctId);
|
|
@@ -6460,8 +6430,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6460
6430
|
session.identified = true;
|
|
6461
6431
|
StorageManager.saveSession(session);
|
|
6462
6432
|
}
|
|
6463
|
-
|
|
6464
|
-
console.log(`✅ [Identity] Distinct ID merged: ${currentDistinctId} → ${result.newDistinctId}`);
|
|
6465
6433
|
} else {
|
|
6466
6434
|
console.warn('⚠️ [Identity] No distinctId or newDistinctId in response:', result);
|
|
6467
6435
|
}
|
|
@@ -6560,8 +6528,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6560
6528
|
// Ignore errors
|
|
6561
6529
|
}
|
|
6562
6530
|
|
|
6563
|
-
console.log(`🔄 [Identity] Reset to anonymous: ${newDistinctId}`);
|
|
6564
|
-
|
|
6565
6531
|
return { success: true, distinctId: newDistinctId };
|
|
6566
6532
|
} catch (error) {
|
|
6567
6533
|
console.error('❌ [Identity] Error in reset():', error);
|
|
@@ -6617,8 +6583,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6617
6583
|
StorageManager.updateBackup({ id: sessionData.sessionId, userId: sessionData.userId });
|
|
6618
6584
|
// That's it - session sync will pick it up automatically, just like automatic detection
|
|
6619
6585
|
|
|
6620
|
-
console.log(`✅ [Identity] Wallet address set in sessionData: ${trimmedWalletAddress}`);
|
|
6621
|
-
|
|
6622
6586
|
// Get current distinct_id
|
|
6623
6587
|
const currentDistinctId = StorageManager.getDistinctId();
|
|
6624
6588
|
|
|
@@ -6665,12 +6629,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6665
6629
|
|
|
6666
6630
|
// Update userSession
|
|
6667
6631
|
userSession.userId = result.newUserId;
|
|
6668
|
-
|
|
6669
|
-
console.log(`✅ [Identity] User merged via wallet: ${currentUserId} → ${result.newUserId}`);
|
|
6670
6632
|
}
|
|
6671
6633
|
|
|
6672
|
-
console.log(`✅ [Identity] Wallet address set: ${trimmedWalletAddress}`);
|
|
6673
|
-
|
|
6674
6634
|
return result;
|
|
6675
6635
|
} catch (error) {
|
|
6676
6636
|
console.error('❌ [Identity] Error in walletAddress():', error);
|
|
@@ -7383,7 +7343,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7383
7343
|
return { success: false, error: result.message || 'Set failed' };
|
|
7384
7344
|
}
|
|
7385
7345
|
|
|
7386
|
-
console.log('✅ [People] Properties set successfully');
|
|
7387
7346
|
return result;
|
|
7388
7347
|
|
|
7389
7348
|
} catch (error) {
|
|
@@ -7433,7 +7392,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7433
7392
|
return { success: false, error: result.message || 'SetOnce failed' };
|
|
7434
7393
|
}
|
|
7435
7394
|
|
|
7436
|
-
console.log('✅ [People] Properties set once successfully');
|
|
7437
7395
|
return result;
|
|
7438
7396
|
|
|
7439
7397
|
} catch (error) {
|
|
@@ -7483,7 +7441,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7483
7441
|
return { success: false, error: result.message || 'Unset failed' };
|
|
7484
7442
|
}
|
|
7485
7443
|
|
|
7486
|
-
console.log('✅ [People] Properties unset successfully');
|
|
7487
7444
|
return result;
|
|
7488
7445
|
|
|
7489
7446
|
} catch (error) {
|
|
@@ -7540,7 +7497,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7540
7497
|
return { success: false, error: result.message || 'Increment failed' };
|
|
7541
7498
|
}
|
|
7542
7499
|
|
|
7543
|
-
console.log('✅ [People] Property incremented successfully');
|
|
7544
7500
|
return result;
|
|
7545
7501
|
|
|
7546
7502
|
} catch (error) {
|
|
@@ -7597,7 +7553,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7597
7553
|
return { success: false, error: result.message || 'Append failed' };
|
|
7598
7554
|
}
|
|
7599
7555
|
|
|
7600
|
-
console.log('✅ [People] Values appended successfully');
|
|
7601
7556
|
return result;
|
|
7602
7557
|
|
|
7603
7558
|
} catch (error) {
|
|
@@ -7654,7 +7609,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7654
7609
|
return { success: false, error: result.message || 'Union failed' };
|
|
7655
7610
|
}
|
|
7656
7611
|
|
|
7657
|
-
console.log('✅ [People] Values unioned successfully');
|
|
7658
7612
|
return result;
|
|
7659
7613
|
|
|
7660
7614
|
} catch (error) {
|
|
@@ -7711,7 +7665,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7711
7665
|
return { success: false, error: result.message || 'Remove failed' };
|
|
7712
7666
|
}
|
|
7713
7667
|
|
|
7714
|
-
console.log('✅ [People] Values removed successfully');
|
|
7715
7668
|
return result;
|
|
7716
7669
|
|
|
7717
7670
|
} catch (error) {
|
|
@@ -7763,7 +7716,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7763
7716
|
return { success: false, error: result.message || 'TrackCharge failed' };
|
|
7764
7717
|
}
|
|
7765
7718
|
|
|
7766
|
-
console.log('✅ [People] Charge tracked successfully');
|
|
7767
7719
|
return result;
|
|
7768
7720
|
|
|
7769
7721
|
} catch (error) {
|
|
@@ -7806,7 +7758,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7806
7758
|
return { success: false, error: result.message || 'ClearCharges failed' };
|
|
7807
7759
|
}
|
|
7808
7760
|
|
|
7809
|
-
console.log('✅ [People] Charges cleared successfully');
|
|
7810
7761
|
return result;
|
|
7811
7762
|
|
|
7812
7763
|
} catch (error) {
|
|
@@ -7849,8 +7800,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7849
7800
|
return { success: false, error: result.message || 'DeleteUser failed' };
|
|
7850
7801
|
}
|
|
7851
7802
|
|
|
7852
|
-
console.log('✅ [People] User deleted successfully');
|
|
7853
|
-
|
|
7854
7803
|
// Clear local storage after successful deletion
|
|
7855
7804
|
StorageManager.clearSession();
|
|
7856
7805
|
StorageManager.clearUserId();
|
package/lib/umd/index.js
CHANGED
|
@@ -435,12 +435,7 @@
|
|
|
435
435
|
sessionData.utm_id = persistentData.utm_id;
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
|
|
439
|
-
wallet_address: sessionData.wallet_address,
|
|
440
|
-
is_web3_user: sessionData.is_web3_user,
|
|
441
|
-
referrer: sessionData.referrer,
|
|
442
|
-
utm_source: sessionData.utm_source
|
|
443
|
-
});
|
|
438
|
+
// Session-specific persistent data restored successfully (wallet, web3 status, referrer, UTM source)
|
|
444
439
|
|
|
445
440
|
} catch (err) {
|
|
446
441
|
console.warn('Failed to restore session-specific persistent data:', err);
|
|
@@ -464,11 +459,9 @@
|
|
|
464
459
|
if (currentSessionId) {
|
|
465
460
|
const sessionKey = `${CONFIG.STORAGE_KEYS.PERSISTENT_DATA}_${currentSessionId}`;
|
|
466
461
|
localStorage.removeItem(sessionKey);
|
|
467
|
-
console.log(`✅ Cleared session-specific persistent data for session ${currentSessionId}`);
|
|
468
462
|
} else {
|
|
469
463
|
// Fallback: clear old global persistent data if session ID not available
|
|
470
464
|
localStorage.removeItem(CONFIG.STORAGE_KEYS.PERSISTENT_DATA);
|
|
471
|
-
console.log('✅ Cleared global persistent data from localStorage');
|
|
472
465
|
}
|
|
473
466
|
} catch (err) {
|
|
474
467
|
console.warn('Failed to clear persistent data:', err);
|
|
@@ -499,8 +492,6 @@
|
|
|
499
492
|
keysToRemove.forEach(key => {
|
|
500
493
|
localStorage.removeItem(key);
|
|
501
494
|
});
|
|
502
|
-
|
|
503
|
-
console.log(`✅ Cleared all persistent data (${keysToRemove.length} keys removed)`);
|
|
504
495
|
} catch (err) {
|
|
505
496
|
console.warn('Failed to clear all persistent data:', err);
|
|
506
497
|
}
|
|
@@ -807,7 +798,6 @@
|
|
|
807
798
|
_cachedDistinctId = distinctId;
|
|
808
799
|
|
|
809
800
|
const type = distinctId.startsWith('anon_') ? 'anonymous' : 'identified';
|
|
810
|
-
console.log(`✅ [Storage] Stored ${type} distinct_id in localStorage and sessionStorage: ${distinctId}`);
|
|
811
801
|
} catch (err) {
|
|
812
802
|
console.warn('Failed to set distinct_id:', err);
|
|
813
803
|
}
|
|
@@ -2323,7 +2313,6 @@
|
|
|
2323
2313
|
}
|
|
2324
2314
|
} catch (error) {
|
|
2325
2315
|
// API may not be available or user denied permission
|
|
2326
|
-
console.debug('User-Agent Client Hints API not available:', error);
|
|
2327
2316
|
}
|
|
2328
2317
|
} else {
|
|
2329
2318
|
// Fallback: parse from user agent string
|
|
@@ -2551,16 +2540,10 @@
|
|
|
2551
2540
|
// Current address is valid - only update to another valid address
|
|
2552
2541
|
if (newIsValid) {
|
|
2553
2542
|
sessionData.wallet_address = newAddress;
|
|
2554
|
-
console.log(`🔄 Wallet address updated: ${currentAddress} → ${newAddress}`);
|
|
2555
|
-
} else {
|
|
2556
|
-
console.log(`🔒 Wallet address protected: keeping ${currentAddress} (cannot set to ${newAddress})`);
|
|
2557
2543
|
}
|
|
2558
2544
|
} else {
|
|
2559
2545
|
// Current address is not valid - can set to any value
|
|
2560
2546
|
sessionData.wallet_address = newAddress;
|
|
2561
|
-
if (newIsValid) {
|
|
2562
|
-
console.log(`✅ Wallet address set: ${newAddress}`);
|
|
2563
|
-
}
|
|
2564
2547
|
}
|
|
2565
2548
|
},
|
|
2566
2549
|
|
|
@@ -2859,8 +2842,6 @@
|
|
|
2859
2842
|
// Invalid wallet type - only set if wallet_type is not already set to a valid value
|
|
2860
2843
|
if (!sessionData.wallet_type || sessionData.wallet_type === "No Wallet Detected") {
|
|
2861
2844
|
sessionData.wallet_type = walletType;
|
|
2862
|
-
} else {
|
|
2863
|
-
console.log(`🔒 Wallet type protected: keeping ${sessionData.wallet_type} (cannot set to ${walletType})`);
|
|
2864
2845
|
}
|
|
2865
2846
|
}
|
|
2866
2847
|
// Update chain_name with immutability protection
|
|
@@ -2872,8 +2853,6 @@
|
|
|
2872
2853
|
// Invalid chain name - only set if chain_name is not already set to a valid value
|
|
2873
2854
|
if (!sessionData.chain_name || sessionData.chain_name === "Not Connected") {
|
|
2874
2855
|
sessionData.chain_name = chainName;
|
|
2875
|
-
} else {
|
|
2876
|
-
console.log(`🔒 Chain name protected: keeping ${sessionData.chain_name} (cannot set to ${chainName})`);
|
|
2877
2856
|
}
|
|
2878
2857
|
}
|
|
2879
2858
|
// Keep is_web3_user as true if it's already true or if we detect a wallet
|
|
@@ -3160,7 +3139,6 @@
|
|
|
3160
3139
|
} else {
|
|
3161
3140
|
// Wallet disconnected - but protect wallet_address, chain_name, and wallet_type from becoming null/placeholder
|
|
3162
3141
|
// Keep the last known values for session consistency
|
|
3163
|
-
console.log('🔒 Wallet disconnected but keeping wallet data for session consistency');
|
|
3164
3142
|
sessionData.wallet_connected = false;
|
|
3165
3143
|
// Do NOT set wallet_address, chain_name, or wallet_type to null/placeholder - keep them for session attribution
|
|
3166
3144
|
// The updateWalletInfo() method already has immutability protection, so we don't need to call it here
|
|
@@ -5716,15 +5694,9 @@
|
|
|
5716
5694
|
// Save session to storage
|
|
5717
5695
|
StorageManager.saveSession(sessionData);
|
|
5718
5696
|
|
|
5719
|
-
// Always sync distinctId from storage before
|
|
5697
|
+
// Always sync distinctId from storage before sending to ensure consistency
|
|
5720
5698
|
sessionData.distinctId = StorageManager.getDistinctId();
|
|
5721
5699
|
|
|
5722
|
-
// Console log raw session data intermittently
|
|
5723
|
-
console.log('📊 [Session] Raw Session Data:', {
|
|
5724
|
-
sessionData: sessionData,
|
|
5725
|
-
storedSession: storedSession
|
|
5726
|
-
});
|
|
5727
|
-
|
|
5728
5700
|
// Send session data
|
|
5729
5701
|
await APIClient.sendSessionData();
|
|
5730
5702
|
} catch (error) {
|
|
@@ -6445,8 +6417,6 @@
|
|
|
6445
6417
|
session.identified = true;
|
|
6446
6418
|
StorageManager.saveSession(session);
|
|
6447
6419
|
}
|
|
6448
|
-
|
|
6449
|
-
console.log(`✅ [Identity] Distinct ID updated: ${currentDistinctId} → ${result.distinctId}`);
|
|
6450
6420
|
} else if (result.merged && result.newDistinctId) {
|
|
6451
6421
|
// Fallback: use newDistinctId if distinctId not present
|
|
6452
6422
|
StorageManager.setDistinctId(result.newDistinctId);
|
|
@@ -6466,8 +6436,6 @@
|
|
|
6466
6436
|
session.identified = true;
|
|
6467
6437
|
StorageManager.saveSession(session);
|
|
6468
6438
|
}
|
|
6469
|
-
|
|
6470
|
-
console.log(`✅ [Identity] Distinct ID merged: ${currentDistinctId} → ${result.newDistinctId}`);
|
|
6471
6439
|
} else {
|
|
6472
6440
|
console.warn('⚠️ [Identity] No distinctId or newDistinctId in response:', result);
|
|
6473
6441
|
}
|
|
@@ -6566,8 +6534,6 @@
|
|
|
6566
6534
|
// Ignore errors
|
|
6567
6535
|
}
|
|
6568
6536
|
|
|
6569
|
-
console.log(`🔄 [Identity] Reset to anonymous: ${newDistinctId}`);
|
|
6570
|
-
|
|
6571
6537
|
return { success: true, distinctId: newDistinctId };
|
|
6572
6538
|
} catch (error) {
|
|
6573
6539
|
console.error('❌ [Identity] Error in reset():', error);
|
|
@@ -6623,8 +6589,6 @@
|
|
|
6623
6589
|
StorageManager.updateBackup({ id: sessionData.sessionId, userId: sessionData.userId });
|
|
6624
6590
|
// That's it - session sync will pick it up automatically, just like automatic detection
|
|
6625
6591
|
|
|
6626
|
-
console.log(`✅ [Identity] Wallet address set in sessionData: ${trimmedWalletAddress}`);
|
|
6627
|
-
|
|
6628
6592
|
// Get current distinct_id
|
|
6629
6593
|
const currentDistinctId = StorageManager.getDistinctId();
|
|
6630
6594
|
|
|
@@ -6671,12 +6635,8 @@
|
|
|
6671
6635
|
|
|
6672
6636
|
// Update userSession
|
|
6673
6637
|
userSession.userId = result.newUserId;
|
|
6674
|
-
|
|
6675
|
-
console.log(`✅ [Identity] User merged via wallet: ${currentUserId} → ${result.newUserId}`);
|
|
6676
6638
|
}
|
|
6677
6639
|
|
|
6678
|
-
console.log(`✅ [Identity] Wallet address set: ${trimmedWalletAddress}`);
|
|
6679
|
-
|
|
6680
6640
|
return result;
|
|
6681
6641
|
} catch (error) {
|
|
6682
6642
|
console.error('❌ [Identity] Error in walletAddress():', error);
|
|
@@ -7389,7 +7349,6 @@
|
|
|
7389
7349
|
return { success: false, error: result.message || 'Set failed' };
|
|
7390
7350
|
}
|
|
7391
7351
|
|
|
7392
|
-
console.log('✅ [People] Properties set successfully');
|
|
7393
7352
|
return result;
|
|
7394
7353
|
|
|
7395
7354
|
} catch (error) {
|
|
@@ -7439,7 +7398,6 @@
|
|
|
7439
7398
|
return { success: false, error: result.message || 'SetOnce failed' };
|
|
7440
7399
|
}
|
|
7441
7400
|
|
|
7442
|
-
console.log('✅ [People] Properties set once successfully');
|
|
7443
7401
|
return result;
|
|
7444
7402
|
|
|
7445
7403
|
} catch (error) {
|
|
@@ -7489,7 +7447,6 @@
|
|
|
7489
7447
|
return { success: false, error: result.message || 'Unset failed' };
|
|
7490
7448
|
}
|
|
7491
7449
|
|
|
7492
|
-
console.log('✅ [People] Properties unset successfully');
|
|
7493
7450
|
return result;
|
|
7494
7451
|
|
|
7495
7452
|
} catch (error) {
|
|
@@ -7546,7 +7503,6 @@
|
|
|
7546
7503
|
return { success: false, error: result.message || 'Increment failed' };
|
|
7547
7504
|
}
|
|
7548
7505
|
|
|
7549
|
-
console.log('✅ [People] Property incremented successfully');
|
|
7550
7506
|
return result;
|
|
7551
7507
|
|
|
7552
7508
|
} catch (error) {
|
|
@@ -7603,7 +7559,6 @@
|
|
|
7603
7559
|
return { success: false, error: result.message || 'Append failed' };
|
|
7604
7560
|
}
|
|
7605
7561
|
|
|
7606
|
-
console.log('✅ [People] Values appended successfully');
|
|
7607
7562
|
return result;
|
|
7608
7563
|
|
|
7609
7564
|
} catch (error) {
|
|
@@ -7660,7 +7615,6 @@
|
|
|
7660
7615
|
return { success: false, error: result.message || 'Union failed' };
|
|
7661
7616
|
}
|
|
7662
7617
|
|
|
7663
|
-
console.log('✅ [People] Values unioned successfully');
|
|
7664
7618
|
return result;
|
|
7665
7619
|
|
|
7666
7620
|
} catch (error) {
|
|
@@ -7717,7 +7671,6 @@
|
|
|
7717
7671
|
return { success: false, error: result.message || 'Remove failed' };
|
|
7718
7672
|
}
|
|
7719
7673
|
|
|
7720
|
-
console.log('✅ [People] Values removed successfully');
|
|
7721
7674
|
return result;
|
|
7722
7675
|
|
|
7723
7676
|
} catch (error) {
|
|
@@ -7769,7 +7722,6 @@
|
|
|
7769
7722
|
return { success: false, error: result.message || 'TrackCharge failed' };
|
|
7770
7723
|
}
|
|
7771
7724
|
|
|
7772
|
-
console.log('✅ [People] Charge tracked successfully');
|
|
7773
7725
|
return result;
|
|
7774
7726
|
|
|
7775
7727
|
} catch (error) {
|
|
@@ -7812,7 +7764,6 @@
|
|
|
7812
7764
|
return { success: false, error: result.message || 'ClearCharges failed' };
|
|
7813
7765
|
}
|
|
7814
7766
|
|
|
7815
|
-
console.log('✅ [People] Charges cleared successfully');
|
|
7816
7767
|
return result;
|
|
7817
7768
|
|
|
7818
7769
|
} catch (error) {
|
|
@@ -7855,8 +7806,6 @@
|
|
|
7855
7806
|
return { success: false, error: result.message || 'DeleteUser failed' };
|
|
7856
7807
|
}
|
|
7857
7808
|
|
|
7858
|
-
console.log('✅ [People] User deleted successfully');
|
|
7859
|
-
|
|
7860
7809
|
// Clear local storage after successful deletion
|
|
7861
7810
|
StorageManager.clearSession();
|
|
7862
7811
|
StorageManager.clearUserId();
|
package/package.json
CHANGED