diff --git a/frontend/index.html b/frontend/index.html index e1945184..cabbd9c2 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -21,6 +21,19 @@ + + K-Scale Store @@ -29,4 +42,4 @@ - + \ No newline at end of file diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 31a33d98..c9693bba 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,10 @@ -import { Route, BrowserRouter as Router, Routes } from "react-router-dom"; +import { useEffect } from "react"; +import { + Route, + BrowserRouter as Router, + Routes, + useLocation, +} from "react-router-dom"; import "App.css"; @@ -25,6 +31,29 @@ import NotFound from "components/pages/NotFound"; import Profile from "components/pages/Profile"; import Signup from "components/pages/Signup"; +const PendoInitializer = () => { + const location = useLocation(); // Hook to get current route + + useEffect(() => { + if (window.pendo) { + window.pendo.initialize({ + visitor: { id: "" }, // Leave empty for anonymous tracking + account: { id: "" }, + }); + console.log("Pendo initialized"); + } + }, []); + + useEffect(() => { + // Track page views when the route changes + if (window.pendo) { + window.pendo.pageLoad(); // Notify Pendo of page transitions + } + }, [location.pathname]); + + return null; // This component only handles Pendo initialization and page tracking +}; + const App = () => { return ( @@ -34,6 +63,8 @@ const App = () => {
+ {" "} + {/* This component is where Pendo is initialized */}
diff --git a/frontend/src/pendo.d.ts b/frontend/src/pendo.d.ts new file mode 100644 index 00000000..a93000c5 --- /dev/null +++ b/frontend/src/pendo.d.ts @@ -0,0 +1,23 @@ +interface PendoVisitor { + id: string; +} + +interface PendoAccount { + id: string; +} + +interface Pendo { + initialize: (options: { + visitor: PendoVisitor; + account?: PendoAccount; + }) => void; + pageLoad: () => void; +} + +declare global { + interface Window { + pendo: Pendo; + } +} + +export {};