File: /var/www/quadcode.com/src/utils/formTracker.ts
import { browser } from "$app/environment";
export function initFormTracker() {
if (!browser) return;
if (window.__formTrackerInitialized__) {
return;
}
window.__formTrackerInitialized__ = true;
const handleInteraction = (e: Event) => {
const target = e.target as HTMLElement;
if (!['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)) return;
window.isUserFillingForm = true;
document.removeEventListener('focus', handleInteraction, { capture: true });
document.removeEventListener('input', handleInteraction, { capture: true });
};
document.addEventListener('focus', handleInteraction, { capture: true });
document.addEventListener('input', handleInteraction, { capture: true });
}