-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: don't require wallet connection #1452
base: master
Are you sure you want to change the base?
Changes from all commits
f9b3eb5
5647bc7
ac2904c
761f76b
8983c6c
7fc643a
83ff1e0
fd27e67
6c5f22f
9024c9f
ffdaa64
7afe65c
b7e88e2
a4b42b9
4d41c70
31ca518
b09541e
2bc8d60
70009f6
0cfd82b
8308443
3559b13
8da44c8
372d448
eacaf21
cac297d
4d1d3a0
ccaa45b
ad56e66
bd63a10
d487132
17fcc0e
5963c24
185f985
cff40a4
1fb780b
9c6386f
fa6956b
a3e5a46
b081628
b155e33
9e2cbf5
c4c2ac4
34e738f
e3899dc
4a26749
6c8a094
628b2df
1e0bca7
01440ca
b919b1a
4410acf
58aa6ec
706aea6
a46e804
1cb8915
3ae13c1
f1f8cd4
bb03868
7b8b0da
9434492
82be657
24d4540
cf2fe84
ffaaed9
ec99753
38ab23e
692932b
5711ed3
abdb15e
aad2762
c4f6b11
23d11b0
9e6d9cd
b3e758b
e5f7919
89f1dae
fd7e13b
3b1e1ce
4bbabfb
d16ba20
660868c
43f81d3
5c15c73
cd4de57
b3de47e
be282e0
efe9ccf
6367f2b
8364d25
a79bf54
9417a00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { useAccount } from 'wagmi' | ||
import { useEffect } from 'react' | ||
import { useAccount } from 'wagmi' | ||
import * as Sentry from '@sentry/react' | ||
|
||
import { useNetworks } from '../../hooks/useNetworks' | ||
|
@@ -16,53 +16,57 @@ function getWalletName(connectorName: string): ProviderName { | |
case 'Safe': | ||
case 'Injected': | ||
case 'Ledger': | ||
return connectorName | ||
|
||
case 'WalletConnectLegacy': | ||
case 'WalletConnect': | ||
return 'WalletConnect' | ||
return connectorName | ||
|
||
default: | ||
return 'Other' | ||
} | ||
} | ||
|
||
/** given our RPC url, sanitize it before logging to Sentry, to only pass the url and not the keys */ | ||
function getBaseUrl(url: string) { | ||
function getBaseUrl(url: string | undefined): string | null { | ||
if (typeof url === 'undefined') { | ||
return null | ||
} | ||
|
||
try { | ||
const urlObject = new URL(url) | ||
return `${urlObject.protocol}//${urlObject.hostname}` | ||
} catch { | ||
// if invalid url passed | ||
return '' | ||
return null | ||
} | ||
} | ||
|
||
export function useSyncConnectedChainToAnalytics() { | ||
const { isConnected, connector } = useAccount() | ||
const [networks] = useNetworks() | ||
const { parentChain, childChain } = useNetworksRelationship(networks) | ||
const { isConnected, connector } = useAccount() | ||
|
||
useEffect(() => { | ||
if (isConnected && connector) { | ||
const walletName = getWalletName(connector.name) | ||
trackEvent('Connect Wallet Click', { walletName }) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's coming exactly from the previous file, but wouldn't this fire on every-refresh? Ideally we want it to fire only when we connect to UI using the connect wallet button. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// set a custom tag in sentry to filter issues by connected wallet.name | ||
Sentry.setTag('wallet.name', connector?.name ?? '') | ||
// set a custom tag in sentry to filter issues by connected wallet.name | ||
Sentry.setTag('wallet.name', walletName) | ||
} | ||
}, [isConnected, connector]) | ||
|
||
useEffect(() => { | ||
Sentry.setTag('network.parent_chain_id', parentChain.id) | ||
Sentry.setTag( | ||
'network.parent_chain_rpc_url', | ||
getBaseUrl(rpcURLs[parentChain.id] ?? '') | ||
) | ||
Sentry.setTag('network.child_chain_id', childChain.id) | ||
Sentry.setTag( | ||
'network.child_chain_rpc_url', | ||
getBaseUrl(rpcURLs[childChain.id] ?? '') | ||
) | ||
|
||
const parentChainRpcUrl = getBaseUrl(rpcURLs[parentChain.id]) | ||
const childChainRpcUrl = getBaseUrl(rpcURLs[childChain.id]) | ||
|
||
if (parentChainRpcUrl) { | ||
Sentry.setTag('network.parent_chain_rpc_url', parentChainRpcUrl) | ||
} | ||
|
||
if (childChainRpcUrl) { | ||
Sentry.setTag('network.child_chain_rpc_url', childChainRpcUrl) | ||
} | ||
}, [childChain.id, parentChain.id]) | ||
} |
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.
Extracted into
useSyncConnectedChainToQueryParams