sendEvent method

  1. @override
Future<void> sendEvent({
  1. required String eventName,
  2. required String appToken,
  3. required String identifier,
  4. required String registration,
  5. Map<String, dynamic> eventValues = const {},
  6. bool conversionEvent = false,
  7. double conversionValue = 0,
  8. String conversionNotId = '',
})
override

Implementation

@override
Future<void> sendEvent({
  required String eventName,
  required String appToken,
  required String identifier,
  required String registration,
  Map<String, dynamic> eventValues = const {},
  bool conversionEvent = false,
  double conversionValue = 0,
  String conversionNotId = '',
}) async {
  final eventRequest = NewEventRequest(
    appToken: appToken,
    identifier: identifier,
    registration: registration,
    eventName: eventName,
    eventValues: eventValues,
    conversionEvent: conversionEvent,
    conversionNotId: conversionNotId,
    conversionValue: conversionValue,
  );
  final event = Event(newEventRequest: eventRequest);

  final payload = eventToJson(event);

  final resp = await http.post(
    Uri.parse(AppConstants.baseUrl + '/events/newEvent/'),
    headers: {
      'Content-Type': 'application/json; charset=UTF-8',
      if (keyAuthorization.isNotEmpty)
        'Authorization': 'key=$keyAuthorization'
    },
    body: payload,
  );
  if (InngageProperties.getDebugMode()) {
    logger.i(resp.request);
    logger.i(payload);
    logger.i(resp.body);
  }

  if (resp.statusCode != 200) {
   debugPrint(
      'Unfortunately it was not possible send an event',
    );
  }
}