diff --git a/src/analytics/Properties.tsx b/src/analytics/Properties.tsx index 5406c4cac50..11fd7990521 100644 --- a/src/analytics/Properties.tsx +++ b/src/analytics/Properties.tsx @@ -1581,18 +1581,18 @@ interface PointsEventsProperties { [PointsEvents.points_screen_activity_learn_more_press]: undefined } -interface EarnDepositProperties { - tokenId: string +interface EarnCommonProperties { + providerId: 'aave-v3' networkId: NetworkId + depositTokenId: string +} + +interface EarnDepositProperties extends EarnCommonProperties { tokenAmount: string - providerId: string } -interface EarnWithdrawProperties { - tokenId: string +interface EarnWithdrawProperties extends EarnCommonProperties { tokenAmount: string - networkId: NetworkId - providerId: string rewards: SerializableRewardsInfo[] } @@ -1612,10 +1612,10 @@ interface EarnEventsProperties { [EarnEvents.earn_add_crypto_action_press]: { action: TokenActionName } & TokenProperties - [EarnEvents.earn_deposit_provider_info_press]: undefined - [EarnEvents.earn_deposit_terms_and_conditions_press]: undefined - [EarnEvents.earn_deposit_complete]: undefined - [EarnEvents.earn_deposit_cancel]: undefined + [EarnEvents.earn_deposit_provider_info_press]: EarnDepositProperties + [EarnEvents.earn_deposit_terms_and_conditions_press]: EarnDepositProperties + [EarnEvents.earn_deposit_complete]: EarnDepositProperties + [EarnEvents.earn_deposit_cancel]: EarnDepositProperties [EarnEvents.earn_deposit_submit_start]: EarnDepositProperties [EarnEvents.earn_deposit_submit_success]: EarnDepositProperties & EarnDepositTxsReceiptProperties [EarnEvents.earn_deposit_submit_error]: EarnDepositProperties & @@ -1623,27 +1623,22 @@ interface EarnEventsProperties { error: string } [EarnEvents.earn_deposit_submit_cancel]: EarnDepositProperties - [EarnEvents.earn_view_pools_press]: undefined + [EarnEvents.earn_view_pools_press]: { + poolTokenId: string + networkId: string + providerId: 'aave-v3' + } [EarnEvents.earn_enter_amount_info_press]: undefined [EarnEvents.earn_enter_amount_continue_press]: { userHasFunds: boolean - tokenAmount: string amountInUsd: string amountEnteredIn: AmountEnteredIn - tokenId: string - networkId: string - } + } & EarnDepositProperties [EarnEvents.earn_enter_amount_info_more_pools]: undefined [EarnEvents.earn_exit_pool_press]: { - poolTokenId: string - networkId: NetworkId tokenAmount: string - providerId: string - } - [EarnEvents.earn_deposit_more_press]: { - depositTokenId: string - providerId: string - } + } & EarnCommonProperties + [EarnEvents.earn_deposit_more_press]: EarnCommonProperties [EarnEvents.earn_deposit_add_gas_press]: { gasTokenId: string } [EarnEvents.earn_feed_item_select]: { origin: 'EarnDeposit' | 'EarnWithdraw' | 'EarnClaimReward' diff --git a/src/earn/EarnActivePool.test.tsx b/src/earn/EarnActivePool.test.tsx index e8d74fab2a7..6b56ed662cb 100644 --- a/src/earn/EarnActivePool.test.tsx +++ b/src/earn/EarnActivePool.test.tsx @@ -73,7 +73,11 @@ describe('EarnActivePool', () => { ) fireEvent.press(getByText('earnFlow.activePools.viewPools')) - expect(ValoraAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_view_pools_press) + expect(ValoraAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_view_pools_press, { + poolTokenId: networkConfig.aaveArbUsdcTokenId, + networkId: NetworkId['arbitrum-sepolia'], + providerId: 'aave-v3', + }) expect(navigate).toBeCalledWith(Screens.TabDiscover) }) @@ -90,7 +94,7 @@ describe('EarnActivePool', () => { fireEvent.press(getByText('earnFlow.activePools.exitPool')) expect(ValoraAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_exit_pool_press, { - poolTokenId: networkConfig.aaveArbUsdcTokenId, + depositTokenId: networkConfig.arbUsdcTokenId, networkId: NetworkId['arbitrum-sepolia'], tokenAmount: '10.75', providerId: 'aave-v3', @@ -116,6 +120,7 @@ describe('EarnActivePool', () => { expect(ValoraAnalytics.track).toHaveBeenCalledWith(EarnEvents.earn_deposit_more_press, { depositTokenId: networkConfig.arbUsdcTokenId, providerId: 'aave-v3', + networkId: NetworkId['arbitrum-sepolia'], }) expect(navigate).toBeCalledWith(Screens.EarnEnterAmount, { tokenId: networkConfig.arbUsdcTokenId, diff --git a/src/earn/EarnActivePool.tsx b/src/earn/EarnActivePool.tsx index 7b8a7b5287b..f7af550535c 100644 --- a/src/earn/EarnActivePool.tsx +++ b/src/earn/EarnActivePool.tsx @@ -6,6 +6,7 @@ import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import SkeletonPlaceholder from 'src/components/SkeletonPlaceholder' import TokenDisplay from 'src/components/TokenDisplay' +import { PROVIDER_ID } from 'src/earn/constants' import { useAavePoolInfo } from 'src/earn/hooks' import UpwardGraph from 'src/icons/UpwardGraph' import { navigate } from 'src/navigator/NavigationService' @@ -45,6 +46,12 @@ export default function EarnActivePool({ depositTokenId, poolTokenId, cta }: Pro const poolToken = useTokenInfo(poolTokenId) const asyncPoolInfo = useAavePoolInfo({ depositTokenId }) + if (!poolToken) { + // should never happen + Logger.error(TAG, `No pool token found ${poolTokenId}`) + return null + } + return ( @@ -52,7 +59,7 @@ export default function EarnActivePool({ depositTokenId, poolTokenId, cta }: Pro {t('earnFlow.activePools.totalValue')} - {poolToken && poolToken.balance && ( + {poolToken.balance && ( )} - {poolToken && poolToken.balance && ( + {poolToken.balance && (