diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-24 13:58:35 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 13:58:35 -0600 |
commit | 21f5f4de157a73b3c4406461b2a36555b1bff228 (patch) | |
tree | 0429a553bb3ea9d156036545fc252cb9455e7583 /src/App.native.tsx | |
parent | f36c9565362b741c58672204fe0c155252affe28 (diff) | |
download | voidsky-21f5f4de157a73b3c4406461b2a36555b1bff228.tar.zst |
Add basic analytics (#89)
* Add basic analytics * Fix: add mock for analytics
Diffstat (limited to 'src/App.native.tsx')
-rw-r--r-- | src/App.native.tsx | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/App.native.tsx b/src/App.native.tsx index e9d7542c0..30747dbfc 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -6,6 +6,11 @@ import {GestureHandlerRootView} from 'react-native-gesture-handler' import SplashScreen from 'react-native-splash-screen' import {SafeAreaProvider} from 'react-native-safe-area-context' import {observer} from 'mobx-react-lite' +import { + createClient, + SegmentClient, + AnalyticsProvider, +} from '@segment/analytics-react-native' import {ThemeProvider} from './view/lib/ThemeContext' import * as view from './view/index' import {RootStoreModel, setupState, RootStoreProvider} from './state' @@ -16,10 +21,17 @@ const App = observer(() => { const [rootStore, setRootStore] = useState<RootStoreModel | undefined>( undefined, ) + const [segment, setSegment] = useState<SegmentClient | undefined>(undefined) // init useEffect(() => { view.setup() + setSegment( + createClient({ + writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', + trackAppLifecycleEvents: true, + }), + ) setupState().then(store => { setRootStore(store) SplashScreen.hide() @@ -42,13 +54,15 @@ const App = observer(() => { return ( <GestureHandlerRootView style={s.h100pct}> <RootSiblingParent> - <RootStoreProvider value={rootStore}> - <ThemeProvider theme={rootStore.shell.darkMode ? 'dark' : 'light'}> - <SafeAreaProvider> - <MobileShell /> - </SafeAreaProvider> - </ThemeProvider> - </RootStoreProvider> + <AnalyticsProvider client={segment}> + <RootStoreProvider value={rootStore}> + <ThemeProvider theme={rootStore.shell.darkMode ? 'dark' : 'light'}> + <SafeAreaProvider> + <MobileShell /> + </SafeAreaProvider> + </ThemeProvider> + </RootStoreProvider> + </AnalyticsProvider> </RootSiblingParent> </GestureHandlerRootView> ) |