Skip to content

Commit

Permalink
fix: fixed failing analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
The24thDS committed Apr 28, 2023
1 parent 244e08b commit 81a0105
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
28 changes: 14 additions & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
10 changes: 3 additions & 7 deletions src/components/LightLocatorsGeneratorTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -90,12 +92,7 @@ export default function LightLocatorsGeneratorTab() {
min={1}
required
/>
<Button
onClick={onGenerateClick}
className="umami--click--generate-light-locators-button"
>
Generate locators
</Button>
<Button onClick={onGenerateClick}>Generate locators</Button>
</Stack>
</Grid.Col>
<Grid.Col span={gridColums} lg={8} offsetLg={1}>
Expand All @@ -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"}
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/components/TraitsBuilderTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/components/shared/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
</Button>
Expand Down
4 changes: 4 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ interface ImportMetaEnv {
interface ImportMeta {
readonly env: ImportMetaEnv;
}

interface Window {
umami: { track: (name: string, data?: { [key: string]: any }) => void };
}

0 comments on commit 81a0105

Please sign in to comment.