Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACRA sending a custom data REPORTFIELD

How to configure a CUSTOM_DATA field with a couchdb ?

I want to set a config value to send with with the error. In the back end I have a couch db with an ACLARYZER web app.

This is the code on my Application.class in Android where I defined this custom data value.

@ReportsCrashes(
    formUri = "https://user.cloudant.com/acra-report/_design/acra-storage/_update/report",
    reportType = HttpSender.Type.JSON,
    httpMethod = HttpSender.Method.POST,
    formUriBasicAuthLogin = "user",
    formUriBasicAuthPassword = "pass",
    formKey = "", // This is required for backward compatibility but not used
    customReportContent = {
            ReportField.APP_VERSION_CODE,
            ReportField.APP_VERSION_NAME,
            ReportField.ANDROID_VERSION,
            ReportField.PACKAGE_NAME,
            ReportField.REPORT_ID,
            ReportField.BUILD,
            ReportField.STACK_TRACE,
            ReportField.CUSTOM_DATA
    },
    mode = ReportingInteractionMode.TOAST,
    resToastText = R.string.reporte_error
)
public class my_applicaction  extends Application{

 @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
    ACRA.init(my_applicaction.this);
    ACRA.getErrorReporter().putCustomData("myKey", "myValue");
    ACRA.getErrorReporter().handleException(null);


}
}

Now the question is how to add the value in the couch db to get this custom data field. Or I have to define the custom data in the ACRALYZER?

thanks

like image 975
exequielc Avatar asked Mar 13 '23 20:03

exequielc


1 Answers

Finally it's more easy than I can imagine.

Simply put this line with every CUSTOM_DATA

 ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1");

Then your code is somthing like this.

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    ACRA.init(Application.this);
    ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1");
    ACRA.getErrorReporter().putCustomData("NAME_VALUE2", "VALUE2");
    ACRA.getErrorReporter().putCustomData("NAME_VALUE3", "VALUE3");
}

The ACLARYZER do the rest.

like image 194
exequielc Avatar answered Mar 28 '23 06:03

exequielc