refactor(analytics): migrate settings thunk MetaMetrics events#44379
Conversation
Part of analytics migration umbrella #43885 (15g · Settings Redux thunks).
|
|
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. |
Builds ready [cdabb3b]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 8 warn · 🔴 1 fail)
Bundle sizes
|
There was a problem hiding this comment.
Pull request overview
Migrates two Settings-related Redux thunks from legacy trackMetaMetricsEvent usage to the newer analytics event builder (createEventBuilder) and trackAnalyticsEvent, aligning with the broader AnalyticsController migration effort.
Changes:
- Replaces
trackMetaMetricsEventpayload objects withcreateEventBuilder(...).addCategory(...).addProperties(...).build()for settings-updated events. - Updates imports to pull in
createEventBuilderalongside analytics event types.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
## **Description** Migrates remaining legacy `MetaMetricsContext.trackEvent` / `trackMetaMetricsEvent` call sites in the **Settings (smart account suggestion and smart transactions opt-in thunks)** domain to `useAnalytics()` + `createEventBuilder` (or `trackAnalyticsEvent` for Redux thunks). Part of umbrella tracker #43885 (**15g · Settings Redux thunks**). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** 1. Build and load the extension (`yarn start`). 2. Exercise the flows touched by this PR (see changed files). 3. With MetaMetrics debug enabled, confirm events still fire with the same names and properties. <!-- ## **Screenshots/Recordings** ### **Before** ### **After** --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] 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](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Mechanical telemetry refactor with unchanged event names and properties; preference dispatch logic is untouched. > > **Overview** > Continues the analytics migration in **Settings Redux thunks** by replacing legacy `trackMetaMetricsEvent` payloads with `trackAnalyticsEvent` + `createEventBuilder` in `ui/store/actions.ts`. > > **`setDismissSmartAccountSuggestionEnabled`** and **`setSmartTransactionsPreferenceEnabled`** still emit `SettingsUpdated` under the Settings category with the same property keys (`dismiss_smt_acc_suggestion_enabled` / `prev_*` and `stx_opt_in` / `prev_stx_opt_in`); only the construction path changes. The file now imports `createEventBuilder` (not just types) from `shared/lib/analytics/create-event-builder`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cdabb3b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->



Description
Migrates remaining legacy
MetaMetricsContext.trackEvent/trackMetaMetricsEventcall sites in the Settings (smart account suggestion and smart transactions opt-in thunks) domain touseAnalytics()+createEventBuilder(ortrackAnalyticsEventfor Redux thunks).Part of umbrella tracker #43885 (15g · Settings Redux thunks).
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
yarn start).Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Mechanical telemetry refactor with unchanged event names and properties; preference dispatch logic is untouched.
Overview
Continues the analytics migration in Settings Redux thunks by replacing legacy
trackMetaMetricsEventpayloads withtrackAnalyticsEvent+createEventBuilderinui/store/actions.ts.setDismissSmartAccountSuggestionEnabledandsetSmartTransactionsPreferenceEnabledstill emitSettingsUpdatedunder the Settings category with the same property keys (dismiss_smt_acc_suggestion_enabled/prev_*andstx_opt_in/prev_stx_opt_in); only the construction path changes. The file now importscreateEventBuilder(not just types) fromshared/lib/analytics/create-event-builder.Reviewed by Cursor Bugbot for commit cdabb3b. Bugbot is set up for automated code reviews on this repo. Configure here.