Skip to content

Commit

Permalink
2580 google analytics (#2681)
Browse files Browse the repository at this point in the history
* feat(app): google analytics

* chore(app): add sample to env

* chore(infra): add amplify env variable
  • Loading branch information
tim-schultz authored Jul 9, 2024
1 parent a81dd69 commit 33e16d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=YOUR_WALLET_CONNECT_PROJECT_ID
NEXT_PUBLIC_WEB3_ONBOARD_EXPLORE_URL=http://localhost:3000/
NEXT_PUBLIC_FF_CERAMIC_CLIENT=off
NEXT_PUBLIC_ONBOARD_RESET_INDEX=1
NEXT_PUBLIC_GA_ID=id
12 changes: 12 additions & 0 deletions app/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ import hash from "object-hash";
import TagManager from "react-gtm-module";
import { useDatastoreConnectionContext } from "../context/datastoreConnectionContext";
import { useWeb3ModalError } from "@web3modal/ethers/react";
import Script from "next/script";

const success = "../../assets/check-icon2.svg";
const fail = "../assets/verification-failed-bright.svg";

const GA_ID = process.env.NEXT_PUBLIC_GA_ID;

export default function Dashboard() {
const customization = useCustomization();
const { useCustomDashboardPanel } = customization;
Expand Down Expand Up @@ -258,6 +261,15 @@ export default function Dashboard() {

return (
<PageRoot className="text-color-1">
<Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} strategy="afterInteractive" />
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`}
</Script>
{modals}
<HeaderContentFooterGrid>
<Header />
Expand Down
5 changes: 4 additions & 1 deletion infra/aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ const stakingEnvVars = Object({
NEXT_PUBLIC_ENABLE_ARBITRUM_MAINNET: "on",
NEXT_PUBLIC_ARBITRUM_RPC_URL: arbitrumRpcUrl,
NEXT_PUBLIC_GET_GTC_STAKE_API: "https://api.scorer.gitcoin.co/registry/gtc-stake/",
NEXT_PUBLIC_MAX_LEGACY_ROUND_ID: 7,
NEXT_PUBLIC_MAX_LEGACY_ROUND_ID: 7,
NEXT_PUBLIC_GA_ID: "",
},
staging: {
NEXT_PUBLIC_CERAMIC_CACHE_ENDPOINT: "https://api.staging.scorer.gitcoin.co/ceramic-cache",
Expand All @@ -128,6 +129,7 @@ const stakingEnvVars = Object({
NEXT_PUBLIC_ARBITRUM_RPC_URL: arbitrumRpcUrl,
NEXT_PUBLIC_GET_GTC_STAKE_API: "https://api.scorer.gitcoin.co/registry/gtc-stake/",
NEXT_PUBLIC_MAX_LEGACY_ROUND_ID: 7,
NEXT_PUBLIC_GA_ID: "",
},
production: {
NEXT_PUBLIC_CERAMIC_CACHE_ENDPOINT: "https://api.scorer.gitcoin.co/ceramic-cache",
Expand All @@ -147,6 +149,7 @@ const stakingEnvVars = Object({
NEXT_PUBLIC_ARBITRUM_RPC_URL: arbitrumRpcUrl,
NEXT_PUBLIC_GET_GTC_STAKE_API: "https://api.scorer.gitcoin.co/registry/gtc-stake/",
NEXT_PUBLIC_MAX_LEGACY_ROUND_ID: 7,
NEXT_PUBLIC_GA_ID: "G-XHXGR14F2B",
},
});

Expand Down

0 comments on commit 33e16d7

Please sign in to comment.