captureEvent method
Future<SentryId>
captureEvent(
- SentryEvent event, {
- Scope? scope,
- dynamic stackTrace,
- dynamic hint,
Reports an event
to Sentry.io.
Implementation
Future<SentryId> captureEvent(
SentryEvent event, {
Scope? scope,
dynamic stackTrace,
dynamic hint,
}) async {
if (_sampleRate()) {
_options.logger(
SentryLevel.debug,
'Event ${event.eventId.toString()} was dropped due to sampling decision.',
);
return _sentryId;
}
SentryEvent? preparedEvent = _prepareEvent(event, stackTrace: stackTrace);
if (scope != null) {
preparedEvent = await scope.applyToEvent(preparedEvent, hint);
} else {
_options.logger(SentryLevel.debug, 'No scope is defined');
}
// dropped by scope event processors
if (preparedEvent == null) {
return _sentryId;
}
preparedEvent = await _processEvent(
preparedEvent,
eventProcessors: _options.eventProcessors,
hint: hint,
);
// dropped by event processors
if (preparedEvent == null) {
return _sentryId;
}
final beforeSend = _options.beforeSend;
if (beforeSend != null) {
try {
preparedEvent = beforeSend(preparedEvent, hint: hint);
} catch (err) {
_options.logger(
SentryLevel.error,
'The BeforeSend callback threw an exception, error: $err',
);
}
if (preparedEvent == null) {
_options.logger(
SentryLevel.debug,
'Event was dropped by BeforeSend callback',
);
return _sentryId;
}
}
return _options.transport.send(preparedEvent);
}