From 387c930795fb0ff56370e7d407f7c3e9bd8aa04d Mon Sep 17 00:00:00 2001 From: xxx Date: Tue, 20 Feb 2024 14:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20react-ga=20=E5=92=8C=20=20?= =?UTF-8?q?web-vitals=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 +-- package.json | 4 +--- src/App.tsx | 18 ++---------------- src/reportWebVitals.ts | 15 --------------- 4 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 src/reportWebVitals.ts diff --git a/.env.example b/.env.example index a2e482c..ce3783e 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1 @@ -VITE_APP_URL= -VITE_G_ID= \ No newline at end of file +VITE_APP_URL= \ No newline at end of file diff --git a/package.json b/package.json index 7c7e27b..797ce95 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,10 @@ "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-ga": "^3.3.1", "react-redux": "^8.0.5", "react-router-dom": "^6.9.0", "redux": "^4.2.1", - "sort-by": "^1.2.0", - "web-vitals": "^3.3.0" + "sort-by": "^1.2.0" }, "devDependencies": { "@types/react": "^18.2.0", diff --git a/src/App.tsx b/src/App.tsx index e91f9b2..96f6fed 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,26 +1,12 @@ -import { Suspense, useEffect } from "react"; -import ReactGA from "react-ga"; -import { useLocation, useRoutes } from "react-router-dom"; +import { Suspense } from "react"; +import { useRoutes } from "react-router-dom"; import routes from "./routes"; import "./App.scss"; import LoadingPage from "./pages/loading"; -const G_ID = import.meta.env.VITE_G_ID || ""; -if (G_ID) { - ReactGA.initialize(G_ID); -} - const App = () => { const Views = () => useRoutes(routes); - const location = useLocation(); - useEffect(() => { - if (!G_ID) { - return; - } - ReactGA.pageview(location.pathname + location.search); - }, [location]); - return ( }> diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts deleted file mode 100644 index 49a2a16..0000000 --- a/src/reportWebVitals.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ReportHandler } from 'web-vitals'; - -const reportWebVitals = (onPerfEntry?: ReportHandler) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals;