feat(flags): add $feature_flag_has_experiment to $feature_flag_called events#741
Open
haacked wants to merge 1 commit into
Open
feat(flags): add $feature_flag_has_experiment to $feature_flag_called events#741haacked wants to merge 1 commit into
haacked wants to merge 1 commit into
Conversation
Contributor
posthog-python Compliance ReportDate: 2026-07-15 17:39:33 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
|
Reviews (1): Last reviewed commit: "Add $feature_flag_has_experiment to $fea..." | Re-trigger Greptile |
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), it defaults tofalse.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
FlagMetadata.has_experiment: bool = Falseinposthog/types.py, parsed infrom_json.client.py:has_experimentsourced from the local flag definition on locally-evaluated paths and fromflag_details.metadataon remote paths, threaded through_capture_feature_flag_called(_if_needed), which always sets the property; also set on both_EvaluatedFlagRecordconstructions inevaluate_flags().feature_flag_evaluations.py:has_experimenton_EvaluatedFlagRecord; missing flags reportfalse.💚 How did you test it?
New
test_feature_flag_has_experiment.py(true / reported-false / absent on remote, local-eval, and snapshot paths) plus updated exact-property assertions in existing tests; 235 flag-related tests pass.ruff format --check,ruff check,mypy | mypy-baseline filter, and the public-API check all pass.📝 Checklist
If releasing new changes
sampo addto generate a changeset file