From 72de167671f7b6ad0815140e8e0ab9e6b2660e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Mon, 31 Jul 2023 13:09:41 +0200 Subject: [PATCH 01/16] =?UTF-8?q?r=20legger=20til=20endretSituasjon=20p?= =?UTF-8?q?=C3=A5=20Amplitude=20for=20=C3=A5=20f=C3=B8lge=20de=20som=20har?= =?UTF-8?q?=20endret=20situasjonen=20sin=20etter=20registrering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/besvarelse.tsx | 10 ++++++++++ .../hent-initial-data/amplitude-provider.tsx | 9 ++++++--- src/metrics/amplitude-utils.ts | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index 6b26405b..d941be8f 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -1,6 +1,7 @@ import { createContext, ReactNode, useContext, useEffect, useState } from 'react'; import { useFeatureToggleData, FeatureToggles } from './feature-toggles'; +import { useAmplitudeData } from '../komponenter/hent-initial-data/amplitude-provider'; import { fetchToJson } from '../ducks/api-utils'; import { BESVARELSE_URL, OPPRETT_DIALOG_URL, requestConfig } from '../ducks/api'; @@ -172,6 +173,7 @@ async function opprettDialog(data: { function BesvarelseProvider(props: { children: ReactNode }) { const featureToggles = useFeatureToggleData(); + const { oppdaterAmplitudeData } = useAmplitudeData(); const [besvarelse, settBesvarelse] = useState(null); const erToggletPa = featureToggles[FeatureToggles.BRUK_ENDRING_AV_SITUASJON]; @@ -208,6 +210,14 @@ function BesvarelseProvider(props: { children: ReactNode }) { } }, [erToggletPa]); + useEffect(() => { + if (besvarelse?.erBesvarelsenEndret === true) { + oppdaterAmplitudeData({ + endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', + }); + } + }, [besvarelse]); + const contextValue = { besvarelse, lagreBesvarelse, diff --git a/src/komponenter/hent-initial-data/amplitude-provider.tsx b/src/komponenter/hent-initial-data/amplitude-provider.tsx index c2fc3695..a56c6a34 100644 --- a/src/komponenter/hent-initial-data/amplitude-provider.tsx +++ b/src/komponenter/hent-initial-data/amplitude-provider.tsx @@ -1,16 +1,18 @@ import * as React from 'react'; import { createContext, useContext } from 'react'; import ukerFraDato from '@alheimsins/uker-fra-dato'; + import { InnloggingsNiva, useAutentiseringData } from '../../contexts/autentisering'; import { DinSituasjonSvar, useBrukerregistreringData } from '../../contexts/brukerregistrering'; -import { OppfolgingContext } from '../../contexts/oppfolging'; import { useBrukerinfoData } from '../../contexts/bruker-info'; import { FeautreToggleData, useFeatureToggleData } from '../../contexts/feature-toggles'; +import { useArbeidssokerPerioder, useUnderOppfolging } from '../../contexts/arbeidssoker'; + +import { OppfolgingContext } from '../../contexts/oppfolging'; import grupperGeografiskTilknytning from '../../utils/grupper-geografisk-tilknytning'; import beregnArbeidssokerperioder from '../../lib/beregn-arbeidssokerperioder'; import dagerFraDato from '../../utils/dager-fra-dato'; import { AmplitudeData } from '../../metrics/amplitude-utils'; -import { useArbeidssokerPerioder, useUnderOppfolging } from '../../contexts/arbeidssoker'; import * as SprakValg from '../../contexts/sprak'; import beregnBrukergruppe from '../../lib/beregn-brukergruppe'; @@ -36,6 +38,7 @@ export const initialAmplitudeData: AmplitudeData = { buildTimestamp: new Date().toISOString(), erSykmeldtMedArbeidsgiver: 'ukjent', dinSituasjon: DinSituasjonSvar.INGEN_VERDI, + endretSituasjon: 'INGEN_DATA', reservasjonKRR: 'ukjent', aktiveFeatureToggles: [], sprakValgFraCookie: 'IKKE_VALGT', @@ -155,7 +158,7 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { ...data, }); }, - [amplitudeData] + [amplitudeData], ); return ( diff --git a/src/metrics/amplitude-utils.ts b/src/metrics/amplitude-utils.ts index 20a9d976..b65c10a8 100644 --- a/src/metrics/amplitude-utils.ts +++ b/src/metrics/amplitude-utils.ts @@ -1,9 +1,11 @@ // tslint:disable align no-any import amplitude from 'amplitude-js'; + import { AMPLITUDE_API_KEY_PROD, AMPLITUDE_API_KEY_TEST, AMPLITUDE_ENDPOINT } from '../utils/konstanter'; import { InnloggingsNiva } from '../contexts/autentisering'; import { erProduksjon } from '../utils/app-state-utils'; import { DinSituasjonSvar, ForeslattInnsatsgruppe } from '../contexts/brukerregistrering'; +import { PermittertSvar } from '../models/endring-av-situasjon'; import * as SprakValg from '../contexts/sprak'; import { DagpengeStatus } from '../lib/beregn-dagpenge-status'; import { AntattInaktiveringsgrunn } from '../contexts/antatt-inaktiveringsgrunn'; @@ -52,6 +54,7 @@ export type AmplitudeData = { buildTimestamp: string; erSykmeldtMedArbeidsgiver: string; dinSituasjon: DinSituasjonSvar; + endretSituasjon: 'INGEN_DATA' | 'N/A' | DinSituasjonSvar | PermittertSvar; reservasjonKRR: string; aktiveFeatureToggles: string[]; sprakValgFraCookie?: SprakValg.Sprak | 'IKKE_VALGT'; From adf4421ed587c3a6c214289963df03c2a97c933b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Mon, 31 Jul 2023 13:32:19 +0200 Subject: [PATCH 02/16] =?UTF-8?q?r=20legger=20p=C3=A5=20logging=20til=20co?= =?UTF-8?q?nsole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/besvarelse.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index d941be8f..1ca5c1e1 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -182,6 +182,7 @@ function BesvarelseProvider(props: { children: ReactNode }) { try { const oppdatertBesvarelse = await fetchToJson(BESVARELSE_URL, requestConfig()); if (oppdatertBesvarelse) { + console.log('har hentet besvarelse'); settBesvarelse(oppdatertBesvarelse as BesvarelseResponse); } } catch (error) { @@ -212,6 +213,7 @@ function BesvarelseProvider(props: { children: ReactNode }) { useEffect(() => { if (besvarelse?.erBesvarelsenEndret === true) { + console.log('besvarelsen er endret'); oppdaterAmplitudeData({ endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', }); From 33f620f41232f2fd84c5174f07f77b27247bda7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Mon, 31 Jul 2023 13:44:45 +0200 Subject: [PATCH 03/16] =?UTF-8?q?r=20legger=20p=C3=A5=20mer=20logging=20ti?= =?UTF-8?q?l=20console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/besvarelse.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index 1ca5c1e1..86878e5f 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -214,6 +214,7 @@ function BesvarelseProvider(props: { children: ReactNode }) { useEffect(() => { if (besvarelse?.erBesvarelsenEndret === true) { console.log('besvarelsen er endret'); + console.log(besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A'); oppdaterAmplitudeData({ endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', }); From c6fdcb4281b8482183f8e04df6bebfae79a14b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Mon, 31 Jul 2023 14:02:25 +0200 Subject: [PATCH 04/16] r fjerner console.log --- src/contexts/besvarelse.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index 86878e5f..d941be8f 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -182,7 +182,6 @@ function BesvarelseProvider(props: { children: ReactNode }) { try { const oppdatertBesvarelse = await fetchToJson(BESVARELSE_URL, requestConfig()); if (oppdatertBesvarelse) { - console.log('har hentet besvarelse'); settBesvarelse(oppdatertBesvarelse as BesvarelseResponse); } } catch (error) { @@ -213,8 +212,6 @@ function BesvarelseProvider(props: { children: ReactNode }) { useEffect(() => { if (besvarelse?.erBesvarelsenEndret === true) { - console.log('besvarelsen er endret'); - console.log(besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A'); oppdaterAmplitudeData({ endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', }); From 3098547f6aee17b921d023b6c107e468ba74cc93 Mon Sep 17 00:00:00 2001 From: Jostein Holje Date: Mon, 31 Jul 2023 14:04:25 +0200 Subject: [PATCH 05/16] Logg oppdaterAmplitudeData --- src/komponenter/hent-initial-data/amplitude-provider.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komponenter/hent-initial-data/amplitude-provider.tsx b/src/komponenter/hent-initial-data/amplitude-provider.tsx index a56c6a34..8508faf6 100644 --- a/src/komponenter/hent-initial-data/amplitude-provider.tsx +++ b/src/komponenter/hent-initial-data/amplitude-provider.tsx @@ -153,6 +153,7 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { const oppdaterAmplitudeData = React.useCallback( (data: Partial) => { + console.log('oppdaterer amplitude data:', data); setAmplitudeData({ ...amplitudeData, ...data, From 7c1e541b6a06f47c4b9322ca253f1d6f3ca39b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 06:46:42 +0200 Subject: [PATCH 06/16] c fjerner logging av oppdaterer amplitude --- src/komponenter/hent-initial-data/amplitude-provider.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komponenter/hent-initial-data/amplitude-provider.tsx b/src/komponenter/hent-initial-data/amplitude-provider.tsx index 8508faf6..a56c6a34 100644 --- a/src/komponenter/hent-initial-data/amplitude-provider.tsx +++ b/src/komponenter/hent-initial-data/amplitude-provider.tsx @@ -153,7 +153,6 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { const oppdaterAmplitudeData = React.useCallback( (data: Partial) => { - console.log('oppdaterer amplitude data:', data); setAmplitudeData({ ...amplitudeData, ...data, From 1112dd0ec82b22b244d05b942d237ee91c314251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 06:48:56 +0200 Subject: [PATCH 07/16] r flytter henting av amplitudeData inn i loggTabSkifte --- src/tabs/aia-tabs.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tabs/aia-tabs.tsx b/src/tabs/aia-tabs.tsx index af16aef2..c7ae5fcf 100644 --- a/src/tabs/aia-tabs.tsx +++ b/src/tabs/aia-tabs.tsx @@ -114,9 +114,8 @@ function skalViseMeldekortVarsel(meldekortData?: Data) { return meldekortForLevering.length === 1 && erInnenforTidsfrist; } const AiaTabs = () => { - const { amplitudeData } = useAmplitudeData(); - const loggTabSkifte = (tab: string) => { + const { amplitudeData } = useAmplitudeData(); loggAktivitet({ aktivitet: `Bytter til ${tab}`, komponent: 'tabs', ...amplitudeData }); }; From e8d207ce96cbf934aea5a33adf95c6b1b18c2280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 06:53:18 +0200 Subject: [PATCH 08/16] r flytter henting av amplitudeData --- src/tabs/aia-tabs.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tabs/aia-tabs.tsx b/src/tabs/aia-tabs.tsx index c7ae5fcf..d920cf55 100644 --- a/src/tabs/aia-tabs.tsx +++ b/src/tabs/aia-tabs.tsx @@ -2,6 +2,10 @@ import { Tabs } from '@navikt/ds-react'; import { HTMLProps, useEffect, useState } from 'react'; import { useAmplitudeData } from '../komponenter/hent-initial-data/amplitude-provider'; +import useHarGyldigBehovsvurdering from '../hooks/use-har-gyldig-behovsvurdering'; +import { useBeregnDagpengestatus } from '../hooks/use-beregn-dagpengestatus'; +import { Data, useMeldekortData } from '../hooks/use-meldekortdata'; +import { useProfil } from '../contexts/profil'; import RegistrertTittel from '../komponenter/registrert-tittel/registrert-tittel'; import MinSituasjon from '../komponenter/min-situasjon/min-situasjon'; @@ -10,22 +14,18 @@ import DagpengerOgYtelser from '../komponenter/dagpenger/dagpenger-og-ytelser'; import Meldekort from '../komponenter/meldekort/meldekort'; import { loggAktivitet } from '../metrics/metrics'; import { hentQueryParam, settQueryParam } from '../utils/query-param-utils'; - -import tabStyles from './tabs.module.css'; -import styles from '../innhold/innhold.module.css'; -import useHarGyldigBehovsvurdering from '../hooks/use-har-gyldig-behovsvurdering'; import { DagpengeStatus } from '../lib/beregn-dagpenge-status'; -import { useBeregnDagpengestatus } from '../hooks/use-beregn-dagpengestatus'; -import { Data, useMeldekortData } from '../hooks/use-meldekortdata'; import { datoUtenTid } from '../utils/date-utils'; import { hentIDag } from '../utils/chrono'; +import { Profil } from '../profil'; import { beregnDagerEtterFastsattMeldedag, beregnDagerTilInaktivering, hentMeldekortForLevering, } from '../utils/meldekort-utils'; -import { Profil } from '../profil'; -import { useProfil } from '../contexts/profil'; + +import tabStyles from './tabs.module.css'; +import styles from '../innhold/innhold.module.css'; const QUERY_PARAM = 'aia.aktivTab'; @@ -114,15 +114,15 @@ function skalViseMeldekortVarsel(meldekortData?: Data) { return meldekortForLevering.length === 1 && erInnenforTidsfrist; } const AiaTabs = () => { - const loggTabSkifte = (tab: string) => { - const { amplitudeData } = useAmplitudeData(); - loggAktivitet({ aktivitet: `Bytter til ${tab}`, komponent: 'tabs', ...amplitudeData }); - }; - const [aktivTab, settAktivTab] = useState(TabValue.MIN_SITUASJON); const harGyldigBehovsvurdering = useHarGyldigBehovsvurdering(); const visPengestotteVarsel = harIkkeSoktDagpenger(useBeregnDagpengestatus(), useProfil().profil); const visMeldekortVarsel = skalViseMeldekortVarsel(useMeldekortData().meldekortData); + const { amplitudeData } = useAmplitudeData(); + + const loggTabSkifte = (tab: string) => { + loggAktivitet({ aktivitet: `Bytter til ${tab}`, komponent: 'tabs', ...amplitudeData }); + }; const onChangeTab = (tab: string) => { settQueryParam(QUERY_PARAM, tab); From 0cfc29aaa0b9640f13f06f8ed3a32f2ae9b5ee0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 07:09:59 +0200 Subject: [PATCH 09/16] c logger ut amplitudeData.endretSituasjon --- src/komponenter/endre-situasjon/min-situasjon.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komponenter/endre-situasjon/min-situasjon.tsx b/src/komponenter/endre-situasjon/min-situasjon.tsx index 703ae90c..ac53f26b 100644 --- a/src/komponenter/endre-situasjon/min-situasjon.tsx +++ b/src/komponenter/endre-situasjon/min-situasjon.tsx @@ -26,7 +26,9 @@ function MinSituasjon(props: any) { const kanViseKomponent = autentiseringData.securityLevel === InnloggingsNiva.LEVEL_4; const endretStyle = erBesvarelsenEndret ? { background: 'var(--a-blue-50)' } : {}; + if (!kanViseKomponent) return null; + console.log('amplitudeData: ', amplitudeData.endretSituasjon); return ( From a5472b241c231c0ff2df59c704924240908b4feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 07:31:25 +0200 Subject: [PATCH 10/16] =?UTF-8?q?c=20logger=20n=C3=A5r=20dagpengestatus=20?= =?UTF-8?q?og=20besvarelse=20blir=20oppdatert=20i=20amplitudeData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/besvarelse.tsx | 1 + src/contexts/dagpenger-status.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index d941be8f..01ffb312 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -212,6 +212,7 @@ function BesvarelseProvider(props: { children: ReactNode }) { useEffect(() => { if (besvarelse?.erBesvarelsenEndret === true) { + console.log('oppdaterer amplitude for besvarelse'); oppdaterAmplitudeData({ endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', }); diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index 0019e8ce..5205d5ae 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -32,6 +32,7 @@ function DagpengerStatusProvider(props: { children: ReactNode }) { try { const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); settDagpengerStatus(response.dagpengerStatus); + console.log('oppdaterer amplitude for dagpengestatus'); oppdaterAmplitudeData({ dagpengerStatus: response.dagpengerStatus, antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, From 1199bb0abe04bc384aec835a8f67fb52e628ae20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 07:52:04 +0200 Subject: [PATCH 11/16] r fjerner useCallback rundt oppdaterAmplitudeData --- src/komponenter/hent-initial-data/amplitude-provider.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/komponenter/hent-initial-data/amplitude-provider.tsx b/src/komponenter/hent-initial-data/amplitude-provider.tsx index a56c6a34..1bc65b4e 100644 --- a/src/komponenter/hent-initial-data/amplitude-provider.tsx +++ b/src/komponenter/hent-initial-data/amplitude-provider.tsx @@ -151,6 +151,7 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { const [amplitudeData, setAmplitudeData] = React.useState(data); + /* const oppdaterAmplitudeData = React.useCallback( (data: Partial) => { setAmplitudeData({ @@ -160,6 +161,14 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { }, [amplitudeData], ); + */ + + const oppdaterAmplitudeData = (data: Partial) => { + setAmplitudeData({ + ...amplitudeData, + ...data, + }); + }; return ( From 202de79d73bbfb7ca593035d50172a9f06483a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 08:14:03 +0200 Subject: [PATCH 12/16] r oppdaterer alle amplitudeData fra dagpengerstatus --- src/contexts/dagpenger-status.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index 5205d5ae..c0a982cb 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -23,7 +23,7 @@ export const DagpengerStatusContext = createContext function DagpengerStatusProvider(props: { children: ReactNode }) { const { securityLevel } = useAutentiseringData(); - const { oppdaterAmplitudeData } = useAmplitudeData(); + const { amplitudeData, oppdaterAmplitudeData } = useAmplitudeData(); const [dagpengerStatus, settDagpengerStatus] = useState(null); @@ -33,16 +33,17 @@ function DagpengerStatusProvider(props: { children: ReactNode }) { const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); settDagpengerStatus(response.dagpengerStatus); console.log('oppdaterer amplitude for dagpengestatus'); - oppdaterAmplitudeData({ + const oppdaterteAmplitudeData = { dagpengerStatus: response.dagpengerStatus, antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, - }); + }; + oppdaterAmplitudeData({ ...amplitudeData, ...oppdaterteAmplitudeData }); } catch (err) {} }; if (securityLevel === InnloggingsNiva.LEVEL_4) { hentDagpengerStatus(); } - }, [securityLevel]); + }, [securityLevel, amplitudeData]); const contextValue = { dagpengerStatus, From 3f945e93fd8cc77c0174ef85b8f551e1ef07ad86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 08:22:48 +0200 Subject: [PATCH 13/16] =?UTF-8?q?r=20sl=C3=A5r=20av=20evig=20loop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/dagpenger-status.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index c0a982cb..5205d5ae 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -23,7 +23,7 @@ export const DagpengerStatusContext = createContext function DagpengerStatusProvider(props: { children: ReactNode }) { const { securityLevel } = useAutentiseringData(); - const { amplitudeData, oppdaterAmplitudeData } = useAmplitudeData(); + const { oppdaterAmplitudeData } = useAmplitudeData(); const [dagpengerStatus, settDagpengerStatus] = useState(null); @@ -33,17 +33,16 @@ function DagpengerStatusProvider(props: { children: ReactNode }) { const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); settDagpengerStatus(response.dagpengerStatus); console.log('oppdaterer amplitude for dagpengestatus'); - const oppdaterteAmplitudeData = { + oppdaterAmplitudeData({ dagpengerStatus: response.dagpengerStatus, antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, - }; - oppdaterAmplitudeData({ ...amplitudeData, ...oppdaterteAmplitudeData }); + }); } catch (err) {} }; if (securityLevel === InnloggingsNiva.LEVEL_4) { hentDagpengerStatus(); } - }, [securityLevel, amplitudeData]); + }, [securityLevel]); const contextValue = { dagpengerStatus, From 30e59f02dfc0b3b67e112c2426a51d62deb1c138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 09:12:38 +0200 Subject: [PATCH 14/16] r oppdaterer hele amplitudeData --- src/contexts/dagpenger-status.tsx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index 5205d5ae..e9e93047 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -23,26 +23,33 @@ export const DagpengerStatusContext = createContext function DagpengerStatusProvider(props: { children: ReactNode }) { const { securityLevel } = useAutentiseringData(); - const { oppdaterAmplitudeData } = useAmplitudeData(); + const { amplitudeData, oppdaterAmplitudeData } = useAmplitudeData(); const [dagpengerStatus, settDagpengerStatus] = useState(null); + const [erOppdatert, setErOppdatert] = useState(false); useEffect(() => { const hentDagpengerStatus = async () => { try { - const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); - settDagpengerStatus(response.dagpengerStatus); - console.log('oppdaterer amplitude for dagpengestatus'); - oppdaterAmplitudeData({ - dagpengerStatus: response.dagpengerStatus, - antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, - }); + if (!erOppdatert) { + const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); + settDagpengerStatus(response.dagpengerStatus); + setErOppdatert(true); + console.log('oppdaterer amplitude for dagpengestatus'); + oppdaterAmplitudeData({ + ...amplitudeData, + ...{ + dagpengerStatus: response.dagpengerStatus, + antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, + }, + }); + } } catch (err) {} }; - if (securityLevel === InnloggingsNiva.LEVEL_4) { + if (securityLevel === InnloggingsNiva.LEVEL_4 && !erOppdatert) { hentDagpengerStatus(); } - }, [securityLevel]); + }, [securityLevel, amplitudeData, erOppdatert]); const contextValue = { dagpengerStatus, From fd8964efbf73a51cf331c05031c7dbc73a09e165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 09:58:21 +0200 Subject: [PATCH 15/16] =?UTF-8?q?r=20oppdaterer=20oppdaterAmplitudeData=20?= =?UTF-8?q?til=20=C3=A5=20taimort=20en=20funksjon=20med=20amplitudeData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/dagpenger-status.tsx | 27 +++++++------------ .../hent-initial-data/amplitude-provider.tsx | 4 +-- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index e9e93047..5205d5ae 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -23,33 +23,26 @@ export const DagpengerStatusContext = createContext function DagpengerStatusProvider(props: { children: ReactNode }) { const { securityLevel } = useAutentiseringData(); - const { amplitudeData, oppdaterAmplitudeData } = useAmplitudeData(); + const { oppdaterAmplitudeData } = useAmplitudeData(); const [dagpengerStatus, settDagpengerStatus] = useState(null); - const [erOppdatert, setErOppdatert] = useState(false); useEffect(() => { const hentDagpengerStatus = async () => { try { - if (!erOppdatert) { - const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); - settDagpengerStatus(response.dagpengerStatus); - setErOppdatert(true); - console.log('oppdaterer amplitude for dagpengestatus'); - oppdaterAmplitudeData({ - ...amplitudeData, - ...{ - dagpengerStatus: response.dagpengerStatus, - antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, - }, - }); - } + const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); + settDagpengerStatus(response.dagpengerStatus); + console.log('oppdaterer amplitude for dagpengestatus'); + oppdaterAmplitudeData({ + dagpengerStatus: response.dagpengerStatus, + antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, + }); } catch (err) {} }; - if (securityLevel === InnloggingsNiva.LEVEL_4 && !erOppdatert) { + if (securityLevel === InnloggingsNiva.LEVEL_4) { hentDagpengerStatus(); } - }, [securityLevel, amplitudeData, erOppdatert]); + }, [securityLevel]); const contextValue = { dagpengerStatus, diff --git a/src/komponenter/hent-initial-data/amplitude-provider.tsx b/src/komponenter/hent-initial-data/amplitude-provider.tsx index 1bc65b4e..f470705e 100644 --- a/src/komponenter/hent-initial-data/amplitude-provider.tsx +++ b/src/komponenter/hent-initial-data/amplitude-provider.tsx @@ -164,10 +164,10 @@ const AmplitudeProvider = (props: { children: React.ReactNode }) => { */ const oppdaterAmplitudeData = (data: Partial) => { - setAmplitudeData({ + setAmplitudeData((amplitudeData) => ({ ...amplitudeData, ...data, - }); + })); }; return ( From e379cb5ce7442d33135e1e65541f3681d4b26b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Tue, 1 Aug 2023 10:24:26 +0200 Subject: [PATCH 16/16] r fjerner midlertidige console.log --- src/contexts/besvarelse.tsx | 1 - src/contexts/dagpenger-status.tsx | 1 - src/komponenter/endre-situasjon/min-situasjon.tsx | 1 - 3 files changed, 3 deletions(-) diff --git a/src/contexts/besvarelse.tsx b/src/contexts/besvarelse.tsx index 01ffb312..d941be8f 100644 --- a/src/contexts/besvarelse.tsx +++ b/src/contexts/besvarelse.tsx @@ -212,7 +212,6 @@ function BesvarelseProvider(props: { children: ReactNode }) { useEffect(() => { if (besvarelse?.erBesvarelsenEndret === true) { - console.log('oppdaterer amplitude for besvarelse'); oppdaterAmplitudeData({ endretSituasjon: besvarelse.besvarelse?.dinSituasjon?.verdi || 'N/A', }); diff --git a/src/contexts/dagpenger-status.tsx b/src/contexts/dagpenger-status.tsx index 5205d5ae..0019e8ce 100644 --- a/src/contexts/dagpenger-status.tsx +++ b/src/contexts/dagpenger-status.tsx @@ -32,7 +32,6 @@ function DagpengerStatusProvider(props: { children: ReactNode }) { try { const response: DagpengerStatusResponse = await fetchToJson(DAGPENGER_STATUS, requestConfig()); settDagpengerStatus(response.dagpengerStatus); - console.log('oppdaterer amplitude for dagpengestatus'); oppdaterAmplitudeData({ dagpengerStatus: response.dagpengerStatus, antallDagerSidenDagpengerStanset: response.antallDagerSidenDagpengerStanset, diff --git a/src/komponenter/endre-situasjon/min-situasjon.tsx b/src/komponenter/endre-situasjon/min-situasjon.tsx index ac53f26b..c76c866e 100644 --- a/src/komponenter/endre-situasjon/min-situasjon.tsx +++ b/src/komponenter/endre-situasjon/min-situasjon.tsx @@ -28,7 +28,6 @@ function MinSituasjon(props: any) { const endretStyle = erBesvarelsenEndret ? { background: 'var(--a-blue-50)' } : {}; if (!kanViseKomponent) return null; - console.log('amplitudeData: ', amplitudeData.endretSituasjon); return (