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

Analytics(stake): add tx type tracking #4218

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading