diff --git a/packages/bridge-ui/src/components/AddressDropdown.svelte b/packages/bridge-ui/src/components/AddressDropdown.svelte index 3b8643114c4..70018e845b8 100644 --- a/packages/bridge-ui/src/components/AddressDropdown.svelte +++ b/packages/bridge-ui/src/components/AddressDropdown.svelte @@ -62,7 +62,9 @@ 'Cannot communicate with the network. Please try again later or contact support.', ); } else { - Sentry.captureException(error); + Sentry.captureException(error, { + extra: { srcChain: $srcChain?.id }, + }); errorToast('There was an error getting your balance.'); } diff --git a/packages/bridge-ui/src/components/BridgeForm/BridgeForm.svelte b/packages/bridge-ui/src/components/BridgeForm/BridgeForm.svelte index 5ac61de51c9..c0d19930157 100644 --- a/packages/bridge-ui/src/components/BridgeForm/BridgeForm.svelte +++ b/packages/bridge-ui/src/components/BridgeForm/BridgeForm.svelte @@ -231,7 +231,13 @@ ); } catch (error) { console.error(error); - Sentry.captureException(error); + + Sentry.captureException(error, { + extra: { + token: _token.symbol, + srcChain: $srcChain.id, + }, + }); // TODO: we need to improve the toast API so we can simply pass // title (header), note (footer), icon, etc. @@ -422,6 +428,12 @@ } catch (error) { console.error(error); + // Extra information we're gonna send to Sentry + const extra = { + token: _token.symbol, + srcChain: $srcChain.id, + }; + const isBll = _token.symbol.toLocaleLowerCase() === 'bll'; const headerError = 'Failed to bridge funds
'; @@ -432,7 +444,7 @@ if (error.cause?.status === 0) { // No need to capture this error if BLL is the one failing, // otherwise we're gonna spam Sentry with expected errors - !isBll && Sentry.captureException(error); + !isBll && Sentry.captureException(error, { extra }); const explorerUrl = `${$srcChain.explorerUrl}/tx/${error.cause.transactionHash}`; const htmlLink = `here`; @@ -446,7 +458,7 @@ warningToast(`Transaction has been rejected.`); } else { // Do not capture if it's BLL. It's expected. - !isBll && Sentry.captureException(error); + !isBll && Sentry.captureException(error, { extra }); errorToast(`${headerError}Try again later.${noteError}`); } diff --git a/packages/bridge-ui/src/components/BridgeForm/ProcessingFee.svelte b/packages/bridge-ui/src/components/BridgeForm/ProcessingFee.svelte index a13ecd8acc4..04ef51201a0 100644 --- a/packages/bridge-ui/src/components/BridgeForm/ProcessingFee.svelte +++ b/packages/bridge-ui/src/components/BridgeForm/ProcessingFee.svelte @@ -26,7 +26,13 @@ }) .catch((error) => { console.error(error); - Sentry.captureException(error); + Sentry.captureException(error, { + extra: { + token: $token?.symbol, + srcChain: $srcChain?.id, + method, + }, + }); amount = '0'; cannotCompute = true; diff --git a/packages/bridge-ui/src/components/BridgeForm/SelectChain.svelte b/packages/bridge-ui/src/components/BridgeForm/SelectChain.svelte index c24c61769bb..60c6f1a668c 100644 --- a/packages/bridge-ui/src/components/BridgeForm/SelectChain.svelte +++ b/packages/bridge-ui/src/components/BridgeForm/SelectChain.svelte @@ -31,7 +31,11 @@ if (error instanceof UserRejectedRequestError) { warningToast('Switch chain request canceled.'); } else { - Sentry.captureException(error); + Sentry.captureException(error, { + extra: { + chainTo: chain.id, + }, + }); errorToast('Error switching chain.'); } diff --git a/packages/bridge-ui/src/components/ChainDropdown.svelte b/packages/bridge-ui/src/components/ChainDropdown.svelte index 258269cae82..ecb7439dc6a 100644 --- a/packages/bridge-ui/src/components/ChainDropdown.svelte +++ b/packages/bridge-ui/src/components/ChainDropdown.svelte @@ -35,7 +35,7 @@ if (error instanceof UserRejectedRequestError) { warningToast('Switch chain request rejected.'); } else { - Sentry.captureException(error); + Sentry.captureException(error, { extra: { chainTo: chain.id } }); errorToast('Error switching chain.'); } diff --git a/packages/bridge-ui/src/components/Faucet/Faucet.svelte b/packages/bridge-ui/src/components/Faucet/Faucet.svelte index 336fd06b7a5..13a5aee9b07 100644 --- a/packages/bridge-ui/src/components/Faucet/Faucet.svelte +++ b/packages/bridge-ui/src/components/Faucet/Faucet.svelte @@ -74,7 +74,11 @@ if (!wrongChain) { // We only want to capture and inform the user there is a problem here if // they are in the right network. Otherwise, the error is expected. - Sentry.captureException(error); + Sentry.captureException(error, { + extra: { + token: _token.symbol, + }, + }); errorToast( `There seems to be a problem with minting ${_token.symbol} tokens.`, diff --git a/packages/bridge-ui/src/components/Transactions/Transaction.svelte b/packages/bridge-ui/src/components/Transactions/Transaction.svelte index 9f412b41626..50e85213759 100644 --- a/packages/bridge-ui/src/components/Transactions/Transaction.svelte +++ b/packages/bridge-ui/src/components/Transactions/Transaction.svelte @@ -11,7 +11,7 @@ import { chains } from '../../chain/chains'; import { bridgeABI } from '../../constants/abi'; import { BridgeType } from '../../domain/bridge'; - import type { Chain } from '../../domain/chain'; + import type { Chain, ChainID } from '../../domain/chain'; import { MessageStatus } from '../../domain/message'; import type { NoticeOpenArgs } from '../../domain/modal'; import { @@ -82,11 +82,11 @@ // } async function ensureCorrectChain( - currentChain: Chain, - bridgeTx: BridgeTransaction, + currentChainId: ChainID, + wannaBeChainId: ChainID, pendingTx: Transaction[], ) { - const isCorrectChain = currentChain.id === bridgeTx.destChainId; + const isCorrectChain = currentChainId === wannaBeChainId; log(`Are we on the correct chain? ${isCorrectChain}`); if (!isCorrectChain) { @@ -96,7 +96,7 @@ }); } - await switchNetwork(bridgeTx.destChainId); + await switchNetwork(wannaBeChainId); } } @@ -105,7 +105,11 @@ try { loading = true; - await ensureCorrectChain($srcChain, bridgeTx, $pendingTransactions); + await ensureCorrectChain( + $srcChain.id, + bridgeTx.destChainId, + $pendingTransactions, + ); // Confirm after switch chain that it worked const isCorrectChain = await isOnCorrectChain( @@ -170,7 +174,13 @@ $token = $token; } catch (error) { console.error(error); - Sentry.captureException(error); + + Sentry.captureException(error, { + extra: { + srcChain: $srcChain.id, + bridgeTx, + }, + }); const headerError = 'Failed to claim funds'; @@ -215,7 +225,11 @@ try { loading = true; - await ensureCorrectChain($srcChain, bridgeTx, $pendingTransactions); + await ensureCorrectChain( + $srcChain.id, + bridgeTx.srcChainId, + $pendingTransactions, + ); // Confirm after switch chain that it worked const isCorrectChain = await isOnCorrectChain( @@ -262,7 +276,13 @@ $token = $token; } catch (error) { console.error(error); - Sentry.captureException(error); + + Sentry.captureException(error, { + extra: { + srcChain: $srcChain.id, + bridgeTx, + }, + }); const headerError = 'Failed to release funds'; diff --git a/packages/bridge-ui/src/signer/subscriber.ts b/packages/bridge-ui/src/signer/subscriber.ts index 94ce98a5c98..db6e8ddcc8e 100644 --- a/packages/bridge-ui/src/signer/subscriber.ts +++ b/packages/bridge-ui/src/signer/subscriber.ts @@ -57,7 +57,14 @@ export async function subscribeToSigner(newSigner: Signer | null) { Sentry.captureException(error); } - const txs = await storageService.getAllByAddress(userAddress); + let txs = [] as BridgeTransaction[]; + + try { + txs = await storageService.getAllByAddress(userAddress); + } catch (error) { + console.error(error); + Sentry.captureException(error); + } // Create a map of hashes to API transactions to help us // filter out transactions from local storage. diff --git a/packages/bridge-ui/src/utils/switchNetwork.ts b/packages/bridge-ui/src/utils/switchNetwork.ts index 92c4dc1f1bd..2a8982bf4c6 100644 --- a/packages/bridge-ui/src/utils/switchNetwork.ts +++ b/packages/bridge-ui/src/utils/switchNetwork.ts @@ -21,7 +21,7 @@ export async function switchNetwork(chainId: number) { // This will prevent an unlikely infinite loop const starting = Date.now(); - const timeout = 3000; // TODO: config? + const timeout = 5000; // TODO: config? const waitForNetworkChange = () => { const srcChainId = get(srcChain)?.id;