/**
 * Visitor Utilities
 * Generate and manage visitor IDs
 */

/**
 * Generate a unique visitor ID
 */
export function generateVisitorId(): string {
  // Try to get existing ID from localStorage
  const storageKey = 'boostbot_visitor_id';
  
  try {
    const existing = localStorage.getItem(storageKey);
    if (existing) {
      return existing;
    }
  } catch {
    // localStorage not available
  }
  
  // Generate new ID
  const timestamp = Date.now().toString(36);
  const randomPart = Math.random().toString(36).substring(2, 10);
  const visitorId = `v_${timestamp}_${randomPart}`;
  
  // Try to save to localStorage
  try {
    localStorage.setItem(storageKey, visitorId);
  } catch {
    // Ignore storage errors
  }
  
  return visitorId;
}

/**
 * Get visitor info
 */
export function getVisitorInfo() {
  return {
    userAgent: navigator.userAgent,
    language: navigator.language,
    timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
    screenSize: `${window.screen.width}x${window.screen.height}`,
    referrer: document.referrer,
    currentUrl: window.location.href
  };
}








