Skip to content

Commit

Permalink
Merge pull request #61 from mitjans/60-duplication-v-posthog-capture-…
Browse files Browse the repository at this point in the history
…event

fix: avoid duplicating events
  • Loading branch information
mitjans authored Dec 9, 2024
2 parents 3a8a4ee + 5af6844 commit 6f3d308
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/runtime/directives/v-posthog-capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import type { ObjectDirective, FunctionDirective } from 'vue';
const directive: FunctionDirective<HTMLElement, PostHogCaptureEvent | string> = (el, { value, arg }) => {
const { $clientPosthog } = useNuxtApp();

if (el.hasAttribute('posthog-listener')) return;

el.setAttribute('posthog-listener', 'true');

el.addEventListener(arg ?? 'click', () => {
if (!$clientPosthog) return;

Expand Down

0 comments on commit 6f3d308

Please sign in to comment.