Skip to content

Commit

Permalink
Update protocol (#1038)
Browse files Browse the repository at this point in the history
Co-authored-by: Manoel Aranda Neto <[email protected]>
  • Loading branch information
ueman and marandaneto authored Oct 12, 2022
1 parent 559d28f commit 5d15a51
Show file tree
Hide file tree
Showing 36 changed files with 458 additions and 447 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Bring protocol up to date with latest Sentry protocol ([#1038](https://github.com/getsentry/sentry-dart/pull/1038))

## 6.12.2

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion dart/example_web/web/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final event = SentryEvent(
username: 'first-user',
email: '[email protected]',
// ipAddress: '127.0.0.1',
extras: <String, String>{'first-sign-in': '2020-01-01'},
data: <String, String>{'first-sign-in': '2020-01-01'},
),
breadcrumbs: [
Breadcrumb(
Expand Down
2 changes: 1 addition & 1 deletion dart/example_web/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Future<void> runApp() async {
username: 'first-user',
email: '[email protected]',
// ipAddress: '127.0.0.1',
extras: <String, String>{'first-sign-in': '2020-01-01'},
data: <String, String>{'first-sign-in': '2020-01-01'},
),
);
});
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/http_client/failed_request_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class FailedRequestClient extends BaseClient {
queryString: query,
cookies: sendDefaultPii ? request.headers['Cookie'] : null,
data: _getDataFromRequest(request),
// ignore: deprecated_member_use_from_same_package
other: {
'content_length': request.contentLength.toString(),
'duration': requestDuration.toString(),
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export 'protocol/sentry_runtime.dart';
export 'protocol/sentry_stack_frame.dart';
export 'protocol/sentry_stack_trace.dart';
export 'protocol/sentry_user.dart';
export 'protocol/sentry_geo.dart';
export 'protocol/max_body_size.dart';
export 'protocol/sentry_culture.dart';
export 'protocol/sentry_thread.dart';
Expand Down
25 changes: 6 additions & 19 deletions dart/lib/src/protocol/breadcrumb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,14 @@ class Breadcrumb {
/// Converts this breadcrumb to a map that can be serialized to JSON according
/// to the Sentry protocol.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{
return {
'timestamp': formatDateAsIso8601WithMillisPrecision(timestamp),
if (message != null) 'message': message,
if (category != null) 'category': category,
if (data?.isNotEmpty ?? false) 'data': data,
if (level != null) 'level': level!.name,
if (type != null) 'type': type,
};

if (message != null) {
json['message'] = message;
}
if (category != null) {
json['category'] = category;
}
if (data?.isNotEmpty ?? false) {
json['data'] = data;
}
if (level != null) {
json['level'] = level!.name;
}

if (type != null) {
json['type'] = type;
}
return json;
}

Breadcrumb copyWith({
Expand Down
74 changes: 29 additions & 45 deletions dart/lib/src/protocol/debug_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class DebugImage {
/// 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.
final String? codeId;

/// MachO CPU subtype identifier.
final int? cpuSubtype;

/// MachO CPU type identifier.
final int? cpuType;

const DebugImage({
required this.type,
this.name,
Expand All @@ -57,6 +63,8 @@ class DebugImage {
this.codeFile,
this.arch,
this.codeId,
this.cpuType,
this.cpuSubtype,
});

/// Deserializes a [DebugImage] from JSON [Map].
Expand All @@ -73,56 +81,28 @@ class DebugImage {
codeFile: json['code_file'],
arch: json['arch'],
codeId: json['code_id'],
cpuType: json['cpu_type'],
cpuSubtype: json['cpu_subtype'],
);
}

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};

if (uuid != null) {
json['uuid'] = uuid;
}

json['type'] = type;

if (debugId != null) {
json['debug_id'] = debugId;
}

if (name != null) {
json['name'] = name;
}

if (debugFile != null) {
json['debug_file'] = debugFile;
}

if (codeFile != null) {
json['code_file'] = codeFile;
}

if (imageAddr != null) {
json['image_addr'] = imageAddr;
}

if (imageVmAddr != null) {
json['image_vmaddr'] = imageVmAddr;
}

if (imageSize != null) {
json['image_size'] = imageSize;
}

if (arch != null) {
json['arch'] = arch;
}

if (codeId != null) {
json['code_id'] = codeId;
}

return json;
return {
'type': type,
if (uuid != null) 'uuid': uuid,
if (debugId != null) 'debug_id': debugId,
if (name != null) 'name': name,
if (debugFile != null) 'debug_file': debugFile,
if (codeFile != null) 'code_file': codeFile,
if (imageAddr != null) 'image_addr': imageAddr,
if (imageVmAddr != null) 'image_vmaddr': imageVmAddr,
if (imageSize != null) 'image_size': imageSize,
if (arch != null) 'arch': arch,
if (codeId != null) 'code_id': codeId,
if (cpuType != null) 'cpu_type': cpuType,
if (cpuSubtype != null) 'cpu_subtype': cpuSubtype,
};
}

DebugImage copyWith({
Expand All @@ -137,6 +117,8 @@ class DebugImage {
int? imageSize,
String? arch,
String? codeId,
int? cpuType,
int? cpuSubtype,
}) =>
DebugImage(
uuid: uuid ?? this.uuid,
Expand All @@ -150,5 +132,7 @@ class DebugImage {
imageSize: imageSize ?? this.imageSize,
arch: arch ?? this.arch,
codeId: codeId ?? this.codeId,
cpuType: cpuType ?? this.cpuType,
cpuSubtype: cpuSubtype ?? this.cpuSubtype,
);
}
22 changes: 8 additions & 14 deletions dart/lib/src/protocol/debug_meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,15 @@ class DebugMeta {

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};

final sdkInfo = sdk?.toJson();
if (sdkInfo?.isNotEmpty ?? false) {
json['sdk_info'] = sdkInfo;
}

if (_images?.isNotEmpty ?? false) {
json['images'] = _images!
.map((e) => e.toJson())
.where((element) => element.isNotEmpty)
.toList(growable: false);
}

return json;
return {
if (sdkInfo?.isNotEmpty ?? false) 'sdk_info': sdkInfo,
if (_images?.isNotEmpty ?? false)
'images': _images!
.map((e) => e.toJson())
.where((element) => element.isNotEmpty)
.toList(growable: false)
};
}

DebugMeta copyWith({
Expand Down
38 changes: 9 additions & 29 deletions dart/lib/src/protocol/mechanism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,14 @@ class Mechanism {

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};

json['type'] = type;

if (description != null) {
json['description'] = description;
}

if (helpLink != null) {
json['help_link'] = helpLink;
}

if (handled != null) {
json['handled'] = handled;
}

if (_meta?.isNotEmpty ?? false) {
json['meta'] = _meta;
}

if (_data?.isNotEmpty ?? false) {
json['data'] = _data;
}

if (synthetic != null) {
json['synthetic'] = synthetic;
}

return json;
return {
'type': type,
if (description != null) 'description': description,
if (helpLink != null) 'help_link': helpLink,
if (handled != null) 'handled': handled,
if (_meta?.isNotEmpty ?? false) 'meta': _meta,
if (_data?.isNotEmpty ?? false) 'data': _data,
if (synthetic != null) 'synthetic': synthetic,
};
}
}
24 changes: 6 additions & 18 deletions dart/lib/src/protocol/sdk_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,12 @@ class SdkInfo {

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (sdkName != null) {
json['sdk_name'] = sdkName;
}

if (versionMajor != null) {
json['version_major'] = versionMajor;
}

if (versionMinor != null) {
json['version_minor'] = versionMinor;
}

if (versionPatchlevel != null) {
json['version_patchlevel'] = versionPatchlevel;
}

return json;
return {
if (sdkName != null) 'sdk_name': sdkName,
if (versionMajor != null) 'version_major': versionMajor,
if (versionMinor != null) 'version_minor': versionMinor,
if (versionPatchlevel != null) 'version_patchlevel': versionPatchlevel,
};
}

SdkInfo copyWith({
Expand Down
22 changes: 7 additions & 15 deletions dart/lib/src/protocol/sdk_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,13 @@ class SdkVersion {

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};

json['name'] = name;

json['version'] = version;

if (packages.isNotEmpty) {
json['packages'] =
packages.map((p) => p.toJson()).toList(growable: false);
}

if (integrations.isNotEmpty) {
json['integrations'] = integrations;
}
return json;
return {
'name': name,
'version': version,
if (packages.isNotEmpty)
'packages': packages.map((p) => p.toJson()).toList(growable: false),
if (integrations.isNotEmpty) 'integrations': integrations,
};
}

/// Adds a package
Expand Down
Loading

0 comments on commit 5d15a51

Please sign in to comment.