posthog-js
posthog-js copied to clipboard
Callback in updateEarlyAccessFeatureEnrollment
Hi team,
I was trying out the new updateEarlyAccessFeatureEnrollment
. It seems it follows a similar model to something we've been doing internally - where you set a user property to determine access.
I notice that the implementation of posthog.people.set there is a callback parameter. We are using this to say "reload the page when the feature is opted in":
e.g.:
const toggleUserProperty = useCallback((userProperty: string, value: boolean, callback: RequestCallback) => {
window.posthog.people.set(userProperty, String(value), callback);
}, []);
But there's no equivalent on updateEarlyAccessFeatureEnrollment
.
Could there be?
Or do you recommend an alternative way to do this?
For context - we're migrating from a legacy generated HTML page to a react app, and the same URL will serve different versions depending on the opt in status of the feature.
So the user journey looks like this:
- User visits URL
- Posthog feature flags are checked on backend. User is not opted in.
- We load HTML page using backend renderer.
- Clicks Opt In button to new page
- We reload the page
- The feature flags are checked on backend. User is opted in.
- Backend renderer triggers load of React page.
We're finding that we're getting experiences where the user switches on the new page, but when the page reload happens they're still on the old page. A few seconds later, a refresh will end up on the correct - opted in - page.