Hey ๐ are you new around here? Feel free to contribute to this issue! It is quite straightforward since there's a clear spec - no need to think about what's the best solution.
The response will contain an array/list at response['featureFlags'] with the flags that are enabled for this user. The distinct ID should be already available from existing methods implemented in this lib.
The response should be cached and refreshed periodically.
A method isFeatureEnabled
This method takes a feature flag key as an input and returns a boolean indicating if the given flag is on or off for the user based on the response from above.
A method reloadFeatureFlags
This forces a refresh of the cache by calling /decide/ again.
A method onFeatureFlagsLoaded
Every time the flags are reloaded, this should be called as a callback.
Questions?
Feel free to ask me anything about this! I'm also reachable on the PostHog Slack.
New contributors welcome!
Hey ๐ are you new around here? Feel free to contribute to this issue! It is quite straightforward since there's a clear spec - no need to think about what's the best solution.
However, it isn't a teeny tiny task, which is why we're offering a $100 gift card for PostHog merch for a merged PR that implements this. You'll also be listed as a contributor on our main repo's README (4.3k stars) and get a digital contributor card.
Description
PostHog provides support for feature flags. These allow turning functionality on and off based on a response from the PostHog API.
For a client-side library like this one, we'd need an implementation similar to that of
posthog-js
.Here's an overview of what implementing this entails:
A mechanism to send a
POST
request to/decide/
with the following data:The response will contain an array/list at
response['featureFlags']
with the flags that are enabled for this user. The distinct ID should be already available from existing methods implemented in this lib. The response should be cached and refreshed periodically.A method
isFeatureEnabled
This method takes a feature flag key as an input and returns a boolean indicating if the given flag is on or off for the user based on the response from above.
A method
reloadFeatureFlags
This forces a refresh of the cache by calling
/decide/
again.A method
onFeatureFlagsLoaded
Every time the flags are reloaded, this should be called as a callback.
Questions?
Feel free to ask me anything about this! I'm also reachable on the PostHog Slack.