@@ -328,12 +328,17 @@ export const createTransactionEventFragmentWithTxId = async (
328328 * @param transactionMetricsRequest - Contains controller actions
329329 * @param transactionMetricsRequest.getParticipateInMetrics - Returns whether the user has opted into metrics
330330 * @param transactionMetricsRequest.trackEvent - MetaMetrics track event function
331+ * @param transactionMetricsRequest.getHDEntropyIndex - Returns Index of the currently selected HD Keyring
331332 * @param transactionEventPayload - The event payload
332333 * @param transactionEventPayload.transactionMeta - The updated transaction meta
333334 * @param transactionEventPayload.approvalTransactionMeta - The updated approval transaction meta
334335 */
335336export const handlePostTransactionBalanceUpdate = async (
336- { getParticipateInMetrics, trackEvent } : TransactionMetricsRequest ,
337+ {
338+ getParticipateInMetrics,
339+ trackEvent,
340+ getHDEntropyIndex,
341+ } : TransactionMetricsRequest ,
337342 {
338343 transactionMeta,
339344 approvalTransactionMeta,
@@ -345,9 +350,12 @@ export const handlePostTransactionBalanceUpdate = async (
345350 if ( getParticipateInMetrics ( ) && transactionMeta . swapMetaData ) {
346351 if ( transactionMeta . txReceipt ?. status === '0x0' ) {
347352 trackEvent ( {
348- event : 'Swap Failed' ,
349- sensitiveProperties : { ...transactionMeta . swapMetaData } ,
353+ event : MetaMetricsEventName . SwapFailed ,
350354 category : MetaMetricsEventCategory . Swaps ,
355+ sensitiveProperties : { ...transactionMeta . swapMetaData } ,
356+ properties : {
357+ hd_entropy_index : getHDEntropyIndex ( ) ,
358+ } ,
351359 } ) ;
352360 } else {
353361 const tokensReceived = getSwapsTokensReceivedFromTxMeta (
@@ -401,6 +409,9 @@ export const handlePostTransactionBalanceUpdate = async (
401409 token_to_amount :
402410 transactionMeta . swapMetaData . token_to_amount . toString ( 10 ) ,
403411 } ,
412+ properties : {
413+ hd_entropy_index : getHDEntropyIndex ( ) ,
414+ } ,
404415 } ) ;
405416 }
406417 }
@@ -981,6 +992,11 @@ async function buildEventFragmentProperties({
981992 const swapAndSendMetricsProperties =
982993 getSwapAndSendMetricsProps ( transactionMeta ) ;
983994
995+ // Add Entropy Properties
996+ const hdEntropyProperties = {
997+ hd_entropy_index : transactionMetricsRequest . getHDEntropyIndex ( ) ,
998+ } ;
999+
9841000 /** The transaction status property is not considered sensitive and is now included in the non-anonymous event */
9851001 let properties = {
9861002 chain_id : chainId ,
@@ -1013,6 +1029,7 @@ async function buildEventFragmentProperties({
10131029 : [ ] ,
10141030 ...smartTransactionMetricsProperties ,
10151031 ...swapAndSendMetricsProperties ,
1032+ ...hdEntropyProperties ,
10161033 // TODO: Replace `any` with type
10171034 // eslint-disable-next-line @typescript-eslint/no-explicit-any
10181035 } as Record < string , any > ;
0 commit comments