diff --git a/package.json b/package.json index 55dfdd0..4439176 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-to-img", "private": true, - "version": "1.2.0", + "version": "1.3.0", "license": "MIT", "author": { "name": "Rohidul Islam", @@ -66,6 +66,7 @@ }, "devDependencies": { "@types/bcrypt": "^5.0.0", + "@types/gtag.js": "^0.0.11", "@types/node": "^17.0.32", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", diff --git a/pages/_app.tsx b/pages/_app.tsx index ae7be6f..86692de 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,28 +1,10 @@ import { AppProps } from "next/app"; -import { useRouter } from "next/router"; -import { useEffect } from "react"; import Header from "../src/components/Header"; import SEO from "../src/components/SEO"; import { EditorProvider } from "../src/contexts/EditorContext"; import "../styles/global.css"; -import * as gtag from "../src/lib/gtag"; const MyApp = ({ Component, pageProps }: AppProps) => { - const router = useRouter(); - - useEffect(() => { - const handleRouteChange = (url: string) => { - gtag.pageview(url); - }; - - router.events.on("routeChangeComplete", handleRouteChange); - router.events.on("hashChangeComplete", handleRouteChange); - return () => { - router.events.off("routeChangeComplete", handleRouteChange); - router.events.off("hashChangeComplete", handleRouteChange); - }; - }, [router]); - return ( diff --git a/pages/_document.tsx b/pages/_document.tsx index 3770e0a..b023ecd 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,6 +1,6 @@ import { Head, Html, Main, NextScript } from "next/document"; import Script from "next/script"; -import * as gtag from "../src/lib/gtag"; +import { GA_TRACKING_ID } from "../src/lib/gtag"; const MyDocument = () => { return ( @@ -8,20 +8,21 @@ const MyDocument = () => {