From f25f20767a49557d3024ff6d3220ae01dfcab209 Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 29 Nov 2023 17:56:32 +0100 Subject: [PATCH] Add debug_meta to all events (#1756) * load_image_list_integration now appends debug_meta info to all non-transaction events with a stacktrace, instead of checking for Exception existence --- CHANGELOG.md | 5 +++++ .../load_image_list_integration.dart | 21 ++++++++++++++----- .../integrations/load_image_list_test.dart | 7 +------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b00adcfff0..11a30dc056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Fixes + +- Add debug_meta to all events ([#1756](https://github.com/getsentry/sentry-dart/pull/1756)) + - Fixes obfuscated stacktraces when `captureMessage` or `captureEvent` is called with `attachStacktrace` option + ### Features - Add option to opt out of fatal level for automatically collected errors ([#1738](https://github.com/getsentry/sentry-dart/pull/1738)) diff --git a/flutter/lib/src/integrations/load_image_list_integration.dart b/flutter/lib/src/integrations/load_image_list_integration.dart index c2a0c98848..8838ae0e4b 100644 --- a/flutter/lib/src/integrations/load_image_list_integration.dart +++ b/flutter/lib/src/integrations/load_image_list_integration.dart @@ -25,14 +25,25 @@ extension _NeedsSymbolication on SentryEvent { if (this is SentryTransaction) { return false; } - if (exceptions?.isNotEmpty == false) { - return false; - } - final frames = exceptions?.first.stackTrace?.frames; + final frames = _getStacktraceFrames(); if (frames == null) { return false; } - return frames.any((frame) => 'native' == frame.platform); + return frames.any((frame) => 'native' == frame?.platform); + } + + List? _getStacktraceFrames() { + if (exceptions?.isNotEmpty == true) { + return exceptions?.first.stackTrace?.frames; + } + if (threads?.isNotEmpty == true) { + var stacktraces = threads?.map((e) => e.stacktrace); + return stacktraces + ?.where((element) => element != null) + .expand((element) => element!.frames) + .toList(); + } + return null; } } diff --git a/flutter/test/integrations/load_image_list_test.dart b/flutter/test/integrations/load_image_list_test.dart index bb78561dae..085bbcd3dc 100644 --- a/flutter/test/integrations/load_image_list_test.dart +++ b/flutter/test/integrations/load_image_list_test.dart @@ -187,12 +187,7 @@ void main() { SentryEvent _getEvent() { final frame = SentryStackFrame(platform: 'native'); final st = SentryStackTrace(frames: [frame]); - final ex = SentryException( - type: 'type', - value: 'value', - stackTrace: st, - ); - return SentryEvent(exceptions: [ex]); + return SentryEvent(threads: [SentryThread(stacktrace: st)]); } class Fixture {