From 10f92f73783104ce44871feb0ecad8724081abe4 Mon Sep 17 00:00:00 2001 From: Daniel Dimitrov Date: Fri, 20 Sep 2024 12:10:14 +0200 Subject: [PATCH] chore(stake): add analytics --- src/services/analytics/tx-tracking.ts | 5 +++++ src/utils/transaction-guards.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/analytics/tx-tracking.ts b/src/services/analytics/tx-tracking.ts index 9b74293481..b1397a6649 100644 --- a/src/services/analytics/tx-tracking.ts +++ b/src/services/analytics/tx-tracking.ts @@ -8,6 +8,7 @@ import { isCustomTxInfo, isCancellationTxInfo, isSwapOrderTxInfo, + isAnyStakingTxInfo, } from '@/utils/transaction-guards' export const getTransactionTrackingType = (details: TransactionDetails | undefined): string => { @@ -28,6 +29,10 @@ export const getTransactionTrackingType = (details: TransactionDetails | undefin return TX_TYPES.native_swap } + if (isAnyStakingTxInfo(txInfo)) { + return txInfo.type + } + if (isSettingsChangeTxInfo(txInfo)) { switch (txInfo.settingsInfo?.type) { case SettingsInfoType.ADD_OWNER: { diff --git a/src/utils/transaction-guards.ts b/src/utils/transaction-guards.ts index 28b90edec9..38e94421bf 100644 --- a/src/utils/transaction-guards.ts +++ b/src/utils/transaction-guards.ts @@ -38,6 +38,8 @@ import type { StakingTxDepositInfo, StakingTxWithdrawInfo, NativeStakingWithdrawConfirmationView, + NativeStakingValidatorsExitConfirmationView, + StakingTxInfo, } from '@safe-global/safe-gateway-typescript-sdk' import { ConfirmationViewTypes, @@ -54,7 +56,6 @@ import { sameAddress } from '@/utils/addresses' import type { NamedAddress } from '@/components/new-safe/create/types' import type { RecoveryQueueItem } from '@/features/recovery/services/recovery-state' import { ethers } from 'ethers' -import type { NativeStakingValidatorsExitConfirmationView } from '@safe-global/safe-gateway-typescript-sdk/dist/types/decoded-data' export const isTxQueued = (value: TransactionStatus): boolean => { return [TransactionStatus.AWAITING_CONFIRMATIONS, TransactionStatus.AWAITING_EXECUTION].includes(value) @@ -138,6 +139,10 @@ export const isStakingTxWithdrawInfo = (value: TransactionInfo): value is Stakin return value.type === TransactionInfoType.NATIVE_STAKING_WITHDRAW } +export const isAnyStakingTxInfo = (value: TransactionInfo): value is StakingTxInfo => { + return isStakingTxDepositInfo(value) || isStakingTxExitInfo(value) || isStakingTxWithdrawInfo(value) +} + export const isTwapConfirmationViewOrder = ( decodedData: AnyConfirmationView | undefined, ): decodedData is TwapOrderConfirmationView => {