Skip to content

Commit

Permalink
fix: disable autocapture of clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Oct 29, 2024
1 parent bea0862 commit 4da2b7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-ants-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'trench-js': patch
---

Disables automatic tracking of clicks due to high event volume
21 changes: 11 additions & 10 deletions packages/trench-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ class Trench {
sendPageView();
});

window.addEventListener('click', (event) => {
const target = event.target as HTMLElement;
const eventName = target.getAttribute('data-event-name') || 'click';
this.track(eventName, {
tagName: target.tagName,
id: target.id,
className: target.className,
textContent: target.textContent,
});
});
// TODO: Re-enable automatic click tracking once auto-batching events is implemented
// window.addEventListener('click', (event) => {
// const target = event.target as HTMLElement;
// const eventName = target.getAttribute('data-event-name') || 'click';
// this.track(eventName, {
// tagName: target.tagName,
// id: target.id,
// className: target.className,
// textContent: target.textContent,
// });
// });

window.addEventListener('popstate', () => {
sendPageView();
Expand Down

0 comments on commit 4da2b7b

Please sign in to comment.