Skip to content

Commit 69b7388

Browse files
feat(replay): Add OTA Updates Context (#4711)
1 parent 53348ae commit 69b7388

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Allow pii scrubbing of all span `sentry_tags` fields. ([#4698](https://github.com/getsentry/relay/pull/4698))
1212
- Add experimental playstation processing logic. ([#4680](https://github.com/getsentry/relay/pull/4680))
1313
- Add killswitch for trace id partitioning. ([#4706](https://github.com/getsentry/relay/pull/4706))
14+
- Add OTA Updates Event Context for Replay Events. ([#4711](https://github.com/getsentry/relay/pull/4711))
1415

1516
**Bug Fixes**:
1617

relay-event-schema/src/protocol/replay.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use relay_protocol::{Annotated, Array, Empty, FromValue, Getter, IntoValue, Val}
3030
use crate::processor::ProcessValue;
3131
use crate::protocol::{
3232
AppContext, BrowserContext, ClientSdkInfo, Contexts, DefaultContext, DeviceContext, EventId,
33-
LenientString, OsContext, ProfileContext, Request, ResponseContext, Tags, Timestamp,
34-
TraceContext, User,
33+
LenientString, OTAUpdatesContext, OsContext, ProfileContext, Request, ResponseContext, Tags,
34+
Timestamp, TraceContext, User,
3535
};
3636
use uuid::Uuid;
3737

@@ -356,6 +356,21 @@ impl Getter for Replay {
356356
super::Context::Other(context) => context.get("crash_type")?.value()?.into(),
357357
_ => return None,
358358
},
359+
"contexts.ota_updates.channel" => self
360+
.context::<OTAUpdatesContext>()?
361+
.channel
362+
.as_str()?
363+
.into(),
364+
"contexts.ota_updates.runtime_version" => self
365+
.context::<OTAUpdatesContext>()?
366+
.runtime_version
367+
.as_str()?
368+
.into(),
369+
"contexts.ota_updates.update_id" => self
370+
.context::<OTAUpdatesContext>()?
371+
.update_id
372+
.as_str()?
373+
.into(),
359374

360375
// Dynamic access to certain data bags
361376
path => {
@@ -463,4 +478,33 @@ mod tests {
463478
assert_eq!(event, Annotated::from_json(input).unwrap());
464479
assert_eq!(output, event.to_json().unwrap());
465480
}
481+
482+
#[test]
483+
fn test_ota_updates_context_getter() {
484+
let mut contexts = Contexts::new();
485+
contexts.add(OTAUpdatesContext {
486+
channel: Annotated::new("production".to_string()),
487+
runtime_version: Annotated::new("1.0.0".to_string()),
488+
update_id: Annotated::new("12345678-1234-1234-1234-1234567890ab".to_string()),
489+
..OTAUpdatesContext::default()
490+
});
491+
492+
let replay = Replay {
493+
contexts: Annotated::new(contexts),
494+
..Default::default()
495+
};
496+
497+
assert_eq!(
498+
Some(Val::String("production")),
499+
replay.get_value("event.contexts.ota_updates.channel")
500+
);
501+
assert_eq!(
502+
Some(Val::String("1.0.0")),
503+
replay.get_value("event.contexts.ota_updates.runtime_version")
504+
);
505+
assert_eq!(
506+
Some(Val::String("12345678-1234-1234-1234-1234567890ab")),
507+
replay.get_value("event.contexts.ota_updates.update_id")
508+
);
509+
}
466510
}

0 commit comments

Comments
 (0)