From 41d2cc84b70d9ce881c94026b5936540a634df77 Mon Sep 17 00:00:00 2001 From: borcherd Date: Wed, 16 Aug 2023 11:17:51 +0200 Subject: [PATCH] feat: initialise GA --- .env.example | 3 ++- next.config.js | 1 + package.json | 1 + src/app/layout.tsx | 2 ++ yarn.lock | 5 +++++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index b79fc5261..40ab46020 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,5 @@ WC_PROJECT_ID= "" SOCKET_API_KEY= "" PEANUT_API_KEY= "" OPTI_GOERLI_RPC_URL= "" -GOERLI_RPC_URL= "" \ No newline at end of file +GOERLI_RPC_URL= "" +GA_KEY= "" \ No newline at end of file diff --git a/next.config.js b/next.config.js index a3fdfc064..3d2e573cb 100644 --- a/next.config.js +++ b/next.config.js @@ -6,6 +6,7 @@ const nextConfig = { PEANUT_API_KEY: process.env.PEANUT_API_KEY, OPTI_GOERLI_RPC_URL: process.env.OPTI_GOERLI_RPC_URL, GOERLI_RPC_URL: process.env.GOERLI_RPC_URL, + GA_KEY: process.env.GA_KEY, }, }; diff --git a/package.json b/package.json index 9fb79f75f..741355fea 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-fast-marquee": "^1.6.0", + "react-ga4": "^2.1.0", "react-hook-form": "^7.42.1", "react-hot-toast": "^2.4.1", "react-qr-code": "^2.0.11", diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 95de3d367..b5bf7988d 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -7,6 +7,7 @@ import { WagmiConfig } from "wagmi"; import * as config from "@/config"; import { Store } from "@/store/store"; import { useState, useEffect } from "react"; +import ReactGA from "react-ga4"; const inter = Inter({ subsets: ["latin"] }); @@ -20,6 +21,7 @@ export default function RootLayout({ //this useEffect is needed to prevent hydration error when autoConnect in wagmiConfig is true useEffect(() => { setReady(true); + ReactGA.initialize(process.env.GA_KEY ?? ""); }, []); return ( diff --git a/yarn.lock b/yarn.lock index 618a89a62..da5d1c4bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5972,6 +5972,11 @@ react-fast-marquee@^1.6.0: resolved "https://registry.yarnpkg.com/react-fast-marquee/-/react-fast-marquee-1.6.0.tgz#3749a9d0f522234e1e3ab776f105cd0accd76a4a" integrity sha512-jtuwT9SNjrqxnE7lGZ8mTL1I8Q4+9G4aBta2p+y2Pa3SjR17QROblwrLICyM8rbjQFHgHawTHcaH9HvoVO2NOA== +react-ga4@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/react-ga4/-/react-ga4-2.1.0.tgz#56601f59d95c08466ebd6edfbf8dede55c4678f9" + integrity sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ== + react-hook-form@^7.42.1: version "7.45.4" resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.45.4.tgz#73d228b704026ae95d7e5f7b207a681b173ec62a"