11import { type UseMutationResult , useMutation } from "@tanstack/react-query" ;
2+ import { trackPayEvent } from "../../../../analytics/track/pay.js" ;
23import type { Chain } from "../../../../chains/types.js" ;
34import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js" ;
45import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js" ;
@@ -146,6 +147,13 @@ export function useSendTransactionCore(args: {
146147 }
147148
148149 if ( ! showPayModal ) {
150+ trackPayEvent ( {
151+ client : tx . client ,
152+ walletAddress : account . address ,
153+ walletType : wallet ?. id ,
154+ dstChainId : tx . chain . id ,
155+ event : "pay_transaction_modal_disabled" ,
156+ } ) ;
149157 return sendTransaction ( {
150158 transaction : tx ,
151159 account,
@@ -174,7 +182,17 @@ export function useSendTransactionCore(args: {
174182 await Promise . all ( [
175183 resolvePromisedValue ( tx . value ) ,
176184 resolvePromisedValue ( tx . erc20Value ) ,
177- fetchBuySupportedDestinations ( tx . client ) . catch ( ( ) => null ) ,
185+ fetchBuySupportedDestinations ( tx . client ) . catch ( ( err ) => {
186+ trackPayEvent ( {
187+ client : tx . client ,
188+ walletAddress : account . address ,
189+ walletType : wallet ?. id ,
190+ dstChainId : tx . chain . id ,
191+ event : "pay_transaction_modal_pay_api_error" ,
192+ error : err ?. message ,
193+ } ) ;
194+ return null ;
195+ } ) ,
178196 ] ) ;
179197
180198 if ( ! supportedDestinations ) {
@@ -198,6 +216,14 @@ export function useSendTransactionCore(args: {
198216 ) ,
199217 ) )
200218 ) {
219+ trackPayEvent ( {
220+ client : tx . client ,
221+ walletAddress : account . address ,
222+ walletType : wallet ?. id ,
223+ dstChainId : tx . chain . id ,
224+ event : "pay_transaction_modal_chain_token_not_supported" ,
225+ error : `chain ${ tx . chain . id } ${ _erc20Value ? `/ token ${ _erc20Value ?. tokenAddress } ` : "" } not supported` ,
226+ } ) ;
201227 // chain/token not supported, just send the tx
202228 sendTx ( ) ;
203229 return ;
@@ -241,6 +267,13 @@ export function useSendTransactionCore(args: {
241267 resolveTx : resolve ,
242268 } ) ;
243269 } else {
270+ trackPayEvent ( {
271+ client : tx . client ,
272+ walletAddress : account . address ,
273+ walletType : wallet ?. id ,
274+ dstChainId : tx . chain . id ,
275+ event : "pay_transaction_modal_has_enough_funds" ,
276+ } ) ;
244277 sendTx ( ) ;
245278 }
246279 } catch ( e ) {
0 commit comments