-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SENTRY] Context and error description cleanup (#361)
* sentry updater * simplify error description * simpler networl * remove user address sentry logging
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useEffect } from 'react' | ||
import * as Sentry from '@sentry/browser' | ||
|
||
import useIsWindowVisible from 'hooks/useIsWindowVisible' | ||
import { useSwapState } from 'state/swap/hooks' | ||
import { SupportedChainId } from 'constants/chains' | ||
import { useCurrency } from 'hooks/Tokens' | ||
import { useWalletInfo } from 'hooks/useWalletInfo' | ||
|
||
export default function Updater(): null { | ||
const { account, chainId, walletName, isSupportedWallet } = useWalletInfo() | ||
const windowVisible = useIsWindowVisible() | ||
|
||
const { | ||
INPUT: { currencyId: sellTokenAddress }, | ||
OUTPUT: { currencyId: buyTokenAddress }, | ||
} = useSwapState() | ||
|
||
const sellCurrency = useCurrency(sellTokenAddress) | ||
const buyCurrency = useCurrency(buyTokenAddress) | ||
|
||
// create sentry context based on "main" parameters | ||
useEffect(() => { | ||
if (windowVisible) { | ||
Sentry.setContext('user', { | ||
// userAddress: account || 'DISCONNECTED', // TODO: validate with legal | ||
wallet: walletName, | ||
network: chainId ? SupportedChainId[chainId] : chainId, | ||
sellToken: `${sellTokenAddress} <${sellCurrency?.symbol}>`, | ||
buyToken: `${buyTokenAddress} <${buyCurrency?.symbol}>`, | ||
}) | ||
} | ||
}, [ | ||
// user | ||
account, | ||
chainId, | ||
walletName, | ||
isSupportedWallet, | ||
// tokens | ||
sellTokenAddress, | ||
buyTokenAddress, | ||
buyCurrency?.symbol, | ||
sellCurrency?.symbol, | ||
// window visibility check | ||
windowVisible, | ||
]) | ||
|
||
return null | ||
} |
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