Skip to content

Commit

Permalink
feat: add metametricsid in state export (#12621)
Browse files Browse the repository at this point in the history
<!--
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**

Add metaMetrics ID in state export (export on long press on login screen
fox)

## **Related issues**

Fixes #12541 

## **Manual testing steps**

```gherkin
Feature: Add metaMetrics ID in state export

  Scenario: User opted-in for metametrics
    Given app is installed and wallet created
    And user opted-in for metametrics
    And user is on login screen
    When user long press the fox logo (>10s)
    Then download state file starts
    And the file has metaMetricsId value in it.

  Scenario: User did not opt-in or opted-out for metametrics
    Given app is installed and wallet created
    And user did not opt-in or opted-out for metametrics
    And user is on login screen
    When user long press the fox logo (>10s)
    Then download state file starts
    And the file does not have metaMetricsId value in it.
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

N/A

### **After**


![image](https://github.com/user-attachments/assets/3cff2bce-366f-4bf2-a589-f0f868b30a35)

## **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).
- [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-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.
  • Loading branch information
NicolasMassart authored Dec 13, 2024
1 parent 73dfa8a commit 30e8f6d
Show file tree
Hide file tree
Showing 3 changed files with 432 additions and 1 deletion.
356 changes: 356 additions & 0 deletions app/util/logs/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`logs :: generateStateLogs generates a valid json export 1`] = `
{
"appVersion": "1",
"buildNumber": "123",
"engine": {
"backgroundState": {
"AccountTrackerController": {
"accounts": {},
"accountsByChainId": {
"0x1": {},
},
},
"AccountsController": {
"internalAccounts": {
"accounts": {},
"selectedAccount": "",
},
},
"AddressBookController": {
"addressBook": {},
},
"ApprovalController": {
"approvalFlows": [],
"pendingApprovalCount": 0,
"pendingApprovals": {},
},
"AuthenticationController": {
"isSignedIn": false,
},
"CurrencyRateController": {
"currencyRates": {
"ETH": {
"conversionDate": 0,
"conversionRate": 0,
"usdConversionRate": null,
},
},
"currentCurrency": "usd",
},
"GasFeeController": {
"estimatedGasFeeTimeBounds": {},
"gasEstimateType": "none",
"gasFeeEstimates": {},
"gasFeeEstimatesByChainId": {},
"nonRPCGasFeeApisDisabled": false,
},
"KeyringController": {
"keyrings": [
"keyring1",
"keyring2",
],
},
"LoggingController": {
"logs": {},
},
"NetworkController": {
"networkConfigurationsByChainId": {
"0x1": {
"blockExplorerUrls": [],
"chainId": "0x1",
"defaultRpcEndpointIndex": 0,
"name": "Ethereum Mainnet",
"nativeCurrency": "ETH",
"rpcEndpoints": [
{
"networkClientId": "mainnet",
"type": "infura",
"url": "https://mainnet.infura.io/v3/{infuraProjectId}",
},
],
},
"0x5": {
"blockExplorerUrls": [],
"chainId": "0x5",
"defaultRpcEndpointIndex": 0,
"name": "Goerli",
"nativeCurrency": "GoerliETH",
"rpcEndpoints": [
{
"networkClientId": "goerli",
"type": "infura",
"url": "https://goerli.infura.io/v3/{infuraProjectId}",
},
],
},
"0xaa36a7": {
"blockExplorerUrls": [],
"chainId": "0xaa36a7",
"defaultRpcEndpointIndex": 0,
"name": "Sepolia",
"nativeCurrency": "SepoliaETH",
"rpcEndpoints": [
{
"networkClientId": "sepolia",
"type": "infura",
"url": "https://sepolia.infura.io/v3/{infuraProjectId}",
},
],
},
"0xe704": {
"blockExplorerUrls": [],
"chainId": "0xe704",
"defaultRpcEndpointIndex": 0,
"name": "Linea Goerli",
"nativeCurrency": "LineaETH",
"rpcEndpoints": [
{
"networkClientId": "linea-goerli",
"type": "infura",
"url": "https://linea-goerli.infura.io/v3/{infuraProjectId}",
},
],
},
"0xe705": {
"blockExplorerUrls": [],
"chainId": "0xe705",
"defaultRpcEndpointIndex": 0,
"name": "Linea Sepolia",
"nativeCurrency": "LineaETH",
"rpcEndpoints": [
{
"networkClientId": "linea-sepolia",
"type": "infura",
"url": "https://linea-sepolia.infura.io/v3/{infuraProjectId}",
},
],
},
"0xe708": {
"blockExplorerUrls": [],
"chainId": "0xe708",
"defaultRpcEndpointIndex": 0,
"name": "Linea",
"nativeCurrency": "ETH",
"rpcEndpoints": [
{
"networkClientId": "linea-mainnet",
"type": "infura",
"url": "https://linea-mainnet.infura.io/v3/{infuraProjectId}",
},
],
},
},
"networksMetadata": {
"mainnet": {
"EIPS": {},
"status": "unknown",
},
},
"selectedNetworkClientId": "mainnet",
},
"NotificationServicesController": {
"isCheckingAccountsPresence": false,
"isFeatureAnnouncementsEnabled": false,
"isFetchingMetamaskNotifications": false,
"isMetamaskNotificationsFeatureSeen": false,
"isNotificationServicesEnabled": false,
"isUpdatingMetamaskNotifications": false,
"isUpdatingMetamaskNotificationsAccount": [],
"metamaskNotificationsList": [],
"metamaskNotificationsReadList": [],
"subscriptionAccountsSeen": [],
},
"NotificationServicesPushController": {
"fcmToken": "",
},
"PPOMController": {
"storageMetadata": [],
"versionInfo": [],
},
"PermissionController": {
"subjects": {},
},
"PreferencesController": {
"displayNftMedia": true,
"featureFlags": {},
"identities": {},
"ipfsGateway": "https://dweb.link/ipfs/",
"isIpfsGatewayEnabled": true,
"isMultiAccountBalancesEnabled": true,
"lostIdentities": {},
"privacyMode": false,
"securityAlertsEnabled": true,
"selectedAddress": "",
"showIncomingTransactions": {
"0x1": true,
"0x13881": true,
"0x38": true,
"0x5": true,
"0x504": true,
"0x505": true,
"0x507": true,
"0x61": true,
"0x64": true,
"0x89": true,
"0xa": true,
"0xa869": true,
"0xa86a": true,
"0xaa36a7": true,
"0xaa37dc": true,
"0xe704": true,
"0xe705": true,
"0xe708": true,
"0xfa": true,
"0xfa2": true,
},
"showMultiRpcModal": false,
"showTestNetworks": false,
"smartTransactionsOptInStatus": true,
"tokenNetworkFilter": {},
"tokenSortConfig": {
"key": "tokenFiatAmount",
"order": "dsc",
"sortCallback": "stringNumeric",
},
"useNftDetection": true,
"useSafeChainsListValidation": true,
"useTokenDetection": true,
"useTransactionSimulations": true,
},
"RemoteFeatureFlagController": {
"cacheTimestamp": 0,
"remoteFeatureFlags": {},
},
"SelectedNetworkController": {
"domains": {},
},
"SignatureController": {
"signatureRequests": {},
"unapprovedPersonalMsgCount": 0,
"unapprovedPersonalMsgs": {},
"unapprovedTypedMessages": {},
"unapprovedTypedMessagesCount": 0,
},
"SmartTransactionsController": {
"smartTransactionsState": {
"fees": {
"approvalTxFees": null,
"tradeTxFees": null,
},
"feesByChainId": {
"0x1": {
"approvalTxFees": null,
"tradeTxFees": null,
},
"0xaa36a7": {
"approvalTxFees": null,
"tradeTxFees": null,
},
},
"liveness": true,
"livenessByChainId": {
"0x1": true,
"0xaa36a7": true,
},
"smartTransactions": {
"0x1": [],
},
"userOptIn": null,
"userOptInV2": null,
},
},
"SnapController": {
"snapStates": {},
"snaps": {},
"unencryptedSnapStates": {},
},
"SnapsRegistry": {
"database": null,
"databaseUnavailable": false,
"lastUpdated": null,
},
"SubjectMetadataController": {
"subjectMetadata": {},
},
"SwapsController": {
"aggregatorMetadata": null,
"aggregatorMetadataLastFetched": 0,
"approvalTransaction": null,
"chainCache": {
"0x1": {
"aggregatorMetadata": null,
"aggregatorMetadataLastFetched": 0,
"tokens": null,
"tokensLastFetched": 0,
"topAssets": null,
"topAssetsLastFetched": 0,
},
},
"error": {
"description": null,
"key": null,
},
"fetchParams": {
"destinationToken": "",
"slippage": 0,
"sourceAmount": 0,
"sourceToken": "",
"walletAddress": "",
},
"fetchParamsMetaData": {
"destinationTokenInfo": {
"address": "",
"decimals": 0,
"symbol": "",
},
"sourceTokenInfo": {
"address": "",
"decimals": 0,
"symbol": "",
},
},
"isInPolling": false,
"pollingCyclesLeft": 3,
"quoteRefreshSeconds": null,
"quoteValues": {},
"quotes": {},
"quotesLastFetched": 0,
"tokens": null,
"tokensLastFetched": 0,
"topAggId": null,
"topAggSavings": null,
"topAssets": null,
"topAssetsLastFetched": 0,
"usedCustomGas": null,
"usedGasEstimate": null,
},
"TokenBalancesController": {
"tokenBalances": {},
},
"TokenListController": {
"preventPollingOnNetworkRestart": false,
"tokenList": {},
"tokensChainsCache": {},
},
"TokenRatesController": {
"marketData": {},
},
"TransactionController": {
"lastFetchedBlockNumbers": {},
"methodData": {},
"submitHistory": [],
"transactions": [],
},
"UserStorageController": {
"hasAccountSyncingSyncedAtLeastOnce": false,
"isAccountSyncingReadyToBeDispatched": false,
"isProfileSyncingEnabled": true,
"isProfileSyncingUpdateLoading": false,
},
},
},
"metaMetricsId": "6D796265-7374-4953-6D65-74616D61736B",
}
`;
Loading

0 comments on commit 30e8f6d

Please sign in to comment.