sendEventRequest function
Implementation
Future<http.Response> sendEventRequest(
List<EventRequest> eventRequest,
String token,
) async {
Debug.print("EventRequest: ${jsonEncode(eventRequest)}");
final List<Map<String, dynamic>> eventRequestJsonList =
eventRequest.map((request) => request.toJson()).toList();
final headers = <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer $token'
};
final body = jsonEncode({'events': eventRequestJsonList});
final response = await http.post(
Uri.parse('https://app.perceptinsight.com/track/v1/event'),
headers: headers,
body: body,
);
Debug.print("EventRequest Response: ${response.body}");
return response;
}