Skip to content

Report Destinations

F43nd1r edited this page May 19, 2021 · 16 revisions

Documentation has moved! Visit acra.ch for versions 5.8 forward


Introduction

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.

Contents

Choosing a content type

All built-in ReportSenders 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 with:

@AcraCore(reportFormat=StringFormat.JSON)

Sending reports via HTTP

Just use the uri and httpMethod parameter of the @AcraHttpSender annotation in your Application class :

@AcraHttpSender(uri = "http://yourserver.com/yourscript",
                basicAuthLogin = "yourlogin", // optional
                basicAuthPassword = "y0uRpa$$w0rd", // optional
                httpMethod = HttpSender.Method.POST)
public class MyApplication extends Application {
...

The uri can be over HTTPS (even with self signed certificates) and can require a BASIC HTTP authentication (pass your login and password with basicAuthLogin and basicAuthPassword).

The method can be either POST or PUT. Set this depending on your backends requirements. In PUT mode, ACRA adds the Report ID at the end of uri automatically.

Adjusting the socket timeout

The default socket timeout for ACRA is 8 seconds and if your server does not respond quickly enough then ACRA will timeout the socket connection and you can experience this as empty reports on the server.

If you are experiencing timeouts when sending reports, you can adjust the socket timeout with the socketTimeout option (time in milliseconds).

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 mailTo setting from @AcraMailSender:

@AcraMailSender(mailTo = "[email protected]")
public class MyApplication extends Application {
...

Emails are sent with an ACTION_SEND 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 ReportSenders.

public class YourOwnSender implements ReportSender {

    ...

    @Override
    public void send(Context context, CrashReportData report) throws ReportSenderException {
        // Iterate over the CrashReportData instance and do whatever
        // you need with each pair of ReportField key / String value
    }
}

public class YourOwnSenderfactory implements ReportSenderFactory {

    // NB requires a no arg constructor.

    @Override
    public ReportSender create(Context context, ACRAConfiguration config) {
        ...
        return new YourOwnSender(someConfigPerhaps);
    }

    @Override
    public boolean enabled(@Nonnull CoreConfiguration coreConfig) {
        return true;
    }
}

Registering your sender

  • Alternative 1

See Custom extensions

  • Altnerative 2

Set

@AcraCore(reportSenderFactoryClasses = YourOwnSenderfactory.class)

Note: You have to use this alternative if you want to use multiple ReportSenders