Skip to content

Commit

Permalink
feat(replays): Leave non-critical fields as generic "Value" types (#1702
Browse files Browse the repository at this point in the history
)

closes: getsentry/replay-backend#239

Leaves non-critical fields as generic `Value` types which can be
re-serialized later without consequence to PII scrubbing.
  • Loading branch information
cmanallen authored Jan 9, 2023
1 parent 53687fe commit daf7192
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand Down
33 changes: 18 additions & 15 deletions relay-replays/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?,
Expand Down Expand Up @@ -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<String, String>,
attributes: HashMap<String, Value>,
tag_name: String,
child_nodes: Vec<Node>,
#[serde(rename = "isSVG", skip_serializing_if = "Option::is_none")]
is_svg: Option<bool>,
is_svg: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
need_block: Option<bool>,
need_block: Option<Value>,
}

#[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<bool>,
is_style: Option<Value>,
}

/// Incremental Source Parser
Expand Down Expand Up @@ -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<Value>,
}

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -547,14 +550,14 @@ struct MutationIncrementalSourceData {
removes: Vec<Value>,
adds: Vec<MutationAdditionIncrementalSourceData>,
#[serde(skip_serializing_if = "Option::is_none")]
is_attach_iframe: Option<bool>,
is_attach_iframe: Option<Value>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct MutationAdditionIncrementalSourceData {
parent_id: u32,
next_id: Option<u32>,
parent_id: Value,
next_id: Value,
node: Node,
}

Expand Down
4 changes: 3 additions & 1 deletion relay-replays/tests/fixtures/rrweb-node-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"type": 2,
"tagName": "h1",
"attributes": {
"id": "react-tooltip"
"id": "react-tooltip",
"rr_scrollLeft": 1070,
"rr_scrollTop": 385
},
"childNodes": [
{
Expand Down
2 changes: 2 additions & 0 deletions relay-replays/tests/fixtures/rrweb-pii.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"texts": [],
"attributes": [],
"removes": [],
"isAttachIframe": true,
"adds": [
{
"parentId": 74,
"previousId": null,
"nextId": null,
"node": {
"type": 2,
Expand Down

0 comments on commit daf7192

Please sign in to comment.