Skip to content

fix: include experiment key on local-eval exposure events#37

Merged
kyeh-amp merged 1 commit into
mainfrom
experiment-key-exposure
May 8, 2026
Merged

fix: include experiment key on local-eval exposure events#37
kyeh-amp merged 1 commit into
mainfrom
experiment-key-exposure

Conversation

@kyeh-amp
Copy link
Copy Markdown
Contributor

@kyeh-amp kyeh-amp commented May 8, 2026

Summary

  • The proxy's local-eval exposure builder (core/src/main/kotlin/exposure/ExposureTracker.kt) emitted [Experiment] Flag Key, [Experiment] Variant, and the metadata blob, but did not surface [Experiment] Experiment Key as a top-level event property — so proxy-emitted exposures were not run-aware when a flag is reused across multiple experiment runs.
  • Fix: when variant.metadata["experimentKey"] is non-null, set event.eventProperties["[Experiment] Experiment Key"]. Additive and backwards-compatible — metadata blob, flag key, variant, user properties, and insertId are unchanged.
  • Mirrors amplitude/experiment-jvm-server#53 and amplitude/experiment-node-server#83.

Test plan

  • Added test exposure includes experiment key when present in metadata to ExposureTrackerTest. 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 and metadata blob.

Adds a unit test to assert the property is set only for variants that include experimentKey in metadata and absent otherwise.

Reviewed by Cursor Bugbot for commit 1a17454. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@kyeh-amp kyeh-amp requested a review from a team May 8, 2026 05:51
@kyeh-amp kyeh-amp merged commit 6959899 into main May 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants