@@ -8,15 +8,24 @@ import dayjs from "dayjs"
88import { SplashScreen , Stack } from "expo-router"
99import { StatusBar } from "expo-status-bar"
1010import { useColorScheme as useNWColorScheme } from "nativewind"
11+ import { PostHogProvider , usePostHog } from "posthog-react-native"
12+ import * as Sentry from "sentry-expo"
1113
1214import { Toast } from "../components/Toast"
15+ import { IS_PRODUCTION } from "../lib/config"
1316import { useCheckExpoUpdates } from "../lib/hooks/useCheckExpoUpdates"
1417import { useFeatures } from "../lib/hooks/useFeatures"
1518import { useMe } from "../lib/hooks/useMe"
1619import { useNotificationObserver } from "../lib/hooks/useNotificationObserver"
1720import { useBackgroundColor } from "../lib/tailwind"
1821import { api , TRPCProvider } from "../lib/utils/api"
1922
23+ Sentry . init ( {
24+ dsn : "https://2e39a63a183c7a7fab0f691b638da957@o204549.ingest.sentry.io/4506592060309504" ,
25+ enableInExpoDevelopment : false ,
26+ debug : true ,
27+ } )
28+
2029SplashScreen . preventAutoHideAsync ( )
2130
2231// This is the main layout of the app
@@ -45,25 +54,32 @@ export default function RootLayout() {
4554 if ( ! fontsLoaded ) return null
4655
4756 return (
48- < ActionSheetProvider >
49- < TRPCProvider >
50- < PrefetchTabs >
51- < GestureHandlerRootView style = { { flex : 1 } } onLayout = { onLayoutRootView } >
52- < SafeAreaProvider >
53- < View className = "flex-1 bg-white dark:bg-black" >
54- < Stack initialRouteName = "(home)" screenOptions = { { headerShown : false , contentStyle : { backgroundColor } } } >
55- < Stack . Screen name = "(home)" />
56- < Stack . Screen name = "(auth)" options = { { presentation : "modal" } } />
57- < Stack . Screen name = "onboarding" options = { { presentation : "modal" } } />
58- </ Stack >
59- </ View >
60- < Toast />
61- < StatusBar />
62- </ SafeAreaProvider >
63- </ GestureHandlerRootView >
64- </ PrefetchTabs >
65- </ TRPCProvider >
66- </ ActionSheetProvider >
57+ < TRPCProvider >
58+ < PostHogProvider
59+ autocapture
60+ apiKey = "phc_2W9bqjQCsJjOLxyO5wcxb4m5aQrNRjUWmKA9mvu9lcF"
61+ options = { { host : "https://eu.posthog.com" , enable : IS_PRODUCTION } }
62+ >
63+ < ActionSheetProvider >
64+ < PrefetchTabs >
65+ < IdentifyUser />
66+ < GestureHandlerRootView style = { { flex : 1 } } onLayout = { onLayoutRootView } >
67+ < SafeAreaProvider >
68+ < View className = "flex-1 bg-white dark:bg-black" >
69+ < Stack initialRouteName = "(home)" screenOptions = { { headerShown : false , contentStyle : { backgroundColor } } } >
70+ < Stack . Screen name = "(home)" />
71+ < Stack . Screen name = "(auth)" options = { { presentation : "modal" } } />
72+ < Stack . Screen name = "onboarding" options = { { presentation : "modal" } } />
73+ </ Stack >
74+ </ View >
75+ < Toast />
76+ < StatusBar />
77+ </ SafeAreaProvider >
78+ </ GestureHandlerRootView >
79+ </ PrefetchTabs >
80+ </ ActionSheetProvider >
81+ </ PostHogProvider >
82+ </ TRPCProvider >
6783 )
6884}
6985
@@ -87,3 +103,14 @@ function PrefetchTabs(props: { children: React.ReactNode }) {
87103 if ( ! isDoneChecking ) return null
88104 return < > { props . children } </ >
89105}
106+
107+ function IdentifyUser ( ) {
108+ const { me, isLoading } = useMe ( )
109+ const posthog = usePostHog ( )
110+ React . useEffect ( ( ) => {
111+ if ( isLoading || ! me ) return
112+ if ( posthog ) posthog . identify ( me . id , { email : me . email , name : me . firstName + " " + me . lastName } )
113+ Sentry . React . setUser ( { id : me . id , email : me . email } )
114+ } , [ me , isLoading , posthog ] )
115+ return null
116+ }
0 commit comments