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

feat: log swap button click (#6654)

parent e2dd78fd
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
InterfaceEventName, InterfaceEventName,
InterfacePageName, InterfacePageName,
InterfaceSectionName, InterfaceSectionName,
SharedEventName,
SwapEventName, SwapEventName,
} from '@uniswap/analytics-events' } from '@uniswap/analytics-events'
import { Currency, CurrencyAmount, Percent, Token } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, Percent, Token } from '@uniswap/sdk-core'
...@@ -691,39 +692,45 @@ export function Swap({ ...@@ -691,39 +692,45 @@ export function Swap({
</ThemedText.DeprecatedMain> </ThemedText.DeprecatedMain>
</GrayCard> </GrayCard>
) : ( ) : (
<ButtonError <TraceEvent
onClick={() => { events={[BrowserEvent.onClick]}
if (isExpertMode) { name={SharedEventName.ELEMENT_CLICKED}
handleSwap() element={InterfaceElementName.SWAP_BUTTON}
} 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}> <ButtonError
{swapInputError ? ( onClick={() => {
swapInputError if (isExpertMode) {
) : routeIsSyncing || routeIsLoading ? ( handleSwap()
<Trans>Swap</Trans> } else {
) : priceImpactTooHigh ? ( setSwapState({
<Trans>Price Impact Too High</Trans> tradeToConfirm: trade,
) : priceImpactSeverity > 2 ? ( attemptingTxn: false,
<Trans>Swap Anyway</Trans> swapError: undefined,
) : ( showConfirm: true,
<Trans>Swap</Trans> txHash: undefined,
)} })
</Text> }
</ButtonError> }}
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} />} {Boolean(isExpertMode && swapError) && <SwapCallbackError error={swapError?.message} />}
</div> </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