diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 01103e9..f87011d 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -33,13 +33,19 @@ import { Provider as JotaiProvider } from 'jotai' import { Favicon } from 'src/assets' import { Head, MainLayout } from 'src/components/layouts' -import useMatomoTracker from 'src/hooks/useMatomoTracker' import 'src/i18next' import { resources } from 'src/i18next' import { MantineProviders } from 'src/providers' import InitStoreProvider from 'src/providers/InitStoreProvider' import store from 'src/store/store' +// Matomo property added to window object +declare global { + interface Window { + _paq?: unknown[] + } +} + const i18n = initLanguage(resources) type AppProps = NextAppProps & { @@ -47,6 +53,8 @@ type AppProps = NextAppProps & { locale: string env: { THEGRAPH_API_KEY: string + MATOMO_URL: string + MATOMO_SITE_ID: string } } @@ -59,8 +67,6 @@ const dashbordChains: ChainSelectConfig = { const env = process.env.NEXT_PUBLIC_ENV ?? 'development' const walletConnectKey = process.env.NEXT_PUBLIC_WALLET_CONNECT_KEY ?? '' -const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL ?? '' -const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID ?? '' const readOnly = getReadOnlyConnector(dashbordChains) const walletConnect = getWalletConnectV2( @@ -79,6 +85,8 @@ const libraryConnectors = getConnectors({ export const getServerSideProps = async () => ({ props: { THEGRAPH_API_KEY: process.env.THEGRAPH_API_KEY, + MATOMO_URL: process.env.MATOMO_URL, + MATOMO_SITE_ID: process.env.MATOMO_SITE_ID, }, }) @@ -100,19 +108,16 @@ const App = ({ Component, pageProps, colorScheme, env }: AppProps) => { useEffect(() => { // eslint-disable-next-line no-underscore-dangle if (!window._paq) { - console.log('initMatomoNext') - // Triggered twice on page load when using strict mode in dev + // Note: Triggered twice on page load when using strict mode in DEV initMatomoNext({ - url: MATOMO_URL, - siteId: MATOMO_SITE_ID, - disableCookies: false, // TODO: cookie consent banner + url: process.env.MATOMO_URL ?? '', + siteId: process.env.MATOMO_SITE_ID ?? '', + disableCookies: false, // excludeUrlsPatterns: [/^\/login.php/, /\?token=.+/], }) } }, []) - useMatomoTracker() - return ( @@ -144,6 +149,8 @@ App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => { return { env: { THEGRAPH_API_KEY: process.env.THEGRAPH_API_KEY, + MATOMO_URL: process.env.MATOMO_URL, + MATOMO_SITE_ID: process.env.MATOMO_SITE_ID, }, colorScheme: getCookie('mantine-color-scheme', ctx) || 'dark', locale: getCookie('react-i18next', ctx) || 'fr',