Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/thirdweb/src/analytics/track/pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function trackPayEvent(args: {
toAmount?: string;
chainId?: number;
dstChainId?: number;
error?: string;
}) {
return track({
client: args.client,
Expand All @@ -32,6 +33,7 @@ export async function trackPayEvent(args: {
amountWei: args.fromAmount,
dstTokenAddress: args.toToken,
dstChainId: args.chainId,
errorCode: args.error,
},
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
import { trackPayEvent } from "../../../../analytics/track/pay.js";
import type { Chain } from "../../../../chains/types.js";
import type { BuyWithCryptoStatus } from "../../../../pay/buyWithCrypto/getStatus.js";
import type { BuyWithFiatStatus } from "../../../../pay/buyWithFiat/getStatus.js";
Expand Down Expand Up @@ -146,6 +147,13 @@
}

if (!showPayModal) {
trackPayEvent({
client: tx.client,
walletAddress: account.address,
walletType: wallet?.id,
dstChainId: tx.chain.id,
event: "pay_transaction_modal_disabled",
});

Check warning on line 156 in packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts#L150-L156

Added lines #L150 - L156 were not covered by tests
return sendTransaction({
transaction: tx,
account,
Expand Down Expand Up @@ -174,7 +182,17 @@
await Promise.all([
resolvePromisedValue(tx.value),
resolvePromisedValue(tx.erc20Value),
fetchBuySupportedDestinations(tx.client).catch(() => null),
fetchBuySupportedDestinations(tx.client).catch((err) => {
trackPayEvent({
client: tx.client,
walletAddress: account.address,
walletType: wallet?.id,
dstChainId: tx.chain.id,
event: "pay_transaction_modal_pay_api_error",
error: err?.message,
});
return null;
}),

Check warning on line 195 in packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts#L185-L195

Added lines #L185 - L195 were not covered by tests
]);

if (!supportedDestinations) {
Expand All @@ -198,6 +216,14 @@
),
))
) {
trackPayEvent({
client: tx.client,
walletAddress: account.address,
walletType: wallet?.id,
dstChainId: tx.chain.id,
event: "pay_transaction_modal_chain_token_not_supported",
error: `chain ${tx.chain.id} ${_erc20Value ? `/ token ${_erc20Value?.tokenAddress}` : ""} not supported`,
});

Check warning on line 226 in packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts#L219-L226

Added lines #L219 - L226 were not covered by tests
// chain/token not supported, just send the tx
sendTx();
return;
Expand Down Expand Up @@ -241,6 +267,13 @@
resolveTx: resolve,
});
} else {
trackPayEvent({
client: tx.client,
walletAddress: account.address,
walletType: wallet?.id,
dstChainId: tx.chain.id,
event: "pay_transaction_modal_has_enough_funds",
});

Check warning on line 276 in packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/transaction/useSendTransaction.ts#L270-L276

Added lines #L270 - L276 were not covered by tests
sendTx();
}
} catch (e) {
Expand Down
Loading