diff --git a/.changeset/tasty-rivers-itch.md b/.changeset/tasty-rivers-itch.md new file mode 100644 index 000000000..f28246b7d --- /dev/null +++ b/.changeset/tasty-rivers-itch.md @@ -0,0 +1,5 @@ +--- +'@relayprotocol/relay-kit-ui': patch +--- + +Add tracking for eoa detection diff --git a/packages/ui/src/components/widgets/SwapWidgetRenderer.tsx b/packages/ui/src/components/widgets/SwapWidgetRenderer.tsx index 47b099e28..c102cc477 100644 --- a/packages/ui/src/components/widgets/SwapWidgetRenderer.tsx +++ b/packages/ui/src/components/widgets/SwapWidgetRenderer.tsx @@ -40,7 +40,7 @@ import { isValidAddress, findSupportedWallet } from '../../utils/address.js' -import { adaptViemWallet, getDeadAddress } from '@relayprotocol/relay-sdk' +import { adaptViemWallet } from '@relayprotocol/relay-sdk' import { errorToJSON } from '../../utils/errors.js' import { useSwapButtonCta } from '../../hooks/widget/useSwapButtonCta.js' import { sha256 } from '../../utils/hashing.js' diff --git a/packages/ui/src/hooks/useEOADetection.ts b/packages/ui/src/hooks/useEOADetection.ts index 809b39831..d9f20e60b 100644 --- a/packages/ui/src/hooks/useEOADetection.ts +++ b/packages/ui/src/hooks/useEOADetection.ts @@ -117,6 +117,12 @@ const useEOADetection = ( } const detectEOA = async () => { + const baseEventData = { + chain_id: chainId, + address: userAddress, + wallet_type: wallet?.vmType + } + try { if (!wallet || !wallet?.isEOA) { setDetectionState((current) => @@ -132,6 +138,8 @@ const useEOADetection = ( abortController.abort() }, 1000) + const startTime = performance.now() + try { const eoaResult = await Promise.race([ wallet.isEOA(chainId!), @@ -153,6 +161,24 @@ const useEOADetection = ( ) } catch (eoaError: any) { clearTimeout(timeoutId) + const duration = performance.now() - startTime + const isTimeout = eoaError?.message === 'EOA_DETECTION_TIMEOUT' + + if (isTimeout) { + console.error('[EOA Detection]', { + ...baseEventData, + error_type: 'timeout', + duration_ms: Math.round(duration) + }) + } else { + console.error('[EOA Detection]', { + ...baseEventData, + error_type: 'error', + duration_ms: Math.round(duration), + error_message: eoaError?.message || 'Unknown error', + error_name: eoaError?.name + }) + } setDetectionState((current) => current.conditionKey === conditionKey @@ -160,7 +186,14 @@ const useEOADetection = ( : current ) } - } catch (error) { + } catch (error: any) { + console.error('[EOA Detection]', { + ...baseEventData, + error_type: 'error', + error_message: error?.message || 'Unknown error', + error_name: error?.name + }) + setDetectionState((current) => current.conditionKey === conditionKey ? { value: true, conditionKey } @@ -170,7 +203,7 @@ const useEOADetection = ( } detectEOA() - }, [conditionKey, shouldDetect, wallet, chainId]) + }, [conditionKey, shouldDetect, wallet, chainId, userAddress]) if (!shouldDetect && chainVmType === 'evm') { return explicitDeposit ?? true