@@ -164,11 +164,12 @@ export default class ConfirmEncryptionPublicKey extends Component {
className="request-encryption-public-key__footer__cancel-button"
onClick={async (event) => {
await cancelEncryptionPublicKey(txData, event);
- metricsEvent({
- eventOpts: {
- category: 'Messages',
+ trackEvent({
+ category: 'Messages',
+ event: 'Cancel',
+ properties: {
action: 'Encryption public key Request',
- name: 'Cancel',
+ legacy_event: true,
},
});
clearConfirmTransaction();
@@ -183,11 +184,12 @@ export default class ConfirmEncryptionPublicKey extends Component {
className="request-encryption-public-key__footer__sign-button"
onClick={async (event) => {
await encryptionPublicKey(txData, event);
- this.context.metricsEvent({
- eventOpts: {
- category: 'Messages',
+ this.context.trackEvent({
+ category: 'Messages',
+ event: 'Confirm',
+ properties: {
action: 'Encryption public key Request',
- name: 'Confirm',
+ legacy_event: true,
},
});
clearConfirmTransaction();
diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
index 29b5e987a..a46c72f2f 100644
--- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
+++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
@@ -70,7 +70,7 @@ const renderHeartBeatIfNotInTest = () =>
export default class ConfirmTransactionBase extends Component {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -277,13 +277,12 @@ export default class ConfirmTransactionBase extends Component {
methodData = {},
} = this.props;
- this.context.metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ this.context.trackEvent({
+ category: 'Transactions',
+ event: 'User clicks "Edit" on gas',
+ properties: {
action: 'Confirm Screen',
- name: 'User clicks "Edit" on gas',
- },
- customVariables: {
+ legacy_event: true,
recipientKnown: null,
functionType:
actionKey ||
@@ -734,13 +733,12 @@ export default class ConfirmTransactionBase extends Component {
methodData = {},
} = this.props;
- this.context.metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ this.context.trackEvent({
+ category: 'Transactions',
+ event: 'Edit Transaction',
+ properties: {
action: 'Confirm Screen',
- name: 'Edit Transaction',
- },
- customVariables: {
+ legacy_event: true,
recipientKnown: null,
functionType:
actionKey ||
@@ -941,14 +939,13 @@ export default class ConfirmTransactionBase extends Component {
getNextNonce,
tryReverseResolveAddress,
} = this.props;
- const { metricsEvent } = this.context;
- metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ const { trackEvent } = this.context;
+ trackEvent({
+ category: 'Transactions',
+ event: 'Confirm: Started',
+ properties: {
action: 'Confirm Screen',
- name: 'Confirm: Started',
- },
- customVariables: {
+ legacy_event: true,
origin,
},
});
diff --git a/ui/pages/create-account/connect-hardware/index.js b/ui/pages/create-account/connect-hardware/index.js
index 0e784c7c5..decf331ac 100644
--- a/ui/pages/create-account/connect-hardware/index.js
+++ b/ui/pages/create-account/connect-hardware/index.js
@@ -253,23 +253,23 @@ class ConnectHardwareForm extends Component {
description,
)
.then((_) => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: `Connected Account with: ${device}`,
+ properties: {
action: 'Connected Hardware Wallet',
- name: `Connected Account with: ${device}`,
+ legacy_event: true,
},
});
history.push(mostRecentOverviewPage);
})
.catch((e) => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Error connecting hardware wallet',
+ properties: {
action: 'Connected Hardware Wallet',
- name: 'Error connecting hardware wallet',
- },
- customVariables: {
+ legacy_event: true,
error: e.message,
},
});
@@ -414,7 +414,7 @@ const mapDispatchToProps = (dispatch) => {
ConnectHardwareForm.contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
export default connect(
diff --git a/ui/pages/create-account/import-account/json.js b/ui/pages/create-account/import-account/json.js
index fbb237c4a..217e682ae 100644
--- a/ui/pages/create-account/import-account/json.js
+++ b/ui/pages/create-account/import-account/json.js
@@ -116,21 +116,23 @@ class JsonImportSubview extends Component {
.then(({ selectedAddress }) => {
if (selectedAddress) {
history.push(mostRecentOverviewPage);
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Imported Account with JSON',
+ properties: {
action: 'Import Account',
- name: 'Imported Account with JSON',
+ legacy_event: true,
},
});
displayWarning(null);
} else {
displayWarning(t('importAccountError'));
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Error importing JSON',
+ properties: {
action: 'Import Account',
- name: 'Error importing JSON',
+ legacy_event: true,
},
});
setSelectedAddress(firstAddress);
@@ -179,7 +181,7 @@ const mapDispatchToProps = (dispatch) => {
JsonImportSubview.contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
export default compose(
diff --git a/ui/pages/create-account/import-account/private-key.js b/ui/pages/create-account/import-account/private-key.js
index cc509b29a..99d0e3b48 100644
--- a/ui/pages/create-account/import-account/private-key.js
+++ b/ui/pages/create-account/import-account/private-key.js
@@ -11,7 +11,7 @@ import { getMostRecentOverviewPage } from '../../../ducks/history/history';
class PrivateKeyImportView extends Component {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -43,22 +43,24 @@ class PrivateKeyImportView extends Component {
importNewAccount('Private Key', [privateKey])
.then(({ selectedAddress }) => {
if (selectedAddress) {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Imported Account with Private Key',
+ properties: {
action: 'Import Account',
- name: 'Imported Account with Private Key',
+ legacy_event: true,
},
});
history.push(mostRecentOverviewPage);
displayWarning(null);
} else {
displayWarning(t('importAccountError'));
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Error importing with Private Key',
+ properties: {
action: 'Import Account',
- name: 'Error importing with Private Key',
+ legacy_event: true,
},
});
setSelectedAddress(firstAddress);
diff --git a/ui/pages/create-account/new-account.component.js b/ui/pages/create-account/new-account.component.js
index 3908bf40b..336d577eb 100644
--- a/ui/pages/create-account/new-account.component.js
+++ b/ui/pages/create-account/new-account.component.js
@@ -27,23 +27,23 @@ export default class NewAccountCreateForm extends Component {
const createClick = (_) => {
createAccount(newAccountName || defaultAccountName)
.then(() => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Added New Account',
+ properties: {
action: 'Add New Account',
- name: 'Added New Account',
+ legacy_event: true,
},
});
history.push(mostRecentOverviewPage);
})
.catch((e) => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Accounts',
+ this.context.trackEvent({
+ category: 'Accounts',
+ event: 'Error',
+ properties: {
action: 'Add New Account',
- name: 'Error',
- },
- customVariables: {
+ legacy_event: true,
errorMessage: e.message,
},
});
@@ -120,5 +120,5 @@ NewAccountCreateForm.propTypes = {
NewAccountCreateForm.contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
diff --git a/ui/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js b/ui/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
index 42246775c..2d611159c 100644
--- a/ui/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
+++ b/ui/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
@@ -9,7 +9,7 @@ import CreateNewVault from '../../../../components/app/create-new-vault';
export default class ImportWithSeedPhrase extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -21,13 +21,12 @@ export default class ImportWithSeedPhrase extends PureComponent {
UNSAFE_componentWillMount() {
this._onBeforeUnload = () =>
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Close window on import screen',
+ properties: {
action: 'Import Seed Phrase',
- name: 'Close window on import screen',
- },
- customVariables: {
+ legacy_event: true,
errorLabel: 'Seed Phrase Error',
errorMessage: this.state.seedPhraseError,
},
@@ -48,11 +47,12 @@ export default class ImportWithSeedPhrase extends PureComponent {
} = this.props;
await onSubmit(password, seedPhrase);
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Import Complete',
+ properties: {
action: 'Import Seed Phrase',
- name: 'Import Complete',
+ legacy_event: true,
},
});
@@ -70,11 +70,12 @@ export default class ImportWithSeedPhrase extends PureComponent {
{
e.preventDefault();
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Go Back from Onboarding Create',
+ properties: {
action: 'Create Password',
- name: 'Go Back from Onboarding Create',
+ legacy_event: true,
},
});
this.props.history.push(INITIALIZE_SELECT_ACTION_ROUTE);
diff --git a/ui/pages/first-time-flow/end-of-flow/end-of-flow.component.js b/ui/pages/first-time-flow/end-of-flow/end-of-flow.component.js
index e35e5af37..25beb844d 100644
--- a/ui/pages/first-time-flow/end-of-flow/end-of-flow.component.js
+++ b/ui/pages/first-time-flow/end-of-flow/end-of-flow.component.js
@@ -10,7 +10,7 @@ import { returnToOnboardingInitiator } from '../onboarding-initiator-util';
export default class EndOfFlowScreen extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -34,11 +34,12 @@ export default class EndOfFlowScreen extends PureComponent {
async _onOnboardingComplete() {
const { setCompletedOnboarding, completionMetaMetricsName } = this.props;
await setCompletedOnboarding();
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: completionMetaMetricsName,
+ properties: {
action: 'Onboarding Complete',
- name: completionMetaMetricsName,
+ legacy_event: true,
},
});
}
diff --git a/ui/pages/first-time-flow/metametrics-opt-in/metametrics-opt-in.component.js b/ui/pages/first-time-flow/metametrics-opt-in/metametrics-opt-in.component.js
index 883f086d5..cee0342ce 100644
--- a/ui/pages/first-time-flow/metametrics-opt-in/metametrics-opt-in.component.js
+++ b/ui/pages/first-time-flow/metametrics-opt-in/metametrics-opt-in.component.js
@@ -13,12 +13,12 @@ export default class MetaMetricsOptIn extends Component {
};
static contextTypes = {
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
t: PropTypes.func,
};
render() {
- const { metricsEvent, t } = this.context;
+ const { trackEvent, t } = this.context;
const {
nextRoute,
history,
@@ -109,15 +109,20 @@ export default class MetaMetricsOptIn extends Component {
participateInMetaMetrics === null ||
participateInMetaMetrics === true
) {
- await metricsEvent({
- eventOpts: {
+ await trackEvent(
+ {
category: 'Onboarding',
- action: 'Metrics Option',
- name: 'Metrics Opt Out',
+ event: 'Metrics Opt Out',
+ properties: {
+ action: 'Metrics Option',
+ legacy_event: true,
+ },
},
- isOptIn: true,
- flushImmediately: true,
- });
+ {
+ isOptIn: true,
+ flushImmediately: true,
+ },
+ );
}
} finally {
history.push(nextRoute);
@@ -136,28 +141,38 @@ export default class MetaMetricsOptIn extends Component {
participateInMetaMetrics === false
) {
metrics.push(
- metricsEvent({
- eventOpts: {
+ trackEvent(
+ {
category: 'Onboarding',
- action: 'Metrics Option',
- name: 'Metrics Opt In',
+ event: 'Metrics Opt In',
+ properties: {
+ action: 'Metrics Option',
+ legacy_event: true,
+ },
},
- isOptIn: true,
- flushImmediately: true,
- }),
+ {
+ isOptIn: true,
+ flushImmediately: true,
+ },
+ ),
);
}
metrics.push(
- metricsEvent({
- eventOpts: {
+ trackEvent(
+ {
category: 'Onboarding',
- action: 'Import or Create',
- name: firstTimeSelectionMetaMetricsName,
+ event: firstTimeSelectionMetaMetricsName,
+ properties: {
+ action: 'Import or Create',
+ legacy_event: true,
+ },
+ },
+ {
+ isOptIn: true,
+ metaMetricsId,
+ flushImmediately: true,
},
- isOptIn: true,
- metaMetricsId,
- flushImmediately: true,
- }),
+ ),
);
await Promise.all(metrics);
} finally {
diff --git a/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase-component.test.js b/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase-component.test.js
index 852fce269..b47bb9532 100644
--- a/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase-component.test.js
+++ b/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase-component.test.js
@@ -24,7 +24,7 @@ describe('ConfirmSeedPhrase Component', () => {
});
it('should add/remove selected on click', () => {
- const metricsEventSpy = sinon.spy();
+ const trackEventSpy = sinon.spy();
const replaceSpy = sinon.spy();
const component = shallowRender(
{
@@ -32,7 +32,7 @@ describe('ConfirmSeedPhrase Component', () => {
history: { replace: replaceSpy },
},
{
- metricsEvent: metricsEventSpy,
+ trackEvent: trackEventSpy,
},
);
@@ -57,7 +57,7 @@ describe('ConfirmSeedPhrase Component', () => {
});
it('should render correctly on hover', () => {
- const metricsEventSpy = sinon.spy();
+ const trackEventSpy = sinon.spy();
const replaceSpy = sinon.spy();
const component = shallowRender(
{
@@ -65,7 +65,7 @@ describe('ConfirmSeedPhrase Component', () => {
history: { replace: replaceSpy },
},
{
- metricsEvent: metricsEventSpy,
+ trackEvent: trackEventSpy,
},
);
@@ -92,7 +92,7 @@ describe('ConfirmSeedPhrase Component', () => {
});
it('should insert seed in place on drop', () => {
- const metricsEventSpy = sinon.spy();
+ const trackEventSpy = sinon.spy();
const replaceSpy = sinon.spy();
const component = shallowRender(
{
@@ -100,7 +100,7 @@ describe('ConfirmSeedPhrase Component', () => {
history: { replace: replaceSpy },
},
{
- metricsEvent: metricsEventSpy,
+ trackEvent: trackEventSpy,
},
);
@@ -137,7 +137,7 @@ describe('ConfirmSeedPhrase Component', () => {
'狗',
'豬',
];
- const metricsEventSpy = sinon.spy();
+ const trackEventSpy = sinon.spy();
const replaceSpy = sinon.spy();
const initialize3BoxSpy = sinon.spy();
const component = shallowRender(
@@ -148,7 +148,7 @@ describe('ConfirmSeedPhrase Component', () => {
initializeThreeBox: initialize3BoxSpy,
},
{
- metricsEvent: metricsEventSpy,
+ trackEvent: trackEventSpy,
},
);
@@ -166,11 +166,12 @@ describe('ConfirmSeedPhrase Component', () => {
await new Promise((resolve) => setTimeout(resolve, 100));
- expect(metricsEventSpy.args[0][0]).toStrictEqual({
- eventOpts: {
- category: 'Onboarding',
+ expect(trackEventSpy.args[0][0]).toStrictEqual({
+ category: 'Onboarding',
+ event: 'Verify Complete',
+ properties: {
action: 'Seed Phrase Setup',
- name: 'Verify Complete',
+ legacy_event: true,
},
});
expect(initialize3BoxSpy.calledOnce).toStrictEqual(true);
diff --git a/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js b/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js
index 72f1d0b45..2b569eb38 100644
--- a/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js
+++ b/ui/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js
@@ -13,7 +13,7 @@ const EMPTY_SEEDS = Array(12).fill(null);
export default class ConfirmSeedPhrase extends PureComponent {
static contextTypes = {
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
t: PropTypes.func,
};
@@ -77,11 +77,12 @@ export default class ConfirmSeedPhrase extends PureComponent {
}
try {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Verify Complete',
+ properties: {
action: 'Seed Phrase Setup',
- name: 'Verify Complete',
+ legacy_event: true,
},
});
diff --git a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js
index 31a2f80ff..1745a2527 100644
--- a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js
+++ b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js
@@ -16,7 +16,7 @@ import { returnToOnboardingInitiator } from '../../onboarding-initiator-util';
export default class RevealSeedPhrase extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -42,11 +42,12 @@ export default class RevealSeedPhrase extends PureComponent {
const { isShowingSeedPhrase } = this.state;
const { history } = this.props;
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Advance to Verify',
+ properties: {
action: 'Seed Phrase Setup',
- name: 'Advance to Verify',
+ legacy_event: true,
},
});
@@ -65,11 +66,12 @@ export default class RevealSeedPhrase extends PureComponent {
onboardingInitiator,
} = this.props;
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Remind me later',
+ properties: {
action: 'Seed Phrase Setup',
- name: 'Remind me later',
+ legacy_event: true,
},
});
@@ -102,11 +104,12 @@ export default class RevealSeedPhrase extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Onboarding',
+ this.context.trackEvent({
+ category: 'Onboarding',
+ event: 'Revealed Words',
+ properties: {
action: 'Seed Phrase Setup',
- name: 'Revealed Words',
+ legacy_event: true,
},
});
this.setState({ isShowingSeedPhrase: true });
diff --git a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
index 262b64f46..7bc9f4355 100644
--- a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
+++ b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
@@ -22,7 +22,7 @@ describe('Reveal Secret Recovery Phrase', () => {
wrapper = mount(, {
context: {
t: (str) => str,
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
},
});
});
diff --git a/ui/pages/keychains/restore-vault.js b/ui/pages/keychains/restore-vault.js
index 52f216818..87d6635e9 100644
--- a/ui/pages/keychains/restore-vault.js
+++ b/ui/pages/keychains/restore-vault.js
@@ -17,7 +17,7 @@ import { TYPOGRAPHY, COLORS } from '../../helpers/constants/design-system';
class RestoreVaultPage extends Component {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -40,11 +40,12 @@ class RestoreVaultPage extends Component {
leaveImportSeedScreenState();
await createNewVaultAndRestore(password, seedPhrase);
- this.context.metricsEvent({
- eventOpts: {
- category: 'Retention',
+ this.context.trackEvent({
+ category: 'Retention',
+ event: 'onboardingRestoredVault',
+ properties: {
action: 'userEntersSeedPhrase',
- name: 'onboardingRestoredVault',
+ legacy_event: true,
},
});
initializeThreeBox();
diff --git a/ui/pages/onboarding-flow/metametrics/metametrics.js b/ui/pages/onboarding-flow/metametrics/metametrics.js
index 2577b66f0..e9d43ee4f 100644
--- a/ui/pages/onboarding-flow/metametrics/metametrics.js
+++ b/ui/pages/onboarding-flow/metametrics/metametrics.js
@@ -17,7 +17,7 @@ import {
getParticipateInMetaMetrics,
} from '../../../selectors';
-import { MetaMetricsContext } from '../../../contexts/metametrics';
+import { MetaMetricsContext } from '../../../contexts/metametrics.new';
const firstTimeFlowTypeNameMap = {
create: 'Selected Create New Wallet',
@@ -36,33 +36,43 @@ export default function OnboardingMetametrics() {
const firstTimeSelectionMetaMetricsName =
firstTimeFlowTypeNameMap[firstTimeFlowType];
- const metricsEvent = useContext(MetaMetricsContext);
+ const trackEvent = useContext(MetaMetricsContext);
const onConfirm = async () => {
const [, metaMetricsId] = await dispatch(setParticipateInMetaMetrics(true));
try {
if (!participateInMetaMetrics) {
- metricsEvent({
- eventOpts: {
+ trackEvent(
+ {
category: 'Onboarding',
- action: 'Metrics Option',
- name: 'Metrics Opt In',
+ event: 'Metrics Opt In',
+ properties: {
+ action: 'Metrics Option',
+ legacy_event: true,
+ },
},
- isOptIn: true,
- flushImmediately: true,
- });
+ {
+ isOptIn: true,
+ flushImmediately: true,
+ },
+ );
}
- metricsEvent({
- eventOpts: {
+ trackEvent(
+ {
category: 'Onboarding',
- action: 'Import or Create',
- name: firstTimeSelectionMetaMetricsName,
+ event: firstTimeSelectionMetaMetricsName,
+ properties: {
+ action: 'Import or Create',
+ legacy_event: true,
+ },
+ },
+ {
+ isOptIn: true,
+ metaMetricsId,
+ flushImmediately: true,
},
- isOptIn: true,
- metaMetricsId,
- flushImmediately: true,
- });
+ );
} finally {
history.push(nextRoute);
}
@@ -73,15 +83,20 @@ export default function OnboardingMetametrics() {
try {
if (!participateInMetaMetrics) {
- metricsEvent({
- eventOpts: {
+ trackEvent(
+ {
category: 'Onboarding',
- action: 'Metrics Option',
- name: 'Metrics Opt Out',
+ event: 'Metrics Opt Out',
+ properties: {
+ action: 'Metrics Option',
+ legacy_event: true,
+ },
},
- isOptIn: true,
- flushImmediately: true,
- });
+ {
+ isOptIn: true,
+ flushImmediately: true,
+ },
+ );
}
} finally {
history.push(nextRoute);
diff --git a/ui/pages/send/send-content/send-asset-row/send-asset-row.component.js b/ui/pages/send/send-content/send-asset-row/send-asset-row.component.js
index 351f3024f..e68b9c105 100644
--- a/ui/pages/send/send-content/send-asset-row/send-asset-row.component.js
+++ b/ui/pages/send/send-content/send-asset-row/send-asset-row.component.js
@@ -46,7 +46,7 @@ export default class SendAssetRow extends Component {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
state = {
@@ -87,13 +87,12 @@ export default class SendAssetRow extends Component {
isShowingDropdown: false,
},
() => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ this.context.trackEvent({
+ category: 'Transactions',
+ event: 'User clicks "Assets" dropdown',
+ properties: {
action: 'Send Screen',
- name: 'User clicks "Assets" dropdown',
- },
- customVariables: {
+ legacy_event: true,
assetSelected: this.getAssetSelected(type, token),
},
});
diff --git a/ui/pages/send/send-footer/send-footer.component.js b/ui/pages/send/send-footer/send-footer.component.js
index 472c40e0d..84d8283a4 100644
--- a/ui/pages/send/send-footer/send-footer.component.js
+++ b/ui/pages/send/send-footer/send-footer.component.js
@@ -27,7 +27,7 @@ export default class SendFooter extends Component {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
onCancel() {
@@ -60,20 +60,19 @@ export default class SendFooter extends Component {
history,
gasEstimateType,
} = this.props;
- const { metricsEvent } = this.context;
+ const { trackEvent } = this.context;
// TODO: add nickname functionality
await addToAddressBookIfNew(to, toAccounts);
const promise = sign();
Promise.resolve(promise).then(() => {
- metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ trackEvent({
+ category: 'Transactions',
+ event: 'Complete',
+ properties: {
action: 'Edit Screen',
- name: 'Complete',
- },
- customVariables: {
+ legacy_event: true,
gasChanged: gasEstimateType,
},
});
@@ -83,7 +82,7 @@ export default class SendFooter extends Component {
componentDidUpdate(prevProps) {
const { sendErrors } = this.props;
- const { metricsEvent } = this.context;
+ const { trackEvent } = this.context;
if (
Object.keys(sendErrors).length > 0 &&
isEqual(sendErrors, prevProps.sendErrors) === false
@@ -91,13 +90,12 @@ export default class SendFooter extends Component {
const errorField = Object.keys(sendErrors).find((key) => sendErrors[key]);
const errorMessage = sendErrors[errorField];
- metricsEvent({
- eventOpts: {
- category: 'Transactions',
+ trackEvent({
+ category: 'Transactions',
+ event: 'Error',
+ properties: {
action: 'Edit Screen',
- name: 'Error',
- },
- customVariables: {
+ legacy_event: true,
errorField,
errorMessage,
},
diff --git a/ui/pages/send/send-footer/send-footer.component.test.js b/ui/pages/send/send-footer/send-footer.component.test.js
index 23bc565ac..cb2b974e3 100644
--- a/ui/pages/send/send-footer/send-footer.component.test.js
+++ b/ui/pages/send/send-footer/send-footer.component.test.js
@@ -43,7 +43,7 @@ describe('SendFooter Component', () => {
mostRecentOverviewPage="mostRecentOverviewPage"
{...props}
/>,
- { context: { t: (str) => str, metricsEvent: () => ({}) } },
+ { context: { t: (str) => str, trackEvent: () => ({}) } },
);
};
@@ -157,7 +157,7 @@ describe('SendFooter Component', () => {
update={propsMethodSpies.update}
mostRecentOverviewPage="mostRecentOverviewPage"
/>,
- { context: { t: (str) => str, metricsEvent: () => ({}) } },
+ { context: { t: (str) => str, trackEvent: () => ({}) } },
);
});
diff --git a/ui/pages/settings/advanced-tab/advanced-tab.component.js b/ui/pages/settings/advanced-tab/advanced-tab.component.js
index c0bea1a3f..cf8641f45 100644
--- a/ui/pages/settings/advanced-tab/advanced-tab.component.js
+++ b/ui/pages/settings/advanced-tab/advanced-tab.component.js
@@ -25,7 +25,7 @@ import {
export default class AdvancedTab extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -179,11 +179,12 @@ export default class AdvancedTab extends PureComponent {
className="settings-tab__button--red"
onClick={(event) => {
event.preventDefault();
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Reset Account',
+ properties: {
action: 'Reset Account',
- name: 'Reset Account',
+ legacy_event: true,
},
});
showResetAccountConfirmationModal();
@@ -696,11 +697,12 @@ export default class AdvancedTab extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Token Detection',
+ properties: {
action: 'Token Detection',
- name: 'Token Detection',
+ legacy_event: true,
},
});
setUseTokenDetection(!value);
diff --git a/ui/pages/settings/advanced-tab/advanced-tab.component.test.js b/ui/pages/settings/advanced-tab/advanced-tab.component.test.js
index d3f11735b..5c639e551 100644
--- a/ui/pages/settings/advanced-tab/advanced-tab.component.test.js
+++ b/ui/pages/settings/advanced-tab/advanced-tab.component.test.js
@@ -106,7 +106,7 @@ describe('AdvancedTab Component', () => {
/>,
{
context: {
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
t: (s) => `_${s}`,
},
},
@@ -142,7 +142,7 @@ describe('AdvancedTab Component', () => {
/>,
{
context: {
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
t: (s) => `_${s}`,
},
},
diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.js b/ui/pages/settings/experimental-tab/experimental-tab.component.js
index aed013cd6..fd91e01ab 100644
--- a/ui/pages/settings/experimental-tab/experimental-tab.component.js
+++ b/ui/pages/settings/experimental-tab/experimental-tab.component.js
@@ -12,7 +12,7 @@ import { THEME_TYPE } from './experimental-tab.constant';
export default class ExperimentalTab extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -63,11 +63,12 @@ export default class ExperimentalTab extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Token Detection',
+ properties: {
action: 'Token Detection',
- name: 'Token Detection',
+ legacy_event: true,
},
});
setUseTokenDetection(!value);
@@ -110,11 +111,12 @@ export default class ExperimentalTab extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Collectible Detection',
+ properties: {
action: 'Collectible Detection',
- name: 'Collectible Detection',
+ legacy_event: true,
},
});
if (!value && !openSeaEnabled) {
@@ -159,11 +161,12 @@ export default class ExperimentalTab extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Enabled/Disable OpenSea',
+ properties: {
action: 'Enabled/Disable OpenSea',
- name: 'Enabled/Disable OpenSea',
+ legacy_event: true,
},
});
// value is positive when being toggled off
@@ -207,11 +210,12 @@ export default class ExperimentalTab extends PureComponent {
{
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Enabled/Disable OpenSea',
+ properties: {
action: 'Enabled/Disable OpenSea',
- name: 'Enabled/Disable OpenSea',
+ legacy_event: true,
},
});
setEIP1559V2Enabled(!value);
diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.test.js b/ui/pages/settings/experimental-tab/experimental-tab.component.test.js
index 12f518012..d091660a8 100644
--- a/ui/pages/settings/experimental-tab/experimental-tab.component.test.js
+++ b/ui/pages/settings/experimental-tab/experimental-tab.component.test.js
@@ -15,7 +15,7 @@ describe('Experimental Tab', () => {
wrapper = mount(, {
context: {
t: (str) => str,
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
},
});
const useTokenDetection = wrapper.find({ type: 'checkbox' }).at(0);
@@ -29,7 +29,7 @@ describe('Experimental Tab', () => {
wrapper = mount(, {
context: {
t: (str) => str,
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
},
});
const useTokenDetectionText = wrapper.find({ text: 'Use Token Detection' });
diff --git a/ui/pages/settings/security-tab/security-tab.component.js b/ui/pages/settings/security-tab/security-tab.component.js
index 4bc7c25f3..f89c9bb1f 100644
--- a/ui/pages/settings/security-tab/security-tab.component.js
+++ b/ui/pages/settings/security-tab/security-tab.component.js
@@ -11,7 +11,7 @@ import {
export default class SecurityTab extends PureComponent {
static contextTypes = {
t: PropTypes.func,
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
};
static propTypes = {
@@ -62,11 +62,12 @@ export default class SecurityTab extends PureComponent {
large
onClick={(event) => {
event.preventDefault();
- this.context.metricsEvent({
- eventOpts: {
- category: 'Settings',
+ this.context.trackEvent({
+ category: 'Settings',
+ event: 'Reveal Seed Phrase',
+ properties: {
action: 'Reveal Seed Phrase',
- name: 'Reveal Seed Phrase',
+ legacy_event: true,
},
});
history.push(REVEAL_SEED_ROUTE);
diff --git a/ui/pages/settings/security-tab/security-tab.container.test.js b/ui/pages/settings/security-tab/security-tab.container.test.js
index 61946ed18..f1476e9fa 100644
--- a/ui/pages/settings/security-tab/security-tab.container.test.js
+++ b/ui/pages/settings/security-tab/security-tab.container.test.js
@@ -27,7 +27,7 @@ describe('Security Tab', () => {
wrapper = mount(, {
context: {
t: (str) => str,
- metricsEvent: () => undefined,
+ trackEvent: () => undefined,
},
});
});
diff --git a/ui/pages/unlock-page/unlock-page.component.js b/ui/pages/unlock-page/unlock-page.component.js
index 451aeafc6..cdc25bb7d 100644
--- a/ui/pages/unlock-page/unlock-page.component.js
+++ b/ui/pages/unlock-page/unlock-page.component.js
@@ -10,7 +10,7 @@ import { DEFAULT_ROUTE } from '../../helpers/constants/routes';
export default class UnlockPage extends Component {
static contextTypes = {
- metricsEvent: PropTypes.func,
+ trackEvent: PropTypes.func,
t: PropTypes.func,
};
@@ -75,14 +75,19 @@ export default class UnlockPage extends Component {
try {
await onSubmit(password);
const newState = await forceUpdateMetamaskState();
- this.context.metricsEvent({
- eventOpts: {
+ this.context.trackEvent(
+ {
category: 'Navigation',
- action: 'Unlock',
- name: 'Success',
+ event: 'Success',
+ properties: {
+ action: 'Unlock',
+ legacy_event: true,
+ },
},
- isNewVisit: true,
- });
+ {
+ isNewVisit: true,
+ },
+ );
if (
newState.participateInMetaMetrics === null ||
@@ -93,13 +98,12 @@ export default class UnlockPage extends Component {
} catch ({ message }) {
if (message === 'Incorrect password') {
const newState = await forceUpdateMetamaskState();
- this.context.metricsEvent({
- eventOpts: {
- category: 'Navigation',
+ this.context.trackEvent({
+ category: 'Navigation',
+ event: 'Incorrect Password',
+ properties: {
action: 'Unlock',
- name: 'Incorrect Password',
- },
- customVariables: {
+ legacy_event: true,
numberOfTokens: newState.tokens.length,
numberOfAccounts: Object.keys(newState.accounts).length,
},