Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "Transaction Finalized" metrics event on transaction confirmation #24338

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/scripts/lib/transaction/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe('Transaction metrics', () => {
mockTransactionMeta.submittedTime = 123;

await handleTransactionConfirmed(mockTransactionMetricsRequest, {
transactionMeta: mockTransactionMeta,
...mockTransactionMeta,
actionId: mockActionId,
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -665,7 +665,7 @@ describe('Transaction metrics', () => {
mockTransactionMetaWithBlockaid.submittedTime = 123;

await handleTransactionConfirmed(mockTransactionMetricsRequest, {
transactionMeta: mockTransactionMetaWithBlockaid,
...mockTransactionMetaWithBlockaid,
actionId: mockActionId,
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 5 additions & 3 deletions app/scripts/lib/transaction/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ export const handleTransactionConfirmed = async (
transactionMetricsRequest: TransactionMetricsRequest,
transactionEventPayload: TransactionEventPayload,
) => {
if (!transactionEventPayload.transactionMeta) {
if (Object.keys(transactionEventPayload).length === 0) {
return;
}

// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const extraParams = {} as Record<string, any>;
const { transactionMeta } = transactionEventPayload;
const transactionMeta = transactionEventPayload;
const { txReceipt } = transactionMeta;

extraParams.gas_used = txReceipt?.gasUsed;
Expand All @@ -223,7 +223,9 @@ export const handleTransactionConfirmed = async (
await createUpdateFinalizeTransactionEventFragment({
eventName: TransactionMetaMetricsEvent.finalized,
extraParams,
transactionEventPayload,
transactionEventPayload: {
transactionMeta,
},
transactionMetricsRequest,
});
};
Expand Down
Loading