Skip to content
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions src/Sentry/Protocol/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public static Device FromJson(JsonElement json)
var modelId = json.GetPropertyOrNull("model_id")?.GetString();
var architecture = json.GetPropertyOrNull("arch")?.GetString();

// TODO: For next major: Remove this and change batteryLevel from short to float
// TODO: For next major: Remove this and change BatteryLevel from short to float
// The Java and Cocoa SDK report the battery as `float`
// Cocoa https://github.com/getsentry/sentry-cocoa/blob/e773cad622b86735f1673368414009475e4119fd/Sources/Sentry/include/SentryUIDeviceWrapper.h#L18
// Java https://github.com/getsentry/sentry-java/blob/25f1ca4e1636a801c17c1662f0145f888550bce8/sentry/src/main/java/io/sentry/protocol/Device.java#L231-L233
Expand Down Expand Up @@ -456,7 +456,17 @@ public static Device FromJson(JsonElement json)
var bootTime = json.GetPropertyOrNull("boot_time")?.GetDateTimeOffset();
var processorCount = json.GetPropertyOrNull("processor_count")?.GetInt32();
var cpuDescription = json.GetPropertyOrNull("cpu_description")?.GetString();
var processorFrequency = json.GetPropertyOrNull("processor_frequency")?.GetInt32();

// TODO: For next major: Remove this and change ProcessorFrequency from int to float
// The Java SDK reports the processorFrequency as `double`
// Java https://github.com/getsentry/sentry-java/blob/9762f09afa51944b40a9b77e116a55e54636e6c5/sentry/src/main/java/io/sentry/protocol/Device.java#L130
int? processorFrequency = null;
var processorFrequencyProperty = json.GetPropertyOrNull("processor_frequency");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change one of our tests as well (to make sure it works when deserialising a double)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, we don't have any tests for Device as it's not doing anything. But the type-mismatch is obvious from looking at the Java code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to argue against writing tests. I've added it to #3542

if (processorFrequencyProperty.HasValue)
{
processorFrequency = (int)processorFrequencyProperty.Value.GetDouble();
}

var deviceType = json.GetPropertyOrNull("device_type")?.GetString();
var batteryStatus = json.GetPropertyOrNull("battery_status")?.GetString();
var deviceUniqueIdentifier = json.GetPropertyOrNull("device_unique_identifier")?.GetString();
Expand Down
Loading