getsentry / sentry-dotnet

Sentry SDK for .NET

Home Page:https://docs.sentry.io/platforms/dotnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix and align types in `Device`

bitsandfoxes opened this issue · comments

BatteryLevel

// 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
var batteryLevel = json.GetPropertyOrNull("battery_level")?.TryGetDouble(out var level) is true
? (short)level
: (short?)null;

  • Change Device.BatteryLevel from short to float
  • Tests to avoid regressions (i.e. Java changes the underlying types)
  • #3485

ProcessorFrequency

// 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
var processorFrequency = json.GetPropertyOrNull("processor_frequency")?.TryGetDouble(out var frequency) is true
? (int)frequency
: (int?)null;

  • Change Device.ProcessorFrequency from int to float
  • Tests to avoid regressions (i.e. Java changes the underlying types)
  • #3541