fix: include experiment key on local-eval exposure events#37
Merged
Conversation
Set [Experiment] Experiment Key on exposure event properties when variant.metadata["experimentKey"] is present, so proxy-emitted exposures are run-aware when a flag is reused across experiment runs. Mirrors the same change in experiment-jvm-server#53 and experiment-node-server#83. Additive only — metadata blob, flag key, variant, user properties, and insertId are unchanged.
zhukaihan
approved these changes
May 8, 2026
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.
Summary
core/src/main/kotlin/exposure/ExposureTracker.kt) emitted[Experiment] Flag Key,[Experiment] Variant, and themetadatablob, but did not surface[Experiment] Experiment Keyas a top-level event property — so proxy-emitted exposures were not run-aware when a flag is reused across multiple experiment runs.variant.metadata["experimentKey"]is non-null, setevent.eventProperties["[Experiment] Experiment Key"]. Additive and backwards-compatible —metadatablob, flag key, variant, user properties, andinsertIdare unchanged.Test plan
test exposure includes experiment key when present in metadatatoExposureTrackerTest. Asserts[Experiment] Experiment Key == "exp-1"for the variant carrying it and absent for the variant without it../gradlew :core:test— passes.Note
Low Risk
Low risk: additive event property plumbing plus a focused unit test; no changes to filtering, insertId generation, or sending behavior.
Overview
Local-eval exposure events now surface
variant.metadata["experimentKey"]as a top-level event property ([Experiment] Experiment Key) when present, in addition to the existing flag key/variant andmetadatablob.Adds a unit test to assert the property is set only for variants that include
experimentKeyin metadata and absent otherwise.Reviewed by Cursor Bugbot for commit 1a17454. Bugbot is set up for automated code reviews on this repo. Configure here.