fix: include experiment key on local-eval exposure events#53
Merged
Conversation
Local evaluation exposure events emit `metadata.experimentKey` inside the metadata blob but never lift it onto a top-level event property. Custom reports keying off `[Experiment] Experiment Key` therefore see no value for customers using local evaluation. When `variant.metadata.experimentKey` is present, set `event_properties['[Experiment] Experiment Key']`. Mirrors the equivalent fix in the Node SDK (amplitude/experiment-node-server#83). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kyeh-amp
approved these changes
May 7, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
May 8, 2026
## [1.8.3](1.8.2...1.8.3) (2026-05-08) ### Bug Fixes * include experiment key on local-eval exposure events ([#53](#53)) ([8bd7645](8bd7645)), closes [amplitude/experiment-node-server#83](amplitude/experiment-node-server#83)
|
🎉 This PR is included in version 1.8.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
2 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.
Summary
Exposure.toAmplitudeEvent()carriedexperimentKeyonly inside themetadatablob — the top-level event property[Experiment] Experiment Keywas never set, so custom reports keying off it saw no value for local-eval customers.variant.metadata["experimentKey"]is non-null, setevent.eventProperties["[Experiment] Experiment Key"]. Additive and backwards-compatible —metadata,[Experiment] Flag Key,[Experiment] Variant, user properties, andinsertIdare unchanged.Test plan
with-experiment-keyfixture toExposureServiceTest. Asserts[Experiment] Experiment Keyequals"exp-1"for that flag and is absent for the others../gradlew test --tests "com.amplitude.experiment.exposure.ExposureServiceTest"— passes.🤖 Generated with Claude Code
Note
Low Risk
Low risk additive change: only adds an optional top-level event property derived from existing
variant.metadata, with a small test update to cover it.Overview
Local-eval exposure events now include a top-level
[Experiment] Experiment KeyineventPropertieswhenvariant.metadata["experimentKey"]is present, instead of only embedding it inside themetadatablob.Tests add a
with-experiment-keyfixture and assert the new field is set only for that flag, updating expected event count andinsertIdcanonicalization accordingly.Reviewed by Cursor Bugbot for commit 2314e1d. Bugbot is set up for automated code reviews on this repo. Configure here.