Repository navigation
feat: Record exposures under local evaluation - #276
Conversation
Carry each feature state's experiment metadata from the environment document into the engine context, and set it on flags built from evaluation results, so get_experiment_flag records exposures under local evaluation as it does under remote evaluation. Environment flags carry no experiment, matching the API, which only sends experiment metadata for identity flags.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
🤖 I have created a release *beep* *boop* --- ## [6.5.0](v6.4.0...v6.5.0) (2026-11-06) ### Features * Record exposures under local evaluation ([#276](#276)) ([4a25d50](4a25d50)) ### Dependency Updates * update dependency flagsmith-flag-engine to v11.1.2 ([#277](#277)) ([dbf4554](dbf4554)) ### Other * Let Renovate keep updating spec bumps the webhook handler commits to ([#279](#279)) ([f47856d](f47856d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.
Since Flagsmith/flagsmith#8532, the environment document carries
metadata.experimenton feature states. The SDK dropped it when mapping the document for the engine, so under local evaluationFlag.experimentwas alwaysNoneandget_experiment_flagnever recorded an exposure.Changes
FeatureStateModelgainsmetadata;FeatureMetadatagainsexperiment.metadata.experimentfor environment and segment feature states. Identity overrides carry none, as on the API.Flag.from_evaluation_resultsetsexperiment. The engine already returns the winning feature context's metadata, so no engine change is needed (flagsmith-flag-engine11.1.1).Tests
get_experiment_flagunder local evaluation: an enrolled identity records one exposure with its variant and experiment ID; an identity outside the rollout, one with an identity override, and a feature with no experiment record none.Follow-up
Bump the
engine-test-datasubmodule once Flagsmith/engine-test-data#64 is released.