captureFeedback method

Future<SentryId> captureFeedback(
  1. SentryFeedback feedback, {
  2. Hint? hint,
  3. ScopeCallback? withScope,
})

Captures the feedback.

Implementation

Future<SentryId> captureFeedback(
  SentryFeedback feedback, {
  Hint? hint,
  ScopeCallback? withScope,
}) async {
  var sentryId = SentryId.empty();

  if (!_isEnabled) {
    _options.logger(
      SentryLevel.warning,
      "Instance is disabled and this 'captureFeedback' call is a no-op.",
    );
  } else {
    final item = _peek();
    late Scope scope;
    final s = _cloneAndRunWithScope(item.scope, withScope);
    if (s is Future<Scope>) {
      scope = await s;
    } else {
      scope = s;
    }

    try {
      sentryId = await item.client.captureFeedback(
        feedback,
        hint: hint,
        scope: scope,
      );
    } catch (exception, stacktrace) {
      _options.logger(
        SentryLevel.error,
        'Error while capturing feedback',
        exception: exception,
        stackTrace: stacktrace,
      );
    }
  }
  return sentryId;
}