Skip to content

Commit

Permalink
rename anonymous transaction events.
Browse files Browse the repository at this point in the history
Signed-off-by: Olusegun Akintayo <[email protected]>
  • Loading branch information
segun committed Sep 5, 2023
1 parent 997d135 commit 6278285
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
31 changes: 28 additions & 3 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}),
Expand Down
8 changes: 8 additions & 0 deletions shared/constants/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 6278285

Please sign in to comment.