Android Google Analytics Exception logging

社会主义新天地 提交于 2019-12-24 03:22:30

问题


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.


回答1:


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




回答2:


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":

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

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



来源:https://stackoverflow.com/questions/23753079/android-google-analytics-exception-logging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!