function identifyUserWithoutEmail() {
const sessionId = posthog.get_distinct_id(); // Get PostHog's session ID
const uniqueId = generateUniqueId(); // Generate a unique ID
// Capture the user in PostHog explicitly with session ID or IP
posthog.capture('Anonymous User', {
session_id: sessionId,
name: 'Anonymous User',
unique_id: uniqueId // Include the unique ID
});
// Boot Intercom using a combination of session ID and unique ID
window.Intercom('boot', {
user_id: uniqueId, // Use the unique ID as user_id
name: 'Anonymous User',
session_id: sessionId // Optionally send session_id as a custom attribute
});
console.log('Identified anonymous user with session ID:', sessionId, 'and unique ID:', uniqueId);
}
// Function to generate a unique ID
function generateUniqueId() {
return 'id-' + crypto.getRandomValues(new Uint32Array(1))[0].toString(16);
}