From bc7929b1c96f09e5ae3c3b76d4ef2c649b0dd78a Mon Sep 17 00:00:00 2001 From: Nick Gambino <35090461+gambinish@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:09:17 -0700 Subject: [PATCH] chore: Add currency conversion telemetry (#26876) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** In order to figure out which currencies we should support 24hr % change, we need to know which currencies are the most popular. Adds currency change dropdown event to telemetry events. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26876?quickstart=1) ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/MMASSETS-344 ## **Screenshots/Recordings** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] 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-extension/blob/develop/.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. --- app/scripts/controllers/metametrics.js | 1 + shared/constants/metametrics.ts | 5 +++++ .../settings/settings-tab/settings-tab.component.js | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index d815607d27e8..d799249bb71b 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -837,6 +837,7 @@ export default class MetaMetricsController { metamaskState.useTokenDetection, [MetaMetricsUserTrait.UseNativeCurrencyAsPrimaryCurrency]: metamaskState.useNativeCurrencyAsPrimaryCurrency, + [MetaMetricsUserTrait.CurrentCurrency]: metamaskState.currentCurrency, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) [MetaMetricsUserTrait.MmiExtensionId]: this.extension?.runtime?.id, [MetaMetricsUserTrait.MmiAccountAddress]: mmiAccountAddress, diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index daec305bfb11..0ad1bc9e1deb 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -468,6 +468,10 @@ export enum MetaMetricsUserTrait { MmiIsCustodian = 'mmi_is_custodian', ///: END:ONLY_INCLUDE_IF PetnameAddressCount = 'petname_addresses_count', + /** + * Identified when the user selects a currency from settings + */ + CurrentCurrency = 'current_currency', } /** @@ -514,6 +518,7 @@ export enum MetaMetricsEventName { BridgeLinkClicked = 'Bridge Link Clicked', BitcoinSupportToggled = 'Bitcoin Support Toggled', BitcoinTestnetSupportToggled = 'Bitcoin Testnet Support Toggled', + CurrentCurrency = 'Current Currency', DappViewed = 'Dapp Viewed', DecryptionApproved = 'Decryption Approved', DecryptionRejected = 'Decryption Rejected', diff --git a/ui/pages/settings/settings-tab/settings-tab.component.js b/ui/pages/settings/settings-tab/settings-tab.component.js index 45407ece008d..d798b62f77ba 100644 --- a/ui/pages/settings/settings-tab/settings-tab.component.js +++ b/ui/pages/settings/settings-tab/settings-tab.component.js @@ -119,7 +119,16 @@ export default class SettingsTab extends PureComponent { id="select-currency" options={currencyOptions} selectedOption={currentCurrency} - onChange={(newCurrency) => setCurrentCurrency(newCurrency)} + onChange={(newCurrency) => { + setCurrentCurrency(newCurrency); + this.context.trackEvent({ + category: MetaMetricsEventCategory.Settings, + event: MetaMetricsEventName.CurrentCurrency, + properties: { + current_currency: newCurrency, + }, + }); + }} />