Skip to content

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

Merged
kyeh-amp merged 1 commit intomainfrom
feat/exposure-experiment-key
May 8, 2026
Merged

fix: include experiment key on local-eval exposure events#93
kyeh-amp merged 1 commit intomainfrom
feat/exposure-experiment-key

Conversation

@zhukaihan
Copy link
Copy Markdown
Collaborator

@zhukaihan zhukaihan commented May 7, 2026

Summary

  • Local evaluation exposure events from ExposureService.to_exposure_events carried experimentKey only inside the metadata blob — the top-level event property [Experiment] Experiment Key was never set, so custom reports keying off it saw no value for local-eval customers.
  • Fix: when variant.metadata['experimentKey'] is present, set event_properties['[Experiment] Experiment Key']. Additive and backwards-compatible — metadata, [Experiment] Flag Key, [Experiment] Variant, user properties, and insert_id are unchanged.
  • Mirrors amplitude/experiment-node-server#83.

Test plan

  • Added with_experiment_key fixture to ExposureService spec. Asserts [Experiment] Experiment Key equals 'exp-1' for that flag and is absent for the others.
  • Updated event count expectation accordingly.
  • bundle exec rspec spec/experiment/local/exposure/exposure_service_spec.rb — 3 examples, 0 failures.

🤖 Generated with Claude Code


Note

Low Risk
Low risk, additive analytics change that only adds a new event property when variant.metadata['experimentKey'] is present and expands test coverage accordingly.

Overview
Local-eval exposure events now copy variant.metadata['experimentKey'] into a dedicated top-level event property, [Experiment] Experiment Key, instead of leaving it only inside the metadata blob.

Specs add a with_experiment_key fixture and assertions that this property is present only when provided, updating the expected event count.

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

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 <[email protected]>
@zhukaihan zhukaihan deployed to Unit Test May 7, 2026 23:01 — with GitHub Actions Active
@kyeh-amp kyeh-amp self-requested a review May 7, 2026 23:25
@kyeh-amp kyeh-amp merged commit f821d35 into main May 8, 2026
8 checks passed
@kyeh-amp kyeh-amp deleted the feat/exposure-experiment-key branch May 8, 2026 04:29
github-actions Bot pushed a commit 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

🎉 This PR is included in version 1.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants