Commit b57a5d7d authored by eddie's avatar eddie Committed by GitHub

feat: log swap button click (#6654)

parent e2dd78fd
......@@ -6,6 +6,7 @@ import {
InterfaceEventName,
InterfacePageName,
InterfaceSectionName,
SharedEventName,
SwapEventName,
} from '@uniswap/analytics-events'
import { Currency, CurrencyAmount, Percent, Token } from '@uniswap/sdk-core'
......@@ -691,39 +692,45 @@ export function Swap({
</ThemedText.DeprecatedMain>
</GrayCard>
) : (
<ButtonError
onClick={() => {
if (isExpertMode) {
handleSwap()
} else {
setSwapState({
tradeToConfirm: trade,
attemptingTxn: false,
swapError: undefined,
showConfirm: true,
txHash: undefined,
})
}
}}
id="swap-button"
data-testid="swap-button"
disabled={!isValid || routeIsSyncing || routeIsLoading || priceImpactTooHigh}
error={isValid && priceImpactSeverity > 2 && allowance.state === AllowanceState.ALLOWED}
<TraceEvent
events={[BrowserEvent.onClick]}
name={SharedEventName.ELEMENT_CLICKED}
element={InterfaceElementName.SWAP_BUTTON}
>
<Text fontSize={20} fontWeight={600}>
{swapInputError ? (
swapInputError
) : routeIsSyncing || routeIsLoading ? (
<Trans>Swap</Trans>
) : priceImpactTooHigh ? (
<Trans>Price Impact Too High</Trans>
) : priceImpactSeverity > 2 ? (
<Trans>Swap Anyway</Trans>
) : (
<Trans>Swap</Trans>
)}
</Text>
</ButtonError>
<ButtonError
onClick={() => {
if (isExpertMode) {
handleSwap()
} else {
setSwapState({
tradeToConfirm: trade,
attemptingTxn: false,
swapError: undefined,
showConfirm: true,
txHash: undefined,
})
}
}}
id="swap-button"
data-testid="swap-button"
disabled={!isValid || routeIsSyncing || routeIsLoading || priceImpactTooHigh}
error={isValid && priceImpactSeverity > 2 && allowance.state === AllowanceState.ALLOWED}
>
<Text fontSize={20} fontWeight={600}>
{swapInputError ? (
swapInputError
) : routeIsSyncing || routeIsLoading ? (
<Trans>Swap</Trans>
) : priceImpactTooHigh ? (
<Trans>Price Impact Too High</Trans>
) : priceImpactSeverity > 2 ? (
<Trans>Swap Anyway</Trans>
) : (
<Trans>Swap</Trans>
)}
</Text>
</ButtonError>
</TraceEvent>
)}
{Boolean(isExpertMode && swapError) && <SwapCallbackError error={swapError?.message} />}
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment