relay_server/services/processor/unreal.rs
1//! Unreal 4 processor related code.
2//!
3//! These functions are included only in the processing mode.
4
5use crate::envelope::ItemType;
6use crate::managed::TypedEnvelope;
7use crate::services::processor::{ErrorGroup, EventFullyNormalized, ProcessingError};
8use crate::utils;
9
10use relay_config::Config;
11use relay_event_schema::protocol::Event;
12use relay_protocol::Annotated;
13
14/// Expands Unreal 4 items inside an envelope.
15///
16/// If the envelope does NOT contain an `UnrealReport` item, it doesn't do anything. If the
17/// envelope contains an `UnrealReport` item, it removes it from the envelope and inserts new
18/// items for each of its contents.
19///
20/// The envelope may be dropped if it exceeds size limits after decompression. Particularly,
21/// this includes cases where a single attachment file exceeds the maximum file size. This is in
22/// line with the behavior of the envelope endpoint.
23///
24/// After this, [`crate::services::processor::EnvelopeProcessorService`] should be able to process the envelope the same
25/// way it processes any other envelopes.
26pub fn expand(
27 managed_envelope: &mut TypedEnvelope<ErrorGroup>,
28 config: &Config,
29) -> Result<(), ProcessingError> {
30 let envelope = &mut managed_envelope.envelope_mut();
31
32 if let Some(item) = envelope.take_item_by(|item| item.ty() == &ItemType::UnrealReport) {
33 utils::expand_unreal_envelope(item, envelope, config)?;
34 }
35
36 Ok(())
37}
38
39/// Extracts event information from an unreal context.
40///
41/// If the event does not contain an unreal context, this function does not perform any action.
42/// If there was no event payload prior to this function, it is created.
43pub fn process(
44 managed_envelope: &mut TypedEnvelope<ErrorGroup>,
45 event: &mut Annotated<Event>,
46) -> Result<Option<EventFullyNormalized>, ProcessingError> {
47 if utils::process_unreal_envelope(event, managed_envelope.envelope_mut())
48 .map_err(ProcessingError::InvalidUnrealReport)?
49 {
50 return Ok(Some(EventFullyNormalized(false)));
51 }
52
53 Ok(None)
54}