Skip to content

Commit

Permalink
chore: Add currency conversion telemetry (#26876)
Browse files Browse the repository at this point in the history
## **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.
  • Loading branch information
gambinish committed Sep 17, 2024
1 parent c462fb8 commit bc7929b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

/**
Expand Down Expand Up @@ -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',
Expand Down
11 changes: 10 additions & 1 deletion ui/pages/settings/settings-tab/settings-tab.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}}
/>
</div>
</div>
Expand Down

0 comments on commit bc7929b

Please sign in to comment.