Skip to main content

Senders

The following sections details the possible destinations for your crash reports: server backend, email, or any other destination you can imagine (if you implement the sender). And you can even send reports to multiple destinations.

Choosing a content type

All official report senders support two types of report formats: StringFormat.JSON and StringFormat.KEY_VALUE_LIST (form-data-compliant for http). Choose whichever your backend requires / which you like best:

initAcra {
reportFormat = StringFormat.JSON
}

Sending reports via HTTP

The most convenient way to send your report with no necessary user interaction is via HTTP.

httpSender {
//required. Https recommended
uri = "https://your.server.com/report"
//optional. Enables http basic auth
basicAuthLogin = "acra"
//required if above set
basicAuthPassword = "password"
// defaults to POST
httpMethod = HttpSender.Method.POST
//defaults to 5000ms
connectionTimeout = 5000
//defaults to 20000ms
socketTimeout = 20000
// defaults to false
dropReportsOnTimeout = false
//the following options allow you to configure a self signed certificate
keyStoreFactoryClass = MyKeyStoreFactory::class.java
certificatePath = "asset://mycert.cer"
resCertificate = R.raw.mycert
certificateType = "X.509"
//defaults to false. Recommended if your backend supports it
compress = false
//defaults to all
tlsProtocols = arrayOf(TLS.V1_3, TLS.V1_2, TLS.V1_1, TLS.V1)
}

In PUT mode, ACRA adds the Report ID at the end of uri automatically.

See also Backends

Sending reports by email

For some applications, sending reports to a http based solution is not an option. The problem is that they require the INTERNET permission.

For pure offline applications, users might even be frightened to grant this permission and can be suspicious about the real goal of the app or the developer.

To get crash reports without granting INTERNET permission, you can use the mail sender:

mailSender {
//required
mailTo = "acra@yourserver.com"
//defaults to true
reportAsFile = true
//defaults to ACRA-report.stacktrace
reportFileName = "Crash.txt"
//defaults to "<applicationId> Crash Report"
subject = getString(R.string.mail_subject)
//defaults to empty
body = getString(R.string.mail_body)
}

Emails are sent with an ACTION_SEND_MULTIPLE intent. This means that the following steps are required for the application user before any report is sent:

  • pick preferred email client (if no default app set)
  • review & actually send the email

Implementing your own sender

You can implement your own ReportSender and configure ACRA to use that instead of or in addition to other senders.

class YourOwnSender : ReportSender {

override fun send(context: Context, report: CrashReportData) {
// Iterate over the CrashReportData instance and do whatever
// you need with each pair of ReportField key / String value
}
}

class YourOwnSenderfactory : ReportSenderFactory {

// requires a no arg constructor.

override fun create(context: Context, config: ACRAConfiguration) : ReportSender {
return YourOwnSender()
}

//optional implementation in case you want to disable your sender in certain cases
override fun enabled(coreConfig : CoreConfiguration) : Boolean {
return true
}
}

Registering your sender

See Custom extensions.

You can also look at our example projects, which contain an example of a custom sender each.