Commit b852e4e6 authored by lynn's avatar lynn Committed by GitHub

feat: adding analytics for fiat on ramp buy button feature (#6272)

* init

* testing if it works

* wip

* tooltip still not working correctly

* modal still not triggered after initial buy click

* remove invalid import

* region check fixed

* add disabled buy button treatment

* simplify and fix toggle twice bug

* no more state mgmt bugs finally

* rename vars for clarity and add todos

* add feature flag, remove toast

* keep wallet drawer open upon repeated buy clicks

* remove from feature flag modal for now

* unused vars

* first round respond to tina comments

* respond to tina padding comments, fix padding in response to cal feedback

* last round tina comments

* init pending element names being added to analytics events repo

* update event names

* add tooltip delay requested by fred and cal

* middle of revisions, fiat buy flow readability wip

* hook logic refactor done + added basic unit test

* rename enum and add todo for unit tests

* mouseover tooltip disable properly

* fix mouseover tooltip not working, ensure dot working as expected, rename buyFiatClicked to buyFiatFlowCompleted

* change developer doc comment

* respond comments

* update snapshot test

* lint fix

* remove unnecessary changes
parent 55bd3555
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { TraceEvent } from '@uniswap/analytics'
import { BrowserEvent, InterfaceElementName, SharedEventName } from '@uniswap/analytics-events'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { ButtonText } from 'components/Button' import { ButtonText } from 'components/Button'
import { MouseoverTooltipContent } from 'components/Tooltip' import { MouseoverTooltipContent } from 'components/Tooltip'
...@@ -114,18 +116,31 @@ export default function SwapBuyFiatButton() { ...@@ -114,18 +116,31 @@ export default function SwapBuyFiatButton() {
content={ content={
<div data-testid="fiat-on-ramp-unavailable-tooltip"> <div data-testid="fiat-on-ramp-unavailable-tooltip">
<Trans>Crypto purchases are not available in your region. </Trans> <Trans>Crypto purchases are not available in your region. </Trans>
<ExternalLink href={MOONPAY_REGION_AVAILABILITY_ARTICLE} style={{ paddingLeft: '4px' }}> <TraceEvent
<Trans>Learn more</Trans> events={[BrowserEvent.onClick]}
</ExternalLink> name={SharedEventName.ELEMENT_CLICKED}
element={InterfaceElementName.FIAT_ON_RAMP_LEARN_MORE_LINK}
>
<ExternalLink href={MOONPAY_REGION_AVAILABILITY_ARTICLE} style={{ paddingLeft: '4px' }}>
<Trans>Learn more</Trans>
</ExternalLink>
</TraceEvent>
</div> </div>
} }
placement="bottom" placement="bottom"
disableHover={fiatOnRampsUnavailableTooltipDisabled} disableHover={fiatOnRampsUnavailableTooltipDisabled}
> >
<StyledTextButton onClick={handleBuyCrypto} disabled={buyCryptoButtonDisabled} data-testid="buy-fiat-button"> <TraceEvent
<Trans>Buy</Trans> events={[BrowserEvent.onClick]}
{!buyFiatFlowCompleted && <Dot data-testid="buy-fiat-flow-incomplete-indicator" />} name={SharedEventName.ELEMENT_CLICKED}
</StyledTextButton> element={InterfaceElementName.FIAT_ON_RAMP_BUY_BUTTON}
properties={{ account_connected: !!account }}
>
<StyledTextButton onClick={handleBuyCrypto} disabled={buyCryptoButtonDisabled} data-testid="buy-fiat-button">
<Trans>Buy</Trans>
{!buyFiatFlowCompleted && <Dot data-testid="buy-fiat-flow-incomplete-indicator" />}
</StyledTextButton>
</TraceEvent>
</MouseoverTooltipContent> </MouseoverTooltipContent>
) )
} }
...@@ -4567,10 +4567,10 @@ ...@@ -4567,10 +4567,10 @@
"@typescript-eslint/types" "5.47.0" "@typescript-eslint/types" "5.47.0"
eslint-visitor-keys "^3.3.0" eslint-visitor-keys "^3.3.0"
"@uniswap/analytics-events@^2.8.0": "@uniswap/analytics-events@^2.9.0":
version "2.8.0" version "2.9.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.8.0.tgz#651eb08913b1a47c79814f0536b46cd91a6102d3" resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.9.0.tgz#80c634bfae850da33b446df0a9fb325869fa8ffa"
integrity sha512-unaNUxPYGoaPsPS+j6UuQRnxikha6Dr9Knv9jBVY/vIj03f8AOisVM7Zw9493QZP14lq2guARddkN3NzlttuwQ== integrity sha512-pgrr44L26/0MhRNKC7u8NwjIjVv5tKFqKre2h+TYpzRamZsOD37sR9mnovlF6FA91jNPRMPKK+kHouiimMfmrA==
"@uniswap/analytics@^1.3.1": "@uniswap/analytics@^1.3.1":
version "1.3.1" version "1.3.1"
......
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