From 3943d220d15601bb870ff3494aac4bbc52cadb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 16 Dec 2024 17:19:52 +0100 Subject: [PATCH] hotfix: depend on network on matomo init --- govtool/frontend/src/hooks/useMatomo.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/govtool/frontend/src/hooks/useMatomo.ts b/govtool/frontend/src/hooks/useMatomo.ts index 825683651..5c323e78c 100644 --- a/govtool/frontend/src/hooks/useMatomo.ts +++ b/govtool/frontend/src/hooks/useMatomo.ts @@ -7,10 +7,10 @@ import { useEffect } from "react"; export const useMatomo = () => { useEffect(() => { - const env = import.meta.env.VITE_APP_ENV; - if (env !== "production" || env !== "staging") { - return; - } + const isSancho = window.location.href.includes("sancho"); + if (isSancho) return; + + const network = import.meta.env.VITE_NETWORK_FLAG; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error const _paq = (window._paq = window._pag || []); @@ -19,7 +19,7 @@ export const useMatomo = () => { (function () { const u = "//analytics.gov.tools/"; _paq.push(["setTrackerUrl", u + "matomo.php"]); - _paq.push(["setSiteId", env === "production" ? "1" : "2"]); + _paq.push(["setSiteId", network === 1 ? "1" : "2"]); const d = document; const g = d.createElement("script"); const s = d.getElementsByTagName("script")[0];