Initial Analitys with Posthog

This commit is contained in:
Adolfo Reyna
2025-02-06 10:32:52 -05:00
parent caaed40476
commit 602081bf98
5 changed files with 89 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import Post from './../components/Post.js';
import PostPopularUsers from '../components/PostPopularUsers.js';
import GlobalState from '../contexts/GlobalState.js';
import * as Linking from 'expo-linking';
import { posthog } from './../PostHog.js';
import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -77,6 +78,12 @@ let Feed = ({ navigation, route }) => {
API.getMe().then((me) => {
if (subscribed){
GlobalState.me = me;
posthog.identify(me._id,
{
name: me.profile.firstName
}
);
posthog.capture('login');
}
});
console.log("Feed from cache")
@@ -91,7 +98,7 @@ let Feed = ({ navigation, route }) => {
storeFeed(posts);
}
console.log("Feed, end useEffect")
posthog.capture('feed_impression');
}
getData()
return () => {
@@ -99,6 +106,13 @@ let Feed = ({ navigation, route }) => {
}
}, [route.params]);
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'){
return (<PostPopularUsers post={item}/>)