don't log pageviews when admin looking at it
This commit is contained in:
parent
ec9e65a721
commit
034838af8c
|
@ -20,6 +20,7 @@ import AccountPage from "./pages/AccountPage";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
import ReactGA from "react-ga";
|
import ReactGA from "react-ga";
|
||||||
|
import { useUser } from "./user-context";
|
||||||
const chapters = content.reduce((chapters, item) => (
|
const chapters = content.reduce((chapters, item) => (
|
||||||
item.content
|
item.content
|
||||||
? [...chapters, item]
|
? [...chapters, item]
|
||||||
|
@ -35,6 +36,7 @@ if (prod) {
|
||||||
|
|
||||||
function App(props: RouteComponentProps) {
|
function App(props: RouteComponentProps) {
|
||||||
const [navOpen, setNavOpen] = useState(false);
|
const [navOpen, setNavOpen] = useState(false);
|
||||||
|
const { user } = useUser();
|
||||||
// TODO: seperate function for getUserInfo with useUser and fetch
|
// TODO: seperate function for getUserInfo with useUser and fetch
|
||||||
// then set cronjob to call that - also do signin flox
|
// then set cronjob to call that - also do signin flox
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -42,7 +44,7 @@ function App(props: RouteComponentProps) {
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.scroll(0, 0);
|
window.scroll(0, 0);
|
||||||
if (prod) {
|
if (prod && !(user?.admin)) {
|
||||||
ReactGA.pageview(window.location.pathname);
|
ReactGA.pageview(window.location.pathname);
|
||||||
}
|
}
|
||||||
}, [props.location.pathname]);
|
}, [props.location.pathname]);
|
||||||
|
|
Loading…
Reference in New Issue