Skip to content

Commit

Permalink
feat: add hasNogs attribute to CONNECT_WALLET analytics event
Browse files Browse the repository at this point in the history
  • Loading branch information
nounspaceryan committed Jul 4, 2024
1 parent 79c3713 commit 5ce6bfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/common/providers/AnalyticsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export enum AnalyticsEvent {
}

type AnalyticsEventProperties = {
[AnalyticsEvent.CONNECT_WALLET]: Record<string, never>;
[AnalyticsEvent.CONNECT_WALLET]: { hasNogs: boolean };
[AnalyticsEvent.SIGN_UP]: Record<string, never>;
[AnalyticsEvent.LINK_FID]: { fid: number };
[AnalyticsEvent.SAVE_SPACE_THEME]: Record<string, never>;
Expand Down
16 changes: 9 additions & 7 deletions src/common/providers/LoggedInStateProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -96,7 +96,7 @@ const LoggedInStateProvider: React.FC<LoggedInLayoutProps> = ({ children }) => {
const { signMessage, ready: walletsReady } = useSignMessage();
const authenticatorManager = useAuthenticatorManager();
const logout = useLogout();
const previousStep = usePrevious(currentStep);
const previousSteps = useValueHistory<SetupStep>(currentStep, 4);

async function loadWallet() {
if (walletsReady && ready && authenticated && user) {
Expand All @@ -113,14 +113,16 @@ const LoggedInStateProvider: React.FC<LoggedInLayoutProps> = ({ 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) {
Expand Down

0 comments on commit 5ce6bfc

Please sign in to comment.