Skip to content

feat: Use new Segment implementation in onboarding steps (Batch 3 of 4)#7990

Merged
NicolasMassart merged 37 commits into
feat/batch_1129_segmentfrom
feat/1275_segment_onboarding_impl
Dec 8, 2023
Merged

feat: Use new Segment implementation in onboarding steps (Batch 3 of 4)#7990
NicolasMassart merged 37 commits into
feat/batch_1129_segmentfrom
feat/1275_segment_onboarding_impl

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Dec 1, 2023

Copy link
Copy Markdown
Contributor

Description

  1. What is the reason for the change?
    Implement the New Segment metrics system created in PR feat: create Segment analytics implementation + use geo-localization proxy (Batch 2 of 4) #7520 in the onboarding steps.

  2. What is the improvement/solution?

  • Initialise MetaMetrics on app start without removing Analytics yet as we still uses it outside of onboarding
  • create a trackAfterInteractions utility function to reduce code when tracking events.
  • Replace calls to Analytics with calls to trackAfterInteractions in all components involved in onboarding screens (see OnboardingNav in app/components/Nav/App/index.js)
  • Fix onboarding events queue usage in app/components/UI/OptinMetrics/index.js
  • Update Opt-on/Opt-out in onboarding
  • Extract Analytics User profil properties in UserProfileMetaData util and inject it in MetaMetrics identify request alongside device metadata

Related issues

Fixes https://github.com/MetaMask/mobile-planning/issues/1275

Manual testing steps

Scenario Outline: Onboarding up to metrics opt-in

Given user installed Metamask on the device

And user starts the Metamask for the first time

And user sees the the “Welcome to MetaMask” screen

And user touches “Get Started” button

And user touches <wallet action>

And user sees the “Help us improve Metamask” screen

When user touches “I agree” button

Then events (from app start) appear on Segment Dashboard source(1) debugger after at most 30s

And events are the following (not necessarily in order):

- `identify` type event with userId of the form of a UUIDv4
- `Welcome Message Viewed`
- `Onboarding Started`
- `Welcome Screen Engagement` (more than one if swiped through the welcome screen images)
- `Wallet Setup Started`
- `Analytics Preference Selected` with `properties[analytics_option_selected]=Metrics Opt In`

Examples:
| wallet action | 
|    “create new wallet” | 
|    “Import Using Recovery Phrase” | 
Scenario: Finish Onboarding after Opt-in with new wallet

Given user started a new wallet onboarding

And user touched “I agree” button on “Help us improve Metamask” screen

And events tracked up to the opt-in are displayed on Segment Dashboard source debugger

And user continues the onboarding

When user reaches the wallet screen at the end of onboarding

Then Segment Dashboard source debugger contains the following events:

- `Wallet Creation Attempted`
- `Wallet Created`
- `Wallet Setup Completed` with properties `{"new_wallet": true, "wallet_setup_type": "new"}`

And if securing SRP is skipped:

- `Wallet Security Skip Initiated`
- `Wallet Security Skip Confirmed`

But if securing SRP is done:

- `Wallet Security Started`
- `Manual Backup Initiated`
- `Phrase Revealed`
- `Phrase Confirmed`
- `Wallet Security Completed`
Scenario: Finish Onboarding after Opt-in with imported wallet

Given user started an imported wallet onboarding

And user touched “I agree” button on “Help us improve Metamask” screen

And events tracked up to the opt-in are displayed on Segment Dashboard source debugger

And user continues the onboarding

When user reaches the wallet screen at the end of onboarding

Then Segment Dashboard source debugger contains the following events:

- `Wallet Import Started`
- `Wallet Import Attempted`

And if user fails some import attempt you should have some occurrences of:

- `Wallet Setup Failure`

And when import SRP succeeds:

- `Wallet Imported`
- `Wallet Setup Completed`
- `Wallet Security Completed`
Scenario Outline: Onboarding with metrics opt-out

Given user installed Metamask on the device

And user starts the Metamask for the first time

And user sees the the “Welcome to MetaMask” screen

And user touches “Get Started” button

And user touches <wallet action>

And user sees the “Help us improve Metamask” screen

And user touches “No thanks” button

