diff --git a/general/src/protocol/event.rs b/general/src/protocol/event.rs index 701ac7daf8..a094c038ad 100644 --- a/general/src/protocol/event.rs +++ b/general/src/protocol/event.rs @@ -172,6 +172,8 @@ pub struct GroupingConfig { /// The id of the grouping config. #[metastructure(max_chars = "enumlike")] pub id: Annotated, + /// The enhancements configuration. + pub enhancements: Annotated, } /// The sentry v7 event structure. @@ -337,7 +339,7 @@ pub struct Event { pub project: Annotated, /// The grouping configuration for this event. - pub grouping_config: Annotated, + pub grouping_config: Annotated>, /// Legacy checksum used for grouping before fingerprint hashes. #[metastructure(max_chars = "hash")] diff --git a/general/src/store/mod.rs b/general/src/store/mod.rs index 961fda614c..bb075918f0 100644 --- a/general/src/store/mod.rs +++ b/general/src/store/mod.rs @@ -3,10 +3,11 @@ use std::collections::BTreeSet; use std::sync::Arc; use serde::{Deserialize, Serialize}; +use serde_json::Value; use crate::processor::{ProcessingState, Processor}; -use crate::protocol::{Event, GroupingConfig, IpAddr}; -use crate::types::{Annotated, Meta, ValueAction}; +use crate::protocol::{Event, IpAddr}; +use crate::types::{Meta, ValueAction}; mod event_error; mod geo; @@ -18,23 +19,6 @@ mod trimming; pub use crate::store::geo::GeoIpLookup; -/// The config for the grouping config in store -#[derive(Serialize, Deserialize, Debug, Default)] -#[serde(default)] -pub struct StoreGroupingConfig { - /// The id of the grouping algorithm that should be used. - pub id: String, -} - -impl StoreGroupingConfig { - /// Converts this config into one the event structure supports. - pub fn as_grouping_config(&self) -> GroupingConfig { - GroupingConfig { - id: Annotated::from(self.id.clone()), - } - } -} - /// The config for store. #[derive(Serialize, Deserialize, Debug, Default)] #[serde(default)] @@ -44,7 +28,7 @@ pub struct StoreConfig { pub client: Option, pub key_id: Option, pub protocol_version: Option, - pub grouping_config: Option, + pub grouping_config: Option, /// Hard limit for stacktrace frames /// Corresponds to SENTRY_STACKTRACE_FRAMES_HARD_LIMIT diff --git a/general/src/store/normalize.rs b/general/src/store/normalize.rs index bcaa6ee333..318363498c 100644 --- a/general/src/store/normalize.rs +++ b/general/src/store/normalize.rs @@ -16,7 +16,9 @@ use crate::protocol::{ Frame, IpAddr, Level, LogEntry, Request, Stacktrace, Tags, User, }; use crate::store::{GeoIpLookup, StoreConfig}; -use crate::types::{Annotated, Empty, Error, ErrorKind, Meta, Object, ValueAction}; +use crate::types::{ + Annotated, Empty, Error, ErrorKind, FromValue, Meta, Object, Value, ValueAction, +}; mod contexts; mod logentry; @@ -293,12 +295,13 @@ impl<'a> Processor for NormalizeProcessor<'a> { event.key_id = Annotated::from(self.config.key_id.clone()); event.ty = Annotated::from(self.infer_event_type(event)); event.version = Annotated::from(self.config.protocol_version.clone()); - event.grouping_config = Annotated::from( - self.config - .grouping_config - .as_ref() - .map(|x| x.as_grouping_config()), - ); + event.grouping_config = self + .config + .grouping_config + .clone() + .map_or(Annotated::empty(), |x| { + FromValue::from_value(Annotated::::from(x)) + }); // Validate basic attributes event.platform.apply(|platform, _| { @@ -542,7 +545,6 @@ impl<'a> Processor for NormalizeProcessor<'a> { use crate::{ processor::process_value, protocol::{PairList, TagEntry}, - types::Value, }; #[cfg(test)] @@ -1179,9 +1181,9 @@ fn test_discards_received() { #[test] fn test_grouping_config() { use crate::protocol::LogEntry; - use crate::store::StoreGroupingConfig; use crate::types::SerializableAnnotated; use insta::assert_ron_snapshot_matches; + use serde_json::json; let mut event = Annotated::new(Event { logentry: Annotated::from(LogEntry { @@ -1193,9 +1195,9 @@ fn test_grouping_config() { let mut processor = NormalizeProcessor::new( Arc::new(StoreConfig { - grouping_config: Some(StoreGroupingConfig { - id: "legacy:1234-12-12".into(), - }), + grouping_config: Some(json!({ + "id": "legacy:1234-12-12".to_string(), + })), ..Default::default() }), None,