From 81a010501e79533b6849eb1da824028b03351fb7 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 28 Apr 2023 16:34:02 +0300 Subject: [PATCH] fix: fixed failing analytics --- src/App.tsx | 28 ++++++++++---------- src/components/LightLocatorsGeneratorTab.tsx | 10 +++---- src/components/TraitsBuilderTab.tsx | 1 + src/components/shared/DownloadButton.tsx | 1 - src/vite-env.d.ts | 4 +++ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index fde9cc8..b38d778 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,22 +27,22 @@ export default function App() { // Analytics script for prod useEffect(() => { - if (import.meta.env.PROD && !isDNTEnabled()) { - const script = document.createElement("script"); + // if (import.meta.env.PROD && !isDNTEnabled()) { + const script = document.createElement("script"); - script.src = "https://athena.david-sima.dev/umami.js"; - script.async = true; - script.defer = true; - script.setAttribute( - "data-website-id", - "2d43657d-0b56-43f0-864a-930b350bacef" - ); + script.src = "https://athena.david-sima.dev/script.js"; + script.async = true; + script.defer = true; + script.setAttribute( + "data-website-id", + "2d43657d-0b56-43f0-864a-930b350bacef" + ); - document.body.appendChild(script); - return () => { - document.body.removeChild(script); - }; - } + document.body.appendChild(script); + return () => { + document.body.removeChild(script); + }; + // } }, []); return ( diff --git a/src/components/LightLocatorsGeneratorTab.tsx b/src/components/LightLocatorsGeneratorTab.tsx index 12689aa..22bb212 100644 --- a/src/components/LightLocatorsGeneratorTab.tsx +++ b/src/components/LightLocatorsGeneratorTab.tsx @@ -25,6 +25,7 @@ export default function LightLocatorsGeneratorTab() { const result = makeLocators(Number(locators || 0), Number(stateTime || 0)); setGeneratedLocators(result.join("\n")); if (!isDNTEnabled()) { + window.umami.track("Generate light locators button"); const body = { locators, stateTime, type: "generate" }; try { await netlifyFunctionInvoke( @@ -44,6 +45,7 @@ export default function LightLocatorsGeneratorTab() { const onCopyClick = async (copy: Function) => { copy(); if (!isDNTEnabled()) { + window.umami.track("Copy light locators button"); const body = { locators: generatedLocators.split("\n").length, stateTime, @@ -90,12 +92,7 @@ export default function LightLocatorsGeneratorTab() { min={1} required /> - + @@ -116,7 +113,6 @@ export default function LightLocatorsGeneratorTab() { color={copied ? "teal" : "blue"} onClick={() => onCopyClick(copy)} styles={{ root: { alignSelf: "flex-end" } }} - className="umami--click--copy-light-locators-button" > {copied ? "Done!" : "Copy locators to clipboard"} diff --git a/src/components/TraitsBuilderTab.tsx b/src/components/TraitsBuilderTab.tsx index 567292f..4182d81 100644 --- a/src/components/TraitsBuilderTab.tsx +++ b/src/components/TraitsBuilderTab.tsx @@ -128,6 +128,7 @@ export default function TraitsBuilderTab() { const postAnalytics = async (type: "PNG" | "DDS") => { if (!isDNTEnabled()) { + window.umami.track(`download-trait-${type}`); const body = { type, state }; try { await netlifyFunctionInvoke( diff --git a/src/components/shared/DownloadButton.tsx b/src/components/shared/DownloadButton.tsx index 0e2ca7d..a84e773 100644 --- a/src/components/shared/DownloadButton.tsx +++ b/src/components/shared/DownloadButton.tsx @@ -94,7 +94,6 @@ export default function DownloadButton({ disabled={isDisabled} styles={{ root: { paddingRight: "9px", paddingLeft: "9px" } }} onClick={onClick} - className={`umami--click--download-trait-${type}`} > Download {type} diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 44dde8e..6298185 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -9,3 +9,7 @@ interface ImportMetaEnv { interface ImportMeta { readonly env: ImportMetaEnv; } + +interface Window { + umami: { track: (name: string, data?: { [key: string]: any }) => void }; +}