diff --git a/pages/_app.tsx b/pages/_app.tsx index 2bf0bbb491..9c43d15419 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,11 +1,11 @@ -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useRouter } from "next/router"; import Script from "next/script"; import type { AppProps } from "next/app"; import { DocsContextProvider } from "layouts/DocsPage/context"; -import { posthog, sendPageview } from "utils/posthog"; +import { posthog, sendEngagedView, sendPageview } from "utils/posthog"; import { TabContextProvider } from "components/Tabs"; - +import { TrackingEvent } from "utils/tracking"; // https://larsmagnus.co/blog/how-to-optimize-custom-fonts-with-next-font // Next Font to enable zero layout shift which is hurting SEO. import localUbuntu from "next/font/local"; @@ -68,7 +68,32 @@ interface dataLayerItem { declare global { var dataLayer: dataLayerItem[]; // eslint-disable-line no-var } +const useIsEngaged = () => { + const router = useRouter(); + const [timerReached, setTimerReached] = useState(false); + const [secondPageReached, setSecondPageReached] = useState(false); + const [isEngaged, setIsEngaged] = useState(false); + + useEffect(() => { + setTimeout(() => { + setTimerReached(true); + }, 30000); + const routeChanged = () => { + setSecondPageReached(true); + }; + + router.events.on("routeChangeComplete", routeChanged); + return () => { + router.events.off("routeChangeComplete", routeChanged); + }; + }, [router.events]); + + useEffect(() => { + setIsEngaged(secondPageReached && timerReached); + }, [secondPageReached, timerReached]); + return isEngaged; +}; const Analytics = () => { return ( <> @@ -163,6 +188,45 @@ const Analytics = () => { {/* End Google Tag Manager (noscript) */} )} + {/* LinkedIn Tracking script */} + + + + {/* Quailified Script */} + +