Skip to content

Commit a04133e

Browse files
authored
Merge pull request #137 from CodeClimbersIO/posthog-user-segmentation
feat: add Posthog user properties for email marketing
2 parents ad87b14 + e47bc04 commit a04133e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/hooks/useInitializeAppState.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import { usePostHog } from 'posthog-js/react'
99
import { useShortcutStore } from '@/lib/stores/shortcutStore'
1010
import { useConnectedStore } from '@/lib/stores/connectedStore'
1111
import { useProfile } from '@/api/hooks/useProfile'
12+
import { useLicenseWithDevices } from '@/api/hooks/useLicense'
1213
import { useWorkerPolling } from '@/hooks/useWorkerPolling'
1314
import { useCreateNotification, useGetNotificationBySentId } from '@/api/hooks/useNotifications'
1415
import { isFocusScheduleFeatureEnabled } from '@/lib/utils/environment.util'
1516

17+
18+
1619
export const useInitializeAppState = () => {
1720
useProfile()
1821
useWorkerPolling()
@@ -21,6 +24,7 @@ export const useInitializeAppState = () => {
2124
const { beginCheckForUpdates } = useUpdate()
2225
const { user } = useAuth()
2326
const { profile } = useProfile()
27+
const { data: licenseData } = useLicenseWithDevices(user?.id || null)
2428
const { setConnected } = useConnectedStore()
2529
const { loadShortcutFromStorage } = useShortcutStore()
2630
const { mutate: createNotification } = useCreateNotification()
@@ -50,15 +54,19 @@ export const useInitializeAppState = () => {
5054
init()
5155
}, [])
5256

57+
5358
useEffect(() => {
5459
if (user && profile?.latitude && profile?.longitude) {
5560
setConnected(true)
5661
posthog.identify(user.id, {
5762
email: user.email,
63+
created_at: user.created_at,
64+
subscription_status: licenseData?.license?.status || 'free',
65+
last_check_in: profile.last_check_in,
66+
full_name: user.user_metadata?.full_name
5867
})
5968
}
60-
61-
}, [user, posthog, profile])
69+
}, [user, posthog, profile, licenseData])
6270

6371

6472

0 commit comments

Comments
 (0)