digest method
Digests the provided event.
This is used to digest the provided event and send it to the AppFit dashboard.
Before any event is sent to the AppFit dashboard, it is first added to the cache.
If the event is successfully sent to the AppFit dashboard, it is removed from the cache,
otherwise it will be retried later.
Implementation
Future<void> digest(AppFitEvent event) async {
final rawEvent = await _createRawEvent(event);
final result = await _apiClient.track(rawEvent);
// If the network requests succeeds, remove the event from the cache
// otherwise, we want to add it to the cache
switch (result) {
case true:
// For now, so nothing
break;
case false:
_cache.add(event);
break;
}
}