feat(flags): add $feature_flag_has_experiment to $feature_flag_called events#219
Merged
Conversation
Parse the server-reported has_experiment field from /flags v2 metadata and /flags/definitions flag definitions, defaulting to false when the server does not send it (older deployments), and include it as a boolean property on every $feature_flag_called event across the single-flag, snapshot (evaluate_flags), local, and remote evaluation paths.
posthog-ruby Compliance ReportDate: 2026-07-15 23:27:12 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
haacked
marked this pull request as ready for review
July 15, 2026 18:29
Contributor
|
Reviews (1): Last reviewed commit: "Add $feature_flag_has_experiment to $fea..." | Re-trigger Greptile |
turnipdabeets
approved these changes
Jul 15, 2026
turnipdabeets
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Every read is nil-safe (&. chains / short-circuits), the internal flagDetails key is stripped before the public return, and true/false/absent are covered on the metadata, single-flag local/remote, and snapshot paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Part of a cross-SDK effort to shrink
$feature_flag_calledevents. This first phase adds a$feature_flag_has_experimentboolean property to every$feature_flag_calledevent, reflecting the server'shas_experimentsignal:metadata.has_experimentin the/flags?v=2response andhas_experimenton/api/feature_flag/local_evaluationflag definitions. When the server does not report the field (older deployments, bootstrapped flags), the property is omitted, so it is tri-state:true,false, or absent (unknown).This lets ingestion distinguish experiment-linked flag events (which need the full property set for exposure analysis) from the rest, and lets us measure the split before a later phase strips the expensive properties (
$feature/<key>,$feature_flag_payload, per-event system metadata) from non-experiment flag events. This PR intentionally minimizes nothing: no properties are removed, no config options are added, and dedupe behavior is unchanged.Changes
FeatureFlagMetadataparseshas_experimentfrom/flags?v=2metadata (boolean-coerced, defaultfalse).get_feature_flagreturnshas_experimentsourced from the stored/flags/definitionsdefinition on local eval and from response metadata on remote fallback;get_all_flags_and_payloadscarries parsed flag objects through an internal key (stripped from the public return) to reach metadata on the bulk remote path.client.rbadds the property on the single-flag path and threads it intoEvaluatedFlagRecords; snapshot-path events include it (missing flags omit the property).💚 How did you test it?
bundle exec rspec: 614 examples, 0 failures, with new coverage for remote true/false/absent/missing-flag, local-definition true/absent, single-flag local and remote v4/v3 paths, and metadata parsing; five existing exact-hash assertions updated.rubocopclean.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file