diff --git a/CHANGELOG.md b/CHANGELOG.md index e381de8999..d4eab3f8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -156,6 +156,11 @@ - Now the device context from Android is available in `BeforeSendCallback` - Set ip_address to {{auto}} by default, even if sendDefaultPII is disabled ([#1665](https://github.com/getsentry/sentry-dart/pull/1665)) - Instead use the "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io + +### Features + +- Add support for exception aggregates ([#1866](https://github.com/getsentry/sentry-dart/pull/1866)) +- Add support for exception aggregates for PlatformExceptions from Android ([#1998](https://github.com/getsentry/sentry-dart/pull/1998)) ### Fixes diff --git a/flutter/lib/src/event_processor/android_platform_exception_event_processor.dart b/flutter/lib/src/event_processor/android_platform_exception_event_processor.dart index 6570dedd81..51e238ca1f 100644 --- a/flutter/lib/src/event_processor/android_platform_exception_event_processor.dart +++ b/flutter/lib/src/event_processor/android_platform_exception_event_processor.dart @@ -95,9 +95,22 @@ class AndroidPlatformExceptionEventProcessor implements EventProcessor { jvmThreads.add(first); } + final eventExceptions = event.exceptions?.map((e) { + if (event.throwable is! PlatformException) { + return e; + } + return e.copyWith( + mechanism: Mechanism( + type: 'chained', + exceptionId: jvmExceptions.length, + parentId: 0, + ), + ); + }); + return event.copyWith( exceptions: [ - ...?event.exceptions, + ...?eventExceptions, ...jvmExceptions, ], threads: [ @@ -140,15 +153,18 @@ class _JvmExceptionFactory { ...?jvmException.suppressed, ]; - return jvmExceptions.map((exception) { - return exception.toSentryException(nativePackageName); + return jvmExceptions.asMap().entries.map((indexedException) { + return indexedException.value + .toSentryException(nativePackageName, indexedException.key); }).toList(growable: false); } } extension on JvmException { MapEntry toSentryException( - String nativePackageName) { + String nativePackageName, + int index, + ) { String? exceptionType; String? module; final typeParts = type?.split('.'); @@ -170,6 +186,12 @@ extension on JvmException { stackTrace: SentryStackTrace( frames: stackFrames.reversed.toList(growable: false), ), + mechanism: Mechanism( + type: index == 0 ? "sentry-flutter" : "chained", + exceptionId: index, + parentId: index == 0 ? null : index - 1, + isExceptionGroup: index == 0 ? true : null, + ), ); String threadName;