diff --git a/.env.development b/.env.development index c97198d5..4ff41f4d 100644 --- a/.env.development +++ b/.env.development @@ -13,3 +13,5 @@ AMPLITUDE_API_KEY= SOKNADSDIALOG_URL=https://arbeid.intern.dev.nav.no/dagpenger/dialog NEXT_PUBLIC_LOCALHOST=true + +APP_ENV=localhost \ No newline at end of file diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 3765fb38..1445c8da 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -15,6 +15,8 @@ import { innenfor12Uker } from "../util/soknadDato.util"; import { PaabegyntSoknad, hentPaabegynteSoknader } from "./api/paabegynteSoknader"; import { Søknad, hentSoknader } from "./api/soknader"; import { UxSignalsWidget } from "../components/UxSignalsWidget"; +import { useRouter } from "next/router"; +import { useEffect } from "react"; interface Props { fullforteSoknader: Søknad[] | null; @@ -24,6 +26,7 @@ interface Props { interface IEnv { soknadsdialogIngress: string; + appEnv; uxSignals: { enabled: boolean; mode: string; @@ -81,6 +84,7 @@ export async function getServerSideProps( paabegynteSoknader, env: { soknadsdialogIngress: process.env.SOKNADSDIALOG_URL, + appEnv: process.env.APP_ENV, uxSignals: { enabled: process.env.UXSIGNALS_ENABLED === "enabled", mode: process.env.UXSIGNALS_MODE === "demo" ? "demo" : "", @@ -92,6 +96,28 @@ export async function getServerSideProps( export default function Status({ fullforteSoknader, paabegynteSoknader, env }: Props) { const { getAppText } = useSanity(); + const router = useRouter(); + + useEffect(() => { + // Task analytic Spørreundersøkelse for gammel og ny vedtaksbrev + const nyBrev = env.appEnv === "production" ? "03409" : "03400"; + const gammelBrev = env.appEnv === "production" ? "03408" : "03400"; + + setTimeout(() => { + //@ts-ignore Ukjent TA type + if (router.query && typeof window.TA === "function") { + if (router.query.brev === "ny") { + //@ts-ignore Ukjent TA type + window.TA("start", nyBrev); + } + + if (router.query.brev === "gammel") { + //@ts-ignore Ukjent TA type + window.TA("start", gammelBrev); + } + } + }, 2000); + }); return ( <>