@@ -30,8 +30,8 @@ use relay_protocol::{Annotated, Array, Empty, FromValue, Getter, IntoValue, Val}
3030use crate :: processor:: ProcessValue ;
3131use 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} ;
3636use 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