Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ramp): add event when user expands quotes #8729

Merged
merged 19 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
50d2a60
feat(ramp): add bottom sheet quotes
wachunei Feb 19, 2024
450aa28
test(ramp): update snapshots
wachunei Feb 19, 2024
41ea249
refactor(ramp): add a11y props to bottom sheet button
wachunei Feb 20, 2024
3c6a72b
feat(ramp): add orders providers selectors
wachunei Feb 19, 2024
c10bb71
feat(ramp): add previously used provider logic
wachunei Feb 19, 2024
0b2d069
feat(ramp): use TagColored component
wachunei Feb 22, 2024
92689fc
fix(ramp): fix typo
wachunei Feb 22, 2024
dfb5895
Merge branch 'main' into feat/ramp-bottom-sheet-quotes
wachunei Feb 26, 2024
388ee23
Merge branch 'feat/ramp-bottom-sheet-quotes' into feat/ramp-previousl…
wachunei Feb 26, 2024
101f50a
feat(ramp): add quotes expanded event
wachunei Feb 26, 2024
2b28c12
feat(ramp): add fields to event
wachunei Feb 28, 2024
f75fa79
Merge branch 'main' into feat/ramp-bottom-sheet-quotes
wachunei Feb 28, 2024
274af9f
test(ramp): update snapshots
wachunei Feb 28, 2024
29b9144
Merge branch 'feat/ramp-bottom-sheet-quotes' into feat/ramp-previousl…
wachunei Feb 28, 2024
6944395
Merge branch 'feat/ramp-previously-used-provider' into feat/ramp-expl…
wachunei Feb 28, 2024
43452fe
Merge branch 'main' into feat/ramp-previously-used-provider
wachunei Feb 28, 2024
c7bb597
Merge branch 'feat/ramp-previously-used-provider' into feat/ramp-expl…
wachunei Feb 28, 2024
67e3d80
Merge branch 'main' into feat/ramp-explore-quotes-event
wachunei Feb 29, 2024
a08985f
Merge branch 'main' into feat/ramp-explore-quotes-event
wachunei Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/components/UI/Ramp/Views/Quotes/Quotes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,27 @@ describe('Quotes', () => {
jest.advanceTimersByTime(3000);
jest.clearAllTimers();
});
expect(mockTrackEvent.mock.lastCall).toMatchInlineSnapshot(`
Array [
"ONRAMP_QUOTES_EXPANDED",
Object {
"amount": 50,
"chain_id_destination": "1",
"currency_destination": "ETH",
"currency_source": "USD",
"payment_method_id": "/payment-methods/test-payment-method",
"previously_used_count": 0,
"provider_onramp_first": "Banxa (Staging)",
"provider_onramp_list": Array [
"Banxa (Staging)",
"MoonPay (Staging)",
"Transak (Staging)",
],
"refresh_count": 1,
"results_count": 3,
},
]
`);
expect(screen.toJSON()).toMatchSnapshot();
act(() => {
jest.useRealTimers();
Expand Down
44 changes: 43 additions & 1 deletion app/components/UI/Ramp/Views/Quotes/Quotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,48 @@ function Quotes() {
trackEvent,
]);

const handleExpandQuotes = useCallback(() => {
setIsExpanded(true);
const payload = {
payment_method_id: selectedPaymentMethodId as string,
amount: params.amount,
refresh_count: appConfig.POLLING_CYCLES - pollingCyclesLeft,
results_count: filteredQuotes.length,
provider_onramp_first: filteredQuotes[0]?.provider?.name,
provider_onramp_list: filteredQuotes.map(({ provider }) => provider.name),
previously_used_count: filteredQuotes.filter(({ provider }) =>
ordersProviders.includes(provider.id),
).length,
};
if (isBuy) {
trackEvent('ONRAMP_QUOTES_EXPANDED', {
...payload,
chain_id_destination: selectedChainId,
currency_source: params.fiatCurrency?.symbol,
currency_destination: params.asset?.symbol,
});
} else {
trackEvent('OFFRAMP_QUOTES_EXPANDED', {
...payload,
chain_id_source: selectedChainId,
currency_source: params.asset?.symbol,
currency_destination: params.fiatCurrency?.symbol,
});
}
}, [
appConfig.POLLING_CYCLES,
filteredQuotes,
isBuy,
ordersProviders,
params.amount,
params.asset?.symbol,
params.fiatCurrency?.symbol,
pollingCyclesLeft,
selectedChainId,
selectedPaymentMethodId,
trackEvent,
]);

const handleOnQuotePress = useCallback(
(quote: QuoteResponse | SellQuoteResponse) => {
setProviderId(quote.provider.id);
Expand Down Expand Up @@ -747,7 +789,7 @@ function Quotes() {
label: strings(
'fiat_on_ramp_aggregator.explore_more_options',
),
onPress: () => setIsExpanded(true),
onPress: handleExpandQuotes,
},
]
: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ exports[`Quotes renders correctly after animation with quotes 1`] = `
</View>
`;

exports[`Quotes renders correctly after animation with quotes and expanded 1`] = `
exports[`Quotes renders correctly after animation with quotes and expanded 2`] = `
<View
style={
Object {
Expand Down
23 changes: 21 additions & 2 deletions app/components/UI/Ramp/types/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,24 @@ interface RampTransaction {
order_id?: string;
}

interface RampQuotesExpanded {
payment_method_id: string;
currency_source: string;
currency_destination: string;
amount: number | string;
refresh_count: number;
results_count: number;
previously_used_count: number;
}

interface OnRampQuotesExpanded extends RampQuotesExpanded {
chain_id_destination: string;
}

interface OffRampQuotesExpanded extends RampQuotesExpanded {
chain_id_source: string;
}

export interface AnalyticsEvents {
BUY_BUTTON_CLICKED: BuyButtonClicked;
SELL_BUTTON_CLICKED: SellButtonClicked;
Expand All @@ -305,6 +323,9 @@ export interface AnalyticsEvents {
ONRAMP_QUOTES_RECEIVED: OnRampQuotesReceived;
OFFRAMP_QUOTES_RECEIVED: OffRampQuotesReceived;

ONRAMP_QUOTES_EXPANDED: OnRampQuotesExpanded;
OFFRAMP_QUOTES_EXPANDED: OffRampQuotesExpanded;

ONRAMP_PROVIDER_SELECTED: OnRampProviderSelected;
OFFRAMP_PROVIDER_SELECTED: OffRampProviderSelected;

Expand Down Expand Up @@ -341,6 +362,4 @@ export interface AnalyticsEvents {
OFFRAMP_SEND_TRANSACTION_INVOKED: RampTransaction;
OFFRAMP_SEND_TRANSACTION_CONFIRMED: RampTransaction;
OFFRAMP_SEND_TRANSACTION_REJECTED: RampTransaction;

// after redirection events will go here
}
4 changes: 4 additions & 0 deletions app/core/Analytics/MetaMetrics.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ enum EVENT_NAME {
ONRAMP_QUOTES_REQUESTED = 'On-ramp Quotes Requested',
ONRAMP_CANCELED = 'On-ramp Canceled',
ONRAMP_QUOTES_RECEIVED = 'On-ramp Quotes Received',
ONRAMP_QUOTES_EXPANDED = 'On-ramp Quotes Expanded',
ONRAMP_PROVIDER_SELECTED = 'On-ramp Provider Selected',
ONRAMP_PROVIDER_DETAILS_VIEWED = 'On-ramp Provider Details Viewed',
ONRAMP_DIRECT_PROVIDER_CLICKED = 'On-ramp Provider Custom Action Clicked',
Expand All @@ -228,6 +229,7 @@ enum EVENT_NAME {
OFFRAMP_QUOTES_REQUESTED = 'Off-ramp Quotes Requested',
OFFRAMP_CANCELED = 'Off-ramp Canceled',
OFFRAMP_QUOTES_RECEIVED = 'Off-ramp Quotes Received',
OFFRAMP_QUOTES_EXPANDED = 'Off-ramp Quotes Expanded',
OFFRAMP_PROVIDER_SELECTED = 'Off-ramp Provider Selected',
OFFRAMP_PROVIDER_DETAILS_VIEWED = 'Off-ramp Provider Details Viewed',
OFFRAMP_DIRECT_PROVIDER_CLICKED = 'Off-ramp Provider Custom Action Clicked',
Expand Down Expand Up @@ -592,6 +594,7 @@ const events = {
ONRAMP_QUOTES_REQUESTED: generateOpt(EVENT_NAME.ONRAMP_QUOTES_REQUESTED),
ONRAMP_CANCELED: generateOpt(EVENT_NAME.ONRAMP_CANCELED),
ONRAMP_QUOTES_RECEIVED: generateOpt(EVENT_NAME.ONRAMP_QUOTES_RECEIVED),
ONRAMP_QUOTES_EXPANDED: generateOpt(EVENT_NAME.ONRAMP_QUOTES_EXPANDED),
ONRAMP_PROVIDER_SELECTED: generateOpt(EVENT_NAME.ONRAMP_PROVIDER_SELECTED),
ONRAMP_PROVIDER_DETAILS_VIEWED: generateOpt(
EVENT_NAME.ONRAMP_PROVIDER_DETAILS_VIEWED,
Expand Down Expand Up @@ -628,6 +631,7 @@ const events = {
OFFRAMP_QUOTES_REQUESTED: generateOpt(EVENT_NAME.OFFRAMP_QUOTES_REQUESTED),
OFFRAMP_CANCELED: generateOpt(EVENT_NAME.OFFRAMP_CANCELED),
OFFRAMP_QUOTES_RECEIVED: generateOpt(EVENT_NAME.OFFRAMP_QUOTES_RECEIVED),
OFFRAMP_QUOTES_EXPANDED: generateOpt(EVENT_NAME.OFFRAMP_QUOTES_EXPANDED),
OFFRAMP_PROVIDER_SELECTED: generateOpt(EVENT_NAME.OFFRAMP_PROVIDER_SELECTED),
OFFRAMP_PROVIDER_DETAILS_VIEWED: generateOpt(
EVENT_NAME.OFFRAMP_PROVIDER_DETAILS_VIEWED,
Expand Down
Loading