feat: add time to sign analytics (#7140)

* add time to sign analytics

* move comment
This commit is contained in:
Tina 2023-08-14 14:13:38 -04:00 committed by GitHub
parent bb6de9056b
commit def4ab3bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

@ -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,
})

@ -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,

@ -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),
})