Repository navigation
feat(flags): add $feature_flag_has_experiment to $feature_flag_called events - #621
Merged
Merged
Conversation
Contributor
posthog-android Compliance ReportDate: 2026-07-15 23:31:22 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! All four send paths read the metadata null-safely, the Gson absent-field default is pinned by tests, and true/false/absent are covered on every layer. The greptile binary-compat P1s look dismissible to me since both classes are @PostHogInternal and posthog/posthog-server release in lockstep — same precedent as ensureExperienceContinuity.
3 of 5 tasks
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
FeatureFlagMetadata.hasExperiment(@SerializedName("has_experiment"), defaultfalse) parsed from/flags?v=2metadata and round-tripping through both flag caches; the same field onFlagDefinitionfor/local_evaluation, threaded intobuildFeatureFlagFromResult.PostHog.sendFeatureFlagCalled,PostHogStateless.sendFeatureFlagCalled,PostHogFeatureFlagEvaluations.recordAccess, and the compliance adapter's hand-built capture, defaulting tofalsewhen details are unavailable (null details, unknown flags, bootstrap/cache-degraded flags).posthog.apiregenerated; minor changeset forposthogandposthog-server.Known pre-existing gap (not introduced here): the server SDK's single-flag local-evaluation fast path (
resolveFeatureFlag) doesn't populate flag details, so events from that path reportfalseeven for experiment flags, same as the existing$feature_flag_id/$feature_flag_versionbehavior there. TheevaluateFlagssnapshot path reports it correctly. This must be fixed before any event-minimization phase.💚 How did you test it?
./gradlew :posthog:test :posthog-server:test :posthog:apiCheck :posthog-server:apiCheck spotlessCheck: BUILD SUCCESSFUL. New tests cover true / explicit-false / absent across the client, stateless, snapshot, Gson-parse, and local-evaluation paths. The:posthog-androidmodule is untouched (and requires an Android SDK not present locally); the change lives in the pure-JVMposthogandposthog-servermodules. The compliance adapter compiles (:sdk_compliance_adapter:compileKotlin).📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file