feat(flags): add $feature_flag_has_experiment to $feature_flag_called events - #165
Merged
Conversation
Contributor
posthog-elixir Compliance ReportDate: 2026-07-15 23:28:08 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
|
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! get_in + == true keeps it crash-proof and always-boolean, both the legacy and Evaluations paths converge on the same Result field, and the true/false/absent cases are all asserted.
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
has_experiment: boolean()on theResultstruct (defaultfalse);build_result/3parsesmetadata.has_experimentfrom the/flags?v=2response with strict boolean coercion (this SDK has no local evaluation).log_feature_flag_usage/4always adds the property, covering both the legacy single-flag path and theEvaluationssnapshot path (missing flags omit the property).$feature_flag_calledalso includes the property via anextract_has_experiment/2helper over the response it already parses.💚 How did you test it?
mix test: 336 tests, 0 failures, with new coverage for true / reported-false / absent on both send paths plus the struct default.mix format --check-formatted,mix credo --strict, andmix posthog.public_api --checkall clean. Note: ran on Elixir 1.18.3/OTP 27 (the repo pins 1.20/OTP 29, not installed locally;mix.exsrequires only~> 1.17); CI covers the pinned toolchain.📝 Checklist
If releasing new changes
sampo addto generate a changeset file