exportEvent method

  1. @override
Future<ResultDart<void, TelemetryException>> exportEvent(
  1. TelemetryEvent event
)
override

Export an event to telemetry backend.

The event will be queued and sent asynchronously.

Implementation

@override
Future<ResultDart<void, TelemetryException>> exportEvent(
  TelemetryEvent event,
) async {
  if (!_isInitialized) {
    return const Failure(
      TelemetryException(
        message: 'Telemetry not initialized',
        code: 'NOT_INITIALIZED',
      ),
    );
  }

  return _retry.execute(
    () async {
      final shouldFlush = _buffer.addEvent(event);
      if (shouldFlush) {
        _exportBatch();
      }
      return const Success(unit);
    },
    operationName: 'exportEvent',
  );
}