8

The stack trace is crucial to fix problems. In Android you can find nice reports in the Play store console. Unless you use Google Analytics V2. In this case Analytics seems to swallow the exceptions. Worse, Analytics seems to log only the first line of the exception and thus loosing the stacktrace. At least it is not shown in the error report.

Here's a snip from our analytics.xml:

<!-- Enable automatic exception tracking -->
<bool name="ga_reportUncaughtExceptions">true</bool>
<bool name="ga_debug">false</bool>

See also here: https://developers.google.com/analytics/devguides/collection/android/v2/exceptions#easytracker

So, could there be something missing/wrong in our app?

Markus Junginger
  • 6,950
  • 31
  • 52

3 Answers3

15

As previous answer (user857661) says, see the Google Analytics docs on creating a new ExceptionReporter, or see my blog post on how to assign a custom ExceptionParser into the default handler.

Dan Dar3
  • 1,199
  • 13
  • 23
  • 2
    Excellent custom Parser Dan! Works like a charm! – Alan Poggetti Mar 13 '13 at 17:34
  • According to [changelog](https://developers.google.com/analytics/devguides/collection/android/changelog) starting from version 2.0b3 there's StandardExceptionReporter that can be used – mente Jun 12 '13 at 07:03
  • @mente A good point, although I think you meant StandardExceptionParser. You can decompile the sources with say JD-GUI and look how it's implemented, or instantiate it directly - it seems to produce some useful information, but not a whole lot, e.g.
    `StandardExceptionParser standardExceptionParser = new StandardExceptionParser(this, null); Log.e("TEST", standardExceptionParser.getDescription(Thread.currentThread().getName(), new RuntimeException("Testing StandardExceptionParser stack trace")));`
    Outputs = `RuntimeException (@MainActivity:onCreate:29) {main}`
    – Dan Dar3 Jan 05 '14 at 01:39
  • @Nemi The idea should work with v3 as well (in fact I know cause I migrated a project or two to it), but other things have changed since, like how to programmatically send a caught exception - I will look at writing a new post that will work with v3.01 https://developers.google.com/analytics/devguides/collection/android/v3/migration#ez2 – Dan Dar3 Jan 05 '14 at 01:47
  • 1
    What about the big read warning here: https://developers.google.com/analytics/devguides/collection/android/v4/exceptions ? There is a certain risk of violating the privacy guidelines if care is not taken to filter out the actual exception messages... – sfThomas Sep 05 '14 at 14:10
  • @sfThomas Interesting bit... Although probably unlikely for an uncaught exception to contain personally identifiable information in the exception message - a responsible developer would most likely treat sensitive areas as such and catch the exceptions and display useful information to the user rather than let them be reported through Analytics package. Technically it should be possible to leave out / remove the message from the stack trace in the ExceptionParser implementation, I don't know, looking for the ":" after the exception class name and the first "at". – Dan Dar3 Sep 08 '14 at 16:35
1

If you want to see complete exception trace on GA V3.0 onwards, send your exception like

String exceptionTrace = "Any custom string as well " + getExceptionDescription(Ex);    
EasyTracker.getInstance(context).send(MapBuilder.createException(exceptionTrace, false).build());
Pawan Maheshwari
  • 15,088
  • 1
  • 48
  • 50
0

You can overwrite the ExceptionParser class to get more info about the stacktrace: https://developers.google.com/analytics/devguides/collection/android/v2/exceptions#exception-parser. I am not sure if the stacktrace will be very readable in the Google Analyctics web interface though.

Arian
  • 90
  • 8
  • 2
    Might be a workaround. The strange thing is that the doc says "The description field is automatically populated using the stack trace." It seems to have the exception message only though. – Markus Junginger Dec 28 '12 at 10:49