-
Notifications
You must be signed in to change notification settings - Fork 145
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(flags): Add version info to $feature_flag_called request #1811
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +24.3 kB (+0.68%) Total Size: 3.6 MB
ℹ️ View Unchanged
|
4aef13d
to
f6706fb
Compare
f6706fb
to
e78b1bf
Compare
7f19dc2
to
aaf68fb
Compare
This also includes the feature flag `version` and the evaluation `reason` in the `$feature_flag_called` event. This is done in a backwards compatible manner so if it's pointing at `/decide?v=3`, it will still work fine, it'll just lack the version info. This depends on: PostHog/posthog#29751
aaf68fb
to
a5df719
Compare
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 support for /decide?v=4
endpoint in the PostHog JavaScript SDK, introducing significant enhancements to feature flag functionality. Here's a summary of the key changes:
- Added new
getFeatureFlagDetails()
method returning comprehensive flag information including evaluation reasons, metadata, and version info - Enhanced
$feature_flag_called
event with additional fields like$feature_flag_version
,$feature_flag_id
, and$feature_flag_reason
- Added tracking of original flag values when overridden through
overrideFeatureFlags()
for debugging purposes - Added proper handling of quota limiting scenarios for feature flag requests
- Updated all relevant tests and types while maintaining backwards compatibility with
/decide?v=3
The changes appear well-structured with comprehensive test coverage and proper type definitions. The new functionality will help with debugging and provide more detailed insights into feature flag behavior.
7 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
It's a lot of data to send with every single capture.
@@ -71,6 +72,7 @@ export const PERSISTENCE_RESERVED_PROPERTIES = [ | |||
ENABLED_FEATURE_FLAGS, | |||
USER_STATE, | |||
PERSISTENCE_EARLY_ACCESS_FEATURES, | |||
PERSISTENCE_FEATURE_FLAG_DETAILS, |
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.
Made one last (hopefully) change to how we include the I think the whole structure is useful. Later, when we implement a human friendly description, it can be included in there. I need to dig into this, but by having structured data in there, I hope this'll make it possible to filter on Happy to roll that back if others don't like it and would rather it just be the human friendly description. |
This PR adds
/decide?v=4
support toposthog-js
. What we get with this support are the following:A new
getFeatureFlagDetails(key)
methodThis returns the full details of a feature flag. For example:
This includes an evaluation
reason
(description
is currently null, but will be populated in a future PR).It also includes
metadata
such as the db id of the flag and its version.There's also the corresponding
getFlagsWithDetails()
method to get all the flag details.Updates to the
$feature_flag_called
eventWhen capturing the
$feature_flag_called
event, additional information are now captured:$feature_flag_version
: The version of the feature flag.$feature_flag_id
: The database id of the flag. A flag can be deleted and recreated with the same key, so this helps us determine if that's the case.$feature_flag_reason
: The reason the flag evaluated as it did. For now, it's just the evaluation code, but once [Flag reporting improvements] Add evaluation reason to decide response posthog#29445 is completed, this will include a human friendly description.$feature_flag_original_response
: This contains the original response in the situation that the client overrode the flag via a call tooverrideFeatureFlags()
.$feature_flag_original_payload
: This contains the original payload in the situation that the client overrode the payload via a call tooverrideFeatureFlags()
.Sending the original values will help debug in the rare situation that a customer is confused by a flag result and forgot they were overriding it. 😆
Backwards compatibility:
The changes are all backwards compatible with
/decide?v=3
. Any requests for/decide?v=4
today will return av=3
response. Once PostHog/posthog#29751 is deployed, then these new additions will "light up".