Skip to content

Commit

Permalink
fix: remove stx deposit analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 18, 2023
1 parent 5f539ca commit 95d3d86
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
43 changes: 0 additions & 43 deletions src/app/common/hooks/analytics/transactions-analytics.hooks.ts
Original file line number Diff line number Diff line change
@@ -1,43 +0,0 @@
import { useEffect, useMemo } from 'react';

import { AccountStxBalanceBigNumber } from '@shared/models/account.model';

import { useCurrentStacksAccountUnanchoredBalances } from '@app/query/stacks/balance/stx-balance.hooks';
import { store } from '@app/store';
import { analyticsActions } from '@app/store/analytics/analytics.actions';
import { useAnalyticsHasStxDeposits } from '@app/store/analytics/analytics.selectors';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';

import { useAnalytics } from './use-analytics';

function useIsFirstDeposit(stxBalance: AccountStxBalanceBigNumber | undefined): boolean {
const currentNetwork = useCurrentNetworkState();
const { chainId: stxChainId } = currentNetwork.chain.stacks;
const hasStxDeposits = useAnalyticsHasStxDeposits()[stxChainId];
const hasZeroStx = useMemo(
() => stxBalance?.total_received.amount?.isEqualTo(0) || false,
[stxBalance?.total_received]
);
useEffect(() => {
if (!stxBalance) return;
if (hasZeroStx || !hasStxDeposits) {
store.dispatch(
analyticsActions.hasStxDeposits({
network: stxChainId,
hasStxDeposits: !hasZeroStx,
})
);
}
}, [hasZeroStx, hasStxDeposits, stxChainId, stxBalance]);
return !hasStxDeposits && !hasZeroStx;
}

export function useTrackFirstDeposit() {
const analytics = useAnalytics();
const { data: balances } = useCurrentStacksAccountUnanchoredBalances();
const firstDeposit = useIsFirstDeposit(balances?.stx);
useEffect(() => {
if (!firstDeposit || !balances) return;
void analytics.track('deposit_first_stx', { type: 'stx' });
}, [analytics, balances, firstDeposit]);
}
3 changes: 0 additions & 3 deletions src/app/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Route, useNavigate } from 'react-router-dom';

import { RouteUrls } from '@shared/route-urls';

import { useTrackFirstDeposit } from '@app/common/hooks/analytics/transactions-analytics.hooks';
import { useOnboardingState } from '@app/common/hooks/auth/use-onboarding-state';
import { useOnMount } from '@app/common/hooks/use-on-mount';
import { useRouteHeader } from '@app/common/hooks/use-route-header';
Expand All @@ -23,8 +22,6 @@ export function Home() {

const navigate = useNavigate();

useTrackFirstDeposit();

useRouteHeader(
<>
<InAppMessages />
Expand Down

0 comments on commit 95d3d86

Please sign in to comment.