Android Google Analytics Exception logging

2019-07-19 18:12发布

I'm using Google Analytics SDK v4 for Android to record the exceptions. I followed the sample app but I could see no exceptions getting registered in the dashboard.

I wrote the code as below

/*exception tracking */
// Get tracker.
Tracker t2 =
  ((MyApp) this.getApplication()).getTracker(TrackerName.APP_TRACKER);

// Build and send exception.
int a = 0;
String exceptionStr = "";

try{
  int b = a/0;
}catch(Exception ex){
  exceptionStr = ex.toString();
}finally{
  t2.send(new HitBuilders.ExceptionBuilder()
          .setDescription(exceptionStr + ":" + "In Main screen")
          .setFatal(true)
          .build());

  GoogleAnalytics.getInstance(this.getApplicationContext()).dispatchLocalHits();

  Log.v("Manual logging", "finished for analytics");
}

"Manual logging", "finished for analytics" is showing up in the logcat window but when I check the analytics there is nothing registered.

BTW the user screen flow etc working just fine with the SDK. Just the exception logging is not working.

2条回答
我只想做你的唯一
2楼-- · 2019-07-19 19:10

Data can take some time to show up in the GoogleAnalytics dashboard. Give it some time, it will show up under exceptions.

查看更多
Luminary・发光体
3楼-- · 2019-07-19 19:11

This works for me but I'm using advanced crash report implementation.

Go to Behavior --> Crashes & Exceptions

In the top right drop-down (below date range selector), select "Faster Response, less Precision" option instead of the default "Slower Response, Greater Precision":

Faster Response, less Precision

Also, additionally, you can click on the "Refresh Report" button in the lower right corner if the last reported generated is stale:

"Refresh Report"

If none of the above work, then wait for 24 hours for GA to generate the reports :)

查看更多
登录 后发表回答