Skip to content

Commit 5d15a51

Browse files
uemanmarandaneto
andauthored
Update protocol (#1038)
Co-authored-by: Manoel Aranda Neto <[email protected]>
1 parent 559d28f commit 5d15a51

36 files changed

+458
-447
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Bring protocol up to date with latest Sentry protocol ([#1038](https://github.com/getsentry/sentry-dart/pull/1038))
8+
39
## 6.12.2
410

511
### Fixes

dart/example_web/web/event.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final event = SentryEvent(
1414
username: 'first-user',
1515
1616
// ipAddress: '127.0.0.1',
17-
extras: <String, String>{'first-sign-in': '2020-01-01'},
17+
data: <String, String>{'first-sign-in': '2020-01-01'},
1818
),
1919
breadcrumbs: [
2020
Breadcrumb(

dart/example_web/web/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Future<void> runApp() async {
5252
username: 'first-user',
5353
5454
// ipAddress: '127.0.0.1',
55-
extras: <String, String>{'first-sign-in': '2020-01-01'},
55+
data: <String, String>{'first-sign-in': '2020-01-01'},
5656
),
5757
);
5858
});

dart/lib/src/http_client/failed_request_client.dart

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class FailedRequestClient extends BaseClient {
166166
queryString: query,
167167
cookies: sendDefaultPii ? request.headers['Cookie'] : null,
168168
data: _getDataFromRequest(request),
169+
// ignore: deprecated_member_use_from_same_package
169170
other: {
170171
'content_length': request.contentLength.toString(),
171172
'duration': requestDuration.toString(),

dart/lib/src/protocol.dart

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export 'protocol/sentry_runtime.dart';
2323
export 'protocol/sentry_stack_frame.dart';
2424
export 'protocol/sentry_stack_trace.dart';
2525
export 'protocol/sentry_user.dart';
26+
export 'protocol/sentry_geo.dart';
2627
export 'protocol/max_body_size.dart';
2728
export 'protocol/sentry_culture.dart';
2829
export 'protocol/sentry_thread.dart';

dart/lib/src/protocol/breadcrumb.dart

+6-19
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,14 @@ class Breadcrumb {
148148
/// Converts this breadcrumb to a map that can be serialized to JSON according
149149
/// to the Sentry protocol.
150150
Map<String, dynamic> toJson() {
151-
final json = <String, dynamic>{
151+
return {
152152
'timestamp': formatDateAsIso8601WithMillisPrecision(timestamp),
153+
if (message != null) 'message': message,
154+
if (category != null) 'category': category,
155+
if (data?.isNotEmpty ?? false) 'data': data,
156+
if (level != null) 'level': level!.name,
157+
if (type != null) 'type': type,
153158
};
154-
155-
if (message != null) {
156-
json['message'] = message;
157-
}
158-
if (category != null) {
159-
json['category'] = category;
160-
}
161-
if (data?.isNotEmpty ?? false) {
162-
json['data'] = data;
163-
}
164-
if (level != null) {
165-
json['level'] = level!.name;
166-
}
167-
168-
if (type != null) {
169-
json['type'] = type;
170-
}
171-
return json;
172159
}
173160

174161
Breadcrumb copyWith({

dart/lib/src/protocol/debug_image.dart

+29-45
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class DebugImage {
4545
/// Optional. Identifier of the dynamic library or executable. It is the value of the LC_UUID load command in the Mach header, formatted as UUID. Can be empty for Mach images, as it is equivalent to the debug identifier.
4646
final String? codeId;
4747

48+
/// MachO CPU subtype identifier.
49+
final int? cpuSubtype;
50+
51+
/// MachO CPU type identifier.
52+
final int? cpuType;
53+
4854
const DebugImage({
4955
required this.type,
5056
this.name,
@@ -57,6 +63,8 @@ class DebugImage {
5763
this.codeFile,
5864
this.arch,
5965
this.codeId,
66+
this.cpuType,
67+
this.cpuSubtype,
6068
});
6169

6270
/// Deserializes a [DebugImage] from JSON [Map].
@@ -73,56 +81,28 @@ class DebugImage {
7381
codeFile: json['code_file'],
7482
arch: json['arch'],
7583
codeId: json['code_id'],
84+
cpuType: json['cpu_type'],
85+
cpuSubtype: json['cpu_subtype'],
7686
);
7787
}
7888

7989
/// Produces a [Map] that can be serialized to JSON.
8090
Map<String, dynamic> toJson() {
81-
final json = <String, dynamic>{};
82-
83-
if (uuid != null) {
84-
json['uuid'] = uuid;
85-
}
86-
87-
json['type'] = type;
88-
89-
if (debugId != null) {
90-
json['debug_id'] = debugId;
91-
}
92-
93-
if (name != null) {
94-
json['name'] = name;
95-
}
96-
97-
if (debugFile != null) {
98-
json['debug_file'] = debugFile;
99-
}
100-
101-
if (codeFile != null) {
102-
json['code_file'] = codeFile;
103-
}
104-
105-
if (imageAddr != null) {
106-
json['image_addr'] = imageAddr;
107-
}
108-
109-
if (imageVmAddr != null) {
110-
json['image_vmaddr'] = imageVmAddr;
111-
}
112-
113-
if (imageSize != null) {
114-
json['image_size'] = imageSize;
115-
}
116-
117-
if (arch != null) {
118-
json['arch'] = arch;
119-
}
120-
121-
if (codeId != null) {
122-
json['code_id'] = codeId;
123-
}
124-
125-
return json;
91+
return {
92+
'type': type,
93+
if (uuid != null) 'uuid': uuid,
94+
if (debugId != null) 'debug_id': debugId,
95+
if (name != null) 'name': name,
96+
if (debugFile != null) 'debug_file': debugFile,
97+
if (codeFile != null) 'code_file': codeFile,
98+
if (imageAddr != null) 'image_addr': imageAddr,
99+
if (imageVmAddr != null) 'image_vmaddr': imageVmAddr,
100+
if (imageSize != null) 'image_size': imageSize,
101+
if (arch != null) 'arch': arch,
102+
if (codeId != null) 'code_id': codeId,
103+
if (cpuType != null) 'cpu_type': cpuType,
104+
if (cpuSubtype != null) 'cpu_subtype': cpuSubtype,
105+
};
126106
}
127107

128108
DebugImage copyWith({
@@ -137,6 +117,8 @@ class DebugImage {
137117
int? imageSize,
138118
String? arch,
139119
String? codeId,
120+
int? cpuType,
121+
int? cpuSubtype,
140122
}) =>
141123
DebugImage(
142124
uuid: uuid ?? this.uuid,
@@ -150,5 +132,7 @@ class DebugImage {
150132
imageSize: imageSize ?? this.imageSize,
151133
arch: arch ?? this.arch,
152134
codeId: codeId ?? this.codeId,
135+
cpuType: cpuType ?? this.cpuType,
136+
cpuSubtype: cpuSubtype ?? this.cpuSubtype,
153137
);
154138
}

dart/lib/src/protocol/debug_meta.dart

+8-14
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,15 @@ class DebugMeta {
3333

3434
/// Produces a [Map] that can be serialized to JSON.
3535
Map<String, dynamic> toJson() {
36-
final json = <String, dynamic>{};
37-
3836
final sdkInfo = sdk?.toJson();
39-
if (sdkInfo?.isNotEmpty ?? false) {
40-
json['sdk_info'] = sdkInfo;
41-
}
42-
43-
if (_images?.isNotEmpty ?? false) {
44-
json['images'] = _images!
45-
.map((e) => e.toJson())
46-
.where((element) => element.isNotEmpty)
47-
.toList(growable: false);
48-
}
49-
50-
return json;
37+
return {
38+
if (sdkInfo?.isNotEmpty ?? false) 'sdk_info': sdkInfo,
39+
if (_images?.isNotEmpty ?? false)
40+
'images': _images!
41+
.map((e) => e.toJson())
42+
.where((element) => element.isNotEmpty)
43+
.toList(growable: false)
44+
};
5145
}
5246

5347
DebugMeta copyWith({

dart/lib/src/protocol/mechanism.dart

+9-29
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,14 @@ class Mechanism {
9999

100100
/// Produces a [Map] that can be serialized to JSON.
101101
Map<String, dynamic> toJson() {
102-
final json = <String, dynamic>{};
103-
104-
json['type'] = type;
105-
106-
if (description != null) {
107-
json['description'] = description;
108-
}
109-
110-
if (helpLink != null) {
111-
json['help_link'] = helpLink;
112-
}
113-
114-
if (handled != null) {
115-
json['handled'] = handled;
116-
}
117-
118-
if (_meta?.isNotEmpty ?? false) {
119-
json['meta'] = _meta;
120-
}
121-
122-
if (_data?.isNotEmpty ?? false) {
123-
json['data'] = _data;
124-
}
125-
126-
if (synthetic != null) {
127-
json['synthetic'] = synthetic;
128-
}
129-
130-
return json;
102+
return {
103+
'type': type,
104+
if (description != null) 'description': description,
105+
if (helpLink != null) 'help_link': helpLink,
106+
if (handled != null) 'handled': handled,
107+
if (_meta?.isNotEmpty ?? false) 'meta': _meta,
108+
if (_data?.isNotEmpty ?? false) 'data': _data,
109+
if (synthetic != null) 'synthetic': synthetic,
110+
};
131111
}
132112
}

dart/lib/src/protocol/sdk_info.dart

+6-18
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,12 @@ class SdkInfo {
2727

2828
/// Produces a [Map] that can be serialized to JSON.
2929
Map<String, dynamic> toJson() {
30-
final json = <String, dynamic>{};
31-
if (sdkName != null) {
32-
json['sdk_name'] = sdkName;
33-
}
34-
35-
if (versionMajor != null) {
36-
json['version_major'] = versionMajor;
37-
}
38-
39-
if (versionMinor != null) {
40-
json['version_minor'] = versionMinor;
41-
}
42-
43-
if (versionPatchlevel != null) {
44-
json['version_patchlevel'] = versionPatchlevel;
45-
}
46-
47-
return json;
30+
return {
31+
if (sdkName != null) 'sdk_name': sdkName,
32+
if (versionMajor != null) 'version_major': versionMajor,
33+
if (versionMinor != null) 'version_minor': versionMinor,
34+
if (versionPatchlevel != null) 'version_patchlevel': versionPatchlevel,
35+
};
4836
}
4937

5038
SdkInfo copyWith({

dart/lib/src/protocol/sdk_version.dart

+7-15
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,13 @@ class SdkVersion {
7979

8080
/// Produces a [Map] that can be serialized to JSON.
8181
Map<String, dynamic> toJson() {
82-
final json = <String, dynamic>{};
83-
84-
json['name'] = name;
85-
86-
json['version'] = version;
87-
88-
if (packages.isNotEmpty) {
89-
json['packages'] =
90-
packages.map((p) => p.toJson()).toList(growable: false);
91-
}
92-
93-
if (integrations.isNotEmpty) {
94-
json['integrations'] = integrations;
95-
}
96-
return json;
82+
return {
83+
'name': name,
84+
'version': version,
85+
if (packages.isNotEmpty)
86+
'packages': packages.map((p) => p.toJson()).toList(growable: false),
87+
if (integrations.isNotEmpty) 'integrations': integrations,
88+
};
9789
}
9890

9991
/// Adds a package

0 commit comments

Comments
 (0)