Skip to content

Commit

Permalink
Move all properties back to from attachment to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Feb 24, 2022
1 parent 8ade235 commit 8794238
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 24 deletions.
40 changes: 32 additions & 8 deletions lib/src/common/network/wiredash_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,23 @@ extension FeedbackBody on PersistedFeedbackItem {

values.addAll({'message': nonNull(message)});

values.addAll({
'physicalGeometry': nonNull(deviceInfo.physicalGeometry).toJson(),
});

values.addAll({
'platformBrightness': nonNull(deviceInfo.platformBrightness).jsonEncode()
});

final platformDartVersion = deviceInfo.platformVersion;
if (platformDartVersion != null) {
values.addAll({'platformDartVersion': platformDartVersion});
}

values.addAll({
'platformGestureInsets': nonNull(deviceInfo.gestureInsets).toJson(),
});

values.addAll({'platformLocale': nonNull(deviceInfo.platformLocale)});

final platformOS = deviceInfo.platformOS;
Expand Down Expand Up @@ -308,6 +320,26 @@ extension FeedbackBody on PersistedFeedbackItem {
values.addAll({'userId': _userId});
}

values.addAll({
'windowInsets': nonNull(deviceInfo.viewInsets).toJson(),
});

values.addAll({
'windowPadding': nonNull(deviceInfo.padding).toJson(),
});

values.addAll({
'windowPixelRatio': nonNull(deviceInfo.pixelRatio),
});

values.addAll({
'windowSize': nonNull(deviceInfo.physicalSize).toJson(),
});

values.addAll({
'windowTextScaleFactor': nonNull(deviceInfo.textScaleFactor),
});

return values.map((k, v) => MapEntry(k, v));
}
}
Expand All @@ -316,14 +348,6 @@ extension on Screenshot {
Map<String, dynamic> toJson() {
final Map<String, dynamic> values = {
'id': file.attachmentId!.value,
'physicalGeometry': nonNull(deviceInfo.physicalGeometry).toJson(),
'platformBrightness': nonNull(deviceInfo.platformBrightness).jsonEncode(),
'platformGestureInsets': nonNull(deviceInfo.gestureInsets).toJson(),
'windowPixelRatio': nonNull(deviceInfo.pixelRatio),
'windowSize': nonNull(deviceInfo.physicalSize).toJson(),
'windowTextScaleFactor': nonNull(deviceInfo.textScaleFactor),
'windowInsets': nonNull(deviceInfo.viewInsets).toJson(),
'windowPadding': nonNull(deviceInfo.padding).toJson(),
};

return values;
Expand Down
32 changes: 16 additions & 16 deletions test/common/network/wiredash_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,20 @@ void main() {
'platformOSVersion': 'RSR1.201013.001',
'userEmail': 'email@example.com',
'userId': 'Testy McTestFace',
'physicalGeometry': [0.0, 0.0, 0.0, 0.0],
'platformBrightness': 'dark',
'platformGestureInsets': [0.0, 0.0, 0.0, 0.0],
'windowPixelRatio': 2.75,
'windowSize': [1080.0, 2088.0],
'windowTextScaleFactor': 1.0,
'windowInsets': [0.0, 0.0, 0.0, 685.0],
'windowPadding': [0.0, 66.0, 0.0, 0.0],
'attachments': [
{
'id': 'screenshot_123',
'physicalGeometry': [0.0, 0.0, 0.0, 0.0],
'platformBrightness': 'dark',
'platformGestureInsets': [0.0, 0.0, 0.0, 0.0],
'windowPixelRatio': 2.75,
'windowSize': [1080.0, 2088.0],
'windowTextScaleFactor': 1.0,
'windowInsets': [0.0, 0.0, 0.0, 685.0],
'windowPadding': [0.0, 66.0, 0.0, 0.0]
},
{
'id': 'screenshot_124',
'physicalGeometry': [0.0, 0.0, 0.0, 0.0],
'platformBrightness': 'dark',
'platformGestureInsets': [0.0, 0.0, 0.0, 0.0],
'windowPixelRatio': 2.75,
'windowSize': [1080.0, 2088.0],
'windowTextScaleFactor': 1.0,
'windowInsets': [0.0, 0.0, 0.0, 685.0],
'windowPadding': [0.0, 66.0, 0.0, 360.0]
}
],
},
Expand Down Expand Up @@ -225,6 +217,14 @@ void main() {
'platformOS': 'android',
'platformOSVersion': 'RSR1.201013.001',
'userId': 'Testy McTestFace',
'physicalGeometry': [0.0, 0.0, 0.0, 0.0],
'platformBrightness': 'dark',
'platformGestureInsets': [0.0, 0.0, 0.0, 0.0],
'windowPixelRatio': 2.75,
'windowSize': [1080.0, 2088.0],
'windowTextScaleFactor': 1.0,
'windowInsets': [0.0, 0.0, 0.0, 685.0],
'windowPadding': [0.0, 66.0, 0.0, 0.0]
},
);
});
Expand Down

0 comments on commit 8794238

Please sign in to comment.