From e2a0822f790a3d9ba56b03a071f15281270163a2 Mon Sep 17 00:00:00 2001 From: Tim Pechersky Date: Tue, 31 Aug 2021 13:36:21 +0200 Subject: [PATCH] time to convert to user --- frontend/src/core/providers/AnalyticsProvider/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/core/providers/AnalyticsProvider/index.js b/frontend/src/core/providers/AnalyticsProvider/index.js index cd15579b..daefb962 100644 --- a/frontend/src/core/providers/AnalyticsProvider/index.js +++ b/frontend/src/core/providers/AnalyticsProvider/index.js @@ -8,7 +8,7 @@ import UIContext from "../UIProvider/context"; const AnalyticsProvider = ({ children }) => { const clientID = useClientID(); const analytics = process.env.NEXT_PUBLIC_MIXPANEL_TOKEN; - const { user } = useUser(); + const { user, isInit } = useUser(); const [isMixpanelReady, setIsLoaded] = useState(false); const router = useRouter(); @@ -19,6 +19,12 @@ const AnalyticsProvider = ({ children }) => { } }, [ui.isOnboardingComplete, isMixpanelReady, user]); + useEffect(() => { + if (!user && isInit && isMixpanelReady) { + mixpanel.time_event(MIXPANEL_EVENTS.CONVERT_TO_USER); + } + }, [user, isInit, isMixpanelReady]); + useEffect(() => { if (ui.onboardingStep && isMixpanelReady) { mixpanel.people.set(MIXPANEL_EVENTS.ONBOARDING_STEPS, ui.onboardingStep);