Skip to content

feat(snaps): Add Snap export tracking hook to Snap controller init #14428

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('SnapControllerInit', () => {
getMnemonicSeed: expect.any(Function),
maxIdleTime: expect.any(Number),
preinstalledSnaps: expect.any(Array),
trackEvent: expect.any(Function),
});
});

Expand Down
12 changes: 12 additions & 0 deletions app/core/Engine/controllers/snaps/snap-controller-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { KeyringTypes } from '@metamask/keyring-controller';
import { selectBasicFunctionalityEnabled } from '../../../../selectors/settings';
import { store } from '../../../../store';
import PREINSTALLED_SNAPS from '../../../../lib/snaps/preinstalled-snaps';
import { MetaMetrics } from '../../../Analytics';
import { MetricsEventBuilder } from '../../../Analytics/MetricsEventBuilder';

/**
* Initialize the Snap controller.
Expand Down Expand Up @@ -117,6 +119,16 @@ export const snapControllerInit: ControllerInitFunction<
clientCryptography: {
pbkdf2Sha512: pbkdf2,
},
trackEvent: (params: {
event: string;
properties?: Record<string, unknown>;
}) =>
MetaMetrics.getInstance().trackEvent(
MetricsEventBuilder.createEventBuilder({
category: params.event,
properties: params.properties,
}).build(),
),
});

return {
Expand Down
Loading