-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Add method to wait for feature flag definitions for local evaluation to be loaded. #447
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
feat: Add method to wait for feature flag definitions for local evaluation to be loaded. #447
Conversation
This adds a method to wait for local evaluation flags to be loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR adds asynchronous and synchronous methods for checking local evaluation readiness in the PostHog Node.js client.
- Updated
/posthog-node/src/feature-flags.ts
to emit alocalEvaluationFlagsLoaded
event and implementisLocalEvaluationReady
. - Added
waitForLocalEvaluationReady
with a configurable timeout in/posthog-node/src/posthog-node.ts
. - Enhanced
/posthog-node/test/feature-flags.spec.ts
with tests for flag loading behaviors and edge cases.
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Size Change: +685 B (+0.41%) Total Size: 168 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No notes, this is great. Love the tests.
This PR provides a way for users to determine if feature flag definitions for local evaluation are loaded.
Problem
Fixes #445
Changes
This adds a new
waitForLocalEvaluationReady
method that waits up to 30 seconds (configurable) for local evaluation feature flags to be loaded.true
immediately if flags are already loaded.false
immediately if local evaluation is not enabled.This new method waits for the new
localEvaluationFlagsLoaded
event which is emitted when we retrieve feature flag definitions from the local evaluation endpoint.This PR also adds a synchronous
isLocalEvaluationReady()
method that checks the feature flag poller to see if any flags are loaded.Release info Sub-libraries affected
Bump level
Libraries affected
Changelog notes
waitForLocalEvaluationReady()
method used to wait for local evaluation flags to be loaded.localEvaluationFlagsLoaded
event which is emitted every time local evaluation flags are loaded.isLocalEvaluationReady()
method to quickly check if feature flags are loaded.