When user finishes the onboarding up to the wallet screen

Then no event at all appear on Segment Dashboard source(1) debugger even after more than 30s

Examples:
| wallet action | 
|    “create new wallet” | 
|    “Import Using Recovery Phrase” |

(1) source to look at should match the app type: dev/qa. Ask in Slack if you need access to Segment dashboards.

Screenshots/Recordings

The event tracking scope for this PR is all the screens between first start welcome screen:

image

and wallet screen:

image

From 1st start to optin. The dev logs should display the events tracked.
Notice the delay before they are sent as we have a 30s batch timer that actually sends the events in batches either every 30s or when the batch reaches 20 events.

segment_optin.mov

Then you can see the events on the Segment Dashboard. Best is to filter either by date or if you have the logs, copy the user id.

Screenshot 2023-12-06 at 18 30 27

Onboarding started event:
Screenshot 2023-12-06 at 18 31 40

Note

Events may not display in chronological order currently due to a behaviour on Segment server side that rewrites the timestamps. This is being worked on bit not in this PR.

Before

No visual change for users

After

No visual change for users

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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 and others added 30 commits November 10, 2023 17:16
- update metrics class
- extract utils
- add tests
- patch Segment SDK to handle proxy required content type
and updated unit tests
and fix bug and format
…_metrics_system

# Conflicts:
#	app/components/Nav/App/index.js
add tests
add delete date getter
add tests
add delete date getter
…5_segment_onboarding_impl

# Conflicts:
#	app/core/Analytics/MetaMetrics.test.ts
…_metrics_system

# Conflicts:
#	ios/Podfile.lock
and remove useless test
…_metrics_system

# Conflicts:
#	ios/Podfile.lock
@NicolasMassart NicolasMassart removed DO-NOT-MERGE Pull requests that should not be merged needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Dec 6, 2023
@NicolasMassart NicolasMassart marked this pull request as draft December 6, 2023 11:32
@NicolasMassart NicolasMassart changed the base branch from main to feat/batch_1129_segment December 6, 2023 13:30
@MetaMask MetaMask deleted a comment from socket-security Bot Dec 6, 2023
@MetaMask MetaMask deleted a comment from socket-security Bot Dec 6, 2023
@NicolasMassart NicolasMassart marked this pull request as ready for review December 6, 2023 22:34
@github-actions

github-actions Bot commented Dec 6, 2023

Copy link
Copy Markdown
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ff341f31-e3b3-4b03-9a36-845e7250c87c
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Comment thread app/components/Views/ChoosePassword/index.js Outdated
and call it from onboarding views

@frankvonhoven frankvonhoven left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good 👍 Thanks for making that helper :)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (feat/batch_1129_segment@e457b27). Click here to learn what that means.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             feat/batch_1129_segment    #7990   +/-   ##
==========================================================
  Coverage                           ?   37.24%           
==========================================================
  Files                              ?     1142           
  Lines                              ?    29285           
  Branches                           ?     2761           
==========================================================
  Hits                               ?    10906           
  Misses                             ?    17750           
  Partials                           ?      629           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonarqubecloud

sonarqubecloud Bot commented Dec 8, 2023

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

11.3% 11.3% Coverage
0.0% 0.0% Duplication

@NicolasMassart NicolasMassart merged commit 726fd80 into feat/batch_1129_segment Dec 8, 2023
@NicolasMassart NicolasMassart deleted the feat/1275_segment_onboarding_impl branch December 8, 2023 21:39
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 8, 2023
@NicolasMassart NicolasMassart restored the feat/1275_segment_onboarding_impl branch December 8, 2023 21:40
@NicolasMassart NicolasMassart added needs-qa Any New Features that needs a full manual QA prior to being added to a release. team-data-and-analytics and removed Run Smoke E2E labels Dec 8, 2023
@NicolasMassart NicolasMassart deleted the feat/1275_segment_onboarding_impl branch December 8, 2023 23:28
@metamaskbot metamaskbot added issues-found and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Dec 13, 2023
@NicolasMassart NicolasMassart self-assigned this Jan 8, 2024
@gauthierpetetin gauthierpetetin added the team-mobile-platform Mobile Platform team label Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants