Skip to content

Commit 8024a6c

Browse files
authored
Implement envelope based transport (#391)
1 parent 9828733 commit 8024a6c

File tree

93 files changed

+3546
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3546
-1159
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Unreleased
22

33
* Feat: Add Culture Context (#491)
4+
5+
## Breaking Changes:
6+
7+
* Feat: Support envelope based transport for events (#391)
8+
* The method signature of `Transport` changed from `Future<SentryId> send(SentryEvent event)` to `Future<SentryId> send(SentryEnvelope envelope)`
49
* Remove `Sentry.currentHub` (#490)
510

611
# 5.1.0
@@ -32,6 +37,10 @@
3237
* Feature: Add `withScope` callback to capture methods (#463)
3338
* Fix: Add missing properties `language`, `screenHeightPixels` and `screenWidthPixels` to `SentryDevice` (#465)
3439

40+
## Sentry Self Hosted Compatibility
41+
42+
* This version of the `sentry` Dart package requires [Sentry server >= v20.6.0](https://github.com/getsentry/onpremise/releases). This only applies to on-premise Sentry, if you are using sentry.io no action is needed.
43+
3544
# 5.0.0
3645

3746
* Sound null safety

dart/lib/sentry.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export 'src/noop_isolate_error_integration.dart'
1313
export 'src/protocol.dart';
1414
export 'src/scope.dart';
1515
export 'src/sentry.dart';
16+
export 'src/sentry_envelope.dart';
1617
export 'src/sentry_client.dart';
1718
export 'src/sentry_options.dart';
1819
// useful for integrations

dart/lib/src/noop_sentry_client.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:async';
33
import 'protocol.dart';
44
import 'scope.dart';
55
import 'sentry_client.dart';
6+
import 'sentry_envelope.dart';
67

78
class NoOpSentryClient implements SentryClient {
89
NoOpSentryClient._();
@@ -42,6 +43,10 @@ class NoOpSentryClient implements SentryClient {
4243
}) =>
4344
Future.value(SentryId.empty());
4445

46+
@override
47+
Future<SentryId> captureEnvelope(SentryEnvelope envelope) =>
48+
Future.value(SentryId.empty());
49+
4550
@override
4651
Future<void> close() async {
4752
return;

dart/lib/src/protocol/breadcrumb.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ class Breadcrumb {
7676
/// The value is submitted to Sentry with second precision.
7777
final DateTime timestamp;
7878

79+
/// Deserializes a [Breadcrumb] from JSON [Map].
80+
factory Breadcrumb.fromJson(Map<String, dynamic> json) {
81+
final levelName = json['level'];
82+
final timestamp = json['timestamp'];
83+
return Breadcrumb(
84+
timestamp: timestamp != null ? DateTime.tryParse(timestamp) : null,
85+
message: json['message'],
86+
category: json['category'],
87+
data: json['data'],
88+
level: levelName != null ? SentryLevel.fromName(levelName) : null,
89+
type: json['type'],
90+
);
91+
}
92+
7993
/// Converts this breadcrumb to a map that can be serialized to JSON according
8094
/// to the Sentry protocol.
8195
Map<String, dynamic> toJson() {

dart/lib/src/protocol/contexts.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Contexts extends MapView<String, dynamic> {
2727
SentryCulture.type: culture,
2828
});
2929

30+
/// Deserializes [Contexts] from JSON [Map].
3031
factory Contexts.fromJson(Map<String, dynamic> data) {
3132
final contexts = Contexts(
3233
device: data[SentryDevice.type] != null

dart/lib/src/protocol/debug_image.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ class DebugImage {
5050
this.codeId,
5151
});
5252

53+
/// Deserializes a [DebugImage] from JSON [Map].
54+
factory DebugImage.fromJson(Map<String, dynamic> json) {
55+
return DebugImage(
56+
type: json['type'],
57+
imageAddr: json['image_addr'],
58+
debugId: json['debug_id'],
59+
debugFile: json['debug_file'],
60+
imageSize: json['image_size'],
61+
uuid: json['uuid'],
62+
codeFile: json['code_file'],
63+
arch: json['arch'],
64+
codeId: json['code_id'],
65+
);
66+
}
67+
68+
/// Produces a [Map] that can be serialized to JSON.
5369
Map<String, dynamic> toJson() {
5470
final json = <String, dynamic>{};
5571

dart/lib/src/protocol/debug_meta.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ class DebugMeta {
1818

1919
DebugMeta({this.sdk, List<DebugImage>? images}) : _images = images;
2020

21+
/// Deserializes a [DebugMeta] from JSON [Map].
22+
factory DebugMeta.fromJson(Map<String, dynamic> json) {
23+
final sdkInfoJson = json['sdk_info'];
24+
final debugImagesJson = json['images'] as List<dynamic>?;
25+
return DebugMeta(
26+
sdk: sdkInfoJson != null ? SdkInfo.fromJson(sdkInfoJson) : null,
27+
images: debugImagesJson
28+
?.map((debugImageJson) =>
29+
DebugImage.fromJson(debugImageJson as Map<String, dynamic>))
30+
.toList(),
31+
);
32+
}
33+
34+
/// Produces a [Map] that can be serialized to JSON.
2135
Map<String, dynamic> toJson() {
2236
final json = <String, dynamic>{};
2337

dart/lib/src/protocol/dsn.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Dsn {
4343
apiPath = 'api';
4444
}
4545
return Uri.parse(
46-
'${uriCopy.scheme}://${uriCopy.host}$port/$apiPath/$projectId/store/',
46+
'${uriCopy.scheme}://${uriCopy.host}$port/$apiPath/$projectId/envelope/',
4747
);
4848
}
4949

dart/lib/src/protocol/mechanism.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ class Mechanism {
7474
synthetic: synthetic ?? this.synthetic,
7575
);
7676

77+
/// Deserializes a [Mechanism] from JSON [Map].
78+
factory Mechanism.fromJson(Map<String, dynamic> json) {
79+
return Mechanism(
80+
type: json['type'],
81+
description: json['description'],
82+
helpLink: json['help_link'],
83+
handled: json['handled'],
84+
meta: json['meta'],
85+
data: json['data'],
86+
synthetic: json['synthetic'],
87+
);
88+
}
89+
90+
/// Produces a [Map] that can be serialized to JSON.
7791
Map<String, dynamic> toJson() {
7892
final json = <String, dynamic>{};
7993

dart/lib/src/protocol/sdk_info.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ class SdkInfo {
1515
this.versionPatchlevel,
1616
});
1717

18+
/// Deserializes a [SdkInfo] from JSON [Map].
19+
factory SdkInfo.fromJson(Map<String, dynamic> json) {
20+
return SdkInfo(
21+
sdkName: json['sdk_name'],
22+
versionMajor: json['version_major'],
23+
versionMinor: json['version_minor'],
24+
versionPatchlevel: json['version_patchlevel'],
25+
);
26+
}
27+
28+
/// Produces a [Map] that can be serialized to JSON.
1829
Map<String, dynamic> toJson() {
1930
final json = <String, dynamic>{};
2031
if (sdkName != null) {

dart/lib/src/protocol/sdk_version.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ class SdkVersion {
6363

6464
String get identifier => '$name/$version';
6565

66+
/// Deserializes a [SdkVersion] from JSON [Map].
67+
factory SdkVersion.fromJson(Map<String, dynamic> json) {
68+
final packagesJson = json['packages'] as List<dynamic>?;
69+
final integrationsJson = json['integrations'] as List<dynamic>?;
70+
return SdkVersion(
71+
name: json['name'],
72+
version: json['version'],
73+
packages: packagesJson
74+
?.map((e) => SentryPackage.fromJson(e as Map<String, dynamic>))
75+
.toList(),
76+
integrations: integrationsJson?.map((e) => e as String).toList(),
77+
);
78+
}
79+
6680
/// Produces a [Map] that can be serialized to JSON.
6781
Map<String, dynamic> toJson() {
6882
final json = <String, dynamic>{};

dart/lib/src/protocol/sentry_app.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ class SentryApp {
1818
this.deviceAppHash,
1919
});
2020

21-
factory SentryApp.fromJson(Map<String, dynamic> data) => SentryApp(
22-
name: data['app_name'],
23-
version: data['app_version'],
24-
identifier: data['app_identifier'],
25-
build: data['app_build'],
26-
buildType: data['build_type'],
27-
startTime: data['app_start_time'] != null
28-
? DateTime.tryParse(data['app_start_time'])
29-
: null,
30-
deviceAppHash: data['device_app_hash'],
31-
);
32-
3321
/// Human readable application name, as it appears on the platform.
3422
final String? name;
3523

@@ -51,6 +39,19 @@ class SentryApp {
5139
/// Application specific device identifier.
5240
final String? deviceAppHash;
5341

42+
/// Deserializes a [SentryApp] from JSON [Map].
43+
factory SentryApp.fromJson(Map<String, dynamic> data) => SentryApp(
44+
name: data['app_name'],
45+
version: data['app_version'],
46+
identifier: data['app_identifier'],
47+
build: data['app_build'],
48+
buildType: data['build_type'],
49+
startTime: data['app_start_time'] != null
50+
? DateTime.tryParse(data['app_start_time'])
51+
: null,
52+
deviceAppHash: data['device_app_hash'],
53+
);
54+
5455
/// Produces a [Map] that can be serialized to JSON.
5556
Map<String, dynamic> toJson() {
5657
final json = <String, String>{};

dart/lib/src/protocol/sentry_browser.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ class SentryBrowser {
1111
/// Creates an instance of [SentryBrowser].
1212
const SentryBrowser({this.name, this.version});
1313

14-
factory SentryBrowser.fromJson(Map<String, dynamic> data) => SentryBrowser(
15-
name: data['name'],
16-
version: data['version'],
17-
);
18-
1914
/// Human readable application name, as it appears on the platform.
2015
final String? name;
2116

2217
/// Human readable application version, as it appears on the platform.
2318
final String? version;
2419

20+
/// Deserializes a [SentryBrowser] from JSON [Map].
21+
factory SentryBrowser.fromJson(Map<String, dynamic> data) => SentryBrowser(
22+
name: data['name'],
23+
version: data['version'],
24+
);
25+
2526
/// Produces a [Map] that can be serialized to JSON.
2627
Map<String, dynamic> toJson() {
2728
final json = <String, dynamic>{};

0 commit comments

Comments
 (0)