-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: amplitude logs is_reconnect (#4214)
* modified redux state to track wallet connections to properly log reconnects * linted and removed console.log * fixes for lynn's comments + documenting
- Loading branch information
Showing
6 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useCallback } from 'react' | ||
import { useAppDispatch, useAppSelector } from 'state/hooks' | ||
|
||
import { addConnectedWallet } from './reducer' | ||
import { Wallet } from './types' | ||
|
||
export function useConnectedWallets(): [Wallet[], (wallet: Wallet) => void] { | ||
const dispatch = useAppDispatch() | ||
const connectedWallets = useAppSelector((state) => state.wallets.connectedWallets) | ||
const addWallet = useCallback( | ||
(wallet: Wallet) => { | ||
dispatch(addConnectedWallet(wallet)) | ||
}, | ||
[dispatch] | ||
) | ||
return [connectedWallets, addWallet] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
import { shallowEqual } from 'react-redux' | ||
|
||
import { Wallet } from './types' | ||
|
||
/* Used to track wallets that have been connected by the user in current session, and remove them when deliberately disconnected. | ||
Used to compute is_reconnect event property for analytics */ | ||
export interface WalletState { | ||
connectedWallets: Wallet[] | ||
} | ||
|
||
export const initialState: WalletState = { | ||
connectedWallets: [], | ||
} | ||
|
||
const walletsSlice = createSlice({ | ||
name: 'wallets', | ||
initialState, | ||
reducers: { | ||
addConnectedWallet(state, { payload }) { | ||
state.connectedWallets = state.connectedWallets.concat(payload) | ||
}, | ||
removeConnectedWallet(state, { payload }) { | ||
state.connectedWallets = state.connectedWallets.filter((wallet) => !shallowEqual(wallet, payload)) | ||
}, | ||
}, | ||
}) | ||
|
||
export const { addConnectedWallet, removeConnectedWallet } = walletsSlice.actions | ||
export default walletsSlice.reducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Wallet { | ||
walletType: string | ||
account: string | ||
} |
f918b34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interface – ./
interface-uniswap.vercel.app
interface-git-main-uniswap.vercel.app