fix: track user on page load
This commit is contained in:
@@ -3,6 +3,8 @@ import NextLink from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { trackClick } from "@/utils/tracking"
|
||||
|
||||
import { linkVariants } from "./variants"
|
||||
|
||||
import type { LinkProps } from "./link"
|
||||
@@ -36,11 +38,13 @@ export default function Link({
|
||||
|
||||
useEffect(() => {
|
||||
if (trackingId) {
|
||||
document.getElementById(trackingId)?.addEventListener("click", () => {})
|
||||
document
|
||||
.getElementById(trackingId)
|
||||
?.addEventListener("click", () => trackClick(trackingId))
|
||||
return () => {
|
||||
document
|
||||
.getElementById(trackingId)
|
||||
?.removeEventListener("click", () => {})
|
||||
?.removeEventListener("click", () => trackClick(trackingId))
|
||||
}
|
||||
}
|
||||
}, [trackingId])
|
||||
@@ -51,6 +55,7 @@ export default function Link({
|
||||
prefetch={prefetch}
|
||||
className={classNames}
|
||||
href={href}
|
||||
id={trackingId}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user