Skip to content

Commit

Permalink
added react-ga
Browse files Browse the repository at this point in the history
  • Loading branch information
NwinNwin committed Sep 25, 2023
1 parent 6db9b81 commit 574a304
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react": "^18.2.0",
"react-calendar": "^4.6.0",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-icons": "^4.10.1",
"react-leaflet": "^4.2.1",
"react-resizable": "^3.0.5",
Expand Down
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { ChakraProvider } from "@chakra-ui/react";
import "leaflet/dist/leaflet.css";
import { AuthContextProvider } from "./context/AuthContext";
import AboutPage from "./components/AboutPage/AboutPage";
//
import ReactGA from "react-ga";

ReactGA.initialize("UA-283774176-1");
function App() {
return (
<AuthContextProvider>
Expand Down
7 changes: 5 additions & 2 deletions src/components/AboutPage/AboutPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import "swiper/css/navigation";
import logo from "../../assets/images/small_logo.png";
import login_page from "../../assets/images/login_page.jpg";
import axios from "axios";
import ReactGA from "react-ga";

export default function AboutPage() {
const navigate = useNavigate();
const [screenWidth, setScreenWidth] = useState(window.screen.width);
const [data, setData] = useState([]);
const [leaderboard, setLeaderboard] = useState([]);
console.log("leaderboard", leaderboard);
console.log("data", data);

useEffect(() => {
ReactGA.pageview(window.location.pathname);
}, []);

window.onresize = () => {
setScreenWidth(window.screen.width);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default function Home() {
};

getLeaderboard();
}, [user]);
}, [user, token]);

// set token to auth
useEffect(() => {
Expand Down
9 changes: 9 additions & 0 deletions src/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import InfoModal from "../InfoModal/InfoModal";

import DataContext from "../../context/DataContext";
import { UserAuth } from "../../context/AuthContext";
import ReactGA from "react-ga";

import axios from "axios";

Expand Down Expand Up @@ -65,6 +66,10 @@ export default function Map({
setShowDonut(false);
};

useEffect(() => {
ReactGA.pageview(window.location.pathname);
}, []);

useEffect(() => {
const handleFocus = async () => {
await handleMarkerSelect();
Expand Down Expand Up @@ -101,6 +106,10 @@ export default function Map({
onOpen();
setItemData(item);
setFocusLocation(item.location);
ReactGA.event({
category: item.name,
action: "click on item",
});
},
}}
icon={
Expand Down
5 changes: 5 additions & 0 deletions src/components/UpdatePage/UpdatePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { useNavigate } from "react-router-dom";
import { ChevronRightIcon, ArrowBackIcon } from "@chakra-ui/icons";
import { SiInstagram } from "react-icons/si";
import ReactGA from "react-ga";

export default function UpdatePage() {
const navigate = useNavigate();
Expand All @@ -21,6 +22,10 @@ export default function UpdatePage() {
navigate("/");
};

useEffect(() => {
ReactGA.pageview(window.location.pathname);
}, []);

window.onresize = () => {
setScreenWidth(window.screen.width);
};
Expand Down

0 comments on commit 574a304

Please sign in to comment.