-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expo-router
touch events support
#171
Comments
A quick solution would be to adapt the new router integration based on the other integrations such as https://github.com/PostHog/posthog-js-lite/blob/01fff0242a620345614a792379397029cf6cc9f1/posthog-react-native/src/frameworks/wix-navigation.ts and https://github.com/PostHog/posthog-js-lite/blob/01fff0242a620345614a792379397029cf6cc9f1/posthog-react-native/src/hooks/useNavigationTracker.ts |
https://expo.github.io/router/docs/migration/react-navigation/screen-tracking/ should give a head start. |
FYI I just pulled posthog into my expo-router react native app and it captured navigation/screen events without me needing to do anything special. I think because it is built on top of react-navigation 🤷 ? |
Most likely but there are a few limitations as pointed out here. |
Oh no, I just ran into this. Yes it appears everything related to Is this being worked on? |
@AdamDorwart not at the moment, would you like to take a look and open a draft PR? happy to help out/review. |
I gave myself and hour to see what I could do but unfortunately I couldn't get touch events to work in the existing examples. I ran into some regressions on main that I at least gave a quick fix for #206 Unfortunately I couldn't get any touch events working in the
I'm not sure why <View>
<Text testID="example-ph-label" ph-label="special-text">
I have the property "ph-label" which means touching me will be autocaptured with a specific label
</Text>
</View> I ran out of time so I need to move on for now and just use manual event capture. |
Thanks for checking it out @AdamDorwart |
With expo-router many of my screens are named index.ts. Which causes a problem with autocapture since it uses the filename to define the Screen Name. So I get a lot of dupes in the PH logs. Would be great if i could change how PH autocapture generates the Screen Name instead of default using the filename. Any workarounds besides changing the name of all my files away from index.ts. |
@kwong70 you can try https://expo.github.io/router/docs/migration/react-navigation/screen-tracking/ |
Hey, so for our app using expo-router for native & web, we're actually forgetting about $pageview and instead using screen. export const usePostHogNavigationTracker = () => {
const posthog = usePostHog() || posthogClient
const pathname = usePathname()
const params = useGlobalSearchParams()
let pathAndParams = pathname
try {
const strippedParams = { ...params }
// remove props we don't care about. (screen is redundant, params is not parsable and useless)
delete strippedParams['screen']
delete strippedParams['params']
pathAndParams = pathname + objectToQueryParams(strippedParams)
} catch (e) {
l.warn('Could not parse parameters', params, e)
}
useEffect(() => {
posthog?.screen(pathAndParams)
}, [posthog, pathAndParams])
} This was at the beginning of the project.
We're going to revise our implementation as we're actually interested in all 3 data:
|
Hello, i want to add here, i can capture screen events like this in my expo app: const pathname = usePathname();
const params = useGlobalSearchParams();
useEffect(() => {
posthog.screen(pathname, {
...params,
});
}, [pathname, params]); Now, i want to capture screen touches like where users press the most but i think i cannot do it. I only put custom captures on buttons but it would be a nice feature to have. |
Hi, I want to capture performance marketing parameters like UTMs, gclid, fbclid, etc. I’m using a universal link to open the app, but it seems that the PostHog library doesn’t set properties (e.g., Latest/Initial UTM source) on the user from the universal link, as it does on the web. How can I achieve this? |
I settled on using route segments instead so I get screen names like
|
Description
https://docs.expo.dev/router/installation/#quick-start
https://github.com/expo/expo/tree/main/packages/expo-router
right now we support
@react-navigation/native
andreact-native-navigation
but not yetexpo-router
which is getting more popular day by dayhttps://results.stateofreactnative.com/navigation/
The text was updated successfully, but these errors were encountered: