Skip to content

Commit

Permalink
feat: added visited-eth-overview-with-staked-positions event
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt561 committed Dec 12, 2024
1 parent 8a9d08e commit 60f1ec1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import Badge, {
BadgeVariant,
} from '../../../../../component-library/components/Badges/Badge';
Expand Down Expand Up @@ -44,20 +44,29 @@ import useBalance from '../../hooks/useBalance';
import { NetworkBadgeSource } from '../../../AssetOverview/Balance/Balance';
import { selectChainId } from '../../../../../selectors/networkController';
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
import { MetaMetricsEvents, useMetrics } from '../../../../hooks/useMetrics';

export interface StakingBalanceProps {
asset: TokenI;
}

const StakingBalanceContent = ({ asset }: StakingBalanceProps) => {
const { styles } = useStyles(styleSheet, {});

const [
hasSentViewingStakingRewardsMetric,
setHasSentViewingStakingRewardsMetric,
] = useState(false);

const chainId = useSelector(selectChainId);
const networkName = useSelector(selectNetworkName);

const { isEligible: isEligibleForPooledStaking } = useStakingEligibility();

const { isStakingSupportedChain } = useStakingChain();

const { trackEvent, createEventBuilder } = useMetrics();

const {
pooledStakesData,
exchangeRate,
Expand Down Expand Up @@ -92,6 +101,28 @@ const StakingBalanceContent = ({ asset }: StakingBalanceProps) => {

const hasClaimableEth = !!Number(claimableEth);

useEffect(() => {
if (hasStakedPositions && !hasSentViewingStakingRewardsMetric) {
trackEvent(
createEventBuilder(
MetaMetricsEvents.VISITED_ETH_OVERVIEW_WITH_STAKED_POSITIONS,
)
.addProperties({
selected_provider: 'consensys',
location: 'StakingBalance',
})
.build(),
);

setHasSentViewingStakingRewardsMetric(true);
}
}, [
createEventBuilder,
hasSentViewingStakingRewardsMetric,
hasStakedPositions,
trackEvent,
]);

if (!isStakingSupportedChain) {
return <></>;
}
Expand Down
4 changes: 4 additions & 0 deletions app/core/Analytics/MetaMetrics.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ enum EVENT_NAME {
UNSTAKE_TRANSACTION_FAILED = 'Unstake Transaction Failed',
UNSTAKE_TRANSACTION_CONFIRMED = 'Unstake Transaction Confirmed',
UNSTAKE_TRANSACTION_SUBMITTED = 'Unstake Transaction Submitted',
VISITED_ETH_OVERVIEW_WITH_STAKED_POSITIONS = 'Visited ETH Overview with Staked Positions',

// Force Upgrade | Automatic Security Checks
FORCE_UPGRADE_UPDATE_NEEDED_PROMPT_VIEWED = 'Force Upgrade Update Needed Prompt Viewed',
Expand Down Expand Up @@ -986,6 +987,9 @@ const events = {
UNSTAKE_TRANSACTION_SUBMITTED: generateOpt(
EVENT_NAME.UNSTAKE_TRANSACTION_SUBMITTED,
),
VISITED_ETH_OVERVIEW_WITH_STAKED_POSITIONS: generateOpt(
EVENT_NAME.VISITED_ETH_OVERVIEW_WITH_STAKED_POSITIONS,
),
};

/**
Expand Down

0 comments on commit 60f1ec1

Please sign in to comment.