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: Adding delete metametrics data to security and privacy tab #24571

Open
wants to merge 32 commits into
base: develop
Choose a base branch
from

Conversation

NiranjanaBinoy
Copy link
Contributor

@NiranjanaBinoy NiranjanaBinoy commented May 17, 2024

This PR is dependant on #24503

Description

  • Added a new functional component as an entry to the Security & Privacy tab with the Delete MetaMetrics Data button.
  • A new Delete MetaMetrics Data model will open when you click the button.
  • Clicking the Clear button in the modal will create a data deletion regulation, update the state, and close the modal, deactivating the Delete MetaMetrics Data button.
  • The Erroring on the Clear button click opens a new error modal.

Scenarios to disable the DeleteMetaMetrics button:

  1. Metametrics ID not created / not available
  2. Just performed a deletion independent on participate in metametrics toggle
  3. Participate in metric opt-out & no data is recorded after deletion.
  4. Status of current delete regulation as INITIALIZED, RUNNING, or FINISHED and (Participate in metric opt-out/no data recorded after deletion)

Open in GitHub Codespaces

Related issues

Fixes #24406, #24407, https://github.com/MetaMask/MetaMask-planning/issues/2523

Manual testing steps

Perquisite:
Provide the following details in the .metamaskrc file:

ANALYTICS_DATA_DELETION_SOURCE_ID="wygFTooEUUtcckty9kaMc"
ANALYTICS_DATA_DELETION_ENDPOINT="https://proxy.dev-api.cx.metamask.io/segment/v1"
  1. Make a build(yarn, yarn dist) against the code.
  2. Load the extension in any browser.
  3. Navigate to the "Security & privacy" in the Settings
  4. Click on the "Delete MetaMetrics data" button which enables when the "Participate in MetaMetrics" is selected.
  5. Validate the post request is made in the service worker with the id - wygFTooEUUtcckty9kaMc.

Screenshots/Recordings

Before

After

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.

@NiranjanaBinoy NiranjanaBinoy self-assigned this May 17, 2024
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.

JustifyContent,
TextVariant,
} from '../../../helpers/constants/design-system';
import { createMetaMetricsDataDeletionTask } from '../../../store/actions';
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this PR should stay in draft until the controller exists? As-is this is not mergable because this function does not exist.

@legobeat legobeat marked this pull request as draft May 23, 2024 00:11
@NiranjanaBinoy NiranjanaBinoy marked this pull request as ready for review June 1, 2024 04:06
@NiranjanaBinoy NiranjanaBinoy marked this pull request as draft June 3, 2024 17:27
@NiranjanaBinoy NiranjanaBinoy changed the base branch from develop to delete-metametrics-data-controller June 26, 2024 14:50
@NiranjanaBinoy NiranjanaBinoy changed the base branch from delete-metametrics-data-controller to develop June 26, 2024 14:50
@NiranjanaBinoy NiranjanaBinoy changed the base branch from develop to delete-metametrics-data-controller June 26, 2024 15:11
@NiranjanaBinoy NiranjanaBinoy force-pushed the delete-metametrics-data-modal branch 2 times, most recently from 1941496 to 6a4d150 Compare June 27, 2024 14:38
@NiranjanaBinoy NiranjanaBinoy force-pushed the delete-metametrics-data-controller branch from cb4f42a to 429a444 Compare June 27, 2024 20:10
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 68.23529% with 27 lines in your changes missing coverage. Please review.

Project coverage is 70.19%. Comparing base (ba04af8) to head (cfd4a7c).

Files with missing lines Patch % Lines
ui/ducks/app/app.ts 12.50% 14 Missing ⚠️
.../clear-metametrics-data/clear-metametrics-data.tsx 53.85% 6 Missing ⚠️
...deletion-error-modal/data-deletion-error-modal.tsx 66.67% 2 Missing ⚠️
ui/helpers/constants/settings.js 33.33% 2 Missing ⚠️
...es/settings/security-tab/security-tab.container.js 0.00% 2 Missing ⚠️
...es/settings/security-tab/security-tab.component.js 66.67% 1 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           delete-metametrics-data-controller   #24571      +/-   ##
======================================================================
- Coverage                               70.19%   70.19%   -0.00%     
======================================================================
  Files                                    1427     1430       +3     
  Lines                                   49745    49829      +84     
  Branches                                13921    13936      +15     
======================================================================
+ Hits                                    34916    34974      +58     
- Misses                                  14829    14855      +26     

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

@metamaskbot
Copy link
Collaborator

Builds ready [39130bb]
Page Load Metrics (158 ± 192 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint59134932311
domContentLoaded96026189
load401894158399192
domInteractive96026189
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 7.5 KiB (0.22%)
  • ui: 12.75 KiB (0.18%)
  • common: 3.66 KiB (0.06%)

@NiranjanaBinoy NiranjanaBinoy marked this pull request as ready for review July 3, 2024 20:54
@NiranjanaBinoy NiranjanaBinoy requested a review from a team as a code owner July 3, 2024 20:54
@NiranjanaBinoy NiranjanaBinoy force-pushed the delete-metametrics-data-controller branch from fc6b061 to e2509b6 Compare July 4, 2024 15:40
@NiranjanaBinoy NiranjanaBinoy requested review from a team as code owners July 4, 2024 15:40
@NiranjanaBinoy NiranjanaBinoy marked this pull request as draft July 5, 2024 18:54
} else {
await setHasMetaMetricsDataRecorded(false);
}
} catch (error: unknown) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also track an error event here? e.g. MetaMetricsEventName.MetricsDataDeletionRequestError

cc @gauthierpetetin

Copy link
Contributor

@gauthierpetetin gauthierpetetin Jul 10, 2024

Choose a reason for hiding this comment

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

Hi @danjm ,

In Mobile, we've started to track expected errors as Analytics in order to reduce the noise in Sentry (which shall be kept for unexpected errors).
To achieve that we've introduced a generic Error occured event that we want to use for all our errors.

Do we have an equivalent generic event for errors in Extension?

  • If yes we could use it
  • If not, it might be a good occasion to introduce such an event in Extension as well, wdyt?

cc @worldlyjohn @Cal-L for visibility

Copy link
Contributor

Choose a reason for hiding this comment

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

@NiranjanaBinoy Can you add an 'Error Occured' metrics event, and then track that event here?

@metamaskbot
Copy link
Collaborator

Builds ready [f0083a1]
Page Load Metrics (1931 ± 114 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint28422681775527253
domContentLoaded139421971899224108
load140222711931238114
domInteractive14181493617
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 12.47 KiB (0.17%)
  • common: 2.98 KiB (0.04%)

@@ -6,6 +6,7 @@
"api.web3modal.com",
"app.ens.domains",
"arbitrum-mainnet.infura.io",
"authentication.api.cx.metamask.io",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"authentication.api.cx.metamask.io",

Duplicate (line 59)

"min-api.cryptocompare.com",
"nft.api.cx.metamask.io",
"oidc.api.cx.metamask.io",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"oidc.api.cx.metamask.io",

Duplicate

Copy link

sonarcloud bot commented Sep 19, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [ce675f0]
Page Load Metrics (1834 ± 110 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31324771766402193
domContentLoaded145424681807226109
load146224791834230110
domInteractive16100462110
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 12.47 KiB (0.17%)
  • common: 2.98 KiB (0.04%)

@@ -1547,6 +1547,29 @@
"deleteContact": {
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -550,6 +550,7 @@ export enum MetaMetricsEventName {
MarkAllNotificationsRead = 'Notifications Marked All as Read',
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -324,6 +324,13 @@ const SETTINGS_CONSTANTS = [
route: `${SECURITY_ROUTE}#dataCollectionForMarketing`,
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -170,7 +170,7 @@ describe('Settings Search Utils', () => {
it('returns "Security & privacy" section count', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

selectors.deleteMetaMetricsDataButton,
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await (deleteMetaMetricsDataButton as any).waitForElementState(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's find a way to not use any here. What is the type error that you saw that made it necessary to use any?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for the other cases


import ClearMetaMetricsData from './clear-metametrics-data';

describe('ClearMetaMetricsData', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a unit test that checks if there is a button and that createMetaMetricsDataDeletionTask is called if the button is clicked?

@@ -0,0 +1,21 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a unit test that checks if there is a button and that hideDataDeletionErrorModal is called if the button is clicked?

@@ -0,0 +1,99 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -98,6 +98,8 @@ type AppState = {
customTokenAmount: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -1818,6 +1818,59 @@ exports[`Security Tab should match snapshot 1`] = `
</label>
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -0,0 +1,207 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

const DeleteMetaMetricsDataButton = ({
wrapperRef,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's find a way to remove the use of any. What is the error you see that caused you use any?

@@ -50,8 +50,10 @@ import {
} from '../../../helpers/utils/settings-search';
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -20,10 +20,12 @@ import {
setUseExternalNameSources,
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

@@ -11,6 +11,8 @@ import { renderWithProvider } from '../../../../test/lib/render-helpers';
import { getIsSecurityAlertsEnabled } from '../../../selectors';
Copy link
Contributor

Choose a reason for hiding this comment

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

✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

Adding MetaMetrics data deletion to Security & Privacy
8 participants