You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Record exposures under local evaluation - #246
Since Flagsmith/flagsmith#8532, the environment document carries metadata.experiment on feature states. The SDK dropped it when mapping the document for the engine, so under local evaluation Flag.Experiment was always nil and GetExperimentFlag never recorded an exposure.
Changes
FeatureStateModel reads metadata.experiment; the engine's FeatureMetadata gains Experiment.
The mapper copies it for environment and segment feature states. Identity overrides carry none, as on the API.
Flags built from evaluation results set Experiment.
Locally evaluated environment flags carry no experiment, matching the API, which only sends it for identity flags.
README and doc comments no longer say exposures need remote evaluation.
Tests
GetExperimentFlag under 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. Environment flags carry no experiment.
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 GetExperimentFlag 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. Bump engine-test-data to
v3.13.0 for its experiment cases.
No actionable comments were generated in the recent review.
Walkthrough
The flag engine now decodes experiment metadata and maps it into evaluation results. Identity-evaluated flags copy the experiment ID, name, and enrollment status. Environment-level flags clear experiment metadata. The client skips exposure recording when a flag has no variant. Tests cover local treatment enrollment, non-enrollment, identity overrides, features without experiments, environment-level evaluation, and exposure event submission.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: d2d98b93-40a7-49d4-99ce-8ededd671905
Commits
Reviewing files that changed from the base of the PR and between 790c20d and 2ddc2eb.
Files selected for processing: 3
client.go
client_test.go
models.go
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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: 8328f800-680e-4d71-9815-6dfbdb738897
Commits
Reviewing files that changed from the base of the PR and between f31460b and 790c20d.
Files selected for processing: 7
client.go
client_test.go
fixtures/fixture.go
flagengine/engine_eval/context.go
flagengine/engine_eval/mappers.go
models_test.go
sdk-spec/steps.go
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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.
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
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.
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 always nil andGetExperimentFlagnever recorded an exposure.Changes
FeatureStateModelreadsmetadata.experiment; the engine'sFeatureMetadatagainsExperiment.Experiment.engine-test-datato v3.13.0 for its experiment cases (feat: Add experiment metadata test cases engine-test-data#64).Tests
GetExperimentFlagunder 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. Environment flags carry no experiment.Also ran Flagsmith/sdk-spec#21 against this branch: 12 passed.