Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Nov 9, 2022
1 parent be87aa7 commit 16dede7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
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

- Feat: Screenshot Attachment ([#1088](https://github.com/getsentry/sentry-dart/pull/1088))

### Fixes

- Merging of integrations and packages ([#1111](https://github.com/getsentry/sentry-dart/pull/1111))
Expand Down
3 changes: 2 additions & 1 deletion flutter/lib/src/integrations/screenshot_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class ScreenshotIntegration implements Integration<SentryFlutterOptions> {
options.clientAttachmentProcessor =
ScreenshotAttachmentProcessor(options);
_options = options;

options.sdk.addIntegration('screenshotIntegration');
}
options.sdk.addIntegration('screenshotIntegration');
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class ScreenshotAttachmentProcessor implements SentryClientAttachmentProcessor {
ScreenshotAttachmentProcessor(this._options);

/// This is true when the SentryWidget is in the view hierarchy
bool get _attachScreenshot =>
bool get _hasSentryScreenshotWidget =>
sentryScreenshotWidgetGlobalKey.currentContext != null;

@override
Future<List<SentryAttachment>> processAttachments(
List<SentryAttachment> attachments, SentryEvent event) async {
if (event.exceptions == null &&
event.throwable == null &&
_attachScreenshot) {
_hasSentryScreenshotWidget) {
return attachments;
}
final renderer = _options.rendererWrapper.getRenderer();
Expand Down Expand Up @@ -60,8 +60,8 @@ class ScreenshotAttachmentProcessor implements SentryClientAttachmentProcessor {
}

final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
final bytes = byteData?.buffer.asUint8List() ?? Uint8List(0);
if (bytes.isNotEmpty) {
final bytes = byteData?.buffer.asUint8List();
if (bytes?.isNotEmpty == true) {
return bytes;
} else {
_options.logger(SentryLevel.debug,
Expand Down
2 changes: 2 additions & 0 deletions flutter/lib/src/screenshot/sentry_screenshot_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

/// Key which is used to identify the [RepaintBoundary]
@internal
final sentryScreenshotWidgetGlobalKey =
GlobalKey(debugLabel: 'sentry_screenshot_widget');

Expand Down
2 changes: 2 additions & 0 deletions flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class SentryFlutterOptions extends SentryOptions {
bool autoAppStart = true;

/// Automatically attaches a screenshot when capturing an error or exception.
///
/// Requires adding the [SentryScreenshotWidget] to the widget tree.
bool attachScreenshot = false;

@internal
Expand Down
2 changes: 1 addition & 1 deletion flutter/test/sentry_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void main() {
List<Integration> integrations = [];
Transport transport = MockTransport();

// Tests that iOS || macOS integrations aren't added on a browswer which
// Tests that iOS || macOS integrations aren't added on a browser which
// runs on iOS or macOS
await SentryFlutter.init(
(options) async {
Expand Down

0 comments on commit 16dede7

Please sign in to comment.