diff --git a/src/hooks/useEthersProvider.ts b/src/hooks/useEthersProvider.ts index fe4d5d8102..dfbd82b602 100644 --- a/src/hooks/useEthersProvider.ts +++ b/src/hooks/useEthersProvider.ts @@ -13,7 +13,7 @@ function clientToProvider(client?: Client, chainId?: number) { } const { chain, transport } = client - const ensAddress = chain.contracts?.ensRegistry?.address + const ensAddress = chain?.contracts?.ensRegistry?.address const network = chain ? { chainId: chain.id, diff --git a/src/hooks/useLogin.tsx b/src/hooks/useLogin.tsx index df2f68a208..9b0a8af4c6 100644 --- a/src/hooks/useLogin.tsx +++ b/src/hooks/useLogin.tsx @@ -71,7 +71,7 @@ const useLogin = (autoLogin = false) => { } catch (error) { const e = new Error('createProfile Error', { cause: error }) e.name = 'createProfile Error' - captureException(e, { extra: { walletAddress, account } }) + captureException(e, { extra: { walletAddress, account }, level: 'warning' }) setProfile({ profile: undefined, isAnonymous, account }) } }, diff --git a/src/index.tsx b/src/index.tsx index efdb0d8048..717506321a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -50,10 +50,25 @@ if (ENV_LEVEL > ENV_TYPE.LOCAL) { environment: 'production', ignoreErrors: ['AbortError'], integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], - tracesSampleRate: 0.1, + tracesSampleRate: 1.0, normalizeDepth: 5, - replaysSessionSampleRate: 0.1, + replaysSessionSampleRate: 1.0, replaysOnErrorSampleRate: 1.0, + beforeSend(event, hint) { + const error = hint?.originalException as Error + const { name, message } = error + if ( + (name === 'TypeError' && message === 'Load failed') || // Almost come from mobile safari fetch API issues + (name === 'ChunkLoadError' && message.includes('Failed to fetch')) || + (name === 'Error' && message === 'Java object is gone') || + (name === 'UnhandledRejection' && message === 'Non-Error promise rejection captured with value: null') || + (name === '' && message.includes('Non-Error promise rejection captured with value')) || // this always happens when a some external library throws an error + (name === '' && message.includes('Object captured as promise rejection with keys')) // this always happens when a some external library throws an error + ) + return null + + return event + }, }) Sentry.setTag('request_id', sentryRequestId) Sentry.setTag('version', TAG) diff --git a/src/state/transactions/reducer.ts b/src/state/transactions/reducer.ts index df7c6e293d..e5c871acfd 100644 --- a/src/state/transactions/reducer.ts +++ b/src/state/transactions/reducer.ts @@ -24,7 +24,7 @@ const initialState: TransactionState = {} const clearOldTransactions = (transactions: GroupedTxsByHash | undefined): GroupedTxsByHash | undefined => { if (!transactions) return undefined const chainTxs = Object.values(transactions ?? {}).filter(Boolean) as TransactionDetails[][] - chainTxs.sort((a, b) => a[0].addedTime - b[0].addedTime) + chainTxs.sort((a, b) => (a[0]?.addedTime || 0) - (b[0]?.addedTime || 0)) const slicedChainTxs = chainTxs.slice(-10).filter(tx => tx[0].addedTime > Date.now() - 7 * 24 * 60 * 60 * 1000) const result = slicedChainTxs.reduce((acc, cur) => ({ ...acc, [cur[0].hash]: cur }), {}) as GroupedTxsByHash return result diff --git a/src/utils/sentry.ts b/src/utils/sentry.ts index 3744e26c25..510cd96b7e 100644 --- a/src/utils/sentry.ts +++ b/src/utils/sentry.ts @@ -35,7 +35,7 @@ export function captureSwapError(error: TransactionError) { : 'other' captureException(e, { - level: 'fatal', + level: 'warning', extra: { rawData: error.rawData }, tags: { type: tag,