MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.03k stars 1.06k forks source link

metametrics tracks too many events #9996

Open NicolasMassart opened 2 weeks ago

NicolasMassart commented 2 weeks ago

What is this about?

MetaMetrics trackEvents sends too many events in some cases.

It's like it's doing both anonymous and non anonymous tracking at the same time, resulting in 3 events instead of 1.

Example:

Onboaring phase: when not checking marketing checkbox

 INFO  TRACK event saved {"event": "Terms of Use Shown", "properties": {}, "type": "track"}
 INFO  IDENTIFY event saved {"traits": {"Batch account balance requests": "ON", "Enable OpenSea API": "ON", "NFT Autodetection": "OFF", "Theme": "light", "applicationVersion": "7.23.0", "currentBuildNumber": "1333", "deviceBrand": "Apple", "is_metrics_opted_in": true, "operatingSystemVersion": "17.5", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "19f4001c-68a6-4b62-9f1d-d8f6ff92718e"}
 INFO  TRACK event saved {"event": "Wallet Setup Started", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "location": "onboarding_metametrics", "updated_after_onboarding": false}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "location": "onboarding_metametrics", "updated_after_onboarding": false}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Welcome Message Viewed", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Onboarding Started", "properties": {}, "type": "track"}
 INFO  Sent 1 events
 INFO  Sent 7 events

We should not have so many "Analytics Preference Selected" events, 1 and 2 seems to be an anonymous and a non-anonymous events (not sure of the order, 1 and 2 may be reverted).

But if we consider they are in the right order, in the following, event 2 is wrong and should not exist as the event was sent using trackEvent and not trackAnonymousEvent. See app/components/UI/OptinMetrics/index.js onConfirm()

1: this is an anonymous event (UUID Zero), properly not showing in user events

 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "location": "onboarding_metametrics", "updated_after_onboarding": false}, "type": "track"}

2: event with props, should be anonymous (UUID Zero) but it's not, showing up in user (see screenshot first event)

 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "location": "onboarding_metametrics", "updated_after_onboarding": false}, "type": "track"}

3: anonymous event (no props), see second event in screenshot

 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}

image

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

Stakeholder review needed before the work gets merged

References

See @worldlyjohn comment on this PR https://github.com/MetaMask/metamask-mobile/pull/9905#issuecomment-2155321704

bschorchit commented 3 days ago

In the example Analytics Preference Selected there's no need to trigger an anonymous event, right? Only the non-anonymous event should be triggered.