Skip to content

Commit

Permalink
removing roots of amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Jul 29, 2024
1 parent 0732183 commit 6dcdb6f
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions packages/docs/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,7 @@
import "../styles.css";
import amplitude from "amplitude-js";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";

export default function Nextra({ Component, pageProps }) {
const getLayout = Component.getLayout || ((page) => page);
const router = useRouter();

const isBrowser = typeof window !== "undefined";
const [initialRouteTracked, setInitialRouteTracked] = useState(false);

useEffect(() => {
if (isBrowser && !initialRouteTracked) {
const event = "pageview";
const eventProperties = {
source: "docs",
path: router.asPath,
};
amplitude.getInstance().logEvent(event, eventProperties);
setInitialRouteTracked(true);
}
}, [router]);

useEffect(() => {
// Track page views
const handleRouteChange = (path) => {
const event = "pageview";
const eventProperties = {
source: "docs",
path: path,
};
amplitude.getInstance().logEvent(event, eventProperties);
};

router.events.on("routeChangeComplete", handleRouteChange);

return () => {
router.events.off("routeChangeComplete", handleRouteChange);
};
}, []);

return getLayout(<Component {...pageProps} />);
}

0 comments on commit 6dcdb6f

Please sign in to comment.