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

chore: add privacy query params to portfolio navigation #25958

Merged
merged 23 commits into from
Jul 23, 2024
Merged

Conversation

julesat22
Copy link
Contributor

@julesat22 julesat22 commented Jul 18, 2024

Description

  • Added metricsEnabled and marketingEnabled query params to reflect user privacy preferences on user navigation to Portfolio. These settings, sent from extension, will be consumed by the Portfolio to update and align privacy preferences.

  • Updated all relevant e2e and unit tests to include the params.

Context: Our current privacy opt-in rate has been low since some recent updates to our privacy flow, so we are aligning our privacy settings with the other platforms.

Related issues

Fixes:

Manual testing steps

  1. Update privacy preferences in settings for both MetaMetrics and Marketing
  2. Navigate to Portfolio
  3. See that the privacy params accurately reflect the user's settings in mobile

Example URL:

https://portfolio.metamask.io/?metamaskEntry=ext_portfolio_button&metametricsId=0xbcd1a47f61d820aac3158af775dfee88828e5330aae11f3048767aab7e99b474&metricsEnabled=false&marketingEnabled=false

Screenshots/Recordings

Before

After

With query params attached:
https://www.loom.com/share/7f372324de1e452a837e5faa9860ee94

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.

@julesat22 julesat22 requested a review from a team as a code owner July 18, 2024 22:16
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.

@julesat22 julesat22 marked this pull request as draft July 19, 2024 18:01
@julesat22 julesat22 marked this pull request as ready for review July 19, 2024 21:06
@julesat22 julesat22 requested review from a team as code owners July 19, 2024 21:06
@julesat22 julesat22 self-assigned this Jul 19, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [2b321a9]
Page Load Metrics (173 ± 180 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722321173316
domContentLoaded9147393014
load391803173375180
domInteractive9147393014
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 907 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Project coverage is 69.69%. Comparing base (a3c4333) to head (4ae034a).
Report is 1 commits behind head on develop.

Files Patch % Lines
ui/helpers/utils/portfolio.js 88.89% 1 Missing ⚠️
ui/hooks/ramps/useRamps/useRamps.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25958      +/-   ##
===========================================
+ Coverage    69.68%   69.69%   +0.01%     
===========================================
  Files         1405     1405              
  Lines        49701    49723      +22     
  Branches     13738    13741       +3     
===========================================
+ Hits         34630    34650      +20     
- Misses       15071    15073       +2     

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

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

Added metricsEnabled and marketingEnabled query parameters to URLs for portfolio navigation to reflect user privacy preferences.

  • Updated test/e2e/tests/bridge/bridge-click-from-asset-overview.spec.ts to verify new query parameters in portfolio URL.
  • Modified ui/components/app/wallet-overview/coin-buttons.tsx to include new query parameters in generated URLs.
  • Enhanced ui/helpers/utils/portfolio.js to append privacy preferences to portfolio URLs.
  • Adjusted ui/hooks/ramps/useRamps/useRamps.ts to include new query parameters in Ramps buy page URL.
  • Updated relevant e2e and unit tests to incorporate the new query parameters.

14 file(s) reviewed, 37 comment(s)
Edit PR Review Bot Settings

Comment on lines +8 to +9
const EXPECTED_PORTFOLIO_URL =
'https://portfolio.metamask.io/bridge?metametricsId=null&metricsEnabled=false&marketingEnabled=false';
Copy link

Choose a reason for hiding this comment

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

Info: Added EXPECTED_PORTFOLIO_URL constant to include new query parameters.

'https://portfolio.metamask.io/bridge?metametricsId=null',
);

await bridgePage.verifyPortfolioTab(EXPECTED_PORTFOLIO_URL);
Copy link

Choose a reason for hiding this comment

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

Info: Updated URL verification to include metricsEnabled and marketingEnabled query parameters.

await bridgePage.verifyPortfolioTab(
'https://portfolio.metamask.io/bridge?metametricsId=null',
);
await bridgePage.verifyPortfolioTab(EXPECTED_PORTFOLIO_URL);
Copy link

Choose a reason for hiding this comment

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

Info: Updated URL verification to include metricsEnabled and marketingEnabled query parameters.

