Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(unreal): Add support for LoginId in Unreal Crash Context #4093

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Add user geo information to Replays. ([#4088](https://github.com/getsentry/relay/pull/4088))
- Configurable span.op inference. ([#4056](https://github.com/getsentry/relay/pull/4056))
- Enable support for zstd `Content-Encoding`. ([#4089](https://github.com/getsentry/relay/pull/4089))
- Add support for creating User from LoginId in Unreal Crash Context. ([#4093](https://github.com/getsentry/relay/pull/4093))

**Internal:**

Expand Down
36 changes: 36 additions & 0 deletions relay-server/src/utils/unreal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ fn merge_unreal_context(event: &mut Event, context: Unreal4Context) {
.set_value(Some(username.into()));
}

if let Some(login_id) = &runtime_props.login_id {
let user = event.user.get_or_insert_with(User::default);
if user.id.0.is_none() {
user.id.set_value(Some(login_id.clone().into()));
}
}
tobias-wilfert marked this conversation as resolved.
Show resolved Hide resolved

let contexts = event.contexts.get_or_insert_with(Contexts::default);

if let Some(memory_physical) = runtime_props.memory_stats_total_physical.take() {
Expand Down Expand Up @@ -402,6 +409,22 @@ mod tests {
Unreal4Context::parse(raw_context).unwrap()
}

fn get_context_with_login_id() -> Unreal4Context {
let raw_context = br#"<?xml version="1.0" encoding="UTF-8"?>
<FGenericCrashContext>
<RuntimeProperties>
<LoginId>SOME_ID</LoginId>
</RuntimeProperties>
<EngineData>
</EngineData>
<PlatformProperties>
</PlatformProperties>
</FGenericCrashContext>
"#;

Unreal4Context::parse(raw_context).unwrap()
}

#[test]
fn test_merge_unreal_context() {
let context = get_context();
Expand Down Expand Up @@ -481,4 +504,17 @@ mod tests {

insta::assert_snapshot!(Annotated::new(event).to_json_pretty().unwrap());
}

#[test]
fn test_merge_unreal_context_login_id() {
Dav1dde marked this conversation as resolved.
Show resolved Hide resolved
let context = get_context_with_login_id();
let mut event = Event::default();

merge_unreal_context(&mut event, context);

assert_eq!(
event.user.0.unwrap().id.0.unwrap(),
LenientString("SOME_ID".to_string())
tobias-wilfert marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Loading