diff --git a/app/scripts/lib/transaction/metrics.test.ts b/app/scripts/lib/transaction/metrics.test.ts index a4eb13918d7d..acf82095ed24 100644 --- a/app/scripts/lib/transaction/metrics.test.ts +++ b/app/scripts/lib/transaction/metrics.test.ts @@ -571,7 +571,7 @@ describe('Transaction metrics', () => { mockTransactionMeta.submittedTime = 123; await handleTransactionConfirmed(mockTransactionMetricsRequest, { - transactionMeta: mockTransactionMeta, + ...mockTransactionMeta, actionId: mockActionId, } as any); @@ -627,7 +627,7 @@ describe('Transaction metrics', () => { mockTransactionMetaWithBlockaid.submittedTime = 123; await handleTransactionConfirmed(mockTransactionMetricsRequest, { - transactionMeta: mockTransactionMetaWithBlockaid, + ...mockTransactionMetaWithBlockaid, actionId: mockActionId, } as any); diff --git a/app/scripts/lib/transaction/metrics.ts b/app/scripts/lib/transaction/metrics.ts index 1335878393a9..108a60557855 100644 --- a/app/scripts/lib/transaction/metrics.ts +++ b/app/scripts/lib/transaction/metrics.ts @@ -92,6 +92,11 @@ export type TransactionEventPayload = { error?: string; }; +export type TransactionMetaEventPayload = TransactionMeta & { + actionId?: string; + error?: string; +}; + /** * This function is called when a transaction is added to the controller. * @@ -185,14 +190,14 @@ export const handleTransactionFailed = async ( */ export const handleTransactionConfirmed = async ( transactionMetricsRequest: TransactionMetricsRequest, - transactionEventPayload: TransactionEventPayload, + transactionEventPayload: TransactionMetaEventPayload, ) => { - if (!transactionEventPayload.transactionMeta) { + if (Object.keys(transactionEventPayload).length === 0) { return; } const extraParams = {} as Record; - const { transactionMeta } = transactionEventPayload; + const transactionMeta = { ...transactionEventPayload }; const { txReceipt } = transactionMeta; extraParams.gas_used = txReceipt?.gasUsed; @@ -209,7 +214,10 @@ export const handleTransactionConfirmed = async ( await createUpdateFinalizeTransactionEventFragment({ eventName: TransactionMetaMetricsEvent.finalized, extraParams, - transactionEventPayload, + transactionEventPayload: { + actionId: transactionMeta.actionId, + transactionMeta, + }, transactionMetricsRequest, }); };