/** * Helper functions for Hotjar * * @author [Vivek Sudarsan] * @version 0.1.0 */ import { avinaLog } from '../helpers'; export const handleHotjarIntegration = (visitorId: string) => { let tries = 0, max = 100; const interval = setInterval(() => { if (window.hj) { clearInterval(interval); avinaLog(`Hotjar loaded. Sending visitor id: ${visitorId}`); try { window.hj('identify', null, { avina_visitor_id: visitorId }); } catch (e) { console.error('Hotjar identify failed:', e); } } else if (++tries >= max) { clearInterval(interval); console.warn('Hotjar not loaded after 10s.'); } }, 100); };