Skip to content
Open
Changes from 1 commit
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
Next Next commit
chore: include regular tx events during the stx status changes
  • Loading branch information
nikoferro committed Feb 15, 2023
commit 397aa0e28b1ca8fa175e022ed26cb0b0e3976e25
41 changes: 40 additions & 1 deletion src/SmartTransactionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class SmartTransactionsController extends BaseController<
}

const sensitiveProperties = {
stx_status: updatedSmartTransaction.status,
stx_status: updatedSmartTransaction.status as SmartTransactionStatuses,
token_from_symbol: updatedSmartTransaction.sourceTokenSymbol,
token_to_symbol: updatedSmartTransaction.destinationTokenSymbol,
processing_time: getStxProcessingTime(updatedSmartTransaction.time),
Expand All @@ -239,6 +239,45 @@ export default class SmartTransactionsController extends BaseController<
stx_user_opt_in: true,
};

// for reporting reasons we are logging also stx statuses mapped to regular tx statuses
// resulting in 2 events being logged for each stx status change
// the category: swaps and the category: Transactions
const txEventData = {
category: 'Transactions',
properties: {
chain_id: updatedSmartTransaction.chainId,
referrer: updatedSmartTransaction.origin,
network: updatedSmartTransaction.metamaskNetworkId,
// Hardcoded properties since we don't have access to the transaction object at this point
// These properties are the same for all STX
account_type: 'MetaMask',
transaction_type: 'contractInteraction',
source: 'user',
token_standard: 'NONE',
},
sensitiveProperties: {
status: sensitiveProperties.stx_status,
first_seen: updatedSmartTransaction.time,
completion_time: sensitiveProperties.processing_time,
},
};

if (sensitiveProperties.stx_status === SmartTransactionStatuses.PENDING) {
this.trackMetaMetricsEvent({
event: 'Transaction Submitted',
...txEventData,
});
} else if (
sensitiveProperties.stx_status.includes(
SmartTransactionStatuses.CANCELLED,
)
) {
this.trackMetaMetricsEvent({
event: 'Transaction Finalized',
...txEventData,
});
}

this.trackMetaMetricsEvent({
event: 'STX Status Updated',
category: 'swaps',
Expand Down