From b79a46e6c2dc4b6df0a8e4c1a28ecf9178af965e Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 14 Feb 2022 00:05:23 +0100 Subject: chore(matomo): use another dependency to track page views I though the previous package would track all visits with the provided but it seems that I need to add trackPageView on all pages. So I decided to use another package. --- src/pages/_app.tsx | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/pages/_app.tsx') diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 6df1a1d..6ff8e1b 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,10 +1,10 @@ -import { MatomoProvider } from '@datapunt/matomo-tracker-react'; +import * as matomo from '@socialgouv/matomo-next'; import { AppPropsWithLayout } from '@ts/types/app'; import { settings } from '@utils/config'; -import { instance } from '@utils/helpers/matomo'; import { PrismThemeProvider } from '@utils/providers/prism'; import { ThemeProvider } from 'next-themes'; import { useRouter } from 'next/router'; +import { useEffect } from 'react'; import { IntlProvider } from 'react-intl'; import '../styles/globals.scss'; @@ -12,25 +12,30 @@ const MyApp = ({ Component, pageProps }: AppPropsWithLayout) => { const { locale, defaultLocale } = useRouter(); const appLocale: string = locale || settings.locales.defaultLocale; + useEffect(() => { + matomo.init({ + url: settings.matomo.urlBase, + siteId: settings.matomo.siteId, + }); + }, []); + const getLayout = Component.getLayout ?? ((page) => page); return ( - - + - - - {getLayout()} - - - - + + {getLayout()} + + + ); }; -- cgit v1.2.3