Skip to content

Commit

Permalink
chore(stake): add analytics (#4218)
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom authored Sep 20, 2024
1 parent b601216 commit 43c0f9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/services/analytics/tx-tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isCustomTxInfo,
isCancellationTxInfo,
isSwapOrderTxInfo,
isAnyStakingTxInfo,
} from '@/utils/transaction-guards'

export const getTransactionTrackingType = (details: TransactionDetails | undefined): string => {
Expand All @@ -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: {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/transaction-guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import type {
StakingTxDepositInfo,
StakingTxWithdrawInfo,
NativeStakingWithdrawConfirmationView,
NativeStakingValidatorsExitConfirmationView,
StakingTxInfo,
} from '@safe-global/safe-gateway-typescript-sdk'
import {
ConfirmationViewTypes,
Expand All @@ -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)
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 43c0f9e

Please sign in to comment.