wip
fix: make sure loginType and ECID is trackable from webviews
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
import NextLink from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useCallback, useEffect } from "react"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import { useCallback, useEffect, useTransition } from "react"
|
||||
|
||||
import { trackClick } from "@/utils/tracking"
|
||||
import { trackClick, trackPageViewStart } from "@/utils/tracking"
|
||||
|
||||
import { linkVariants } from "./variants"
|
||||
|
||||
@@ -39,6 +39,9 @@ export default function Link({
|
||||
variant,
|
||||
})
|
||||
|
||||
const [isPending, startTransition] = useTransition()
|
||||
const router = useRouter()
|
||||
|
||||
const trackClickById = useCallback(() => {
|
||||
if (trackingId) {
|
||||
trackClick(trackingId)
|
||||
@@ -56,11 +59,28 @@ export default function Link({
|
||||
}
|
||||
}, [trackClickById, trackingId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPending) {
|
||||
console.log("PENDING IS DONE")
|
||||
}
|
||||
}, [isPending])
|
||||
|
||||
return (
|
||||
<NextLink
|
||||
scroll={scroll}
|
||||
prefetch={prefetch}
|
||||
className={classNames}
|
||||
onClick={() => {
|
||||
trackPageViewStart()
|
||||
|
||||
startTransition(() => {
|
||||
router.push(href)
|
||||
console.log({ isPending })
|
||||
if (!isPending) {
|
||||
console.log("Not pending anymore!")
|
||||
}
|
||||
})
|
||||
}}
|
||||
href={href}
|
||||
id={trackingId}
|
||||
{...props}
|
||||
|
||||
Reference in New Issue
Block a user