Skip to content

fix: standardize account type analytics#27596

Merged
grvgoel81 merged 16 commits intomainfrom
fix/standardize-account-type-analytics
Apr 9, 2026
Merged

fix: standardize account type analytics#27596
grvgoel81 merged 16 commits intomainfrom
fix/standardize-account-type-analytics

Conversation

@grvgoel81
Copy link
Copy Markdown
Contributor

@grvgoel81 grvgoel81 commented Mar 18, 2026

Description

There are inconsistencies in how the account_type value is recorded in analytics events. Current values include hardcoded strings like 'social', 'default_google', 'social_import', and template literals like metamask_${provider}. This PR standardizes all account_type values to use the AccountType enum, ensuring consistency across all analytics metrics.

Changes:

  • OAuthService.ts — Replaced default_${authConnection} with getSocialAccountType() for SOCIAL_LOGIN_FAILED event.
  • OAuthRehydration — Replaced hardcoded 'social' values with accountType from Redux (selectOnboardingAccountType), falling back to AccountType.Social
  • ChoosePassword — Replaced metamask_${provider} with getSocialAccountType(provider, false) and AccountType.Metamask

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TO-593

Manual testing steps

Feature: account_type analytics standardization

  Scenario: New wallet creation sends correct account_type
    Given the user is on the onboarding screen
    When user creates a new wallet via "Create a new wallet"
    Then WALLET_SETUP_COMPLETED event has account_type "metamask"

  Scenario: SRP import sends correct account_type
    Given the user is on the onboarding screen
    When user imports wallet via Secret Recovery Phrase
    Then WALLET_SETUP_COMPLETED event has account_type "srp_import"

  Scenario: Social login (Google) sends correct account_type
    Given the user is on the onboarding screen
    When user creates wallet via Google login (new user)
    Then WALLET_CREATION_ATTEMPTED event has account_type "metamask_google"

  Scenario: Social login failure sends correct account_type
    Given the user is on the onboarding screen
    When user attempts Google login and it fails
    Then SOCIAL_LOGIN_FAILED event has account_type "metamask_google"

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Low Risk
Low functional risk since changes are limited to analytics/tracing payload values and related tests, plus a small dependency patch bump. Main risk is metrics/dashboard continuity if downstream expects the old inconsistent account_type strings.

Overview
Standardizes onboarding analytics/tracing account_type values by routing all emitted values through the AccountType enum and getSocialAccountType() helper, replacing hardcoded strings/template literals across wallet creation, SRP import, OAuth rehydration, and social login failure tracking.

Adds coverage in ChoosePassword, ImportFromSecretRecoveryPhrase, and OAuthService tests to assert the new account_type mappings (including social vs rehydration and SRP vs social import). Also bumps @xmldom/xmldom from ^0.8.10 to ^0.8.12.

Reviewed by Cursor Bugbot for commit e3056c5. Bugbot is set up for automated code reviews on this repo. Configure here.

@grvgoel81 grvgoel81 self-assigned this Mar 18, 2026
@grvgoel81 grvgoel81 added the team-onboarding Onboarding team label Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 18, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk size-M and removed risk-medium Moderate testing recommended · Possible bug introduction risk size-S labels Mar 18, 2026
@grvgoel81 grvgoel81 marked this pull request as ready for review March 18, 2026 12:59
@grvgoel81 grvgoel81 requested a review from a team as a code owner March 18, 2026 12:59
Resolve conflicts in OAuthRehydration and import-wallet analytics spec.

- OAuthRehydration: keep single wrong-password path; use accountType from
  Redux for REHYDRATION_PASSWORD_FAILED with handlePasswordError flow from main.
- import-wallet.spec: use analyticsExpectations helper from main.
- import-wallet.analytics: WALLET_SETUP_COMPLETED account_type srp_import
  (matches ImportFromSecretRecoveryPhrase / AccountType.SrpImport).

Made-with: Cursor
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 24, 2026
Copy link
Copy Markdown
Contributor

@tylerc-consensys tylerc-consensys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like Imported is unused?

@grvgoel81
Copy link
Copy Markdown
Contributor Author

Seems like Imported is unused?

It is used in getSocialAccountType for existing users without a Google/Apple mapping and in ImportSRP module too.

@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 6, 2026
@grvgoel81
Copy link
Copy Markdown
Contributor Author

getSocialAccountType(authConnection, false) — should this be userClickedRehydration instead of false?

The existingUser param is hardcoded to false, but userClickedRehydration is already available and sent as is_rehydration in the same event. This means both new and returning user failures emit metamask_google - the imported_google/imported_apple values never get used for failure events. Seems like it should be:

account_type: getSocialAccountType(authConnection, userClickedRehydration)

Resolved.

@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 6, 2026
@@ -710,7 +719,7 @@ const OAuthRehydration: React.FC<OAuthRehydrationProps> = ({

const handleUseOtherMethod = () => {
track(MetaMetricsEvents.USE_DIFFERENT_LOGIN_METHOD_CLICKED, {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanna inform that we don't have this event, Use Different Login Method Clicked in the schema.

## **Description**

Bumps `@xmldom/xmldom` from `^0.8.10` to `^0.8.12` to address the
failing production dependency audit (`GHSA-wh4c-j3r5-mjhp`).

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: Production dependency audit compliance

  Scenario: audit CI passes after xmldom patch update
    Given the repository is on branch chore/fix-audit-xmldom
    When I run yarn audit:ci
    Then no audit suggestions are reported
```

## **Screenshots/Recordings**

### **Before**

N/A (dependency-only change)

### **After**

N/A (dependency-only change)

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk dependency-only update; main risk is unexpected behavior
changes in XML parsing due to the transitive library patch bump.
>
> **Overview**
> Updates the production dependency `@xmldom/xmldom` from
`^0.8.10`/`0.8.11` to `^0.8.12` and refreshes `yarn.lock` to lock the
new resolved version/checksum, addressing the flagged security advisory.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
776772f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

(cherry picked from commit f6dcbae)
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 7, 2026
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 7, 2026
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 7, 2026
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeCard, SmokePerps, SmokeRamps, SmokeMultiChainAPI, SmokePredictions, FlaskBuildTests
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

E2E Test Selection:
Fallback: AI analysis did not complete successfully. Running all tests.

Performance Test Selection:
Fallback: AI analysis did not complete successfully. Running all performance tests.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@grvgoel81 grvgoel81 enabled auto-merge April 9, 2026 05:53
@grvgoel81 grvgoel81 added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 19e3757 Apr 9, 2026
195 of 202 checks passed
@grvgoel81 grvgoel81 deleted the fix/standardize-account-type-analytics branch April 9, 2026 06:05
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-high Extensive testing required · High bug introduction risk size-M team-onboarding Onboarding team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants