MetaMask / MetaMask/metamask-mobile

Fix: has_marketing_consent and security_providers props Type Violations in MetaMask Mobile Identify Events

Open
#24,902 2 comments 0 reactions 0 assignees View on GitHub
team-mobile-platform
Dominant language
TypeScript
Stars
3k
Forks
1.7k
Avg merge
1d 14h
Merged PRs (30d)
669

Description

### What is this about?

The MetaMask Mobile app is sending Identify events with incorrect property types, causing Segment validation violations. The app sends `string` types where the schema expects `boolean` and `array`, preventing proper validation and causing inconsistencies with Extension behavior.

### Scenario

_No response_

### Design

_No response_

### Technical Details

## Type Violations

Segment debugger shows the following violations in `context.protocols.violations`:

### 1. `traits.has_marketing_consent`
- **Expected**: `boolean`
- **Actual**: `string` ("ON"/"OFF" pattern)
- **Schema Location**: `tracking-plans/metamask-mobile.yaml:39-41`

### 2. `traits.security_providers`
- **Expected**: `array`
- **Actual**: `string`
- **Schema Location**: `tracking-plans/metamask-mobile.yaml:50-52`

## Root Cause Analysis

### `has_marketing_consent`
The schema defines this as `boolean` (matching Extension), but the mobile app sends it as a string ("ON"/"OFF" pattern). The Extension already sends this as a boolean, so Mobile should be updated to match for consistency.

### `security_providers`
The schema defines this as `type: array` with `items: {}` (matching Extension), but the mobile app sends it as a string. The Extension already sends this as an array, so Mobile should be updated to match for consistency.

## Proposed Solution

**Fix the Mobile app code to send the correct types to match Extension:**

1. **Fix `has_marketing_consent` in Mobile app**:
- Update Mobile app code to send `boolean` instead of `string`
- Convert "ON"/"OFF" string values to `true`/`false` boolean values
- This will match Extension behavior and align with the schema definition

2. **Fix `security_providers` in Mobile app**:
- Update Mobile app code to send `array` instead of `string`
- Parse/convert the current string format to an array format
- This will match Extension behavior and align with the schema definition

## Files to Modify

- **MetaMask Mobile app codebase** (exact files to be identified by Mobile team):
- Update Identify event tracking code to send `has_marketing_consent` as `boolean` instead of `string`
- Update Identify event tracking code to send `security_providers` as `array` instead of `string`

### Threat Modeling Framework

- **Breaking change**: No - fixes app to match existing schema (which already matches Extension)
- **Affected products**: MetaMask Mobile only
- **Risk level**: Medium - requires Mobile app code changes, but ensures consistency with Extension and prevents validation errors
- **User profile impact**: **Critical** - Without these fixes, validation errors prevent proper user profile updates, affecting analytics and personalization
- **Consistency benefit**: Aligns Mobile with Extension behavior, making cross-platform analytics more reliable

### Acceptance Criteria

- [ ] Mobile app updated to send `has_marketing_consent` as `boolean` (matching Extension)
- [ ] Mobile app updated to send `security_providers` as `array` (matching Extension)
- [ ] No validation violations in Segment debugger for Identify events
- [ ] User profile updates work correctly with all properties
- [ ] Changes tested and verified in staging/production
- [ ] Code changes reviewed and approved by Mobile team
- [ ] PR created in `metamask-mobile` repository

### Stakeholder review needed before the work gets merged

- [x] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)

### References

- Segment Protocols documentation: https://segment.com/docs/protocols
- MetaMask Mobile tracking plan: `tracking-plans/metamask-mobile.yaml` (in segment-schema repo)
- Extension behavior reference: Check Extension Identify event implementation for correct type patterns

Contributor guide

Open the contributing guide

Research direction

Start with tracking-plans/metamask-mobile.yaml to confirm the expected types, then compare the Extension Identify event implementation and locate the corresponding Identify event code in the MetaMask Mobile app. Update the two properties to match the schema and verify that Segment debugger reports no violations and the stated acceptance checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
analytics, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.