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

feat: adds "data collection for marketing" toggles #24605

Merged
merged 54 commits into from
Jun 12, 2024
Merged

Conversation

jonybur
Copy link
Contributor

@jonybur jonybur commented May 20, 2024

Adds data collection for marketing toggles (and toasts/warnings) on:

  • Onboarding
  • Toast in Wallet
  • Settings page

Description

Open in GitHub Codespaces

Related issues

Fixes:
https://github.com/MetaMask/MetaMask-planning/issues/2437
https://github.com/MetaMask/MetaMask-planning/issues/2438
https://github.com/MetaMask/MetaMask-planning/issues/2526

Manual testing steps

Onboarding checkbox:
Make the metametrics.js to return renderOnboarding instead of renderLegacyOnboarding

  1. Start a new account
  2. There should be a new checkbox that asks for marketing consent
  3. Checking it should set the marketing consent to true (check at Settings, Securty tab page)

Security tab:

  1. Go to Security tab
  2. When checking the "Data collection for marketing" to true, the "Participate in MetaMetrics" toggle should turn to true
  3. When checking "Participate in MetaMetrics" to false, "Data collection for marketing" should be set to false
  4. When "Participate in Metametrics" is true and "Data collection for marketing" is true, and the latter is set to false, a warning message should appear.

Toast:
An already onboarded user will have the "dataCollectionForMarketing" value as null (neither true or false). This will trigger the toast.

  1. By clicking on "I accept", it should set the "Data collection for marketing" to true.
  2. By closing the toast or clicking on "No thanks", it should set the "Data collection for marketing" to false.

All of these actions should trigger subsequent Segment events.

Screenshots/Recordings

Before

After

Screenshot 2024-05-20 at 14 19 53
demo2.mp4

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • 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.

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.

@jonybur jonybur changed the title feat: Add metametrics toggle feat: adds "data collection for marketing" toggles May 20, 2024
@jonybur jonybur marked this pull request as ready for review May 21, 2024 12:30
@jonybur jonybur requested a review from a team as a code owner May 21, 2024 12:30
Copy link
Member

@NidhiKJha NidhiKJha left a comment

Choose a reason for hiding this comment

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

Really good start but the checkbox don't show up on this page when I try to create a new account. Also, left some comments

Screenshot 2024-05-21 at 6 38 53 PM

ui/pages/home/home.component.js Outdated Show resolved Hide resolved
ui/pages/home/home.component.js Outdated Show resolved Hide resolved
ui/pages/settings/security-tab/security-tab.component.js Outdated Show resolved Hide resolved
@jonybur
Copy link
Contributor Author

jonybur commented May 21, 2024

@NidhiKJha you will need to render the new onboarding screen, right now it's hidden through the privacy policy date. Just make the metametrics.js to return renderOnboarding instead of renderLegacyOnboarding

return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setDataCollectionForMarketing`);
return new Promise((resolve, reject) => {
callBackgroundMethod<string>(
Copy link
Member

Choose a reason for hiding this comment

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

This function is deprecated, please use submitRequestToBackground instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

(err, metaMetricsId) => {
log.debug(err);
if (err) {
dispatch(displayWarning(err));
Copy link
Member

Choose a reason for hiding this comment

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

displayWarning is deprecated, please find some other way of handling this error. This method will display the error totally out of context in random places in the app, and it'll stick around for a seemingly arbitrary amount of time. Bad UX.

Once this is converted to use submitRequestToBackground, this error variable won't be here unless we add a try...catch block to catch it. We may or may not want to do that, depending on when we expect this to fail.

If it should never fail, I'd recommend not catching the error and letting it bubble up to the global error handler to be captured by Sentry.

If we'd expect it to fail sometimes, then we should catch it. If the failure condition is relevant to the user (e.g. if an operation failed and the user should be informed), then we'll have to think about where in the UI to best display this error. Maybe easiest to throw here and catch it in a UI component where we can show the error.

If we expect it to fail sometimes in a way that isn't important to a user, then we can just log the error to the console and move on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

* changed. The logic to determine which way to toggle is in the
* toggleSession handler in setupSentry.js.
*/
window.sentry?.toggleSession();
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem necessary; this toggle doesn't impact Sentry. Only the overall meta metrics toggle impacts Sentry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -162,6 +163,12 @@ export default function reduceMetamask(state = initialState, action) {
participateInMetaMetrics: action.value,
};

case actionConstants.SET_DATA_COLLECTION_FOR_MARKETING:
Copy link
Member

Choose a reason for hiding this comment

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

What is this for? Generally we shouldn't adding anything to this Redux slice, it's meant as a mirror of the background state. The actions here other than the background state update action are all examples of technical debt that we have not cleaned up yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to mirror the implementation of SET_PARTICIPATE_IN_METAMETRICS. We are adding the marketing toggle flag to the state as well (dataCollectionForMarketing)

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a misunderstanding. SET_PARTICIPATE_IN_METAMETRICS shouldn't be here either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are good points, and these changes will be postponed for a later date given our time constraints. Both SET_PARTICIPATE_IN_METAMETRICS and SET_DATA_COLLECTION_FOR_MARKETING should be deleted from the redux state.

@jonybur jonybur requested a review from Gudahtt June 10, 2024 06:56
NidhiKJha
NidhiKJha previously approved these changes Jun 10, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [e27aef2]
Page Load Metrics (49 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6110080105
domContentLoaded9261132
load40704974
domInteractive9261132
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 406 Bytes (0.01%)
  • ui: 6.51 KiB (0.10%)
  • common: 2.45 KiB (0.04%)

Copy link

codecov bot commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 48.31461% with 46 lines in your changes missing coverage. Please review.

Project coverage is 65.60%. Comparing base (54461ab) to head (e27aef2).
Report is 23 commits behind head on develop.

Current head e27aef2 differs from pull request most recent head 0dc9878

Please upload reports for the commit 0dc9878 to get more accurate results.

Files Patch % Lines
...es/settings/security-tab/security-tab.component.js 44.00% 14 Missing ⚠️
ui/pages/home/home.component.js 18.75% 13 Missing ⚠️
ui/store/actions.ts 14.29% 6 Missing ⚠️
ui/ducks/metamask/metamask.js 0.00% 4 Missing ⚠️
...i/pages/onboarding-flow/metametrics/metametrics.js 55.56% 4 Missing ⚠️
app/scripts/controllers/metametrics.js 66.67% 2 Missing ⚠️
ui/pages/home/home.container.js 0.00% 1 Missing ⚠️
...rity-tab/metametrics-toggle/metametrics-toggle.tsx 80.00% 1 Missing ⚠️
...es/settings/security-tab/security-tab.container.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24605      +/-   ##
===========================================
- Coverage    65.64%   65.60%   -0.04%     
===========================================
  Files         1362     1362              
  Lines        54189    54265      +76     
  Branches     14112    14127      +15     
===========================================
+ Hits         35572    35600      +28     
- Misses       18617    18665      +48     

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

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Marking as RC until Mark's item is addressed: #24605 (review)

@jonybur jonybur requested a review from darkwing June 11, 2024 11:58
@jonybur
Copy link
Contributor Author

jonybur commented Jun 11, 2024

@darkwing comments by @Gudahtt have been addressed

builds.yml Outdated Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [0dc9878]
Page Load Metrics (46 ± 5 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6311879126
domContentLoaded9131011
load398646105
domInteractive9131011
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 406 Bytes (0.01%)
  • ui: 6.51 KiB (0.10%)
  • common: 2.53 KiB (0.04%)

Copy link
Contributor

@bergeron bergeron left a comment

Choose a reason for hiding this comment

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

I think I tested all combinations successfully.

  • New user:
    • metrics off, marketing off
    • metrics on, marketing off
    • metrics on, marketing on
  • existing user:
    • metrics off (don't see modal)
    • metrics on, marketing off
    • metrics on, marketing on

Just make sure we resolve this slack thread to be sure nothing is broken:

https://consensys.slack.com/archives/C06VBTL358A/p1718150795110559

@jonybur jonybur merged commit ab695aa into develop Jun 12, 2024
74 of 75 checks passed
@jonybur jonybur deleted the jb-opt-in-metrics branch June 12, 2024 14:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
marketing-consent release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-wallet-ux
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants