@@ -12,6 +12,7 @@ import {
1212import { EnvironmentModel } from '../../environments/models.js' ;
1313import { IdentityModel } from '../../identities/models.js' ;
1414import { TraitModel } from '../../identities/traits/models.js' ;
15+ import { FeatureStateModel } from '../../features/models.js' ;
1516import { IDENTITY_OVERRIDE_SEGMENT_NAME } from '../../segments/constants.js' ;
1617import { createHash } from 'node:crypto' ;
1718import { uuidToBigInt } from '../../features/util.js' ;
@@ -48,21 +49,12 @@ function mapEnvironmentModelToEvaluationContext(
4849
4950 const features : FeaturesWithMetadata < SDKFeatureMetadata > = { } ;
5051 for ( const fs of environment . featureStates ) {
51- const variants =
52- fs . multivariateFeatureStateValues ?. length > 0
53- ? fs . multivariateFeatureStateValues . map ( mv => ( {
54- value : mv . multivariateFeatureOption . value ,
55- weight : mv . percentageAllocation ,
56- priority : mv . id ?? uuidToBigInt ( mv . mvFsValueUuid )
57- } ) )
58- : undefined ;
59-
6052 features [ fs . feature . name ] = {
6153 key : fs . djangoID ?. toString ( ) || fs . featurestateUUID ,
6254 name : fs . feature . name ,
6355 enabled : fs . enabled ,
6456 value : fs . getValue ( ) ,
65- variants,
57+ variants : mapFeatureStateVariants ( fs ) ,
6658 priority : fs . featureSegment ?. priority ,
6759 metadata : {
6860 id : fs . feature . id
@@ -83,6 +75,7 @@ function mapEnvironmentModelToEvaluationContext(
8375 name : fs . feature . name ,
8476 enabled : fs . enabled ,
8577 value : fs . getValue ( ) ,
78+ variants : mapFeatureStateVariants ( fs ) ,
8679 priority : fs . featureSegment ?. priority ,
8780 metadata : {
8881 id : fs . feature . id
@@ -130,6 +123,16 @@ function mapIdentityModelToIdentityContext(
130123 return identityContext ;
131124}
132125
126+ function mapFeatureStateVariants ( fs : FeatureStateModel ) {
127+ return fs . multivariateFeatureStateValues ?. length > 0
128+ ? fs . multivariateFeatureStateValues . map ( mv => ( {
129+ value : mv . multivariateFeatureOption . value ,
130+ weight : mv . percentageAllocation ,
131+ priority : mv . id ?? uuidToBigInt ( mv . mvFsValueUuid )
132+ } ) )
133+ : undefined ;
134+ }
135+
133136function mapSegmentRuleModelToRule ( rule : any ) : any {
134137 return {
135138 type : rule . type ,
@@ -160,6 +163,7 @@ function mapIdentityOverridesToSegments(
160163 name : fs . feature . name ,
161164 enabled : fs . enabled ,
162165 value : fs . getValue ( ) ,
166+ variants : mapFeatureStateVariants ( fs ) ,
163167 priority : - Infinity ,
164168 metadata : {
165169 id : fs . feature . id
0 commit comments