Initial Analitys with Posthog
This commit is contained in:
6
PostHog.js
Normal file
6
PostHog.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import PostHog from 'posthog-react-native'
|
||||
|
||||
export const posthog = new PostHog('phc_2zh7SoBDi83vaa7Rz4YWTXWCjV0bOLfiqRyUo2mkf0b', {
|
||||
// usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
|
||||
host: 'https://us.i.posthog.com' // host is optional if you use https://us.i.posthog.com
|
||||
})
|
||||
@@ -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}/>)
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useSnapshot } from 'valtio';
|
||||
import GlobalState from '../contexts/GlobalState.js';
|
||||
import i18n from "../i18nMessages.js";
|
||||
import ProfilePhotoCircle from './ProfilePhotoCircle.js';
|
||||
import { posthog } from './../PostHog.js';
|
||||
|
||||
|
||||
let Post = (props) => {
|
||||
@@ -36,6 +37,12 @@ let Post = (props) => {
|
||||
changeLikes(likes + 1);
|
||||
newPostObj.reactions[viewer._id] = { type: "like" };
|
||||
API.newPostReaction(post._id);
|
||||
posthog.capture(
|
||||
'post_clicked',
|
||||
{
|
||||
post_id: post._id,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
changeLikes(likes - 1);
|
||||
delete newPostObj.reactions[viewer._id];
|
||||
|
||||
48
package-lock.json
generated
48
package-lock.json
generated
@@ -16,10 +16,12 @@
|
||||
"@react-navigation/native-stack": "^6.5.0",
|
||||
"assert": "^2.0.0",
|
||||
"expo": "^51.0.0",
|
||||
"expo-application": "~5.9.1",
|
||||
"expo-asset": "~10.0.10",
|
||||
"expo-av": "~14.0.7",
|
||||
"expo-dev-client": "~4.0.27",
|
||||
"expo-device": "~6.0.2",
|
||||
"expo-file-system": "~17.0.1",
|
||||
"expo-image": "~1.13.0",
|
||||
"expo-image-picker": "~15.0.7",
|
||||
"expo-linking": "~6.3.1",
|
||||
@@ -31,6 +33,7 @@
|
||||
"expo-updates": "~0.25.26",
|
||||
"i18n-js": "^4.2.0",
|
||||
"moment": "^2.29.1",
|
||||
"posthog-react-native": "^3.7.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-native": "0.74.5",
|
||||
@@ -12749,6 +12752,51 @@
|
||||
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
|
||||
},
|
||||
"node_modules/posthog-react-native": {
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/posthog-react-native/-/posthog-react-native-3.7.0.tgz",
|
||||
"integrity": "sha512-iPQfYZvujIj81dtDP2lX09PImFQb9Ue/XGLupXrX9iIusTxTtOtN0TZdVhNBFpgY000m0H7lDqP7D32ui7grWw==",
|
||||
"peerDependencies": {
|
||||
"@react-native-async-storage/async-storage": ">=1.0.0",
|
||||
"@react-navigation/native": ">= 5.0.10",
|
||||
"expo-application": ">= 4.0.0",
|
||||
"expo-device": ">= 4.0.0",
|
||||
"expo-file-system": ">= 13.0.0",
|
||||
"expo-localization": ">= 11.0.0",
|
||||
"posthog-react-native-session-replay": "^0.1",
|
||||
"react-native-device-info": ">= 10.0.0",
|
||||
"react-native-navigation": ">=6.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@react-native-async-storage/async-storage": {
|
||||
"optional": true
|
||||
},
|
||||
"@react-navigation/native": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-application": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-device": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-file-system": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-localization": {
|
||||
"optional": true
|
||||
},
|
||||
"posthog-react-native-session-replay": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native-device-info": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native-navigation": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-bytes": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
|
||||
|
||||
15
package.json
15
package.json
@@ -10,6 +10,7 @@
|
||||
"eject": "expo eject"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/metro-config": "~0.18.11",
|
||||
"@react-native-async-storage/async-storage": "1.23.1",
|
||||
"@react-native-community/netinfo": "11.3.1",
|
||||
"@react-navigation/bottom-tabs": "^6.2.0",
|
||||
@@ -17,17 +18,24 @@
|
||||
"@react-navigation/native-stack": "^6.5.0",
|
||||
"assert": "^2.0.0",
|
||||
"expo": "^51.0.0",
|
||||
"expo-application": "~5.9.1",
|
||||
"expo-asset": "~10.0.10",
|
||||
"expo-av": "~14.0.7",
|
||||
"expo-dev-client": "~4.0.27",
|
||||
"expo-device": "~6.0.2",
|
||||
"expo-file-system": "~17.0.1",
|
||||
"expo-image": "~1.13.0",
|
||||
"expo-image-picker": "~15.0.7",
|
||||
"expo-linking": "~6.3.1",
|
||||
"expo-localization": "~15.0.3",
|
||||
"expo-media-library": "~16.0.5",
|
||||
"expo-notifications": "~0.28.18",
|
||||
"expo-sharing": "~12.0.1",
|
||||
"expo-status-bar": "~1.12.1",
|
||||
"expo-updates": "~0.25.26",
|
||||
"i18n-js": "^4.2.0",
|
||||
"moment": "^2.29.1",
|
||||
"posthog-react-native": "^3.7.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-native": "0.74.5",
|
||||
@@ -39,12 +47,7 @@
|
||||
"react-native-vector-icons": "^9.1.0",
|
||||
"react-native-web": "~0.19.10",
|
||||
"react-native-webview": "13.8.6",
|
||||
"valtio": "^1.4.0",
|
||||
"@expo/metro-config": "~0.18.11",
|
||||
"expo-image": "~1.13.0",
|
||||
"expo-media-library": "~16.0.5",
|
||||
"expo-sharing": "~12.0.1",
|
||||
"expo-asset": "~10.0.10"
|
||||
"valtio": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.0"
|
||||
|
||||
Reference in New Issue
Block a user