diff --git a/src/lib/components/WaterfallView.svelte b/src/lib/components/WaterfallView.svelte index 8d98b00cc09f84e2f6a6ad7ce7e75f2c2796ff74..6db85731316cb4865885cf3a6f2591dbad0cf16b 100644 --- a/src/lib/components/WaterfallView.svelte +++ b/src/lib/components/WaterfallView.svelte @@ -34,6 +34,7 @@ import type { DisplayMode } from "$lib/displays" import { entityByKey, personEntityKey } from "$lib/entities" import type { VariableCustomization, VariableGraph } from "$lib/graphes" + import { trackTestCaseGraph } from "$lib/matomo" import { type CalculationByName, getSituationVariableValue, @@ -1112,9 +1113,14 @@ {#if firstPersonActivity !== "inactif"} <button class="w-full flex items-center gap-2 text-neutral-600 text-start border-b px-4 py-2 mt-10 hover:bg-neutral-100 active:bg-neutral-200 transition-all" - on:click={situation.slider === undefined - ? requestAxesCalculation - : removeSituationSlider} + on:click={() => { + if (situation.slider === undefined) { + requestAxesCalculation() + trackTestCaseGraph(firstPersonActivity) + } else { + removeSituationSlider() + } + }} > <iconify-icon class="text-lg" icon="ri-line-chart-fill" /> <span class="flex-1 font-bold"> diff --git a/src/lib/matomo.ts b/src/lib/matomo.ts index dad243d4c508275e3cd05c64a570b72767c45d0b..12904890abeaa7bc7e18a992dbf004660f4e9758 100644 --- a/src/lib/matomo.ts +++ b/src/lib/matomo.ts @@ -1,5 +1,6 @@ import { browser } from "$app/environment" import type { ParametricReform } from "$lib/reforms" +import type { VariableValue } from "$lib/variables" function trackEvent(category: string, action: string, name: string) { if (browser) { @@ -206,3 +207,19 @@ export function trackTestCaseShowAllVariables() { export function trackTestCaseShare() { trackEvent("test_case", "share", "Partage d'une simulation cas type") } + +export function trackTestCaseGraph(activity: VariableValue | undefined) { + let variable = "revenu" + switch (activity) { + case "actif": + variable = "salaire" + break + case "retraite": + variable = "retraite" + break + case "chomeur": + variable = "chômage" + break + } + trackEvent("test_case", "show_graph", `Ouverture du graphique "${variable}"`) +}