sendReport method

void sendReport(
  1. String message,
  2. String date, {
  3. dynamic onError(
    1. ReportModel data,
    2. String deviceInfo
    )?,
  4. Function? onSuccessSync,
})

Implementation

void sendReport(String message, String date,
    {Function(ReportModel data, String deviceInfo)? onError,
    Function? onSuccessSync}) async {
  assert(chatId.isNotEmpty);
  assert(botToken.isNotEmpty);
  var deviceInfo = (await _device.getDeviceInfo());
  var clipped = deviceInfo.ellipsize(800);

  var data = ReportModel(
      chartId: chatId,
      text:
          "<==============DEVICE=================> \n\n$clipped\n\n\n\n<==============ERROR=================>\n\n\n${message.ellipsize(3000)} \n\n\n$date");
  try {
    var response =
        await _client.post("bot$botToken/sendMessage", data: data.toJson());
    if (response.isSuccessful) onSuccessSync?.call();
  } catch (e) {
    onError?.call(data, deviceInfo);
  }
}