feat: Populate OpenFeature flag metadata from the evaluation reason - #1869
feat: Populate OpenFeature flag metadata from the evaluation reason#1869kinyoklion wants to merge 1 commit into
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
Populates OpenFeature flag metadata from the LaunchDarkly evaluation reason so consumers (and the OpenFeature/OTel telemetry hooks) can read experiment, rule, prerequisite, and Big Segments information.
variationIndex,inExperiment,ruleIndex,ruleId,prerequisiteKey,bigSegmentsStatus; each is omitted when it does not apply.@cursor review
Requirements
Implementation details
translateResultnow builds aFlagMetadataobject fromLDEvaluationDetail:variationIndexis included only when the SDK returned a variation, so default/error evaluations omit it.inExperimentis emitted only whentrue, rather than emittingfalsefor every non-experiment evaluation.ruleIndex/ruleId,prerequisiteKey, andbigSegmentsStatusare copied through when the reason provides them.Key names are named constants so they cannot drift from the spec.
Backend-only change; no UI, so no screenshots or staging preview apply.
Testing:
yarn workspace @launchdarkly/openfeature-js-server-common testand... lint, plusyarn workspace @launchdarkly/openfeature-node-server test. The existingBaseOpenFeatureProviderresult assertions were updated for the addedflagMetadatafield.Describe alternatives you've considered
Emitting the full reason object under a single nested key was rejected — OpenFeature flag metadata values must be scalars, and flat keys are what the spec draft standardizes across providers.
Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion