Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught Exception in google analytics using Easytracker

I am using just this in every Activity:

@Override
public void onStart() {
    super.onStart();
    EasyTracker.getInstance().activityStart(this);
}

@Override
public void onStop() {
    super.onStop();
    EasyTracker.getInstance().activityStop(this);
}

and going through this doc

I found out:

Using EasyTracker
To automatically track all uncaught exceptions in your app using EasyTracker, add this line to your analytics.xml file:

<bool name="ga_reportUncaughtExceptions">true</bool>

After tracking an exception using automatic exception tracking, EasyTracker will pass the exception on to the Thread's default exception handler.

When using automatic exception tracking, keep in mind the following:

  1. All exceptions tracked via automatic exception tracking are reported as fatal in Google Analytics.
  2. The description field is automatically populated using the stack trace.

But when i get an UncaughtException and the application crashes, in the Google Analytics description, it just shows:

An error occured while executing doInBackground()

not the Stack Trace as mentioned in the above points. Any thing needs to be added??

Thank You

like image 338
Archie.bpgc Avatar asked Jan 02 '13 06:01

Archie.bpgc


2 Answers

I use an open source tool called ACRA for uncaught exception reporting. It provides significantly more information than Google Analytics or Flurry do, and submits reports to a Google Doc, to which you can get email notification for every report added.

I use Google Analytics for the rest.

like image 75
Amir Uval Avatar answered Sep 28 '22 15:09

Amir Uval


You should use a custom exception parser to get the whole stacktrace

import org.apache.commons.lang3.exception.ExceptionUtils;
import com.google.analytics.tracking.android.ExceptionParser;

public class AnalyticsExceptionParser implements ExceptionParser {

public String getDescription(String p_thread, Throwable p_throwable) {
    return "Thread: " + p_thread + ", Exception: " +     ExceptionUtils.getStackTrace(p_throwable);
}
}

and set this as default in you activity, like

public void setupGoogleAnalyticsCrashReportParser() {

    EasyTracker.getInstance().setContext(this);

    Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    if (uncaughtExceptionHandler instanceof ExceptionReporter) {
        ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
        exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
    }
}

Hope this helps to someone.

like image 32
Analizer Avatar answered Sep 28 '22 17:09

Analizer