Skip to content
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

Make the feature flag fetch optional #65

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

markharding
Copy link
Contributor

Currently, when a personalAPIKey is passed, it will immediately try and fetch the feature flags. As there is no way to provide an initial list of ->featureFlags (the constructor sets to an empty array), it makes it difficult to maintain and hydrate a local cache when using Local Evaluation.

This change it pretty simple and should have no breaking changes.

@neilkakkar
Copy link
Contributor

Thanks @markharding for the PR! Trying to understand this a bit better, is your usecase that you have a separate cache of flags, and you want to use that to populate local eval flags? Perhaps because you're initialising the SDK per request?

@markharding
Copy link
Contributor Author

Thanks @markharding for the PR! Trying to understand this a bit better, is your usecase that you have a separate cache of flags, and you want to use that to populate local eval flags? Perhaps because you're initialising the SDK per request?

Kind of, I couldn't see a way of using a cache at all with this SDK, as it the constructor rebuilds on each run. If you're using something like PHP-FPM, the class would be constructed on each user request. I'm also not really a huge fan of constructors doing anything more than handling dependencies. On every new PostHog\Client() call, this will always make a call to fetch the feature flags. My PR provides a way to bypass that logic so you can call ->loadFlags() yourself.

@neilkakkar
Copy link
Contributor

Reasonable, sounds good 👍

@neilkakkar neilkakkar merged commit ee390e2 into PostHog:master Apr 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants