Skip to content

Commit 3e8647c

Browse files
authored
feat(snaps): Add Snap export tracking hook to Snap controller init (#14428)
## **Description** This PR adds MetaMetrics tracking hook to Snap controller init. This way we delegate Snap export tracking to Snap controller. ## **Related issues** Related PR: MetaMask/snaps#3281 MetaMask/metamask-extension#31553 ## **Notes** - Requires Snaps release. - Snaps PR: MetaMask/snaps#3281 - Targets Snaps release when ready. ## **Manual testing steps** 1. TBD ## **Screenshots/Recordings** ### **Before** n/a ### **After** n/a ## **Pre-merge author checklist** - [ ] 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). - [ ] 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-mobile/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.
1 parent ad064e3 commit 3e8647c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/core/Engine/controllers/snaps/snap-controller-init.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('SnapControllerInit', () => {
6868
getMnemonicSeed: expect.any(Function),
6969
maxIdleTime: expect.any(Number),
7070
preinstalledSnaps: expect.any(Array),
71+
trackEvent: expect.any(Function),
7172
});
7273
});
7374

app/core/Engine/controllers/snaps/snap-controller-init.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { selectBasicFunctionalityEnabled } from '../../../../selectors/settings'
2121
import { store } from '../../../../store';
2222
import PREINSTALLED_SNAPS from '../../../../lib/snaps/preinstalled-snaps';
2323
import { Caip25EndowmentPermissionName } from '@metamask/chain-agnostic-permission';
24+
import { MetaMetrics } from '../../../Analytics';
25+
import { MetricsEventBuilder } from '../../../Analytics/MetricsEventBuilder';
2426

2527
/**
2628
* Initialize the Snap controller.
@@ -119,6 +121,16 @@ export const snapControllerInit: ControllerInitFunction<
119121
clientCryptography: {
120122
pbkdf2Sha512: pbkdf2,
121123
},
124+
trackEvent: (params: {
125+
event: string;
126+
properties?: Record<string, unknown>;
127+
}) =>
128+
MetaMetrics.getInstance().trackEvent(
129+
MetricsEventBuilder.createEventBuilder({
130+
category: params.event,
131+
properties: params.properties,
132+
}).build(),
133+
),
122134
});
123135

124136
return {

0 commit comments

Comments
 (0)