sendToSentryWithException function

  1. @visibleForTesting
OnFeedbackCallback sendToSentryWithException({
  1. Hub? hub,
  2. String? name,
  3. String? email,
  4. Object? exception,
  5. StackTrace? stackTrace,
})

Implementation

@visibleForTesting
OnFeedbackCallback sendToSentryWithException({
  Hub? hub,
  String? name,
  String? email,
  Object? exception,
  StackTrace? stackTrace,
}) {
  final realHub = hub ?? HubAdapter();

  return (UserFeedback feedback) async {
    final id = await realHub.captureException(
      exception,
      stackTrace: stackTrace,
      withScope: (scope) {
        scope.addAttachment(SentryAttachment.fromUint8List(
          feedback.screenshot,
          'screenshot.png',
          contentType: 'image/png',
        ));
      },
    );
    await realHub.captureUserFeedback(SentryUserFeedback(
      eventId: id,
      email: email,
      name: name,
      comments: feedback.text + '\n${feedback.extra.toString()}',
    ));
  };
}