Skip to content

Commit 724922e

Browse files
committed
Track wallet type
1 parent e215415 commit 724922e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/contexts/RainbowProvider/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"use client"
22

3+
import { sendGAEvent } from "@next/third-parties/google"
34
import { RainbowKitProvider, getDefaultConfig, useConnectModal } from "@rainbow-me/rainbowkit"
45
import "@rainbow-me/rainbowkit/styles.css"
56
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
67
import { BrowserProvider } from "ethers"
7-
import { createContext, useCallback, useContext, useMemo } from "react"
8+
import { createContext, useCallback, useContext, useEffect, useMemo } from "react"
89
import { type Config, WagmiProvider, useAccount, useConnectorClient, useDisconnect } from "wagmi"
910

1011
import { configs } from "./configs"
@@ -51,10 +52,17 @@ const RainbowProvider = props => {
5152
const Web3ContextProvider = props => {
5253
const { connector: activeConnector, address, isConnected, chainId } = useAccount()
5354
const { data: client } = useConnectorClient<Config>({ chainId })
54-
5555
const { openConnectModal } = useConnectModal()
5656
const { disconnect } = useDisconnect()
5757

58+
useEffect(() => {
59+
if (isConnected && activeConnector?.name) {
60+
sendGAEvent("wallet_connected", {
61+
wallet_type: activeConnector.name,
62+
})
63+
}
64+
}, [isConnected, activeConnector?.name])
65+
5866
const provider = useMemo(() => {
5967
if (client && chainId && chainId === client.chain?.id) return clientToProvider(client)
6068
return null

0 commit comments

Comments
 (0)