From 3ad606fb9ee6eb90f01b32b02a2f46e5c9563c59 Mon Sep 17 00:00:00 2001 From: jonat75 Date: Mon, 29 Jan 2024 16:00:34 +0100 Subject: [PATCH] fix: matomo (#2076) --- packages/app/src/app/layout.tsx | 2 +- packages/app/src/components/utils/Matomo.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/app/src/app/layout.tsx b/packages/app/src/app/layout.tsx index ad5e41984..f5c0e533c 100644 --- a/packages/app/src/app/layout.tsx +++ b/packages/app/src/app/layout.tsx @@ -67,7 +67,7 @@ const RootLayout = ({ children }: PropsWithChildren) => { - + diff --git a/packages/app/src/components/utils/Matomo.tsx b/packages/app/src/components/utils/Matomo.tsx index 8906bf897..e9a0eadf5 100644 --- a/packages/app/src/components/utils/Matomo.tsx +++ b/packages/app/src/components/utils/Matomo.tsx @@ -1,20 +1,20 @@ "use client"; -import { config } from "@common/config"; +import { type config } from "@common/config"; import { init, push } from "@socialgouv/matomo-next"; import { usePathname, useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; import { useConsent } from "../../app/consentManagement"; -export type MatomoProps = Pick & { nonce?: string }; +export type MatomoProps = Pick & Pick & { nonce?: string }; /** * Handle Matomo init and consent. * * Uses `useSearchParams()` internally, must be Suspense-d in server component. */ -export const Matomo = ({ env, nonce }: MatomoProps) => { +export const Matomo = ({ env, nonce, matomo }: MatomoProps) => { const pathname = usePathname(); const searchParams = useSearchParams(); const { finalityConsent } = useConsent(); @@ -29,7 +29,7 @@ export const Matomo = ({ env, nonce }: MatomoProps) => { if (!inited) { init({ - ...config.matomo, + ...matomo, nonce, onInitialization: () => { push(["optUserOut"]); @@ -51,7 +51,7 @@ export const Matomo = ({ env, nonce }: MatomoProps) => { push(["forgetCookieConsentGiven"]); } // eslint-disable-next-line react-hooks/exhaustive-deps -- don't listen on inited - }, [env, matomoConsent]); + }, [env, matomoConsent, matomo]); /* The @socialgouv/matomo-next does not work with next 13 */ useEffect(() => {