Skip to content

Commit

Permalink
track wallet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Jan 22, 2025
1 parent 4f06ff8 commit dcc2b04
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { superpositionTestnet } from "@/config/chains";
import CookieBanner from "@/components/CookieBanner";
import GoogleAnalytics from "@/components/GoogleAnalytics";
import Points from "@/components/Points";
import { WalletConnectionStatus } from "@/components/WalletConnectionStatus";

export const metadata: Metadata = {
title: "Longtail",
Expand Down Expand Up @@ -65,6 +66,7 @@ export default async function RootLayout({
className={cn("flex min-h-screen flex-col bg-white", inter.className)}
>
<Provider>
<WalletConnectionStatus />
<PopulateQueryCache featuresData={featuresData} />
<div className="iridescent-blur absolute left-1/2 top-[180px] size-full max-h-[305px] max-w-[557px] -translate-x-1/2" />

Expand Down
20 changes: 20 additions & 0 deletions web/src/components/WalletConnectionStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";
import { EVENTS, track } from "@/lib/analytics";
import { useEffect, useState } from "react";
import { useAccount, useChainId } from "wagmi";

export const WalletConnectionStatus = () => {
const chainId = useChainId();
const { status, connector } = useAccount();
const [previous, setPrevious] = useState(status);
useEffect(() => {
if (previous === "connecting" && status === "connected") {
track(EVENTS.WALLET_CONNECTED, {
wallet_name: connector?.name ?? "Unknown",
chain_id: chainId,
});
}
setPrevious(status);
}, [previous, status, connector, chainId]);
return <></>;
};
1 change: 1 addition & 0 deletions web/src/lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const EVENTS = {
type EventKeys = (typeof EVENTS)[keyof typeof EVENTS];
type EventTypes = {
wallet_connected: {
wallet_name: string;
chain_id: number;
};
tokens_changed: {
Expand Down

0 comments on commit dcc2b04

Please sign in to comment.