@@ -4,35 +4,48 @@ import 'debug_image_extractor.dart';
4
4
class LoadDartDebugImagesIntegration extends Integration <SentryOptions > {
5
5
@override
6
6
void call (Hub hub, SentryOptions options) {
7
- options.addEventProcessor (
8
- _LoadImageIntegrationEventProcessor ( DebugImageExtractor (options)));
7
+ options.addEventProcessor (_LoadImageIntegrationEventProcessor (
8
+ DebugImageExtractor (options), options ));
9
9
options.sdk.addIntegration ('loadDartImageIntegration' );
10
10
}
11
11
}
12
12
13
13
const hintRawStackTraceKey = 'raw_stacktrace' ;
14
14
15
15
class _LoadImageIntegrationEventProcessor implements EventProcessor {
16
- _LoadImageIntegrationEventProcessor (this ._debugImageExtractor);
16
+ _LoadImageIntegrationEventProcessor (this ._debugImageExtractor, this ._options);
17
+
18
+ final SentryOptions _options;
17
19
18
20
final DebugImageExtractor _debugImageExtractor;
19
21
20
22
@override
21
23
Future <SentryEvent ?> apply (SentryEvent event, Hint hint) async {
22
24
final stackTrace = hint.get (hintRawStackTraceKey) as String ? ;
23
- if (! event.needsSymbolication () || stackTrace == null ) {
25
+ if (! _options.enableDartSymbolication ||
26
+ ! event.needsSymbolication () ||
27
+ stackTrace == null ) {
24
28
return event;
25
29
}
26
30
27
- final syntheticImage =
28
- _debugImageExtractor.extractDebugImageFrom (stackTrace);
31
+ try {
32
+ final syntheticImage =
33
+ _debugImageExtractor.extractDebugImageFrom (stackTrace);
34
+ if (syntheticImage == null ) {
35
+ return event;
36
+ }
29
37
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
+ );
32
47
return event;
33
48
}
34
-
35
- return event.copyWith (debugMeta: DebugMeta (images: [syntheticImage]));
36
49
}
37
50
}
38
51
0 commit comments