Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/engine_eval/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ pub struct FeatureMetadata {
/// The feature ID.
#[serde(default)]
pub feature_id: u32,
/// The feature type (e.g., "STANDARD", "MULTIVARIATE").
#[serde(default = "default_feature_type")]
pub feature_type: String,
}

fn default_feature_type() -> String {
"STANDARD".to_string()
}

/// Represents a multivariate value for a feature flag.
Expand Down
12 changes: 12 additions & 0 deletions src/engine_eval/mappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fn map_feature_state_to_feature_context(fs: &FeatureState) -> FeatureContext {
variants: map_multivariate_values_to_variants(&fs.multivariate_feature_state_values),
metadata: FeatureMetadata {
feature_id: fs.feature.id,
feature_type: fs
.feature
.feature_type
.clone()
.unwrap_or_else(|| "STANDARD".to_string()),
},
};

Expand Down Expand Up @@ -184,6 +189,7 @@ struct OverrideKey {
enabled: String,
feature_value: String,
feature_id: u32,
feature_type: String,
}

/// Maps identity overrides to segment contexts
Expand All @@ -207,6 +213,11 @@ fn map_identity_overrides_to_segments(identities: &[Identity]) -> HashMap<String
enabled: fs.enabled.to_string(),
feature_value,
feature_id: fs.feature.id,
feature_type: fs
.feature
.feature_type
.clone()
.unwrap_or_else(|| "STANDARD".to_string()),
});
}

Expand Down Expand Up @@ -263,6 +274,7 @@ fn map_identity_overrides_to_segments(identities: &[Identity]) -> HashMap<String
variants: vec![],
metadata: FeatureMetadata {
feature_id: override_key.feature_id,
feature_type: override_key.feature_type.clone(),
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Feature {
pub id: u32,
pub name: String,
#[serde(rename = "type")]
feature_type: Option<String>,
pub feature_type: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
Expand Down