cryptique-sdk 1.1.8 → 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 +139 -67
- package/lib/esm/index.js +139 -67
- package/lib/umd/index.js +139 -67
- 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) {
|
|
@@ -6063,6 +6035,30 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6063
6035
|
}
|
|
6064
6036
|
}
|
|
6065
6037
|
|
|
6038
|
+
// Build auto_event_data for custom events (heatmap/position context when possible)
|
|
6039
|
+
let customAutoEventData = {};
|
|
6040
|
+
if (typeof window !== 'undefined' && window.document) {
|
|
6041
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
6042
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
6043
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
6044
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
6045
|
+
customAutoEventData = {
|
|
6046
|
+
scroll_x: scrollX,
|
|
6047
|
+
scroll_y: scrollY,
|
|
6048
|
+
document_height: docHeight,
|
|
6049
|
+
document_width: docWidth
|
|
6050
|
+
};
|
|
6051
|
+
const srcEvent = options.sourceEvent;
|
|
6052
|
+
if (srcEvent && typeof srcEvent === 'object' && (srcEvent.pageX != null || srcEvent.clientX != null)) {
|
|
6053
|
+
customAutoEventData.page_x = srcEvent.pageX != null ? srcEvent.pageX : (srcEvent.clientX + (window.scrollX || window.pageXOffset || 0));
|
|
6054
|
+
customAutoEventData.page_y = srcEvent.pageY != null ? srcEvent.pageY : (srcEvent.clientY + (window.scrollY || window.pageYOffset || 0));
|
|
6055
|
+
customAutoEventData.click_coordinates = {
|
|
6056
|
+
x: srcEvent.clientX != null ? srcEvent.clientX : srcEvent.pageX - (window.scrollX || window.pageXOffset || 0),
|
|
6057
|
+
y: srcEvent.clientY != null ? srcEvent.clientY : srcEvent.pageY - (window.scrollY || window.pageYOffset || 0)
|
|
6058
|
+
};
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
|
|
6066
6062
|
// Prepare event data
|
|
6067
6063
|
const eventData = {
|
|
6068
6064
|
event_type: 'custom',
|
|
@@ -6072,6 +6068,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6072
6068
|
user_id: userId,
|
|
6073
6069
|
// Only include user-provided properties in custom_properties (filtered)
|
|
6074
6070
|
custom_properties: filteredProperties,
|
|
6071
|
+
auto_event_data: customAutoEventData,
|
|
6075
6072
|
// Page context and screen/viewport data go in page_data (not custom_properties)
|
|
6076
6073
|
page_data: {
|
|
6077
6074
|
current_url: window.location.href,
|
|
@@ -6416,8 +6413,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6416
6413
|
session.identified = true;
|
|
6417
6414
|
StorageManager.saveSession(session);
|
|
6418
6415
|
}
|
|
6419
|
-
|
|
6420
|
-
console.log(`✅ [Identity] Distinct ID updated: ${currentDistinctId} → ${result.distinctId}`);
|
|
6421
6416
|
} else if (result.merged && result.newDistinctId) {
|
|
6422
6417
|
// Fallback: use newDistinctId if distinctId not present
|
|
6423
6418
|
StorageManager.setDistinctId(result.newDistinctId);
|
|
@@ -6437,8 +6432,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6437
6432
|
session.identified = true;
|
|
6438
6433
|
StorageManager.saveSession(session);
|
|
6439
6434
|
}
|
|
6440
|
-
|
|
6441
|
-
console.log(`✅ [Identity] Distinct ID merged: ${currentDistinctId} → ${result.newDistinctId}`);
|
|
6442
6435
|
} else {
|
|
6443
6436
|
console.warn('⚠️ [Identity] No distinctId or newDistinctId in response:', result);
|
|
6444
6437
|
}
|
|
@@ -6537,8 +6530,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6537
6530
|
// Ignore errors
|
|
6538
6531
|
}
|
|
6539
6532
|
|
|
6540
|
-
console.log(`🔄 [Identity] Reset to anonymous: ${newDistinctId}`);
|
|
6541
|
-
|
|
6542
6533
|
return { success: true, distinctId: newDistinctId };
|
|
6543
6534
|
} catch (error) {
|
|
6544
6535
|
console.error('❌ [Identity] Error in reset():', error);
|
|
@@ -6594,8 +6585,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6594
6585
|
StorageManager.updateBackup({ id: sessionData.sessionId, userId: sessionData.userId });
|
|
6595
6586
|
// That's it - session sync will pick it up automatically, just like automatic detection
|
|
6596
6587
|
|
|
6597
|
-
console.log(`✅ [Identity] Wallet address set in sessionData: ${trimmedWalletAddress}`);
|
|
6598
|
-
|
|
6599
6588
|
// Get current distinct_id
|
|
6600
6589
|
const currentDistinctId = StorageManager.getDistinctId();
|
|
6601
6590
|
|
|
@@ -6642,12 +6631,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6642
6631
|
|
|
6643
6632
|
// Update userSession
|
|
6644
6633
|
userSession.userId = result.newUserId;
|
|
6645
|
-
|
|
6646
|
-
console.log(`✅ [Identity] User merged via wallet: ${currentUserId} → ${result.newUserId}`);
|
|
6647
6634
|
}
|
|
6648
6635
|
|
|
6649
|
-
console.log(`✅ [Identity] Wallet address set: ${trimmedWalletAddress}`);
|
|
6650
|
-
|
|
6651
6636
|
return result;
|
|
6652
6637
|
} catch (error) {
|
|
6653
6638
|
console.error('❌ [Identity] Error in walletAddress():', error);
|
|
@@ -6886,7 +6871,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6886
6871
|
if (element === lastClickElement && now - lastClickTime < 1000) {
|
|
6887
6872
|
clickCount++;
|
|
6888
6873
|
if (clickCount >= 3) {
|
|
6874
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
6875
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
6876
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
6877
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
6889
6878
|
EventsManager.trackAutoEvent('rage_click', {
|
|
6879
|
+
click_coordinates: { x: event.clientX, y: event.clientY },
|
|
6880
|
+
page_x: event.pageX,
|
|
6881
|
+
page_y: event.pageY,
|
|
6882
|
+
scroll_x: scrollX,
|
|
6883
|
+
scroll_y: scrollY,
|
|
6884
|
+
document_height: docHeight,
|
|
6885
|
+
document_width: docWidth,
|
|
6890
6886
|
click_count: clickCount,
|
|
6891
6887
|
time_span: now - lastClickTime,
|
|
6892
6888
|
element_area: element.offsetWidth * element.offsetHeight,
|
|
@@ -7004,11 +7000,17 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7004
7000
|
|
|
7005
7001
|
if (scrollDepth > maxScrollDepth) {
|
|
7006
7002
|
maxScrollDepth = scrollDepth;
|
|
7007
|
-
|
|
7003
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
7004
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
7005
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
7008
7006
|
EventsManager.trackAutoEvent('page_scroll', {
|
|
7009
7007
|
scroll_depth: scrollDepth,
|
|
7010
7008
|
max_scroll_reached: maxScrollDepth,
|
|
7011
|
-
scroll_position: window.scrollY
|
|
7009
|
+
scroll_position: window.scrollY,
|
|
7010
|
+
scroll_x: scrollX,
|
|
7011
|
+
scroll_y: window.scrollY,
|
|
7012
|
+
document_height: docHeight,
|
|
7013
|
+
document_width: docWidth
|
|
7012
7014
|
}).catch(err => {
|
|
7013
7015
|
console.error('❌ [AutoEvents] Failed to track page_scroll:', err);
|
|
7014
7016
|
});
|
|
@@ -7026,10 +7028,24 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7026
7028
|
document.addEventListener('submit', (event) => {
|
|
7027
7029
|
const form = event.target;
|
|
7028
7030
|
if (form.tagName === 'FORM') {
|
|
7031
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
7032
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
7033
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
7034
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
7035
|
+
const rect = form.getBoundingClientRect();
|
|
7036
|
+
const pageX = rect.left + scrollX;
|
|
7037
|
+
const pageY = rect.top + scrollY;
|
|
7029
7038
|
EventsManager.trackAutoEvent('form_submit', {
|
|
7030
7039
|
form_id: form.id || null,
|
|
7031
7040
|
form_action: form.action || null,
|
|
7032
|
-
form_method: form.method || 'get'
|
|
7041
|
+
form_method: form.method || 'get',
|
|
7042
|
+
scroll_x: scrollX,
|
|
7043
|
+
scroll_y: scrollY,
|
|
7044
|
+
document_height: docHeight,
|
|
7045
|
+
document_width: docWidth,
|
|
7046
|
+
page_x: pageX,
|
|
7047
|
+
page_y: pageY,
|
|
7048
|
+
click_coordinates: { x: event.clientX != null ? event.clientX : rect.left + rect.width / 2, y: event.clientY != null ? event.clientY : rect.top + rect.height / 2 }
|
|
7033
7049
|
}, {
|
|
7034
7050
|
element_tag_name: 'form',
|
|
7035
7051
|
element_id: form.id || null,
|
|
@@ -7038,8 +7054,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7038
7054
|
element_type: form.method || 'get', // FIX: Added element_type (form method)
|
|
7039
7055
|
element_text: form.textContent?.trim().substring(0, 100) || null, // FIX: Added element_text
|
|
7040
7056
|
element_position: { // FIX: Added element_position
|
|
7041
|
-
x: event.clientX ||
|
|
7042
|
-
y: event.clientY ||
|
|
7057
|
+
x: event.clientX || rect.left,
|
|
7058
|
+
y: event.clientY || rect.top,
|
|
7043
7059
|
width: form.offsetWidth || 0,
|
|
7044
7060
|
height: form.offsetHeight || 0
|
|
7045
7061
|
}
|
|
@@ -7051,10 +7067,24 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7051
7067
|
document.addEventListener('focus', (event) => {
|
|
7052
7068
|
const element = event.target;
|
|
7053
7069
|
if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA' || element.tagName === 'SELECT') {
|
|
7070
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
7071
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
7072
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
7073
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
7074
|
+
const rect = element.getBoundingClientRect();
|
|
7075
|
+
const pageX = rect.left + scrollX;
|
|
7076
|
+
const pageY = rect.top + scrollY;
|
|
7054
7077
|
EventsManager.trackAutoEvent('form_focus', {
|
|
7055
7078
|
field_name: element.name || null,
|
|
7056
7079
|
field_type: element.type || null,
|
|
7057
|
-
field_id: element.id || null
|
|
7080
|
+
field_id: element.id || null,
|
|
7081
|
+
scroll_x: scrollX,
|
|
7082
|
+
scroll_y: scrollY,
|
|
7083
|
+
document_height: docHeight,
|
|
7084
|
+
document_width: docWidth,
|
|
7085
|
+
page_x: pageX,
|
|
7086
|
+
page_y: pageY,
|
|
7087
|
+
click_coordinates: { x: event.clientX != null ? event.clientX : rect.left + rect.width / 2, y: event.clientY != null ? event.clientY : rect.top + rect.height / 2 }
|
|
7058
7088
|
}, {
|
|
7059
7089
|
element_tag_name: element.tagName.toLowerCase(),
|
|
7060
7090
|
element_id: element.id || null,
|
|
@@ -7063,8 +7093,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7063
7093
|
element_type: element.type || null,
|
|
7064
7094
|
element_text: element.value ? element.value.toString().trim().substring(0, 100) : null, // FIX: Added element_text (value for form fields)
|
|
7065
7095
|
element_position: { // FIX: Added element_position
|
|
7066
|
-
x: event.clientX
|
|
7067
|
-
y: event.clientY
|
|
7096
|
+
x: event.clientX != null ? event.clientX : rect.left,
|
|
7097
|
+
y: event.clientY != null ? event.clientY : rect.top,
|
|
7068
7098
|
width: element.offsetWidth || 0,
|
|
7069
7099
|
height: element.offsetHeight || 0
|
|
7070
7100
|
}
|
|
@@ -7077,23 +7107,54 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7077
7107
|
* Setup media tracking
|
|
7078
7108
|
*/
|
|
7079
7109
|
setupMediaTracking() {
|
|
7110
|
+
function getPageContext() {
|
|
7111
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
7112
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
7113
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
7114
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
7115
|
+
return { scrollX, scrollY, docHeight, docWidth };
|
|
7116
|
+
}
|
|
7080
7117
|
['video', 'audio'].forEach(mediaType => {
|
|
7081
7118
|
document.addEventListener('play', (event) => {
|
|
7082
7119
|
if (event.target.tagName.toLowerCase() === mediaType) {
|
|
7120
|
+
const el = event.target;
|
|
7121
|
+
const { scrollX, scrollY, docHeight, docWidth } = getPageContext();
|
|
7122
|
+
const rect = el.getBoundingClientRect();
|
|
7123
|
+
const pageX = rect.left + scrollX;
|
|
7124
|
+
const pageY = rect.top + scrollY;
|
|
7083
7125
|
EventsManager.trackAutoEvent('media_play', {
|
|
7084
7126
|
media_type: mediaType,
|
|
7085
|
-
media_src:
|
|
7086
|
-
media_duration:
|
|
7127
|
+
media_src: el.src || null,
|
|
7128
|
+
media_duration: el.duration || null,
|
|
7129
|
+
scroll_x: scrollX,
|
|
7130
|
+
scroll_y: scrollY,
|
|
7131
|
+
document_height: docHeight,
|
|
7132
|
+
document_width: docWidth,
|
|
7133
|
+
page_x: pageX,
|
|
7134
|
+
page_y: pageY,
|
|
7135
|
+
click_coordinates: { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
7087
7136
|
});
|
|
7088
7137
|
}
|
|
7089
7138
|
}, true);
|
|
7090
7139
|
|
|
7091
7140
|
document.addEventListener('pause', (event) => {
|
|
7092
7141
|
if (event.target.tagName.toLowerCase() === mediaType) {
|
|
7142
|
+
const el = event.target;
|
|
7143
|
+
const { scrollX, scrollY, docHeight, docWidth } = getPageContext();
|
|
7144
|
+
const rect = el.getBoundingClientRect();
|
|
7145
|
+
const pageX = rect.left + scrollX;
|
|
7146
|
+
const pageY = rect.top + scrollY;
|
|
7093
7147
|
EventsManager.trackAutoEvent('media_pause', {
|
|
7094
7148
|
media_type: mediaType,
|
|
7095
|
-
media_current_time:
|
|
7096
|
-
media_duration:
|
|
7149
|
+
media_current_time: el.currentTime || null,
|
|
7150
|
+
media_duration: el.duration || null,
|
|
7151
|
+
scroll_x: scrollX,
|
|
7152
|
+
scroll_y: scrollY,
|
|
7153
|
+
document_height: docHeight,
|
|
7154
|
+
document_width: docWidth,
|
|
7155
|
+
page_x: pageX,
|
|
7156
|
+
page_y: pageY,
|
|
7157
|
+
click_coordinates: { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
7097
7158
|
});
|
|
7098
7159
|
}
|
|
7099
7160
|
}, true);
|
|
@@ -7175,11 +7236,33 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7175
7236
|
focus_offset: selection.focusOffset || null
|
|
7176
7237
|
};
|
|
7177
7238
|
|
|
7178
|
-
// Get page context
|
|
7239
|
+
// Get page context and selection position for heatmaps
|
|
7240
|
+
const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
|
|
7241
|
+
const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
|
|
7242
|
+
const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
7243
|
+
const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
|
|
7244
|
+
let pageX = null;
|
|
7245
|
+
let pageY = null;
|
|
7246
|
+
if (range) {
|
|
7247
|
+
try {
|
|
7248
|
+
const selRect = range.getBoundingClientRect();
|
|
7249
|
+
if (selRect.width > 0 || selRect.height > 0) {
|
|
7250
|
+
pageX = selRect.left + scrollX;
|
|
7251
|
+
pageY = selRect.top + scrollY;
|
|
7252
|
+
}
|
|
7253
|
+
} catch (e) { /* getBoundingClientRect can throw in some edge cases */ }
|
|
7254
|
+
}
|
|
7179
7255
|
const pageData = {
|
|
7180
7256
|
page_url: window.location.href,
|
|
7181
7257
|
page_title: document.title,
|
|
7182
|
-
page_path: window.location.pathname
|
|
7258
|
+
page_path: window.location.pathname,
|
|
7259
|
+
scroll_x: scrollX,
|
|
7260
|
+
scroll_y: scrollY,
|
|
7261
|
+
document_height: docHeight,
|
|
7262
|
+
document_width: docWidth,
|
|
7263
|
+
page_x: pageX,
|
|
7264
|
+
page_y: pageY,
|
|
7265
|
+
click_coordinates: pageX != null && pageY != null ? { x: pageX - scrollX, y: pageY - scrollY } : null
|
|
7183
7266
|
};
|
|
7184
7267
|
|
|
7185
7268
|
EventsManager.trackAutoEvent('text_selection', {
|
|
@@ -7262,7 +7345,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7262
7345
|
return { success: false, error: result.message || 'Set failed' };
|
|
7263
7346
|
}
|
|
7264
7347
|
|
|
7265
|
-
console.log('✅ [People] Properties set successfully');
|
|
7266
7348
|
return result;
|
|
7267
7349
|
|
|
7268
7350
|
} catch (error) {
|
|
@@ -7312,7 +7394,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7312
7394
|
return { success: false, error: result.message || 'SetOnce failed' };
|
|
7313
7395
|
}
|
|
7314
7396
|
|
|
7315
|
-
console.log('✅ [People] Properties set once successfully');
|
|
7316
7397
|
return result;
|
|
7317
7398
|
|
|
7318
7399
|
} catch (error) {
|
|
@@ -7362,7 +7443,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7362
7443
|
return { success: false, error: result.message || 'Unset failed' };
|
|
7363
7444
|
}
|
|
7364
7445
|
|
|
7365
|
-
console.log('✅ [People] Properties unset successfully');
|
|
7366
7446
|
return result;
|
|
7367
7447
|
|
|
7368
7448
|
} catch (error) {
|
|
@@ -7419,7 +7499,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7419
7499
|
return { success: false, error: result.message || 'Increment failed' };
|
|
7420
7500
|
}
|
|
7421
7501
|
|
|
7422
|
-
console.log('✅ [People] Property incremented successfully');
|
|
7423
7502
|
return result;
|
|
7424
7503
|
|
|
7425
7504
|
} catch (error) {
|
|
@@ -7476,7 +7555,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7476
7555
|
return { success: false, error: result.message || 'Append failed' };
|
|
7477
7556
|
}
|
|
7478
7557
|
|
|
7479
|
-
console.log('✅ [People] Values appended successfully');
|
|
7480
7558
|
return result;
|
|
7481
7559
|
|
|
7482
7560
|
} catch (error) {
|
|
@@ -7533,7 +7611,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7533
7611
|
return { success: false, error: result.message || 'Union failed' };
|
|
7534
7612
|
}
|
|
7535
7613
|
|
|
7536
|
-
console.log('✅ [People] Values unioned successfully');
|
|
7537
7614
|
return result;
|
|
7538
7615
|
|
|
7539
7616
|
} catch (error) {
|
|
@@ -7590,7 +7667,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7590
7667
|
return { success: false, error: result.message || 'Remove failed' };
|
|
7591
7668
|
}
|
|
7592
7669
|
|
|
7593
|
-
console.log('✅ [People] Values removed successfully');
|
|
7594
7670
|
return result;
|
|
7595
7671
|
|
|
7596
7672
|
} catch (error) {
|
|
@@ -7642,7 +7718,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7642
7718
|
return { success: false, error: result.message || 'TrackCharge failed' };
|
|
7643
7719
|
}
|
|
7644
7720
|
|
|
7645
|
-
console.log('✅ [People] Charge tracked successfully');
|
|
7646
7721
|
return result;
|
|
7647
7722
|
|
|
7648
7723
|
} catch (error) {
|
|
@@ -7685,7 +7760,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7685
7760
|
return { success: false, error: result.message || 'ClearCharges failed' };
|
|
7686
7761
|
}
|
|
7687
7762
|
|
|
7688
|
-
console.log('✅ [People] Charges cleared successfully');
|
|
7689
7763
|
return result;
|
|
7690
7764
|
|
|
7691
7765
|
} catch (error) {
|
|
@@ -7728,8 +7802,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7728
7802
|
return { success: false, error: result.message || 'DeleteUser failed' };
|
|
7729
7803
|
}
|
|
7730
7804
|
|
|
7731
|
-
console.log('✅ [People] User deleted successfully');
|
|
7732
|
-
|
|
7733
7805
|
// Clear local storage after successful deletion
|
|
7734
7806
|
StorageManager.clearSession();
|
|
7735
7807
|
StorageManager.clearUserId();
|