This guide provides strategies and tools for debugging MetaMetrics events in the MetaMask Mobile application.
MetaMetrics is the analytics system used in MetaMask Mobile for tracking user interactions and events. This guide covers both verifying that events are working correctly and debugging issues when they aren't appearing as expected.
Before diving into detailed debugging, verify these basics:
- Is analytics enabled? (check
HAS_TEST_OVERRIDESenvironment variable is NOT set totrue) - Is the user opted into analytics? (
isEnabled()fromuseMetricshook) - Are you using the correct event builder pattern?
- Are events being flushed? (automatic every 30s or 20 events, or custom interval via env vars)
- Are you in the correct environment? (development vs production)
- Can you see events in Segment source?
- Can you see events in Mixpanel?
The most common cause of missing events is the HAS_TEST_OVERRIDES=true environment variable.
If set to true, events will not be sent to Segment.
This is intentional for testing environments.
Impact: When HAS_TEST_OVERRIDES=true, the Segment client is replaced with a mock that does nothing.
For development purposes, you can override the default flush policy using environment variables in .js.env:
# Optional for dev purpose: Segment flush interval in seconds
# example for 1 second flush interval
export SEGMENT_FLUSH_INTERVAL="1"
# example for flush when 1 event is queued
export SEGMENT_FLUSH_EVENT_LIMIT="1"Default Behavior: Events are automatically flushed every 30 seconds or when the queue reaches 20 events.
Development Override: Use the environment variables above to flush events immediately for easier debugging.
In development mode, MetaMetrics provides detailed logging to help you verify events are being tracked correctly. Look for these log patterns:
[MetaMask DEBUG]: MetaMetrics client configured with: {
"writeKey": "[key]",
"proxy": "https://fn.segmentapis.com/?b=[token]",
"debug": true,
"flushInterval": "1",
"flushAt": "1"
}
[MetaMask DEBUG]: MetaMetrics configured with ID: [Your Metrics ID]
INFO IDENTIFY event saved {"traits": {"Theme": "dark", "platform": "ios", ...}, "type": "identify", "userId": "[Your Metrics ID]"}
INFO TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true}, "type": "track"}
INFO TRACK event saved {"event": "Welcome Message Viewed", "properties": {}, "type": "track"}
INFO TRACK event saved {"event": "Onboarding Started", "properties": {}, "type": "track"}
INFO TRACK event saved {"event": "Banner Display", "properties": {"name": "solana"}, "type": "track"}
INFO TRACK event saved {"event": "Navigation Drawer", "properties": {"action": "Navigation Drawer", "name": "Settings"}, "type": "track"}
INFO Sent 2 events
What to Look For:
- ✅ Configuration logs: Confirm MetaMetrics is properly configured
- ✅ User ID: Verify a unique user ID is generated, should display in place of [Your Metrics ID] in the examples
- ✅ Event tracking: See your events being saved
- ✅ Event flushing: Confirm events are being sent to Segment
- ✅ Properties: Verify your event properties are included
Ensure you're using the correct event builder pattern:
// ✅ Correct
trackEvent(
createEventBuilder(MetaMetricsEvents.MY_EVENT)
.addProperties({ key: 'value' })
.build(),
);
// ❌ Incorrect - missing .build()
trackEvent(
createEventBuilder(MetaMetricsEvents.MY_EVENT).addProperties({
key: 'value',
}),
);Verify that your event properties are correctly structured:
// Regular properties (non-sensitive)
.addProperties({
network: 'ethereum',
source: 'navigation'
})
// Sensitive properties (triggers anonymous events)
.addSensitiveProperties({
amount: '0.1',
recipient: '0x1234...'
})Ensure you're using predefined events from MetaMetrics.events.ts:
// ✅ Correct - using predefined event
MetaMetricsEvents.SEND_TRANSACTION_STARTED;
// ❌ Incorrect - custom event name
('custom_event_name');Follow these steps to verify your events are working correctly:
MetaMetrics automatically logs all events in development mode. Look for these log patterns to verify your events are being tracked:
INFO TRACK event saved {"event": "MY_EVENT", "properties": {"debug": true}, "type": "track"}
To find your specific events in Segment and Mixpanel, you need your metrics ID:
- Check Console Logs: Look for
[MetaMask DEBUG]: MetaMetrics configured with ID: [Your Metrics ID]in the console
- Lock the App: Lock MetaMask Mobile
- Access Login Screen: Go to the login screen
- Touch Fox Logo: Touch the MetaMask fox logo for at least 10 seconds
- Wait for Export: The device will generate a state export file (this can take time due to file size)
- Find Metrics ID: Open the exported JSON file and look for the
metametricsIdvalue
Note: The state export is large, so be patient while the device generates the file. Keep your finger on the fox logo.
Check that events are being sent to Segment:
- Request Access: Ask helpdesk for access to the Segment website
- Navigate to Debugger: Go to the correct source debugger:
- Mobile Dev: For local development testing
- Mobile QA: For QA build testing
- Mobile Prod: For production events
- Find Your Events: Use your metrics ID to filter events
- Verify Event Properties: Ensure all properties are present
Example URL: https://app.segment.com/consensys-analytics/sources/raw_segment_metamask_mobile_dev/debugger
Confirm events are appearing in Mixpanel:
- Request Access: Ask helpdesk for access to Mixpanel
- Navigate to Events: Go to Events → Live View
- Find Your Events: Use your metrics ID to filter events
- Check Properties: Verify all properties are correctly received
Symptoms: Events are being tracked but don't appear in Segment dashboard
Debugging Steps:
- Check
HAS_TEST_OVERRIDESenvironment variable - Verify user consent (
isEnabled()) - Check network connectivity
- Verify Segment configuration in your
.js.envfile - Check flush policy override in your
.js.envfile
Symptoms: Events appear in Segment but not in Mixpanel
Send a Slack message in the #data channel to explain your issue
Symptoms: Sensitive properties are being tracked but anonymous events aren't generated
Debugging Steps:
- Verify
addSensitiveProperties()is being used - Check that sensitive properties contain actual data
- Check the events for the anonymous user ID
0x0000000000000000(note: this will show many events from all users)
When debugging analytics, remember to respect user privacy:
- Don't log sensitive data: Avoid logging personal information in debug statements
- Use test data: Use mock data when testing sensitive properties (avoid private keys or any data that could link to other sensitive information)
If you're still experiencing issues after following this guide, ask for help in #metamask-mobile-dev Slack channel.