process method

Future<RawEvent?> process(
  1. RawEvent incomingEvent
)

Implementation

Future<RawEvent?> process(RawEvent incomingEvent) async {
  // apply .before first, ensuring all .before phases for all events triggered
  // in a synchronous block are finished before moving onto the enrichment phase

  final beforeResult = await _queue.enqueue(() async {
    return await applyPlugins(PluginType.before, incomingEvent);
  });

  if (beforeResult == null) {
    return null;
  }

  // .enrichment here is akin to source middleware in the old analytics-ios.
  final enrichmentResult = await applyPlugins(PluginType.enrichment, beforeResult);

  if (enrichmentResult == null) {
    return null;
  }

  // once the event enters a destination, we don't want
  // to know about changes that happen there. those changes
  // are to only be received by the destination.
  await applyPlugins(PluginType.destination, enrichmentResult);

  // apply .after plugins ...
  final afterResult = await applyPlugins(PluginType.after, enrichmentResult);

  return afterResult;
}