Skip to content

Commit

Permalink
Fix: SentryDevice cast error (#1059)
Browse files Browse the repository at this point in the history
Co-authored-by: Manoel Aranda Neto <[email protected]>
  • Loading branch information
denrase and marandaneto authored Oct 10, 2022
1 parent 3fc395e commit fb57416
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Handle traces sampler exception ([#1040](https://github.com/getsentry/sentry-dart/pull/1040))
- tracePropagationTargets ignores invalid Regex ([#1043](https://github.com/getsentry/sentry-dart/pull/1043))
- SentryDevice cast error ([#1059](https://github.com/getsentry/sentry-dart/pull/1059))

### Features

Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/protocol/sentry_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ class SentryDevice {
manufacturer: data['manufacturer'],
brand: data['brand'],
screenResolution: data['screen_resolution'],
screenHeightPixels: data['screen_height_pixels'],
screenWidthPixels: data['screen_width_pixels'],
screenHeightPixels: data['screen_height_pixels']?.toInt(),
screenWidthPixels: data['screen_width_pixels']?.toInt(),
screenDensity: data['screen_density'],
screenDpi: data['screen_dpi'],
online: data['online'],
Expand Down
13 changes: 13 additions & 0 deletions dart/test/protocol/sentry_device_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ void main() {
true,
);
});

test('fromJson double screen_height_pixels and screen_width_pixels', () {
sentryDeviceJson['screen_height_pixels'] = 100.0;
sentryDeviceJson['screen_width_pixels'] = 100.0;

final sentryDevice = SentryDevice.fromJson(sentryDeviceJson);
final json = sentryDevice.toJson();

expect(
MapEquality().equals(sentryDeviceJson, json),
true,
);
});
});

group('copyWith', () {
Expand Down

0 comments on commit fb57416

Please sign in to comment.