Skip to content

Commit

Permalink
Vise Task analytic spørreundersøkelse baser på Query string (#211)
Browse files Browse the repository at this point in the history
* Vise Task analytic spørreundersøkelse baser på Query string

* Legge til ekstra sjek for window.TA

* Debug TA script

* Debug TA script

* Legge til 2s timer før vi trigger TA

* Legge til riktig brev kode baster på applikasjons miljø

* Lagt til riktig TA kode for produksjon

* Oppdatert til riktig ny brevmal TA kode
  • Loading branch information
nattaphongklinjan authored Oct 21, 2024
1 parent a9afe4b commit e842643
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ AMPLITUDE_API_KEY=

SOKNADSDIALOG_URL=https://arbeid.intern.dev.nav.no/dagpenger/dialog
NEXT_PUBLIC_LOCALHOST=true

APP_ENV=localhost
26 changes: 26 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +26,7 @@ interface Props {

interface IEnv {
soknadsdialogIngress: string;
appEnv;
uxSignals: {
enabled: boolean;
mode: string;
Expand Down Expand Up @@ -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" : "",
Expand All @@ -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 (
<>
Expand Down

0 comments on commit e842643

Please sign in to comment.