diff --git a/src/common/providers/AnalyticsProvider.tsx b/src/common/providers/AnalyticsProvider.tsx index 9ada1130..0ea45f13 100644 --- a/src/common/providers/AnalyticsProvider.tsx +++ b/src/common/providers/AnalyticsProvider.tsx @@ -17,7 +17,7 @@ export enum AnalyticsEvent { } type AnalyticsEventProperties = { - [AnalyticsEvent.CONNECT_WALLET]: Record; + [AnalyticsEvent.CONNECT_WALLET]: { hasNogs: boolean }; [AnalyticsEvent.SIGN_UP]: Record; [AnalyticsEvent.LINK_FID]: { fid: number }; [AnalyticsEvent.SAVE_SPACE_THEME]: Record; diff --git a/src/common/providers/LoggedInStateProvider.tsx b/src/common/providers/LoggedInStateProvider.tsx index 8e574a86..121d4bd2 100644 --- a/src/common/providers/LoggedInStateProvider.tsx +++ b/src/common/providers/LoggedInStateProvider.tsx @@ -15,7 +15,7 @@ import { ALCHEMY_API } from "@/constants/urls"; import { AlchemyIsHolderOfContract } from "@/pages/api/signerRequests"; import axios from "axios"; import { NOGS_CONTRACT_ADDR } from "@/constants/nogs"; -import usePrevious from "@/common/lib/hooks/usePrevious"; +import useValueHistory from "@/common/lib/hooks/useValueHistory"; import { analytics, AnalyticsEvent, @@ -96,7 +96,7 @@ const LoggedInStateProvider: React.FC = ({ children }) => { const { signMessage, ready: walletsReady } = useSignMessage(); const authenticatorManager = useAuthenticatorManager(); const logout = useLogout(); - const previousStep = usePrevious(currentStep); + const previousSteps = useValueHistory(currentStep, 4); async function loadWallet() { if (walletsReady && ready && authenticated && user) { @@ -113,14 +113,16 @@ const LoggedInStateProvider: React.FC = ({ children }) => { } useEffect(() => { - // need to check previous step, otherwise this gets called twice if ( - previousStep == SetupStep.NOT_SIGNED_IN && - currentStep === SetupStep.SIGNED_IN + previousSteps[1] === SetupStep.WALLET_CONNECTED && + previousSteps[2] === SetupStep.SIGNED_IN && + previousSteps[3] === SetupStep.NOT_SIGNED_IN ) { - analytics.track(AnalyticsEvent.CONNECT_WALLET); + analytics.track(AnalyticsEvent.CONNECT_WALLET, { + hasNogs: previousSteps[0] === SetupStep.TOKENS_FOUND, + }); } - }, [previousStep, currentStep]); + }, [previousSteps]); async function loadIdentity() { if (walletsReady && ready && authenticated && user) {