diff --git a/src/hooks/useUniswapXSwapCallback.ts b/src/hooks/useUniswapXSwapCallback.ts index d9ab8ac206..94e66cb711 100644 --- a/src/hooks/useUniswapXSwapCallback.ts +++ b/src/hooks/useUniswapXSwapCallback.ts @@ -105,6 +105,7 @@ export function useUniswapXSwapCallback({ } } + const beforeSign = Date.now() const { signature, updatedOrder } = await signDutchOrder() sendAnalyticsEvent(SwapEventName.SWAP_SIGNED, { @@ -112,6 +113,7 @@ export function useUniswapXSwapCallback({ trade, allowedSlippage, fiatValues, + timeToSignSinceRequestMs: Date.now() - beforeSign, }), ...analyticsContext, }) diff --git a/src/hooks/useUniversalRouter.ts b/src/hooks/useUniversalRouter.ts index 5fe269b296..a04ca5e216 100644 --- a/src/hooks/useUniversalRouter.ts +++ b/src/hooks/useUniversalRouter.ts @@ -94,6 +94,7 @@ export function useUniversalRouterSwapCallback( } const gasLimit = calculateGasMargin(gasEstimate) setTraceData('gasLimit', gasLimit.toNumber()) + const beforeSign = Date.now() const response = await provider .getSigner() .sendTransaction({ ...tx, gasLimit }) @@ -101,6 +102,7 @@ export function useUniversalRouterSwapCallback( sendAnalyticsEvent(SwapEventName.SWAP_SIGNED, { ...formatSwapSignedAnalyticsEventProperties({ trade, + timeToSignSinceRequestMs: Date.now() - beforeSign, allowedSlippage: options.slippageTolerance, fiatValues, txHash: response.hash, diff --git a/src/lib/utils/analytics.ts b/src/lib/utils/analytics.ts index 1142936053..3986263923 100644 --- a/src/lib/utils/analytics.ts +++ b/src/lib/utils/analytics.ts @@ -65,15 +65,19 @@ export const formatSwapSignedAnalyticsEventProperties = ({ allowedSlippage, fiatValues, txHash, + timeToSignSinceRequestMs, }: { trade: InterfaceTrade allowedSlippage: Percent fiatValues: { amountIn?: number; amountOut?: number } txHash?: string + timeToSignSinceRequestMs?: number }) => ({ transaction_hash: txHash, token_in_amount_usd: fiatValues.amountIn, token_out_amount_usd: fiatValues.amountOut, + // measures the amount of time the user took to sign the permit message or swap tx in their wallet + time_to_sign_since_request_ms: timeToSignSinceRequestMs, ...formatCommonPropertiesForTrade(trade, allowedSlippage), })