From 034838af8cf9589fcc3702cfd0aa3bc7a3f3ccbc Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sun, 26 Sep 2021 22:28:43 -0400 Subject: [PATCH] don't log pageviews when admin looking at it --- src/App.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 598c66a..fa5c7ff 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,6 +20,7 @@ import AccountPage from "./pages/AccountPage"; import { useEffect } from "react"; import ReactGA from "react-ga"; +import { useUser } from "./user-context"; const chapters = content.reduce((chapters, item) => ( item.content ? [...chapters, item] @@ -35,6 +36,7 @@ if (prod) { function App(props: RouteComponentProps) { const [navOpen, setNavOpen] = useState(false); + const { user } = useUser(); // TODO: seperate function for getUserInfo with useUser and fetch // then set cronjob to call that - also do signin flox useEffect(() => { @@ -42,7 +44,7 @@ function App(props: RouteComponentProps) { }, []); useEffect(() => { window.scroll(0, 0); - if (prod) { + if (prod && !(user?.admin)) { ReactGA.pageview(window.location.pathname); } }, [props.location.pathname]);