Skip to content

Commit

Permalink
chore: add tracking for analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
julio4 committed Feb 8, 2025
1 parent 9174950 commit 0dffcc5
Show file tree
Hide file tree
Showing 4 changed files with 1,218 additions and 1,194 deletions.
22 changes: 22 additions & 0 deletions components/useTracking.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect } from "react";

const CLARITY_ID = "q6bz69wquw";

export const useTracking = () => {
useEffect(() => {
const script = document.createElement("script");
script.type = "text/javascript";
script.text = `
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;
t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "${CLARITY_ID}");
`;
document.head.appendChild(script);
return () => {
document.head.removeChild(script);
};
}, []);
};
2 changes: 2 additions & 0 deletions layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useSidebarToggle } from "./components/useSidebarToggle";
import { useTracking } from "./components/useTracking";

export default function Root({ children }: { children: React.ReactNode }) {
useTracking();
useSidebarToggle();
return <div className="page-wrapper">{children}</div>;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"dependencies": {
"@types/react": "latest",
"react": "latest",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-katex": "^7.0.1",
"remark-math": "^6.0.0",
"typescript": "latest",
Expand Down
Loading

0 comments on commit 0dffcc5

Please sign in to comment.