applyPlugins method
Implementation
Future<RawEvent?> applyPlugins(PluginType type, RawEvent event) async {
RawEvent? result = event;
final plugins = _plugins[type];
if (plugins != null) {
for (var plugin in plugins) {
if (result != null) {
try {
final pluginResult = plugin.execute(result);
// Each destination is independent from each other, so we don't roll over changes caused internally in each one of their processing
if (type != PluginType.destination) {
result = await pluginResult;
}
} catch (error) {
reportInternalError(
PluginError("Destination ${(plugin as DestinationPlugin).key} failed to execute", error),
analytics: plugin.analytics);
if (plugin.type == PluginType.destination) {
log("Destination ${plugin.key} failed to execute: $error", kind: LogFilterKind.warning);
}
}
}
}
}
return result;
}