fix: include experiment key on local-eval exposure events#83
Merged
Conversation
Local evaluation via evaluateV2 was emitting exposure events without a top-level experiment key field, only embedding it inside the nested metadata blob. Custom reports keying off "[Experiment] Experiment Key" consequently saw no value for customers using local evaluation. Lift metadata.experimentKey onto event_properties['[Experiment] Experiment Key'] when present, matching the convention used by the browser SDK (which sets exposure.experiment_key from variant.expKey). Additive, backwards-compatible: the metadata blob is unchanged.
zhukaihan
approved these changes
May 7, 2026
This was referenced May 7, 2026
Merged
Merged
zhukaihan
added a commit
to amplitude/experiment-go-server
that referenced
this pull request
May 7, 2026
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 `EventProperties["[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>
github-actions Bot
pushed a commit
to amplitude/experiment-go-server
that referenced
this pull request
May 8, 2026
## [1.11.1](v1.11.0...v1.11.1) (2026-05-08) ### Bug Fixes * include experiment key on local-eval exposure events ([#46](#46)) ([dc85e36](dc85e36)), closes [amplitude/experiment-node-server#83](amplitude/experiment-node-server#83)
kyeh-amp
pushed a commit
to amplitude/experiment-python-server
that referenced
this pull request
May 8, 2026
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
pushed a commit
to amplitude/experiment-jvm-server
that referenced
this pull request
May 8, 2026
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
pushed a commit
to amplitude/experiment-ruby-server
that referenced
this pull request
May 8, 2026
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>
github-actions Bot
pushed a commit
to amplitude/experiment-ruby-server
that referenced
this pull request
May 8, 2026
## [1.10.1](v1.10.0...v1.10.1) (2026-05-08) ### Bug Fixes * include experiment key on local-eval exposure events ([#93](#93)) ([f821d35](f821d35)), closes [amplitude/experiment-node-server#83](amplitude/experiment-node-server#83)
github-actions Bot
pushed a commit
to amplitude/experiment-jvm-server
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)
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
evaluateV2was emitting exposure events that included the variant metadata blob (containingmetadata.experimentKey) but never lifted the experiment key onto a top-level event property. Custom reports that key off[Experiment] Experiment Keytherefore saw no value for customers on local evaluation.toExposureEvents, whenvariant.metadata?.experimentKeyis truthy, setevent_properties['[Experiment] Experiment Key']. Additive and backwards-compatible — the existingmetadatablob,[Experiment] Flag Key,[Experiment] Variant, user properties, andinsert_idare unchanged.experiment-js-client/.../experimentClient.tssetsexposure.experiment_key = sourceVariant.variant?.expKey). Property name uses the bracketed-namespace convention already established in this file ([Experiment] Flag Key,[Experiment] Variant) rather than the browser SDK's snake_case, since the browser SDK emits via a typedExposureobject that gets translated downstream, whereas this file emits Amplitude events directly.Test plan
with_experiment_keyfixture to the existingtoExposureEventstest inpackages/node/test/local/exposure/exposure-service.test.ts. Asserts the new property equals'exp-1'for that flag and isundefinedfor all other flags in the same exposure.with_experiment_key treatmentappended in alphabetical order).yarn workspace @amplitude/experiment-node-server test— 208 passed, 1 todo, 0 failures.yarn workspace @amplitude/experiment-node-server lint— 0 errors (19 pre-existing warnings, none from this change).yarn workspace @amplitude/experiment-node-server build— clean.Note
Low Risk
Low risk additive change that only adds an extra event property when
variant.metadata.experimentKeyis present; main risk is minor downstream analytics/reporting impact from a new field.Overview
Local-eval exposure events now lift
variant.metadata.experimentKeyinto a top-level event property (event_properties['[Experiment] Experiment Key']) when present, aligning exposure reporting with other SDKs.Tests extend the
toExposureEventsfixture to include a flag with anexperimentKey, assert the new property is set only for that flag, and update expected event count andinsert_idcanonicalization accordingly.Reviewed by Cursor Bugbot for commit 23e1684. Bugbot is set up for automated code reviews on this repo. Configure here.