Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b082933
chore: Update wallet setup started event
huggingbot May 30, 2025
9867979
chore: Update wallet setup/import started/attempted/completed/failed …
huggingbot May 30, 2025
e98e9ef
feat: Enable event buffering and flushing to MetaMetrics
huggingbot May 31, 2025
17e574a
feat: Add tracking for "Learn More" link in create password flow
huggingbot Jun 1, 2025
12f57aa
fix: Incorrect property placement
huggingbot Jun 1, 2025
b56171b
feat: Add tracking for SRP definition clicks in onboarding flow
huggingbot Jun 1, 2025
22012bd
feat: Add wallet login tracking events in onboarding flow
huggingbot Jun 1, 2025
2c55aa8
feat: Add wallet rehydration tracking events for social login flow
huggingbot Jun 1, 2025
ecc033e
feat: Track password change events in security settings
huggingbot Jun 1, 2025
5731900
feat: Add tracking for Forgot Password and Reset Wallet events in unl…
huggingbot Jun 2, 2025
ee01b5f
fix: Include account_type in WalletSetupCompleted
huggingbot Jun 3, 2025
094b8cb
feat: Implement password strength evaluation in WalletCreated event
huggingbot Jun 3, 2025
86de9ab
feat: Include account_type in WalletCreationAttempted
huggingbot Jun 3, 2025
43420a5
refactor: Update wallet login events
huggingbot Jun 3, 2025
9dd795c
refactor: Track social logins for new and existing users
huggingbot Jun 3, 2025
0ecff9f
refactor: Rename wallet rehydration events to rehydration password ev…
huggingbot Jun 3, 2025
5bdc817
feat: Track failed login attempts in unlock page events
huggingbot Jun 3, 2025
76ed378
feat: Include actionId in buffered events for MetaMetrics
huggingbot Jun 10, 2025
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
14 changes: 14 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4085,6 +4085,20 @@ export default class MetamaskController extends EventEmitter {
),
trackInsightSnapView: this.trackInsightSnapView.bind(this),

// MetaMetrics buffering for onboarding
addEventBeforeMetricsOptIn:
metaMetricsController.addEventBeforeMetricsOptIn.bind(
metaMetricsController,
),
trackEventsAfterMetricsOptIn:
metaMetricsController.trackEventsAfterMetricsOptIn.bind(
metaMetricsController,
),
clearEventsAfterMetricsOptIn:
metaMetricsController.clearEventsAfterMetricsOptIn.bind(
metaMetricsController,
),

Copy link
Author

@huggingbot huggingbot Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're just exposing an existing implementation. Not sure why it wasn't exposed. These methods were unused and were probably removed previously, though the implementations were kept

