Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android breadcrumbs on web #1378

Merged
merged 12 commits into from
Apr 11, 2023
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 28 additions & 0 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down