diff --git a/.env.example b/.env.example index 3bf0270..23dee0b 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,7 @@ +VITE_API_BASE_URL= +VITE_MATOMO_URL= +VITE_MATOMO_SITE_ID= + DISCORD_CONTACT_WEBHOOK= DISCORD_ERROR_LOG_WEBHOOK= LICHESS_CLIENT_ID= -VITE_API_BASE_URL= diff --git a/src/components/MatomoAnalytics.tsx b/src/components/MatomoAnalytics.tsx index 37985fb..571374b 100644 --- a/src/components/MatomoAnalytics.tsx +++ b/src/components/MatomoAnalytics.tsx @@ -1,9 +1,10 @@ import { trackAppRouter } from "@socialgouv/matomo-next"; import { useLocation, useSearch } from "@tanstack/react-router"; import { useEffect } from "react"; +import { env } from "#/env.ts"; -const MATOMO_URL = import.meta.env.NEXT_PUBLIC_MATOMO_URL; -const MATOMO_SITE_ID = import.meta.env.NEXT_PUBLIC_MATOMO_SITE_ID; +const MATOMO_URL = env.VITE_MATOMO_URL; +const MATOMO_SITE_ID = env.VITE_MATOMO_SITE_ID; export function MatomoAnalytics() { const location = useLocation(); diff --git a/src/env.ts b/src/env.ts index f4de82b..ca2d139 100644 --- a/src/env.ts +++ b/src/env.ts @@ -2,6 +2,8 @@ import { z } from "zod"; const clientSchema = z.object({ VITE_API_BASE_URL: z.string("Invalid API Base URL format"), + VITE_MATOMO_URL: z.string("Invalid URL format"), + VITE_MATOMO_SITE_ID: z.string("Invalid Site ID"), }); const serverSchema = z.object({