captureTransaction method
Implementation
@internal
Future<SentryId> captureTransaction(
SentryTransaction transaction, {
Scope? scope,
SentryTraceContextHeader? traceContext,
}) async {
SentryTransaction? preparedTransaction =
_prepareEvent(transaction) as SentryTransaction;
if (scope != null) {
preparedTransaction =
await scope.applyToEvent(preparedTransaction) as SentryTransaction?;
} else {
_options.logger(
SentryLevel.debug, 'No scope to apply on transaction was provided');
}
// dropped by scope event processors
if (preparedTransaction == null) {
return _sentryId;
}
preparedTransaction = await _runEventProcessors(
preparedTransaction,
eventProcessors: _options.eventProcessors,
) as SentryTransaction?;
// dropped by event processors
if (preparedTransaction == null) {
return _sentryId;
}
preparedTransaction =
await _runBeforeSend(preparedTransaction) as SentryTransaction?;
// dropped by beforeSendTransaction
if (preparedTransaction == null) {
return _sentryId;
}
preparedTransaction = _eventWithoutBreadcrumbsIfNeeded(preparedTransaction);
final attachments = scope?.attachments
.where((element) => element.addToTransactions)
.toList();
final envelope = SentryEnvelope.fromTransaction(
preparedTransaction,
_options.sdk,
dsn: _options.dsn,
traceContext: traceContext,
attachments: attachments,
);
final profileInfo = preparedTransaction.tracer.profileInfo;
if (profileInfo != null) {
envelope.items.add(profileInfo.asEnvelopeItem());
}
final id = await captureEnvelope(envelope);
return id ?? SentryId.empty();
}