From 4c9205d9f4a195d4c2f1b65d00fd8c5e9b322d93 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Tue, 20 Aug 2024 08:59:18 +0200 Subject: [PATCH] wip fix: make sure loginType and ECID is trackable from webviews --- components/TempDesignSystem/Link/index.tsx | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/components/TempDesignSystem/Link/index.tsx b/components/TempDesignSystem/Link/index.tsx index 1a2e46415..832d5a608 100644 --- a/components/TempDesignSystem/Link/index.tsx +++ b/components/TempDesignSystem/Link/index.tsx @@ -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 ( { + trackPageViewStart() + + startTransition(() => { + router.push(href) + console.log({ isPending }) + if (!isPending) { + console.log("Not pending anymore!") + } + }) + }} href={href} id={trackingId} {...props}