Skip to content

Commit 159d9ed

Browse files
chore(analytics): drop saveDataRecording from Tokens util + sweep assets test mocks (#31990)
## **Description** Removes the unused `saveDataRecording?: boolean` second argument from the `trackEvent` prop type in `goToAddEvmToken` and `removeEvmToken`. That parameter was a holdover from the legacy MetaMetrics API; `useAnalytics`'s `trackEvent` never accepted a second argument. Sweeps the now-dead `setSaveDataRecording: jest.fn().mockReturnThis()` key from the two affected test builder mocks. This is **PR-A of 6** in the owner-scoped sequence finishing the legacy MetaMetrics migration (#26820). PRs A–E are parallel mock-sweeps; PR-F does the interface removal once all five merge. ## **Changelog** CHANGELOG entry: null ## **Related issues** Refs: #26820 ## **Manual testing steps** N/A — test-only and type-signature cleanup; unit tests cover the changed files. ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [x] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [x] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [x] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Type-signature and test-mock cleanup only; analytics call paths are unchanged and `trackEvent` already ignored the removed parameter. > > **Overview** > Continues the legacy MetaMetrics cleanup (#26820) by aligning Assets token helpers and tests with **`useAnalytics`**’s single-argument **`trackEvent`**. > > **`goToAddEvmToken`** and **`removeEvmToken`** no longer type **`trackEvent`** with an optional **`saveDataRecording`** second parameter—that API was never implemented on the hook. **`DeFiPositionsList.test.tsx`** and **`Tokens/index.test.tsx`** drop **`setSaveDataRecording`** from mocked **`createEventBuilder`** chains for the same reason. > > No runtime behavior change; typings and test doubles only. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit bf7b2a1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 87e58f8 commit 159d9ed

4 files changed

Lines changed: 2 additions & 10 deletions

File tree

app/components/UI/DeFiPositions/DeFiPositionsList.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ describe('DeFiPositionsList', () => {
592592
addSensitiveProperties: jest.fn().mockReturnThis(),
593593
removeProperties: jest.fn().mockReturnThis(),
594594
removeSensitiveProperties: jest.fn().mockReturnThis(),
595-
setSaveDataRecording: jest.fn().mockReturnThis(),
596595
build: jest.fn(),
597596
}),
598597
}),

app/components/UI/Tokens/index.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ describe('Tokens', () => {
322322
addSensitiveProperties: jest.fn().mockReturnThis(),
323323
removeProperties: jest.fn().mockReturnThis(),
324324
removeSensitiveProperties: jest.fn().mockReturnThis(),
325-
setSaveDataRecording: jest.fn().mockReturnThis(),
326325
build: jest.fn(),
327326
}),
328327
}),

app/components/UI/Tokens/util/goToAddEvmToken.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import type { AppNavigationProp } from '../../../../core/NavigationService/types
77

88
interface GoToAddEvmTokenProps {
99
navigation: AppNavigationProp;
10-
trackEvent: (
11-
event: AnalyticsTrackingEvent,
12-
saveDataRecording?: boolean,
13-
) => void;
10+
trackEvent: (event: AnalyticsTrackingEvent) => void;
1411
createEventBuilder: typeof AnalyticsEventBuilder.createEventBuilder;
1512
getDecimalChainId: (chainId: string) => number;
1613
currentChainId: string;

app/components/UI/Tokens/util/removeEvmToken.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import Logger from '../../../../util/Logger';
1212
interface RemoveEvmTokenProps {
1313
tokenToRemove: TokenI;
1414
currentChainId: string;
15-
trackEvent: (
16-
event: AnalyticsTrackingEvent,
17-
saveDataRecording?: boolean,
18-
) => void;
15+
trackEvent: (event: AnalyticsTrackingEvent) => void;
1916
strings: (key: string, args?: Record<string, unknown>) => string;
2017
getDecimalChainId: (chainId: string) => number;
2118
createEventBuilder: typeof AnalyticsEventBuilder.createEventBuilder;

0 commit comments

Comments
 (0)