@@ -19,7 +19,7 @@ describe('Click bridge button from wallet overview @no-mmi', function (this: Sui
await logInWithBalanceValidation(driver, ganacheServer);
await bridgePage.load();
await bridgePage.verifyPortfolioTab(
'https://portfolio.metamask.io/bridge?metametricsId=null',
'https://portfolio.metamask.io/bridge?metametricsId=null&metricsEnabled=false&marketingEnabled=false',
Copy link

Choose a reason for hiding this comment

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

Info: Added metricsEnabled and marketingEnabled query parameters to the URL verification.

Comment on lines +45 to +48
const currentUrl = await driver.getCurrentUrl();
const expectedUrl =
'https://portfolio.metamask.io/?metamaskEntry=ext_portfolio_button&metametricsId=null&metricsEnabled=false&marketingEnabled=false';
assert.equal(currentUrl, expectedUrl);
Copy link

Choose a reason for hiding this comment

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

Info: Updated the expected URL to include metricsEnabled and marketingEnabled query parameters.

Comment on lines +291 to 293
isMetaMetricsEnabled,
isMarketingEnabled,
);
Copy link

Choose a reason for hiding this comment

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

Info: Included new query parameters for privacy settings in the Portfolio URL.

Comment on lines 12 to +13
const EXPECTED_BUY_URL =
'https://portfolio.test/buy?metamaskEntry=ext_buy_sell_button&chainId=0x5';
'https://portfolio.test/buy?metamaskEntry=ext_buy_sell_button&chainId=0x5&metricsEnabled=false';
Copy link

Choose a reason for hiding this comment

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

Info: Updated EXPECTED_BUY_URL to include metricsEnabled query parameter.

Comment on lines 64 to 69
getHardwareWalletType,
getIsBridgeChain,
getMetaMetricsId,
getParticipateInMetaMetrics,
getDataCollectionForMarketing,
} from '../../../selectors';
Copy link

Choose a reason for hiding this comment

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

Info: Added selectors to fetch user privacy preferences for MetaMetrics and marketing data collection.

Comment on lines 221 to +225
const currentCurrency = useSelector(getCurrentCurrency);
const fetchingQuotes = useSelector(getFetchingQuotes);
const loadingComplete = !fetchingQuotes && areQuotesPresent;
const isMetaMetricsEnabled = useSelector(getParticipateInMetaMetrics);
const isMarketingEnabled = useSelector(getDataCollectionForMarketing);
Copy link

Choose a reason for hiding this comment

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

Info: Fetched user privacy preferences using the newly added selectors.

Comment on lines 1028 to 1033
'bridge',
'ext_bridge_prepare_swap_link',
metaMetricsId,
isMetaMetricsEnabled,
isMarketingEnabled,
);
Copy link

Choose a reason for hiding this comment

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

Info: Passed the fetched privacy preferences to the getPortfolioUrl function.

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)

Added metricsEnabled and marketingEnabled query parameters to URLs for portfolio navigation to reflect user privacy preferences.

  • Updated app/scripts/controllers/user-storage/user-storage-controller.ts to allow null values for isProfileSyncingEnabled.
  • Added migration script app/scripts/migrations/120.1.ts and corresponding test app/scripts/migrations/120.1.test.ts.
  • Modified app/scripts/migrations/index.js to include the new migration script 120.1.
  • Added end-to-end tests for SIWE in test/e2e/tests/confirmations/signatures/siwe.spec.ts.
  • Updated state snapshots in test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json and errors-after-init-opt-in-ui-state.json to reflect new privacy settings.

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

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)

Added metricsEnabled and marketingEnabled query parameters to URLs for portfolio navigation to reflect user privacy preferences.

  • Updated app/scripts/background.js to introduce test-specific overrides for keyrings.
  • Added app/scripts/lib/hardware-keyring-builder-factory.ts to include FakeKeyringBridge for testing.
  • Modified app/scripts/metamask-controller.js to refactor hardware keyring handling.
  • Added migration script app/scripts/migrations/122.ts and corresponding test app/scripts/migrations/122.test.ts.
  • Updated e2e tests in test/e2e/tests/metrics/signature-approved.spec.js to include redesigned confirmation settings.

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

@julesat22 julesat22 merged commit baf93a3 into develop Jul 23, 2024
76 of 77 checks passed
@julesat22 julesat22 deleted the MMPD-1272 branch July 23, 2024 16:04
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [4ae034a]
Page Load Metrics (446 ± 402 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint822901394823
domContentLoaded1187402210
load492558446838402
domInteractive1187402210
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 907 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 23, 2024
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-portfolio
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants