recordEvents method
Records what the app's paywall and shop saw, for Payments' Reports: the paywall or the shop shown and what opened it, a plan or pack picked, a purchase started or cancelled in the store's sheet. At most 50 at a time. Each event's FFXPurchaseEvent.id makes a repeat record nothing, so a batch can be sent again after a lost answer. Answers how many were new: only the production environment's are kept, and the emulator keeps none.
Implementation
Future<int> recordEvents(List<FFXPurchaseEvent> events) async {
final res = await _http.request(
'POST',
'/v1/purchases/events',
body: {
'events': [for (final event in events) event._toJson()],
},
);
return ((res.body['data'] as Map)['recorded'] as num).toInt();
}