From daf7192da836c06ede3a9f0a6c25bca37aae01d6 Mon Sep 17 00:00:00 2001 From: Colton Allen Date: Mon, 9 Jan 2023 09:30:57 -0600 Subject: [PATCH] feat(replays): Leave non-critical fields as generic "Value" types (#1702) closes: https://github.com/getsentry/replay-backend/issues/239 Leaves non-critical fields as generic `Value` types which can be re-serialized later without consequence to PII scrubbing. --- CHANGELOG.md | 1 + relay-replays/src/recording.rs | 33 ++++++++++--------- .../tests/fixtures/rrweb-node-2.json | 4 ++- relay-replays/tests/fixtures/rrweb-pii.json | 2 ++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08359c852c..a6ba965579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Apply dynamic sampling to transactions from older SDKs and even in case Relay cannot load project information. This avoids accidentally storing 100% of transactions. ([#1667](https://github.com/getsentry/relay/pull/1667)) - Replay recording parser now uses the entire body rather than a subset. ([#1682](https://github.com/getsentry/relay/pull/1682)) - Fix a potential OOM in the Replay recording parser. ([#1691](https://github.com/getsentry/relay/pull/1691)) +- Fix type error in replay recording parser. ([#1702](https://github.com/getsentry/relay/pull/1702)) **Internal**: diff --git a/relay-replays/src/recording.rs b/relay-replays/src/recording.rs index e3fa65d4f6..72beba7ac6 100644 --- a/relay-replays/src/recording.rs +++ b/relay-replays/src/recording.rs @@ -185,7 +185,7 @@ impl RecordingProcessor<'_> { "script" | "style" => {} "img" | "source" => { let attrs = &mut element.attributes; - attrs.insert("src".to_string(), "#".to_string()); + attrs.insert("src".to_string(), Value::String("#".to_string())); self.recurse_element_children(element)? } _ => self.recurse_element_children(element)?, @@ -444,36 +444,36 @@ struct DocumentNode { struct DocumentTypeNode { #[serde(rename = "type")] ty: u8, - id: u32, - public_id: String, - system_id: String, - name: String, + id: Value, + public_id: Value, + system_id: Value, + name: Value, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct ElementNode { - id: u32, + id: Value, #[serde(rename = "type")] ty: u8, - attributes: HashMap, + attributes: HashMap, tag_name: String, child_nodes: Vec, #[serde(rename = "isSVG", skip_serializing_if = "Option::is_none")] - is_svg: Option, + is_svg: Option, #[serde(skip_serializing_if = "Option::is_none")] - need_block: Option, + need_block: Option, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct TextNode { - id: u32, + id: Value, #[serde(rename = "type")] ty: u8, text_content: String, #[serde(skip_serializing_if = "Option::is_none")] - is_style: Option, + is_style: Option, } /// Incremental Source Parser @@ -535,7 +535,10 @@ struct InputIncrementalSourceData { source: u8, id: u32, text: String, - is_checked: bool, + is_checked: Value, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + user_triggered: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -547,14 +550,14 @@ struct MutationIncrementalSourceData { removes: Vec, adds: Vec, #[serde(skip_serializing_if = "Option::is_none")] - is_attach_iframe: Option, + is_attach_iframe: Option, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct MutationAdditionIncrementalSourceData { - parent_id: u32, - next_id: Option, + parent_id: Value, + next_id: Value, node: Node, } diff --git a/relay-replays/tests/fixtures/rrweb-node-2.json b/relay-replays/tests/fixtures/rrweb-node-2.json index e709ebd844..cf7d997c67 100644 --- a/relay-replays/tests/fixtures/rrweb-node-2.json +++ b/relay-replays/tests/fixtures/rrweb-node-2.json @@ -2,7 +2,9 @@ "type": 2, "tagName": "h1", "attributes": { - "id": "react-tooltip" + "id": "react-tooltip", + "rr_scrollLeft": 1070, + "rr_scrollTop": 385 }, "childNodes": [ { diff --git a/relay-replays/tests/fixtures/rrweb-pii.json b/relay-replays/tests/fixtures/rrweb-pii.json index dffa6de5ed..9d1a9f3c21 100644 --- a/relay-replays/tests/fixtures/rrweb-pii.json +++ b/relay-replays/tests/fixtures/rrweb-pii.json @@ -6,9 +6,11 @@ "texts": [], "attributes": [], "removes": [], + "isAttachIframe": true, "adds": [ { "parentId": 74, + "previousId": null, "nextId": null, "node": { "type": 2,