Skip to content

Commit 1bb772c

Browse files
authored
Mark exceptions not handled by user as handled: false (#1535)
1 parent 0aaa46e commit 1bb772c

36 files changed

+366
-80
lines changed

.github/workflows/flutter_integration_test.yml

+32-32
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,42 @@ jobs:
4646
- name: flutter pub get
4747
run: flutter pub get
4848

49-
- name: Gradle cache
50-
uses: gradle/gradle-build-action@v2
49+
- name: Gradle cache
50+
uses: gradle/gradle-build-action@v2
5151

52-
- name: AVD cache
53-
uses: actions/cache@v3
54-
id: avd-cache
55-
with:
56-
path: |
57-
~/.android/avd/*
58-
~/.android/adb*
52+
- name: AVD cache
53+
uses: actions/cache@v3
54+
id: avd-cache
55+
with:
56+
path: |
57+
~/.android/avd/*
58+
~/.android/adb*
5959
key: avd-21
6060
61-
- name: create AVD and generate snapshot for caching
62-
if: steps.avd-cache.outputs.cache-hit != 'true'
63-
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
64-
with:
65-
working-directory: ./flutter/example
66-
api-level: 21
67-
force-avd-creation: false
68-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
69-
disable-animations: false
70-
arch: x86_64
71-
profile: Nexus 6
72-
script: echo "Generated AVD snapshot for caching."
61+
- name: create AVD and generate snapshot for caching
62+
if: steps.avd-cache.outputs.cache-hit != 'true'
63+
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
64+
with:
65+
working-directory: ./flutter/example
66+
api-level: 21
67+
force-avd-creation: false
68+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
69+
disable-animations: false
70+
arch: x86_64
71+
profile: Nexus 6
72+
script: echo "Generated AVD snapshot for caching."
7373

74-
- name: launch android emulator & run android integration test
75-
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
76-
with:
77-
working-directory: ./flutter/example
78-
api-level: 21
79-
force-avd-creation: false
80-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
81-
disable-animations: true
82-
arch: x86_64
83-
profile: Nexus 6
84-
script: flutter test integration_test/integration_test.dart --verbose
74+
- name: launch android emulator & run android integration test
75+
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
76+
with:
77+
working-directory: ./flutter/example
78+
api-level: 21
79+
force-avd-creation: false
80+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
81+
disable-animations: true
82+
arch: x86_64
83+
profile: Nexus 6
84+
script: flutter test integration_test/integration_test.dart --verbose
8585

8686
test-ios:
8787
runs-on: macos-13

CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
# Changelog
22

3-
## Unreleased
3+
## 8.0.0
44

5+
### Breaking Changes
6+
7+
- Mark exceptions not handled by the user as `handled: false` ([#1535](https://github.com/getsentry/sentry-dart/pull/1535))
8+
- This will affect your release health data, and is therefore considered a breaking change.
9+
10+
## 7.9.0
11+
512
### Features
613

714
- Send trace origin ([#1534](https://github.com/getsentry/sentry-dart/pull/1534))
815

916
[Trace origin](https://develop.sentry.dev/sdk/performance/trace-origin/) indicates what created a trace or a span. Not all transactions and spans contain enough information to tell whether the user or what precisely in the SDK created it. Origin solves this problem. The SDK now sends origin for transactions and spans.
1017

18+
- Add `appHangTimeoutInterval` to `SentryFlutterOptions` ([#1568](https://github.com/getsentry/sentry-dart/pull/1568))
19+
- DioEventProcessor: Append http response body ([#1557](https://github.com/getsentry/sentry-dart/pull/1557))
20+
- This is opt-in and depends on `maxResponseBodySize`
21+
- Only for `dio` package
22+
1123
### Dependencies
1224

1325
- Bump Cocoa SDK from v8.8.0 to v8.9.1 ([#1553](https://github.com/getsentry/sentry-dart/pull/1553))

dart/lib/sentry.dart

+2
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ export 'src/utils/url_details.dart';
4646
export 'src/utils/http_header_utils.dart';
4747
// ignore: invalid_export_of_internal_element
4848
export 'src/sentry_trace_origins.dart';
49+
// ignore: invalid_export_of_internal_element
50+
export 'src/utils.dart';

dart/lib/src/run_zoned_guarded_integration.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class RunZonedGuardedIntegration extends Integration<SentryOptions> {
4444
stackTrace: stackTrace,
4545
);
4646

47-
// runZonedGuarded doesn't crash the App.
48-
final mechanism = Mechanism(type: 'runZonedGuarded', handled: true);
47+
// runZonedGuarded doesn't crash the app, but is not handled by the user.
48+
final mechanism = Mechanism(type: 'runZonedGuarded', handled: false);
4949
final throwableMechanism = ThrowableMechanism(mechanism, exception);
5050

5151
final event = SentryEvent(

dart/lib/src/sentry_isolate.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ class SentryIsolate {
6969
stackTrace == null ? null : StackTrace.fromString(stackTrace),
7070
);
7171

72-
// Isolate errors don't crash the App.
73-
final mechanism = Mechanism(type: 'isolateError', handled: true);
72+
// Isolate errors don't crash the app, but is not handled by the user.
73+
final mechanism = Mechanism(type: 'isolateError', handled: false);
7474
final throwableMechanism = ThrowableMechanism(mechanism, throwable);
75+
7576
final event = SentryEvent(
7677
throwable: throwableMechanism,
7778
level: SentryLevel.fatal,

dart/lib/src/sentry_options.dart

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'diagnostic_logger.dart';
1313
import 'environment/environment_variables.dart';
1414
import 'noop_client.dart';
1515
import 'transport/noop_transport.dart';
16-
import 'utils.dart';
1716
import 'version.dart';
1817

1918
// TODO: shutdownTimeout, flushTimeoutMillis

dart/lib/src/utils.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import 'package:meta/meta.dart';
88

99
/// Sentry does not take a timezone and instead expects the date-time to be
1010
/// submitted in UTC timezone.
11+
@internal
1112
DateTime getUtcDateTime() => DateTime.now().toUtc();
1213

1314
/// Formats a Date as ISO8601 and UTC with millis precision
15+
@internal
1416
String formatDateAsIso8601WithMillisPrecision(DateTime date) {
1517
var iso = date.toIso8601String();
1618
final millisecondSeparatorIndex = iso.lastIndexOf('.');
@@ -22,9 +24,10 @@ String formatDateAsIso8601WithMillisPrecision(DateTime date) {
2224
return '${iso}Z';
2325
}
2426

27+
@internal
2528
final utf8JsonEncoder = JsonUtf8Encoder(null, jsonSerializationFallback, null);
2629

27-
@visibleForTesting
30+
@internal
2831
Object? jsonSerializationFallback(Object? nonEncodable) {
2932
if (nonEncodable == null) {
3033
return null;

dart/lib/src/version.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
library version;
1010

1111
/// The SDK version reported to Sentry.io in the submitted events.
12-
const String sdkVersion = '7.8.0';
12+
const String sdkVersion = '7.9.0';
1313

1414
String sdkName(bool isWeb) => isWeb ? _browserSdkName : _ioSdkName;
1515

dart/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sentry
2-
version: 7.8.0
2+
version: 7.9.0
33
description: >
44
A crash reporting library for Dart that sends crash reports to Sentry.io.
55
This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.

dart/test/protocol/breadcrumb_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:collection/collection.dart';
22
import 'package:sentry/sentry.dart';
33
import 'package:test/test.dart';
4-
import 'package:sentry/src/utils.dart';
54

65
void main() {
76
final timestamp = DateTime.now();

dart/test/sentry_envelope_header_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:sentry/sentry.dart';
22
import 'package:sentry/src/sentry_envelope_header.dart';
3-
import 'package:sentry/src/utils.dart';
43
import 'package:test/test.dart';
54

65
import 'mocks.dart';

dart/test/sentry_envelope_item_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:sentry/src/sentry_envelope_item_header.dart';
88
import 'package:sentry/src/sentry_item_type.dart';
99
import 'package:sentry/src/sentry_tracer.dart';
1010
import 'package:sentry/src/transport/data_category.dart';
11-
import 'package:sentry/src/utils.dart';
1211
import 'package:test/test.dart';
1312

1413
import 'mocks/mock_hub.dart';

dart/test/sentry_envelope_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:sentry/src/sentry_envelope_header.dart';
66
import 'package:sentry/src/sentry_envelope_item_header.dart';
77
import 'package:sentry/src/sentry_item_type.dart';
88
import 'package:sentry/src/sentry_tracer.dart';
9-
import 'package:sentry/src/utils.dart';
109
import 'package:test/test.dart';
1110

1211
import 'mocks.dart';

dart/test/sentry_event_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:collection/collection.dart';
66
import 'package:sentry/sentry.dart';
77
import 'package:sentry/src/version.dart';
8-
import 'package:sentry/src/utils.dart';
98
import 'package:test/test.dart';
109

1110
void main() {

dart/test/sentry_span_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:sentry/sentry.dart';
22
import 'package:sentry/src/sentry_tracer.dart';
3-
import 'package:sentry/src/utils.dart';
43
import 'package:test/test.dart';
54

65
import 'mocks/mock_hub.dart';

dart/test/sentry_tracer_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:sentry/sentry.dart';
22
import 'package:sentry/src/sentry_tracer.dart';
3-
import 'package:sentry/src/utils.dart';
43
import 'package:test/test.dart';
54

65
import 'mocks.dart';

dio/lib/src/dio_event_processor.dart

+70-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// ignore_for_file: deprecated_member_use
22

3+
import 'dart:convert';
4+
35
import 'package:dio/dio.dart';
46
import 'package:sentry/sentry.dart';
57

@@ -62,7 +64,7 @@ class DioEventProcessor implements EventProcessor {
6264
}
6365

6466
/// Returns the request data, if possible according to the users settings.
65-
Object? _getRequestData(dynamic data) {
67+
Object? _getRequestData(Object? data) {
6668
if (!_options.sendDefaultPii) {
6769
return null;
6870
}
@@ -87,8 +89,74 @@ class DioEventProcessor implements EventProcessor {
8789

8890
return SentryResponse(
8991
headers: _options.sendDefaultPii ? headers : null,
90-
bodySize: dioError.response?.data?.length as int?,
92+
bodySize: _getBodySize(
93+
dioError.response?.data,
94+
dioError.requestOptions.responseType,
95+
),
9196
statusCode: response?.statusCode,
97+
data: _getResponseData(
98+
dioError.response?.data,
99+
dioError.requestOptions.responseType,
100+
),
92101
);
93102
}
103+
104+
/// Returns the response data, if possible according to the users settings.
105+
Object? _getResponseData(Object? data, ResponseType responseType) {
106+
if (!_options.sendDefaultPii || data == null) {
107+
return null;
108+
}
109+
switch (responseType) {
110+
case ResponseType.json:
111+
// ignore: invalid_use_of_internal_member
112+
final jsData = utf8JsonEncoder.convert(data);
113+
if (_options.maxResponseBodySize.shouldAddBody(jsData.length)) {
114+
return data;
115+
}
116+
break;
117+
case ResponseType.stream:
118+
break; // No support for logging stream body.
119+
case ResponseType.plain:
120+
if (data is String &&
121+
_options.maxResponseBodySize.shouldAddBody(data.codeUnits.length)) {
122+
return data;
123+
}
124+
break;
125+
case ResponseType.bytes:
126+
if (data is List<int> &&
127+
_options.maxResponseBodySize.shouldAddBody(data.length)) {
128+
return data;
129+
}
130+
break;
131+
}
132+
return null;
133+
}
134+
135+
int? _getBodySize(Object? data, ResponseType responseType) {
136+
if (data == null) {
137+
return null;
138+
}
139+
switch (responseType) {
140+
case ResponseType.json:
141+
return json.encode(data).codeUnits.length;
142+
case ResponseType.stream:
143+
if (data is String) {
144+
return data.length;
145+
} else {
146+
return null;
147+
}
148+
case ResponseType.plain:
149+
if (data is String) {
150+
return data.codeUnits.length;
151+
} else {
152+
return null;
153+
}
154+
case ResponseType.bytes:
155+
if (data is List<int>) {
156+
return data.length;
157+
} else {
158+
return null;
159+
}
160+
}
161+
}
94162
}

dio/lib/src/version.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// The SDK version reported to Sentry.io in the submitted events.
2-
const String sdkVersion = '7.8.0';
2+
const String sdkVersion = '7.9.0';
33

44
/// The package name reported to Sentry.io in the submitted events.
55
const String packageName = 'pub:sentry_dio';

dio/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sentry_dio
22
description: An integration which adds support for performance tracing for the Dio package.
3-
version: 7.8.0
3+
version: 7.9.0
44
homepage: https://docs.sentry.io/platforms/dart/
55
repository: https://github.com/getsentry/sentry-dart
66
issue_tracker: https://github.com/getsentry/sentry-dart/issues
@@ -11,7 +11,7 @@ environment:
1111

1212
dependencies:
1313
dio: ^5.0.0
14-
sentry: 7.8.0
14+
sentry: 7.9.0
1515

1616
dev_dependencies:
1717
meta: ^1.3.0

0 commit comments

Comments
 (0)