Skip to content

Commit 7b1455f

Browse files
david0xdMrtenz
authored andcommitted
feat(snaps): Add integration for snap_trackEvent RPC method (#32554)
## **Description** This PR adds integration for new Snap RPC method called `snap_trackEvent`. The implementation is done in Snaps repositories in the following PR: MetaMask/snaps#3375 Method specification: https://metamask.github.io/SIPs/SIPS/sip-32 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32554?quickstart=1) ## **Related issues** Fixes: MetaMask/snaps#3274 ## **Manual testing steps** 1. Within some of the preinstalled Snaps use `snap_trackEvent` RPC method and send some tracking data in format specified in [SIP-32](https://metamask.github.io/SIPs/SIPS/sip-32). 2. Find a way and verify that the event is sent (intercept MetaMetrics track event method or check with other e2e metrics testing utilities) Example Snap code used for testing the method: ```typescript await snap.request({ method: 'snap_trackEvent', params: { event: { event: 'SnapExportUsed', properties: { export: 'onRpcRequest', origin: 'https://metamask.io', snap_category: null, snap_id: 'npm:@metamask/example-snap', success: true, }, sensitiveProperties: { transaction_hash: 'transaction-hash', }, }, }, }); ``` ## **Screenshots/Recordings** ### **Before** No UI changes (n/a). ### **After** No UI changes (n/a). ## **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.
1 parent df20fd7 commit 7b1455f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

app/scripts/controllers/permissions/specifications.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export const unrestrictedMethods = Object.freeze([
193193
'snap_cancelBackgroundEvent',
194194
'snap_getBackgroundEvents',
195195
'snap_experimentalProviderRequest',
196+
'snap_trackEvent',
196197
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
197198
'metamaskinstitutional_authenticate',
198199
'metamaskinstitutional_reauthenticate',

app/scripts/metamask-controller.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7132,6 +7132,9 @@ export default class MetamaskController extends EventEmitter {
71327132
this.controllerMessenger,
71337133
'SnapController:get',
71347134
),
7135+
trackEvent: this.metaMetricsController.trackEvent.bind(
7136+
this.metaMetricsController,
7137+
),
71357138
getAllSnaps: this.controllerMessenger.call.bind(
71367139
this.controllerMessenger,
71377140
'SnapController:getAll',

0 commit comments

Comments
 (0)