// ApprovalController
rejectAllPendingApprovals: this.rejectAllPendingApprovals.bind(this),
rejectPendingApproval: this.rejectPendingApproval,
Expand Down
26 changes: 17 additions & 9 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,23 +700,21 @@ export enum MetaMetricsEventName {
NavSwapButtonClicked = 'Swap Button Clicked',
NavReceiveButtonClicked = 'Receive Button Clicked',
NftAdded = 'NFT Added',
OnboardingWalletCreationStarted = 'Wallet Setup Selected',
OnboardingWalletImportStarted = 'Wallet Import Started',
OnboardingWalletCreationAttempted = 'Wallet Password Created',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unused or replaced with Wallet* events

OnboardingWalletSecurityStarted = 'SRP Backup Selected',
OnboardingWalletSecuritySkipInitiated = 'SRP Skip Backup Selected',
OnboardingWalletSecuritySkipConfirmed = 'SRP Backup Skipped',
OnboardingWalletSecuritySkipCanceled = 'SRP Skip Backup Canceled',
OnboardingWalletSecurityPhraseRevealed = 'SRP Revealed',
OnboardingWalletSecurityPhraseWrittenDown = 'SRP Backup Confirm Display',
OnboardingWalletSecurityPhraseConfirmed = 'SRP Backup Confirmed',
OnboardingWalletCreationComplete = 'Wallet Created',
OnboardingWalletCreationComplete = 'Onboarding Wallet Created',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a Wallet Created value under the WalletCreated key, hence this value was renamed

OnboardingWalletAdvancedSettings = 'Settings Updated',
OnboardingWalletImportAttempted = 'Wallet Import Attempted',
OnboardingWalletVideoPlay = 'SRP Intro Video Played',
OnboardingTwitterClick = 'External Link Clicked',
OnboardingWalletSetupComplete = 'Wallet Setup Complete',
OnrampProviderSelected = 'On-ramp Provider Selected',
PasswordChanged = 'Password Changed',
ForgotPassword = 'Forgot Password',
ResetWallet = 'Reset Wallet',
PermissionsApproved = 'Permissions Approved',
PermissionsRejected = 'Permissions Rejected',
PermissionsRequested = 'Permissions Requested',
Expand Down Expand Up @@ -759,6 +757,7 @@ export enum MetaMetricsEventName {
SrpViewSrpText = 'Views SRP',
SrpCopiedToClipboard = 'Copies SRP to clipboard',
SrpToConfirmBackup = 'SRP Backup Confirm Displayed',
SrpDefinitionClicked = 'SRP Definition Clicked',
StakingEntryPointClicked = 'Stake Button Clicked',
SurveyToast = 'Survey Toast',
SupportLinkClicked = 'Support Link Clicked',
Expand All @@ -776,10 +775,19 @@ export enum MetaMetricsEventName {
TokenImportCanceled = 'Token Import Canceled',
TokenImportClicked = 'Token Import Clicked',
ShowNativeTokenAsMainBalance = 'Show native token as main balance',
WalletSetupStarted = 'Wallet Setup Selected',
WalletSetupCanceled = 'Wallet Setup Canceled',
WalletSetupFailed = 'Wallet Setup Failed',
WalletSetupStarted = 'Wallet Setup Started',
WalletImportStarted = 'Wallet Import Started',
WalletImportAttempted = 'Wallet Import Attempted',
WalletImported = 'Wallet Imported',
WalletCreationAttempted = 'Wallet Creation Attempted',
WalletCreated = 'Wallet Created',
WalletSetupFailure = 'Wallet Setup Failure',
WalletSetupCompleted = 'Wallet Setup Completed',
WalletRehydrationSelected = 'Wallet Rehydration Selected',
SocialLoginCompleted = 'Social Login Completed',
RehydrationPasswordAttempted = 'Rehydration Password Attempted',
RehydrationPasswordCompleted = 'Rehydration Password Completed',
RehydrationPasswordFailed = 'Rehydration Password Failed',
// BEGIN:ONLY_INCLUDE_IF(build-flask)
WatchEthereumAccountsToggled = 'Watch Ethereum Accounts Toggled',
// END:ONLY_INCLUDE_IF
Expand Down
35 changes: 25 additions & 10 deletions ui/contexts/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React, {
} from 'react';
import PropTypes from 'prop-types';
import { matchPath, useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { captureException, captureMessage } from '@sentry/browser';

import { omit } from 'lodash';
Expand All @@ -21,6 +22,11 @@ import { getEnvironmentType } from '../../app/scripts/lib/util';
import { PATH_NAME_MAP } from '../helpers/constants/routes';
import { MetaMetricsContextProp } from '../../shared/constants/metametrics';
import { useSegmentContext } from '../hooks/useSegmentContext';
import { getParticipateInMetaMetrics } from '../selectors';
import {
generateActionId,
submitRequestToBackground,
} from '../store/background-connection';

import { trackMetaMetricsEvent, trackMetaMetricsPage } from '../store/actions';

Expand Down Expand Up @@ -59,6 +65,7 @@ const PATHS_TO_CHECK = Object.keys(PATH_NAME_MAP);
export function MetaMetricsProvider({ children }) {
const location = useLocation();
const context = useSegmentContext();
const isMetricsEnabled = useSelector(getParticipateInMetaMetrics);

// Sometimes we want to track context properties inside the event's "properties" object.
const addContextPropsIntoEventProperties = useCallback(
Expand All @@ -82,18 +89,26 @@ export function MetaMetricsProvider({ children }) {
* @type {UITrackEventMethod}
*/
const trackEvent = useCallback(
(payload, options) => {
async (payload, options) => {
addContextPropsIntoEventProperties(payload, options);
trackMetaMetricsEvent(
{
...payload,
environmentType: getEnvironmentType(),
...context,
},
options,
);

const fullPayload = {
...payload,
environmentType: getEnvironmentType(),
...context,
};

if (isMetricsEnabled) {
// If metrics are enabled, track immediately
trackMetaMetricsEvent(fullPayload, options);
} else {
// If metrics are not enabled, buffer the event
await submitRequestToBackground('addEventBeforeMetricsOptIn', [
{ ...fullPayload, actionId: generateActionId() },
]);
}
},
[addContextPropsIntoEventProperties, context],
[addContextPropsIntoEventProperties, context, isMetricsEnabled],
);

// Used to prevent double tracking page calls
Expand Down
23 changes: 21 additions & 2 deletions ui/pages/onboarding-flow/account-exist/account-exist.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import React, { useContext, useEffect } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import {
Button,
Expand Down Expand Up @@ -40,14 +40,26 @@ import {
TraceOperation,
} from '../../../../shared/lib/trace';
import { useSentryTrace } from '../../../contexts/sentry-trace';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
MetaMetricsEventAccountType,
} from '../../../../shared/constants/metametrics';

export default function AccountExist() {
const history = useHistory();
const location = useLocation();
const dispatch = useDispatch();
const t = useI18nContext();
const firstTimeFlowType = useSelector(getFirstTimeFlowType);
const userSocialLoginEmail = useSelector(getSocialLoginEmail);
const { onboardingParentContext } = useSentryTrace();
const trackEvent = useContext(MetaMetricsContext);

// Get socialConnectionType from query parameters
const urlParams = new URLSearchParams(location.search);
const socialConnectionType = urlParams.get('socialConnectionType') || '';

const onBack = async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
Expand All @@ -63,6 +75,13 @@ export default function AccountExist() {
parentContext: onboardingParentContext.current,
});
dispatch(setFirstTimeFlowType(FirstTimeFlowType.socialImport));
trackEvent({
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.WalletImportStarted,
properties: {
account_type: `${MetaMetricsEventAccountType.Imported}_${socialConnectionType}`,
},
});
history.push(ONBOARDING_UNLOCK_ROUTE);
};

Expand Down
23 changes: 21 additions & 2 deletions ui/pages/onboarding-flow/account-not-found/account-not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import React, { useContext, useEffect } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import {
Button,
Expand Down Expand Up @@ -41,14 +41,26 @@ import {
TraceOperation,
} from '../../../../shared/lib/trace';
import { useSentryTrace } from '../../../contexts/sentry-trace';
import {
MetaMetricsEventAccountType,
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';
import { MetaMetricsContext } from '../../../contexts/metametrics';

export default function AccountNotFound() {
const history = useHistory();
const location = useLocation();
const dispatch = useDispatch();
const t = useI18nContext();
const firstTimeFlowType = useSelector(getFirstTimeFlowType);
const userSocialLoginEmail = useSelector(getSocialLoginEmail);
const { onboardingParentContext } = useSentryTrace();
const trackEvent = useContext(MetaMetricsContext);

// Get socialConnectionType from query parameters
const urlParams = new URLSearchParams(location.search);
const socialConnectionType = urlParams.get('socialConnectionType') || '';

const onBack = async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
Expand All @@ -64,6 +76,13 @@ export default function AccountNotFound() {
parentContext: onboardingParentContext.current,
});
dispatch(setFirstTimeFlowType(FirstTimeFlowType.socialCreate));
trackEvent({
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.WalletSetupStarted,
properties: {
account_type: `${MetaMetricsEventAccountType.Default}_${socialConnectionType}`,
},
});
history.push(ONBOARDING_CREATE_PASSWORD_ROUTE);
};

Expand Down
Loading
Loading