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: update marketing traits when tracked settings change [PR 1/2] #13254

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

NicolasMassart
Copy link
Contributor

@NicolasMassart NicolasMassart commented Jan 29, 2025

Description

Important

This PR is the first of two.
In order to have small scope PRs and limit the amount of changes, the work is split into two PRs.
This PR mainly deals with the changes about marketing consent analytics.
It can be merged independently from 2/2.

  • moves marketing traits to global generateUserProfileAnalyticsMetaData user traits function
  • makes marketing traits use ON or OFF values for consistency with other user profile traits.
  • removes is_metrics_opted_in from user profile traits as we don't have consistent data anyway and the fact that data is tracked means use opted in.
    • the user optin (metrics enabled or not) remains unchanged in the app and is stored to know if events should be tracked or not.
    • If user optin is not set at onboarding, it can be updated in settings.
  • adds unit tests for generateUserProfileAnalyticsMetaData function
  • update other unit tests

Related issues

Fixes part 1/2 of https://github.com/MetaMask/mobile-planning/issues/1459

Manual testing steps

Feature: update marketing consent in user profile when it changes

  Scenario: user accepts marketing during onboarding
    Given a fresh install of the app
    When user accepts metametrics during onboarding
    And user accepts marketing consent
    Then you have IDENTIFY event sent
    And identify event contains "has_marketing_consent" trait with value "ON"
    And you have TRACK event sent
    And track event has "has_marketing_consent" prop set to "true"
    And track event has "location" prop set to "onboarding_metametrics"
    And track event has "updated_after_onboarding" prop set to "false"

  Scenario: user refuses marketing during onboarding
    Given a fresh install of the app
    When user accepts metametrics during onboarding
    And user refuses marketing consent (leave checkbox unchecked)
    Then you have IDENTIFY event sent
    And identify event contains "has_marketing_consent" trait with value "OFF"
    And you have TRACK event sent
    And track event has "has_marketing_consent" prop set to "false"
    And track event has "location" prop set to "onboarding_metametrics"
    And track event has "updated_after_onboarding" prop set to "false"

  Scenario: user accepts marketing in settings after onboarding
    Given an already onboarded app
    And user opted in for metrics
    And user navigates to privacy&security settings 
    When user activates "data collection for marketing"
    Then you have IDENTIFY event sent
    And identify event contains "has_marketing_consent" trait with value "ON"
    And you have TRACK event sent
    And track event has "has_marketing_consent" prop set to "true"
    And track event has "location" prop set to "settings"
    And track event has "updated_after_onboarding" prop set to "true"

  Scenario: user refuses marketing in settings after onboarding
    Given an already onboarded app
    And user opted in for metrics
    And user navigates to privacy&security settings 
    When user activates "data collection for marketing"
    Then you have IDENTIFY event sent
    And identify event contains "has_marketing_consent" trait with value "OFF"
    And you have TRACK event sent
    And track event has "has_marketing_consent" prop set to "false"
    And track event has "location" prop set to "settings"
    And track event has "updated_after_onboarding" prop set to "true"

Screenshots/Recordings

Before

 INFO  IDENTIFY event saved {"traits": {"Batch account balance requests": "ON", "Enable OpenSea API": "ON", "NFT Autodetection": "ON", "Theme": "light", "applicationVersion": "7.37.1", "currentBuildNumber": "1520", "deviceBrand": "Apple", "has_marketing_consent": true, "operatingSystemVersion": "18.2", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "c82a0d7b-599c-4526-8dd7-cd3a35b863fd"}

After

Onboarding

image

When user check the box for collection for marketing in onboarding

 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  IDENTIFY event saved {"traits": {"Batch account balance requests": "ON", "Enable OpenSea API": "ON", "NFT Autodetection": "ON", "Theme": "light", "applicationVersion": "7.37.1", "currentBuildNumber": "1520", "deviceBrand": "Apple", "has_marketing_consent": "ON", "operatingSystemVersion": "18.2", "platform": "ios", "security_providers": "blockaid", "token_detection_enable": "ON"}, "type": "identify", "userId": "e142a0a5-670b-4f74-b531-b207bf0576d4"}

Settings

image

When user switches ON data collection for marketing in settings

 INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": "ON"}, "type": "identify", "userId": "ba888bd9-92cc-4783-a1c6-b72aaeadccab"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "location": "settings", "updated_after_onboarding": true}, "type": "track"}

When user switches OFF data collection for marketing in settings

 INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": "OFF"}, "type": "identify", "userId": "ba888bd9-92cc-4783-a1c6-b72aaeadccab"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": false, "location": "settings", "updated_after_onboarding": true}, "type": "track"}

Marketing modal

image

When user touches "no thanks"

INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": "OFF"}, "type": "identify", "userId": "e142a0a5-670b-4f74-b531-b207bf0576d4"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": false, "location": "marketing_consent_modal", "updated_after_onboarding": true}, "type": "track"}

When user touches "I agree"

 INFO  IDENTIFY event saved {"traits": {"has_marketing_consent": "ON"}, "type": "identify", "userId": "e142a0a5-670b-4f74-b531-b207bf0576d4"}
 INFO  TRACK event saved {"event": "Analytics Preference Selected", "properties": {"has_marketing_consent": true, "location": "marketing_consent_modal", "updated_after_onboarding": true}, "type": "track"}

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.

Copy link
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.

@NicolasMassart NicolasMassart changed the title fix: update traits when tracked settings change fix: update traits when tracked settings change 1/2 Jan 30, 2025
@NicolasMassart NicolasMassart changed the title fix: update traits when tracked settings change 1/2 fix: update marketing traits when tracked settings change [PR 1/2] Jan 30, 2025
@NicolasMassart NicolasMassart added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 30, 2025
@NicolasMassart NicolasMassart marked this pull request as ready for review January 30, 2025 17:24
@NicolasMassart NicolasMassart requested review from a team as code owners January 30, 2025 17:24
@NicolasMassart NicolasMassart added the Run Smoke E2E Triggers smoke e2e on Bitrise label Jan 30, 2025
Copy link
Contributor

github-actions bot commented Jan 30, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 5843240
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ae023d1d-a6a2-4a41-b334-e52637233d79

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

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 a comment

Cal-L
Cal-L previously approved these changes Jan 31, 2025
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

darkwing
darkwing previously approved these changes Jan 31, 2025
@NicolasMassart NicolasMassart added this pull request to the merge queue Jan 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2025
@NicolasMassart NicolasMassart dismissed stale reviews from Cal-L and darkwing via 3f92825 February 4, 2025 11:46
@NicolasMassart NicolasMassart added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 4, 2025
Copy link
Contributor

github-actions bot commented Feb 4, 2025

https://bitrise.io/ Bitrise

🔄🔄🔄 pr_smoke_e2e_pipeline started on Bitrise...🔄🔄🔄

Commit hash: 3f92825
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d4182586-87a2-4147-a997-f3b1cd36581b

Note

  • This comment will auto-update when build completes
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-attribution needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Status: Review finalised - Ready to be merged
Development

Successfully merging this pull request may close these issues.

3 participants