From 3334ac176f15a6d39b435960620ea9a4919aae79 Mon Sep 17 00:00:00 2001 From: mnordine Date: Tue, 11 Apr 2023 08:00:43 -0300 Subject: [PATCH] Fix Android breadcrumbs on web (#1378) Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Co-authored-by: Manoel Aranda Neto --- CHANGELOG.md | 6 ++++++ dart/lib/src/sentry_client.dart | 4 ++++ dart/test/sentry_client_test.dart | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0299191e0..9a7fe1d59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Fix breadcrumbs not being sent on Android web ([#1378](https://github.com/getsentry/sentry-dart/pull/1378)) + ## 7.4.1 ### Fixes diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index bd3ccc585..c4946ba70 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -468,6 +468,10 @@ class SentryClient { /// this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read /// the envelope. bool _shouldRemoveBreadcrumbs(SentryEvent event) { + if (_options.platformChecker.isWeb) { + return false; + } + final isAndroid = _options.platformChecker.platform.isAndroid; final enableScopeSync = _options.enableScopeSync; diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 4062f59b9..158c68487 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -1312,6 +1312,34 @@ void main() { expect((capturedEvent.breadcrumbs ?? []).isNotEmpty, true); }); + + test('web breadcrumbs exist on web Android devices', () async { + fixture.options.enableScopeSync = true; + fixture.options.platformChecker = MockPlatformChecker( + platform: MockPlatform.android(), + isWebValue: true, + ); + + final client = fixture.getSut(); + final event = SentryEvent(exceptions: [ + SentryException( + type: "type", + value: "value", + mechanism: Mechanism( + type: 'type', + handled: true, + ), + ), + ], breadcrumbs: [ + Breadcrumb(), + ]); + await client.captureEvent(event); + + final capturedEnvelope = (fixture.transport).envelopes.first; + final capturedEvent = await eventFromEnvelope(capturedEnvelope); + + expect((capturedEvent.breadcrumbs ?? []).isNotEmpty, true); + }); }); group('ClientReportRecorder', () {