From 5fdf9641da5d86720242bf63011b0f595c2f8d09 Mon Sep 17 00:00:00 2001 From: ryanml Date: Tue, 12 Oct 2021 09:40:41 -0700 Subject: [PATCH] Adds sign typed data type to metrics payload for sign typed data events (#12291) * Adding type to metrics event for eth_sign, personal_sign, eth_signTypedData * Adding type to metrics eevents for eth_signTypedData_v3 and eth_signTypedData_v4 * Factoring in version --- .../signature-request-original.component.js | 16 ++++++--- .../signature-request.component.js | 35 +++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/ui/components/app/signature-request-original/signature-request-original.component.js b/ui/components/app/signature-request-original/signature-request-original.component.js index 41312296c..ec3baf497 100644 --- a/ui/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/components/app/signature-request-original/signature-request-original.component.js @@ -285,7 +285,9 @@ export default class SignatureRequestOriginal extends Component { history, mostRecentOverviewPage, sign, + txData: { type }, } = this.props; + const { metricsEvent, t } = this.context; return (
@@ -296,18 +298,21 @@ export default class SignatureRequestOriginal extends Component { onClick={async (event) => { this._removeBeforeUnload(); await cancel(event); - this.context.metricsEvent({ + metricsEvent({ eventOpts: { category: 'Transactions', action: 'Sign Request', name: 'Cancel', }, + customVariables: { + type, + }, }); clearConfirmTransaction(); history.push(mostRecentOverviewPage); }} > - {this.context.t('cancel')} + {t('cancel')}
); diff --git a/ui/components/app/signature-request/signature-request.component.js b/ui/components/app/signature-request/signature-request.component.js index 37eefcfeb..3f460b4c2 100644 --- a/ui/components/app/signature-request/signature-request.component.js +++ b/ui/components/app/signature-request/signature-request.component.js @@ -33,7 +33,11 @@ export default class SignatureRequest extends PureComponent { } _beforeUnload = (event) => { - const { clearConfirmTransaction, cancel } = this.props; + const { + clearConfirmTransaction, + cancel, + txData: { type }, + } = this.props; const { metricsEvent } = this.context; metricsEvent({ eventOpts: { @@ -41,6 +45,9 @@ export default class SignatureRequest extends PureComponent { action: 'Sign Request', name: 'Cancel Sig Request Via Notification Close', }, + customVariables: { + type, + }, }); clearConfirmTransaction(); cancel(event); @@ -57,22 +64,46 @@ export default class SignatureRequest extends PureComponent { const { fromAccount, txData: { - msgParams: { data, origin }, + msgParams: { data, origin, version }, + type, }, cancel, sign, } = this.props; const { address: fromAddress } = fromAccount; const { message, domain = {} } = JSON.parse(data); + const { metricsEvent } = this.context; const onSign = (event) => { window.removeEventListener('beforeunload', this._beforeUnload); sign(event); + metricsEvent({ + eventOpts: { + category: 'Transactions', + action: 'Sign Request', + name: 'Confirm', + }, + customVariables: { + type, + version, + }, + }); }; const onCancel = (event) => { window.removeEventListener('beforeunload', this._beforeUnload); cancel(event); + metricsEvent({ + eventOpts: { + category: 'Transactions', + action: 'Sign Request', + name: 'Cancel', + }, + customVariables: { + type, + version, + }, + }); }; return (