Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- Breadcrumbs for database operations ([#1656](https://github.com/getsentry/sentry-dart/pull/1656))
- Add `attachScreenshotOnlyWhenResumed` to options ([#1700](https://github.com/getsentry/sentry-dart/pull/1700))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../screenshot/sentry_screenshot_widget.dart';
import '../sentry_flutter_options.dart';
import 'package:flutter/rendering.dart';
import '../renderer/renderer.dart';
import 'package:flutter/widgets.dart' as widget;

class ScreenshotEventProcessor implements EventProcessor {
final SentryFlutterOptions _options;
Expand Down Expand Up @@ -38,6 +39,14 @@ class ScreenshotEventProcessor implements EventProcessor {
return event;
}

if (_options.attachScreenshotOnlyWhenResumed &&
widget.WidgetsBinding.instance.lifecycleState !=
AppLifecycleState.resumed) {
_options.logger(SentryLevel.debug,
'Only attaching screenshots when application state is resumed.');
return event;
}

final bytes = await _createScreenshot();
if (bytes != null) {
hint?.screenshot = SentryAttachment.fromScreenshotData(bytes);
Expand Down
3 changes: 3 additions & 0 deletions flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class SentryFlutterOptions extends SentryOptions {
/// The quality of the attached screenshot
SentryScreenshotQuality screenshotQuality = SentryScreenshotQuality.high;

/// Only attach a screenshot when the app is resumed.
bool attachScreenshotOnlyWhenResumed = false;

/// Enable or disable automatic breadcrumbs for User interactions Using [Listener]
///
/// Requires adding the [SentryUserInteractionWidget] to the widget tree.
Expand Down