don't log pageviews when admin looking at it

This commit is contained in:
lingdocs 2021-09-26 22:28:43 -04:00
parent ec9e65a721
commit 034838af8c
1 changed files with 3 additions and 1 deletions

View File

@ -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]);