Merge ticket/015-json-field-param-metric-declaration
Resolves conflicts with ticket 018 (boolean param kind) in src/engine.rs, webapp/src/lib/api.ts, and Params.tsx: boolean-kind params and JSON-field-path extraction now coexist as independent extraction modes alongside regex capture groups. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
@@ -64,6 +64,10 @@ pub struct ParamDeclarationRecord {
|
||||
pub name: String,
|
||||
pub message_match_regex: String,
|
||||
pub capture_group: String,
|
||||
/// See `crate::data_value::RegexToMetricPrimitiveMatcher::json_field_path`; `#[serde(default)]`
|
||||
/// so profiles saved before this field existed still load as plain regex-capture-group params.
|
||||
#[serde(default)]
|
||||
pub json_field_path: Option<String>,
|
||||
pub kind: ProfileMetricPrimitiveKind,
|
||||
}
|
||||
|
||||
@@ -73,6 +77,7 @@ impl From<&DeclareParamRequest> for ParamDeclarationRecord {
|
||||
name: request.name.clone(),
|
||||
message_match_regex: request.message_match_regex.clone(),
|
||||
capture_group: request.capture_group.clone(),
|
||||
json_field_path: request.json_field_path.clone(),
|
||||
kind: request.kind.into(),
|
||||
}
|
||||
}
|
||||
@@ -84,6 +89,7 @@ impl From<&ParamDeclarationRecord> for DeclareParamRequest {
|
||||
name: record.name.clone(),
|
||||
message_match_regex: record.message_match_regex.clone(),
|
||||
capture_group: record.capture_group.clone(),
|
||||
json_field_path: record.json_field_path.clone(),
|
||||
kind: record.kind.into(),
|
||||
}
|
||||
}
|
||||
@@ -94,6 +100,10 @@ impl From<&ParamDeclarationRecord> for DeclareParamRequest {
|
||||
pub struct MetricParamRecord {
|
||||
pub param_name: String,
|
||||
pub capture_group: String,
|
||||
/// See `crate::data_value::RegexToMetricPrimitiveMatcher::json_field_path`; `#[serde(default)]`
|
||||
/// so profiles saved before this field existed still load as plain regex-capture-group matchers.
|
||||
#[serde(default)]
|
||||
pub json_field_path: Option<String>,
|
||||
pub kind: ProfileMetricPrimitiveKind,
|
||||
/// See `ParamRole`; `#[serde(default)]` so profiles saved before this field existed still load, defaulting to `Label`.
|
||||
#[serde(default)]
|
||||
@@ -125,6 +135,7 @@ impl From<&DeclareMetricRequest> for MetricDeclarationRecord {
|
||||
.map(|matcher| MetricParamRecord {
|
||||
param_name: matcher.param_name.clone(),
|
||||
capture_group: matcher.capture_group.clone(),
|
||||
json_field_path: matcher.json_field_path.clone(),
|
||||
kind: matcher.kind.into(),
|
||||
role: matcher.role,
|
||||
})
|
||||
@@ -148,6 +159,7 @@ impl From<&MetricDeclarationRecord> for DeclareMetricRequest {
|
||||
.map(|param| RegexToMetricPrimitiveMatcher {
|
||||
param_name: param.param_name.clone(),
|
||||
capture_group: param.capture_group.clone(),
|
||||
json_field_path: param.json_field_path.clone(),
|
||||
kind: param.kind.into(),
|
||||
role: param.role,
|
||||
})
|
||||
@@ -630,6 +642,7 @@ mod tests {
|
||||
name: name.to_string(),
|
||||
message_match_regex: pattern.to_string(),
|
||||
capture_group: capture_group.to_string(),
|
||||
json_field_path: None,
|
||||
kind: MetricPrimitiveKind::String,
|
||||
}
|
||||
}
|
||||
@@ -643,6 +656,7 @@ mod tests {
|
||||
params: vec![RegexToMetricPrimitiveMatcher {
|
||||
param_name: param_name.to_string(),
|
||||
capture_group: capture_group.to_string(),
|
||||
json_field_path: None,
|
||||
kind: MetricPrimitiveKind::Number,
|
||||
role: ParamRole::Label,
|
||||
}],
|
||||
|
||||
Reference in New Issue
Block a user