From 480b0c6e0f7ad27a72a46430beab65738439a740 Mon Sep 17 00:00:00 2001 From: Dang Nguyen Nguyen Date: Sun, 24 Sep 2023 20:41:23 -0700 Subject: [PATCH] ga4 test deploy --- package-lock.json | 10 ---------- package.json | 1 - src/App.js | 11 ++++++++++- src/components/AboutPage/AboutPage.jsx | 4 ---- src/components/Map/Map.jsx | 9 --------- src/components/UpdatePage/UpdatePage.jsx | 6 +----- 6 files changed, 11 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04bf05b..0eb24dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,6 @@ "react": "^18.2.0", "react-calendar": "^4.6.0", "react-dom": "^18.2.0", - "react-ga": "^3.3.1", "react-ga4": "^2.1.0", "react-icons": "^4.10.1", "react-leaflet": "^4.2.1", @@ -16511,15 +16510,6 @@ } } }, - "node_modules/react-ga": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.3.1.tgz", - "integrity": "sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==", - "peerDependencies": { - "prop-types": "^15.6.0", - "react": "^15.6.2 || ^16.0 || ^17 || ^18" - } - }, "node_modules/react-ga4": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/react-ga4/-/react-ga4-2.1.0.tgz", diff --git a/package.json b/package.json index d47731c..19bc645 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "react": "^18.2.0", "react-calendar": "^4.6.0", "react-dom": "^18.2.0", - "react-ga": "^3.3.1", "react-ga4": "^2.1.0", "react-icons": "^4.10.1", "react-leaflet": "^4.2.1", diff --git a/src/App.js b/src/App.js index d60573e..5e4de15 100644 --- a/src/App.js +++ b/src/App.js @@ -11,9 +11,18 @@ import "leaflet/dist/leaflet.css"; import { AuthContextProvider } from "./context/AuthContext"; import AboutPage from "./components/AboutPage/AboutPage"; import ReactGA from "react-ga4"; +import { useEffect } from "react"; -ReactGA.initialize("G-T3M3PZTJPN"); +ReactGA.initialize("G-7TSV14ZJ11"); function App() { + useEffect(() => { + ReactGA.send({ + hitType: "pageview", + page: window.location.pathname + window.location.search, + title: "Home", + }); + }, []); + return ( diff --git a/src/components/AboutPage/AboutPage.jsx b/src/components/AboutPage/AboutPage.jsx index 5fa1f44..fa7b931 100644 --- a/src/components/AboutPage/AboutPage.jsx +++ b/src/components/AboutPage/AboutPage.jsx @@ -10,7 +10,6 @@ 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(); @@ -18,9 +17,6 @@ export default function AboutPage() { const [data, setData] = useState([]); const [leaderboard, setLeaderboard] = useState([]); - useEffect(() => { - ReactGA.pageview(window.location.pathname); - }, []); window.onresize = () => { setScreenWidth(window.screen.width); diff --git a/src/components/Map/Map.jsx b/src/components/Map/Map.jsx index d7101dc..683ef8d 100644 --- a/src/components/Map/Map.jsx +++ b/src/components/Map/Map.jsx @@ -22,7 +22,6 @@ import InfoModal from "../InfoModal/InfoModal"; import DataContext from "../../context/DataContext"; import { UserAuth } from "../../context/AuthContext"; -import ReactGA from "react-ga"; import axios from "axios"; @@ -66,10 +65,6 @@ export default function Map({ setShowDonut(false); }; - useEffect(() => { - ReactGA.pageview(window.location.pathname); - }, []); - useEffect(() => { const handleFocus = async () => { await handleMarkerSelect(); @@ -106,10 +101,6 @@ export default function Map({ onOpen(); setItemData(item); setFocusLocation(item.location); - ReactGA.event({ - category: item.name, - action: "click on item", - }); }, }} icon={ diff --git a/src/components/UpdatePage/UpdatePage.jsx b/src/components/UpdatePage/UpdatePage.jsx index 22f66f8..793517d 100644 --- a/src/components/UpdatePage/UpdatePage.jsx +++ b/src/components/UpdatePage/UpdatePage.jsx @@ -1,4 +1,4 @@ -import { React, useState, useEffect } from "react"; +import { React, useState } from "react"; import { Flex, Text, @@ -12,7 +12,6 @@ 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(); @@ -22,9 +21,6 @@ export default function UpdatePage() { navigate("/"); }; - useEffect(() => { - ReactGA.pageview(window.location.pathname); - }, []); window.onresize = () => { setScreenWidth(window.screen.width);