const events = ["mousemove", "click", "keydown"]; function handleUserInteraction() { if (!vi_id) return; fetch('/counter.json', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ vi_id: vi_id }) }) .then(res => res.json()) .then(data => console.log("Link:", data.link, "Act:", data.act)) .catch(console.error); // 모든 이벤트 리스너 제거 (한 번 실행 후 중지) events.forEach(event => document.removeEventListener(event, handleUserInteraction)); } // 각 이벤트에 대해 한 번만 실행되도록 리스너 추가 events.forEach(event => document.addEventListener(event, handleUserInteraction));