Skip to content

Commit 07f0b6b

Browse files
committed
update
1 parent db3bf92 commit 07f0b6b

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

dart/lib/src/load_dart_debug_images_integration.dart

+23-10
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,48 @@ import 'debug_image_extractor.dart';
44
class LoadDartDebugImagesIntegration extends Integration<SentryOptions> {
55
@override
66
void call(Hub hub, SentryOptions options) {
7-
options.addEventProcessor(
8-
_LoadImageIntegrationEventProcessor(DebugImageExtractor(options)));
7+
options.addEventProcessor(_LoadImageIntegrationEventProcessor(
8+
DebugImageExtractor(options), options));
99
options.sdk.addIntegration('loadDartImageIntegration');
1010
}
1111
}
1212

1313
const hintRawStackTraceKey = 'raw_stacktrace';
1414

1515
class _LoadImageIntegrationEventProcessor implements EventProcessor {
16-
_LoadImageIntegrationEventProcessor(this._debugImageExtractor);
16+
_LoadImageIntegrationEventProcessor(this._debugImageExtractor, this._options);
17+
18+
final SentryOptions _options;
1719

1820
final DebugImageExtractor _debugImageExtractor;
1921

2022
@override
2123
Future<SentryEvent?> apply(SentryEvent event, Hint hint) async {
2224
final stackTrace = hint.get(hintRawStackTraceKey) as String?;
23-
if (!event.needsSymbolication() || stackTrace == null) {
25+
if (!_options.enableDartSymbolication ||
26+
!event.needsSymbolication() ||
27+
stackTrace == null) {
2428
return event;
2529
}
2630

27-
final syntheticImage =
28-
_debugImageExtractor.extractDebugImageFrom(stackTrace);
31+
try {
32+
final syntheticImage =
33+
_debugImageExtractor.extractDebugImageFrom(stackTrace);
34+
if (syntheticImage == null) {
35+
return event;
36+
}
2937

30-
print(syntheticImage);
31-
if (syntheticImage == null) {
38+
return event.copyWith(debugMeta: DebugMeta(images: [syntheticImage]));
39+
} catch (e, stackTrace) {
40+
_options.logger(
41+
SentryLevel.info,
42+
"Couldn't add Dart debug image to event. "
43+
'The event will still be reported.',
44+
exception: e,
45+
stackTrace: stackTrace,
46+
);
3247
return event;
3348
}
34-
35-
return event.copyWith(debugMeta: DebugMeta(images: [syntheticImage]));
3649
}
3750
}
3851

dart/test/load_dart_debug_images_integration_test.dart

+14-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ void main() {
2828
);
2929
});
3030

31-
test('Event processor does not modify event if symbolication is not needed',
31+
test(
32+
'Event processor does not add debug image if symbolication is not needed',
3233
() async {
3334
final event = _getEvent(needsSymbolication: false);
3435
final processor = fixture.options.eventProcessors.first;
@@ -37,7 +38,7 @@ void main() {
3738
expect(resultEvent, equals(event));
3839
});
3940

40-
test('Event processor does not modify event if stackTrace is null',
41+
test('Event processor does not add debug image if stackTrace is null',
4142
() async {
4243
final event = _getEvent();
4344
final processor = fixture.options.eventProcessors.first;
@@ -46,6 +47,17 @@ void main() {
4647
expect(resultEvent, equals(event));
4748
});
4849

50+
test(
51+
'Event processor does not add debug image if enableDartSymbolication is false',
52+
() async {
53+
fixture.options.enableDartSymbolication = false;
54+
final event = _getEvent();
55+
final processor = fixture.options.eventProcessors.first;
56+
final resultEvent = await processor.apply(event, Hint());
57+
58+
expect(resultEvent, equals(event));
59+
});
60+
4961
test('Event processor adds debug image when symbolication is needed',
5062
() async {
5163
final stackTrace = '''

0 commit comments

Comments
 (0)