Adding posthog navigation

This commit is contained in:
Adolfo Reyna
2025-02-06 23:16:37 -05:00
parent 602081bf98
commit 7cf6f99503
2 changed files with 75 additions and 78 deletions

5
App.js
View File

@@ -29,6 +29,7 @@ import NewGroup from './Views/NewGroup.js';
import Slideshow from './Views/Slideshow.js'; import Slideshow from './Views/Slideshow.js';
import SongPlayer from './Views/SongPlayer.js'; import SongPlayer from './Views/SongPlayer.js';
import { Platform } from 'react-native'; import { Platform } from 'react-native';
import { PostHogProvider } from 'posthog-react-native'
const Tab = createBottomTabNavigator(); const Tab = createBottomTabNavigator();
@@ -260,6 +261,7 @@ export default function App() {
}} theme={theme}> }} theme={theme}>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={{ flex: 1 }}> <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={{ flex: 1 }}>
<NavigationContainer> <NavigationContainer>
<PostHogProvider apiKey="phc_2zh7SoBDi83vaa7Rz4YWTXWCjV0bOLfiqRyUo2mkf0b" autocapture>
<StatusBar style="dark" /> <StatusBar style="dark" />
<Stack.Navigator screenOptions={{ <Stack.Navigator screenOptions={{
header: (props) => { header: (props) => {
@@ -271,7 +273,7 @@ export default function App() {
<Appbar.Content title="EMI Fellowship" titleStyle={{}} /> <Appbar.Content title="EMI Fellowship" titleStyle={{}} />
<Appbar.Action icon="chat" onPress={() => { <Appbar.Action icon="chat" onPress={() => {
alert("Chats are comming soon."); alert("Chats are comming soon.");
}} onLongPress={()=>{ }} onLongPress={() => {
props.navigation.navigate("SongPlayer"); props.navigation.navigate("SongPlayer");
}} /> }} />
<Appbar.Action icon="search" onPress={() => { props.navigation.navigate("Search") }} /> <Appbar.Action icon="search" onPress={() => { props.navigation.navigate("Search") }} />
@@ -329,6 +331,7 @@ export default function App() {
<Stack.Screen name="Login" component={Login} options={{ headerShown: false }} /> <Stack.Screen name="Login" component={Login} options={{ headerShown: false }} />
<Tab.Screen name="Logout" component={Login} /> <Tab.Screen name="Logout" component={Login} />
</Stack.Navigator> </Stack.Navigator>
</PostHogProvider>
</NavigationContainer> </NavigationContainer>
<MediaView></MediaView> <MediaView></MediaView>
</KeyboardAvoidingView> </KeyboardAvoidingView>

View File

@@ -78,9 +78,11 @@ let Feed = ({ navigation, route }) => {
API.getMe().then((me) => { API.getMe().then((me) => {
if (subscribed){ if (subscribed){
GlobalState.me = me; GlobalState.me = me;
posthog.identify(me._id, posthog.identify(me.userid,
{ {
name: me.profile.firstName name: me.profile.firstName,
profileid: me._id,
is_superuser: me.superuser,
} }
); );
posthog.capture('login'); posthog.capture('login');
@@ -98,7 +100,6 @@ let Feed = ({ navigation, route }) => {
storeFeed(posts); storeFeed(posts);
} }
console.log("Feed, end useEffect") console.log("Feed, end useEffect")
posthog.capture('feed_impression');
} }
getData() getData()
return () => { return () => {
@@ -106,13 +107,6 @@ let Feed = ({ navigation, route }) => {
} }
}, [route.params]); }, [route.params]);
const renderPost = (({ item }) => { const renderPost = (({ item }) => {
posthog.capture(
'feed_impression',
{
post_id: item._id,
post_type: item.type,
}
);
if (item.nonOrganicType === 'PopularUsers' || item.nonOrganicType === 'PopularGroups'){ if (item.nonOrganicType === 'PopularUsers' || item.nonOrganicType === 'PopularGroups'){
if(item.nonOrganicType === 'PopularUsers'){ if(item.nonOrganicType === 'PopularUsers'){
return (<PostPopularUsers post={item}/>) return (<PostPopularUsers post={item}/>)