diff --git a/CHANGELOG.md b/CHANGELOG.md index b34236d5d..894ba1128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ changes. ### Fixed -- +- Move matomo initalization out of the react code ### Changed diff --git a/govtool/frontend/index.html b/govtool/frontend/index.html index cb8734a1b..d50aa332b 100644 --- a/govtool/frontend/index.html +++ b/govtool/frontend/index.html @@ -25,18 +25,27 @@
diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx index 7745ceefb..553d5295f 100644 --- a/govtool/frontend/src/App.tsx +++ b/govtool/frontend/src/App.tsx @@ -39,10 +39,8 @@ import { import { PublicRoute } from "./pages/PublicRoute"; import { TopBanners } from "./components/organisms/TopBanners"; import { DashboardHome } from "./pages/DashboardHome"; -import { useMatomo } from "./hooks/useMatomo"; export default () => { - useMatomo(); const { isProposalDiscussionForumEnabled } = useFeatureFlag(); const { enable, isEnabled } = useCardano(); const navigate = useNavigate(); diff --git a/govtool/frontend/src/hooks/useMatomo.ts b/govtool/frontend/src/hooks/useMatomo.ts deleted file mode 100644 index 5c323e78c..000000000 --- a/govtool/frontend/src/hooks/useMatomo.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable func-names */ -/* eslint-disable no-multi-assign */ -/* eslint-disable prefer-template */ -/* eslint-disable no-underscore-dangle */ -/* eslint-disable wrap-iife */ -import { useEffect } from "react"; - -export const useMatomo = () => { - useEffect(() => { - 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 || []); - _paq.push(["trackPageView"]); - _paq.push(["enableLinkTracking"]); - (function () { - const u = "//analytics.gov.tools/"; - _paq.push(["setTrackerUrl", u + "matomo.php"]); - _paq.push(["setSiteId", network === 1 ? "1" : "2"]); - const d = document; - const g = d.createElement("script"); - const s = d.getElementsByTagName("script")[0]; - g.async = true; - g.src = u + "matomo.js"; - s.parentNode?.insertBefore(g, s); - })(); - }, []); -};