Skip to content

feat: Record exposures under local evaluation - #251

Merged
gagantrivedi merged 3 commits into
mainfrom
feat/local-evaluation-experiment-exposure
Nov 6, 2026
Merged

gagantrivedi merged 3 commits into
mainfrom
feat/local-evaluation-experiment-exposure

Conversation

@gagantrivedi

Copy link
Copy Markdown
Member

Part of Flagsmith/flagsmith-private#325. Java counterpart of Flagsmith/flagsmith-python-client#276, Flagsmith/flagsmith-go-client#246 and Flagsmith/flagsmith-nodejs-client#318.

getExperimentFlag only recorded exposures under remote evaluation. The environment document carries metadata.experiment on feature states, but local evaluation dropped it, along with the variant.

Changes

  • Map the multivariate option key into the evaluation context, and carry variant from the evaluation result onto Flag. Locally evaluated identity flags now report their variant.
  • Map the feature state's metadata.experiment into the context's feature metadata, and carry it onto identity flags.
  • Environment flags carry no experiment: it is removed once, when the environment evaluation context is built, so getEnvironmentFlags does no extra work per call.
  • getExperimentFlag records no exposure when the flag has no variant, as the other SDKs do.

Tests

  • Local evaluation: an enrolled identity records one exposure with the variant and experiment_id; outside the rollout, an identity override, and a feature without an experiment record none.
  • Environment flags carry no experiment under local evaluation.
  • Remote: an enrolled flag without a variant records no exposure.

Map the multivariate option key and the feature state's experiment into the
evaluation context, and carry the variant and experiment onto identity flags.
Environment flags carry no experiment. Skip the exposure when the flag has no
variant.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes propagate experiment metadata and variant keys through flag mapping. Environment evaluation removes experiment metadata from features and identity-free segment overrides. getExperimentFlag skips exposure tracking when an enrolled flag has no variant. Tests cover experiment metadata, local evaluation, and exposure outcomes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: Low · up to 739de

Reusing an events-enabled builder in offline mode can send exposure data. A fresh builder avoids this narrow risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c161ddcb-dd0d-43dc-bfbb-13db7011b31b
Commits

Reviewing files that changed from the base of the PR and between 4b4d076 and 739de51.

Files selected for processing: 2

  • src/test/java/com/flagsmith/FlagsmithClientTest.java
  • src/test/java/com/flagsmith/FlagsmithTestHelper.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@codspeed

codspeed Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks


Comparing feat/local-evaluation-experiment-exposure (739de51) with main (e278fd5)

Open in CodSpeed

@gagantrivedi
gagantrivedi marked this pull request as ready for review November 6, 2026 08:24
@gagantrivedi
gagantrivedi requested a review from a team as a code owner November 6, 2026 08:24
@gagantrivedi
gagantrivedi requested review from Zaimwa9 and khvn26 and removed request for a team and khvn26 November 6, 2026 08:24
Zaimwa9
Zaimwa9 previously approved these changes Nov 6, 2026

@Zaimwa9 Zaimwa9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a NIT, leaving it up to you. I think we also need to bump the engine test data

@gagantrivedi
gagantrivedi merged commit 106d8a6 into main Nov 6, 2026
17 checks passed
@gagantrivedi
gagantrivedi deleted the feat/local-evaluation-experiment-exposure branch November 6, 2026 12:17
gagantrivedi pushed a commit that referenced this pull request Nov 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[8.4.0](v8.3.0...v8.4.0)
(2026-11-06)


### Features

* Record exposures under local evaluation
([#251](#251))
([106d8a6](106d8a6))


### Other

* Let Renovate keep updating spec bumps the webhook handler commits to
([#246](#246))
([e278fd5](e278fd5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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