Skip to content

Commit 54d0bf9

Browse files
authored
feat: updated currency switch clicked event for deposit and withdrawal screens (#22286)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Updated currency switch clicked event for deposit and withdrawal screens ### Changes: - Removed code fence blocking `EARN_INPUT_CURRENCY_SWITCH_CLICKED` event for pooled-staking - Added `token_symbol` and `chain_id_hex` properties to `EARN_INPUT_CURRENCY_SWITCH_CLICKED`, `EARN_INPUT_CURRENCY_SWITCH_CLICKED`, and `UNSTAKE_INPUT_CURRENCY_SWITCH_CLICKED` events <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: updated earn input view deposit and withdrawal currency switch events ## **Related issues** Fixes: [TAT-1909: Add "Stake Input Currency Switch Clicked" to MP Segment events](https://consensyssoftware.atlassian.net/browse/TAT-1909) ## **Manual testing steps** ```gherkin Feature: Event tracking for Earn input view currency switch button Scenario: user wants to enter fiat amount Given user is on EarnInputView (e.g. ETH staking or stablecoin lending) When user clicks currency switch Then currency switch event is tracked with new `token_symbol` and `chain_id_hex` properties for both ETH staking and stablecoin lending tokens. ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> Pooled-Staking currency switch events weren't firing ### **After** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/4b13b5bb-113e-4c9b-b18a-75375e5fcbcb ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Always log currency-switch on deposit and add token_symbol and chain_id (hex) to deposit and withdrawal currency-switch events. > > - **Analytics**: > - **Deposit (`EarnInputView.tsx`)**: > - Always log `EARN_INPUT_CURRENCY_SWITCH_CLICKED` on currency toggle (removes prior gating). > - Add `token_symbol` and `chain_id` (hex) to event properties. > - **Withdrawal (`EarnWithdrawInputView.tsx`)**: > - Add `token_symbol` and `chain_id` (hex) to `EARN_INPUT_CURRENCY_SWITCH_CLICKED` and `UNSTAKE_INPUT_CURRENCY_SWITCH_CLICKED`. > - Import `toHex` for chain ID formatting. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 803d2e2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 1f4fbdf commit 54d0bf9

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

app/components/UI/Earn/Views/EarnInputView/EarnInputView.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -646,26 +646,27 @@ const EarnInputView = () => {
646646
// Call the original handler first
647647
handleCurrencySwitch();
648648

649-
if (shouldLogStablecoinEvent()) {
650-
trackEvent(
651-
createEventBuilder(MetaMetricsEvents.EARN_INPUT_CURRENCY_SWITCH_CLICKED)
652-
.addProperties({
653-
selected_provider: EVENT_PROVIDERS.CONSENSYS,
654-
text: 'Currency Switch Clicked',
655-
location: EVENT_LOCATIONS.EARN_INPUT_VIEW,
656-
currency_type: !isFiat ? 'fiat' : 'native',
657-
experience: earnToken?.experience?.type,
658-
})
659-
.build(),
660-
);
661-
}
649+
trackEvent(
650+
createEventBuilder(MetaMetricsEvents.EARN_INPUT_CURRENCY_SWITCH_CLICKED)
651+
.addProperties({
652+
selected_provider: EVENT_PROVIDERS.CONSENSYS,
653+
text: 'Currency Switch Clicked',
654+
location: EVENT_LOCATIONS.EARN_INPUT_VIEW,
655+
currency_type: !isFiat ? 'fiat' : 'native',
656+
experience: earnToken?.experience?.type,
657+
token_symbol: earnToken?.symbol,
658+
chain_id: earnToken?.chainId ? toHex(earnToken.chainId) : undefined,
659+
})
660+
.build(),
661+
);
662662
}, [
663-
shouldLogStablecoinEvent,
664663
handleCurrencySwitch,
665664
trackEvent,
666665
createEventBuilder,
667666
isFiat,
668667
earnToken?.experience?.type,
668+
earnToken?.symbol,
669+
earnToken?.chainId,
669670
]);
670671

671672
const getButtonLabel = () => {

app/components/UI/Earn/Views/EarnWithdrawInputView/EarnWithdrawInputView.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toHex } from '@metamask/controller-utils';
12
import { Hex } from '@metamask/utils';
23
import {
34
useFocusEffect,
@@ -576,6 +577,10 @@ const EarnWithdrawInputView = () => {
576577
// We want to track the currency switching to. Not the current currency.
577578
currency_type: isFiat ? 'native' : 'fiat',
578579
experience: receiptToken?.experience?.type,
580+
token_symbol: receiptToken?.symbol,
581+
chain_id: receiptToken?.chainId
582+
? toHex(receiptToken.chainId)
583+
: undefined,
579584
})
580585
.build(),
581586
);
@@ -591,6 +596,10 @@ const EarnWithdrawInputView = () => {
591596
// We want to track the currency switching to. Not the current currency.
592597
currency_type: isFiat ? 'native' : 'fiat',
593598
experience: receiptToken?.experience?.type,
599+
token_symbol: receiptToken?.symbol,
600+
chain_id: receiptToken?.chainId
601+
? toHex(receiptToken.chainId)
602+
: undefined,
594603
})
595604
.build(),
596605
);
@@ -603,6 +612,8 @@ const EarnWithdrawInputView = () => {
603612
createEventBuilder,
604613
isFiat,
605614
receiptToken?.experience?.type,
615+
receiptToken?.symbol,
616+
receiptToken?.chainId,
606617
]);
607618

608619
const handleQuickAmountPressWithTracking = useCallback(

0 commit comments

Comments
 (0)