diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 20a7cdcb5493..419068d92361 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -21,9 +21,26 @@ import { SECOND } from '../../../shared/constants/time'; import { isManifestV3 } from '../../../shared/modules/mv3.utils'; import { METAMETRICS_FINALIZE_EVENT_FRAGMENT_ALARM } from '../../../shared/constants/alarms'; import { checkAlarmExists, generateRandomId, isValidDate } from '../lib/util'; +import { + AnonymousTransactionMetaMetricsEvent, + TransactionMetaMetricsEvent, +} from '../../../shared/constants/transaction'; const EXTENSION_UNINSTALL_URL = 'https://metamask.io/uninstalled'; +export const overrideAnonymousEventNames = { + [TransactionMetaMetricsEvent.added]: + AnonymousTransactionMetaMetricsEvent.added, + [TransactionMetaMetricsEvent.approved]: + AnonymousTransactionMetaMetricsEvent.approved, + [TransactionMetaMetricsEvent.finalized]: + AnonymousTransactionMetaMetricsEvent.finalized, + [TransactionMetaMetricsEvent.rejected]: + AnonymousTransactionMetaMetricsEvent.rejected, + [TransactionMetaMetricsEvent.submitted]: + AnonymousTransactionMetaMetricsEvent.submitted, +}; + const defaultCaptureException = (err) => { // throw error on clean stack so its captured by platform integrations (eg sentry) // but does not interrupt the call stack @@ -537,15 +554,23 @@ export default class MetaMetricsController { ); } + // change anonymous event names + const anonymousEventName = + overrideAnonymousEventNames[`${payload.event}`]; + const anonymousPayload = { + ...payload, + event: anonymousEventName, + }; + const combinedProperties = merge( - payload.sensitiveProperties, - payload.properties, + anonymousPayload.sensitiveProperties, + anonymousPayload.properties, ); events.push( this._track( this._buildEventPayload({ - ...payload, + ...anonymousPayload, properties: combinedProperties, isDuplicateAnonymizedEvent: true, }), diff --git a/shared/constants/transaction.ts b/shared/constants/transaction.ts index d14e9400e797..873b798eb544 100644 --- a/shared/constants/transaction.ts +++ b/shared/constants/transaction.ts @@ -446,6 +446,14 @@ export enum TransactionMetaMetricsEvent { submitted = 'Transaction Submitted', } +export enum AnonymousTransactionMetaMetricsEvent { + added = 'Transaction Added Anon', + approved = 'Transaction Approved Anon', + finalized = 'Transaction Finalized Anon', + rejected = 'Transaction Rejected Anon', + submitted = 'Transaction Submitted Anon', +} + /** * The types of assets that a user can send *