Skip to content

Commit

Permalink
feat: batch transfer PostHog events (#1897)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Sep 17, 2024
1 parent 6a8f590 commit 25a41ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ export function TransferPanel() {

setTransferring(true)

const isBatchTransfer = isBatchTransferSupported && Number(amount2) > 0

try {
if (
(isDepositMode && !parentSigner) ||
Expand Down Expand Up @@ -660,6 +662,7 @@ export function TransferPanel() {
accountType: isSmartContractWallet ? 'Smart Contract' : 'EOA',
network: childChainName,
amount: Number(amount),
amount2: isBatchTransfer ? Number(amount2) : undefined,
version: 2
})

Expand Down Expand Up @@ -875,15 +878,14 @@ export function TransferPanel() {
assetType: 'ERC-20',
accountType: 'Smart Contract',
network: childChainName,
amount: Number(amount)
amount: Number(amount),
amount2: isBatchTransfer ? Number(amount2) : undefined
}
)
}

const overrides: TransferOverrides = {}

const isBatchTransfer = isBatchTransferSupported && Number(amount2) > 0

if (isBatchTransfer) {
// when sending additional ETH with ERC-20, we add the additional ETH value as maxSubmissionCost
const gasEstimates = (await bridgeTransferStarter.transferEstimateGas({
Expand Down Expand Up @@ -931,6 +933,8 @@ export function TransferPanel() {
const onTxSubmit = async (bridgeTransfer: BridgeTransfer) => {
if (!walletAddress) return // at this point, walletAddress will always be defined, we just have this to avoid TS checks in this function

const isBatchTransfer = isBatchTransferSupported && Number(amount2) > 0

if (!isSmartContractWallet) {
trackEvent(
isTeleportMode ? 'Teleport' : isDepositMode ? 'Deposit' : 'Withdraw',
Expand All @@ -939,15 +943,14 @@ export function TransferPanel() {
assetType: selectedToken ? 'ERC-20' : 'ETH',
accountType: 'EOA',
network: getNetworkName(childChain.id),
amount: Number(amount)
amount: Number(amount),
amount2: isBatchTransfer ? Number(amount2) : undefined
}
)
}

const { sourceChainTransaction } = bridgeTransfer

const isBatchTransfer = isBatchTransferSupported && Number(amount2) > 0

const timestampCreated = String(normalizeTimestamp(Date.now()))

const txHistoryCompatibleObject = convertBridgeSdkToMergedTransaction({
Expand Down
1 change: 1 addition & 0 deletions packages/arb-token-bridge-ui/src/util/AnalyticsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type AnalyticsEventMap = {
accountType: AccountType
network: string
amount: number
amount2?: number
}
Withdraw: {
tokenSymbol?: string
Expand Down

0 comments on commit 25a41ec

Please sign in to comment.