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: add migration for profile syncing controller #26004

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Jul 22, 2024

Description

For existing users, we want to ensure that profile syncing is disabled (opt-in). This migration ensures that the isProfileSyncingEnabled controller state is changed to false for existing users.

This will need to be cherry-picked into v12.0.0

Open in GitHub Codespaces

Related issues

Fixes: V12 testing issue of the state for profile syncing.

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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.

we want existing users to have profile syncing disabled, this will remove/nullify the isEnableProfileSyncing state field.
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.

@@ -27,15 +27,15 @@ export type UserStorageControllerState = {
/**
* Condition used by UI and to determine if we can use some of the User Storage methods.
*/
isProfileSyncingEnabled: boolean;
isProfileSyncingEnabled: boolean | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checked all references (JS and TS files) it seems okay to change this field to be nullable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not perform strict boolean checks in references, it is truthy checks (isProfileSyncingEnabled && ... or isProfileSyncingEnabled || ...)

@metamaskbot metamaskbot added the team-notifications Notifications team label Jul 22, 2024
@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review July 22, 2024 13:40
@Prithpal-Sooriya Prithpal-Sooriya requested review from a team as code owners July 22, 2024 13:40
…ration

we need to also handle migration of new users who migrated from 11.16 that might have UserStorage in their state
Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.67%. Comparing base (721a38b) to head (5d46b4d).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26004   +/-   ##
========================================
  Coverage    69.67%   69.67%           
========================================
  Files         1402     1403    +1     
  Lines        49652    49676   +24     
  Branches     13720    13726    +6     
========================================
+ Hits         34594    34611   +17     
- Misses       15058    15065    +7     

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

@Prithpal-Sooriya Prithpal-Sooriya requested a review from Gudahtt July 22, 2024 14:46
@Prithpal-Sooriya
Copy link
Contributor Author

Tested the migration on v12 and v11. Seems to work as intended

Gudahtt
Gudahtt previously approved these changes Jul 22, 2024
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM! One pending suggestion about how to handle corrupted state, which would be ideal to fix but doesn't seem critical enough to block.

@Prithpal-Sooriya Prithpal-Sooriya force-pushed the fix/add-profile-syncing-enabled-migration branch from 2ed2f4c to 5c08942 Compare July 22, 2024 16:12
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request introduces a migration to ensure that profile syncing is disabled by default for existing users, aligning with the opt-in policy.

  • Migration Script: Added app/scripts/migrations/120.1.ts to set isProfileSyncingEnabled to null for existing users.
  • Controller Update: Modified app/scripts/controllers/user-storage/user-storage-controller.ts to handle null state for isProfileSyncingEnabled.
  • Unit Tests: Added app/scripts/migrations/120.1.test.ts to validate the migration logic.
  • Migration Index: Updated app/scripts/migrations/index.js to include the new migration script.
  • E2E Test States: Modified multiple E2E test state files to reflect the new default null value for isProfileSyncingEnabled.

8 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces a migration to ensure that profile syncing is disabled by default for existing users, aligning with the opt-in policy.

  • Migration Script Update: Enhanced app/scripts/migrations/120.1.ts to handle malformed UserStorageController states and added Sentry error handling.
  • Test Case Addition: Updated app/scripts/migrations/120.1.test.ts to include scenarios where the UserStorageController state is invalid.
  • E2E Test State Updates: Modified multiple E2E test state files (errors-after-init-opt-in-background-state.json, errors-after-init-opt-in-ui-state.json, errors-before-init-opt-in-background-state.json, errors-before-init-opt-in-ui-state.json) to set isProfileSyncingEnabled to true by default.

6 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings

app/scripts/migrations/120.1.test.ts Show resolved Hide resolved
app/scripts/migrations/120.1.ts Show resolved Hide resolved
app/scripts/migrations/120.1.ts Show resolved Hide resolved
Gudahtt
Gudahtt previously approved these changes Jul 22, 2024
@Gudahtt
Copy link
Member

Gudahtt commented Jul 22, 2024

Hmm, still some e2e test failure in the error capture tests

@Prithpal-Sooriya Prithpal-Sooriya force-pushed the fix/add-profile-syncing-enabled-migration branch from a3b8a3a to 5d46b4d Compare July 22, 2024 17:08
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces a migration to ensure that profile syncing is disabled by default for existing users, aligning with the opt-in policy.

  • Migration Script Update: Enhanced app/scripts/migrations/120.1.ts to handle malformed UserStorageController states and added Sentry error handling.
  • Test Case Addition: Updated app/scripts/migrations/120.1.test.ts to include scenarios where the UserStorageController state is invalid.
  • E2E Test State Updates: Modified multiple E2E test state files (errors-before-init-opt-in-background-state.json, errors-before-init-opt-in-ui-state.json) to set isProfileSyncingEnabled to true by default.

4 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

app/scripts/migrations/120.1.test.ts Show resolved Hide resolved
app/scripts/migrations/120.1.ts Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [5d46b4d]
Page Load Metrics (254 ± 242 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint763091275326
domContentLoaded119832209
load491835254503242
domInteractive119832209
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.18 KiB (0.04%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The pull request introduces a migration to ensure that profile syncing is disabled by default for existing users, aligning with the opt-in policy.

  • Mock Active Tab for E2E Tests: Updated app/scripts/ui.js to mock the active tab during E2E tests using the activeTabOrigin query string parameter.
  • New SIWE E2E Tests: Added test/e2e/tests/confirmations/signatures/siwe.spec.ts to cover SIWE functionality.
  • Request Queuing E2E Tests: Enhanced test/e2e/tests/request-queuing/ui.spec.js with new scenarios and helper functions.
  • Constrain Window Size in WebDriver: Modified test/e2e/webdriver/chrome.js, test/e2e/webdriver/firefox.js, and test/e2e/webdriver/index.js to add constrainWindowSize option.
  • SIWE Message Handling: Updated ui/pages/confirmations/hooks/useCurrentConfirmation.ts and its test to handle SIWE messages correctly.

8 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@matteoscurati matteoscurati left a comment

Choose a reason for hiding this comment

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

Go!

@Prithpal-Sooriya Prithpal-Sooriya merged commit afe1120 into develop Jul 22, 2024
76 of 77 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the fix/add-profile-syncing-enabled-migration branch July 22, 2024 19:26
@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 22, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [8c483f9]
Page Load Metrics (151 ± 168 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7213999178
domContentLoaded115223105
load481674151350168
domInteractive115222105
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.18 KiB (0.04%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants