Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "data collection for marketing" from PR #9687 #9905

Merged
merged 21 commits into from
Jun 13, 2024

Conversation

NicolasMassart
Copy link
Contributor

@NicolasMassart NicolasMassart commented Jun 7, 2024

Description

Onboarding phase

  • prevent metametrics API to be called multiple times for identical actions:
    • group traits addition
    • refactor events into a consolidated one
  • remove useless trackEvent in places where it would never be triggered anyway (when metrics are disabled)
  • add condition to prevent useless data processing when metrics are disabled
  • move async work in InteractionManager.runAfterInteractions as hook doesn't do it by default on traits addition. Move the event too even if handled already to ensure consistency with traits addition.
  • number of events reduced from 11 to 7 when marketing is opted-in.
  • making checkbox text touchable to check the box
  • add unit tests and update snapshot

Settings screen

  • extract a section component to make the section code testable as otherwise you have to mock everything and it conflicts with code under test
    but keep MetaMetrics toggle and marketing toggle together as they have been designed to work together closely.
  • add traits when toggling marketing on/off
  • rework MetaMetrics and Marketing switches interaction logic
  • unit test on all the section and switches interactions

Note

This is a rework of #9687.
I had to extract the settings section as a component for testing to be possible.
I could have split it further into MetaMEtrics seciton and Marketing data section.
but this would have required more work to make sure both components keep their linked behaviours when toggling switches.
however, this is a possible improvement. I consider we should work on this on a full settings sections refactoring, see issue #9979

Related issues

Fixes: #9862

Manual testing steps

Screenshots/Recordings

Before

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", "operatingSystemVersion": "17.5", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "ff0d83a8-9c1e-4897-b1b1-1b5e5e23ed42"}
 INFO  TRACK event saved {"event": "Wallet Setup Started", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt In", "updated_after_onboarding": false}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt In", "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

and Mixpanel view
image

When 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", "operatingSystemVersion": "17.5", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "d1b09ff0-b550-4d7f-a894-1cdc13609473"}
 INFO  TRACK event saved {"event": "Wallet Setup Started", "properties": {}, "type": "track"}
 INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": true, "is_metrics_opted_in": true}, "type": "identify", "userId": "d1b09ff0-b550-4d7f-a894-1cdc13609473"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "is_metrics_opted_in": true, "location": "onboarding_metametrics"}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "is_metrics_opted_in": true, "location": "onboarding_metametrics"}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt In", "updated_after_onboarding": false}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt In", "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 11 events

and Mixpanel view:
image

Settings screen

Missing marketing setting events and user traits:

 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", "operatingSystemVersion": "17.5", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "5e9545ed-84b3-4223-801e-d70fee12e10d"}
 INFO  TRACK event saved {"event": "Views Security & Privacy", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt in", "updated_after_onboarding": true}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"analytics_option_selected": "Metrics Opt in", "updated_after_onboarding": true}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Views Security & Privacy", "properties": {}, "type": "track"}
 INFO  Sent 5 events
 INFO  Sent 1 events

After

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

and Mixpanel view:
image

When 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", "has_marketing_consent": true, "is_metrics_opted_in": true, "operatingSystemVersion": "17.5", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "fb576f56-3e5e-4df8-9a40-55d16ae5b16e"}
 INFO  TRACK event saved {"event": "Wallet Setup Started", "properties": {}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "is_metrics_opted_in": true, "location": "onboarding_metametrics", "updated_after_onboarding": false}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "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

and mixpanel view:
image

Settings screen

 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": "5e9545ed-84b3-4223-801e-d70fee12e10d"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "updated_after_onboarding": true}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"is_metrics_opted_in": true, "updated_after_onboarding": true}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}
 INFO  Sent 4 events
 INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": true}, "type": "identify", "userId": "5e9545ed-84b3-4223-801e-d70fee12e10d"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "location": "settings"}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "location": "settings"}, "type": "track"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {}, "type": "track"}
 INFO  Sent 4 events

and mixpanel view:
image

image

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.

@NicolasMassart NicolasMassart added team-mobile-platform release-7.24.0 Issue or pull request that will be included in release 7.24.0 labels Jun 7, 2024
@NicolasMassart NicolasMassart self-assigned this Jun 7, 2024
Copy link
Contributor

github-actions bot commented Jun 7, 2024

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.

@worldlyjohn
Copy link

@NicolasMassart i know this is still a WIP, but flagging for the "When not checking marketing checkbox" use case we should still send has_marketing_consent but with value of false (applies to both identify and track calls)

second question, in your examples why is Analytics Preference Selected fired 3 times?

Copy link
Contributor

@jonybur jonybur left a comment

Choose a reason for hiding this comment

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

Looks good!

@NicolasMassart
Copy link
Contributor Author

NicolasMassart commented Jun 10, 2024

@worldlyjohn

flagging for the "When not checking marketing checkbox" use case we should still send has_marketing_consent but with value of false (applies to both identify and track calls)

Yes, noticed this issue too while writing tests, I'm on it. It has been missed on the initial PR.

second question, in your examples why is Analytics Preference Selected fired 3 times?

I wondered that too. It seems to be caused by changes made in MetaMetrics #9411
I prefer not to add this in the scope of this PR, but I will check this and create an issue for it after discussing it with @frankvonhoven

jonybur
jonybur previously approved these changes Jun 11, 2024
NicolasMassart and others added 6 commits June 13, 2024 02:06
# Conflicts:
#	app/components/UI/OptinMetrics/__snapshots__/index.test.tsx.snap
#	app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx
@NicolasMassart NicolasMassart marked this pull request as ready for review June 13, 2024 01:44
@NicolasMassart NicolasMassart requested a review from a team as a code owner June 13, 2024 01:44
@NicolasMassart NicolasMassart added release-7.25.0 Issue or pull request that will be included in release 7.25.0 and removed release-7.24.0 Issue or pull request that will be included in release 7.24.0 labels Jun 13, 2024
@NicolasMassart NicolasMassart added release-blocker This bug is blocking the next release and removed release-blocker This bug is blocking the next release labels Jun 13, 2024
@NicolasMassart NicolasMassart requested a review from jonybur June 13, 2024 15:09
Copy link

@NicolasMassart NicolasMassart added release-7.24.0 Issue or pull request that will be included in release 7.24.0 and removed release-7.25.0 Issue or pull request that will be included in release 7.25.0 release-blocker This bug is blocking the next release labels Jun 13, 2024
@NicolasMassart NicolasMassart changed the title fix: remove metametrics redundant calls and improve compliance fix: "data collection for marketing" from PR #9687 Jun 13, 2024
NicolasMassart added a commit that referenced this pull request Jun 13, 2024
Reverts #9948
This will be cherry picked again for 7.24.2 alongside the fix #9905 that
is currently under review
@NicolasMassart NicolasMassart added release-7.24.2 Issue or pull request that will be included in release 7.24.2 needs-qa Any New Features that needs a full manual QA prior to being added to a release. and removed release-7.24.0 Issue or pull request that will be included in release 7.24.0 labels Jun 13, 2024
Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Left some comments

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@sethkfman sethkfman added Run Smoke E2E Triggers smoke e2e on Bitrise and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Jun 13, 2024
Copy link
Contributor

github-actions bot commented Jun 13, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: a3b939a
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c5703b04-4a64-4400-be8c-4298ed4a4e11

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@sethkfman sethkfman merged commit 74b172b into main Jun 13, 2024
52 of 55 checks passed
@sethkfman sethkfman deleted the fix/9862_redundant_metametrics_calls branch June 13, 2024 21:37
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2024
@gauthierpetetin gauthierpetetin added release-7.26.0 Issue or pull request that will be included in release 7.26.0 and removed release-7.28.0 labels Jun 14, 2024
@NicolasMassart
Copy link
Contributor Author

@worldlyjohn

second question, in your examples why is Analytics Preference Selected fired 3 times?

See #9996

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.24.2 Issue or pull request that will be included in release 7.24.2 release-7.26.0 Issue or pull request that will be included in release 7.26.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Archived in project
7 participants