如何获得谷歌Analytics(分析)V4报告未捕获的异常(崩溃),我的应用程序? [英] How to get Google Analytics v4 to report uncaught exceptions (crashes) for my app?

查看:1088
本文介绍了如何获得谷歌Analytics(分析)V4报告未捕获的异常(崩溃),我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在敲打我的头靠在墙上的这一个小时。该 V4文档对于谷歌Analytics(分析)指定2种不同的方法让你的应用程序,以报告未捕获的异常。我可以既不工作。在这两种情况下,我看到这样的LogCat中线路时,我引发未捕获的异常发生在我的应用程序(用我自己的code哑名):

I've been banging my head against a wall for hours on this one. The v4 docs for Google Analytics specify 2 different ways of getting your app to report uncaught exceptions. I can get neither to work. In both cases I see lines like this in LogCat when I trigger the uncaught exception to occur in my app (using dummy names for my own code):

08-17 17:33:30.248: V/GAV4(8968): Thread[main,5,main]: Tracking Exception: MyException (@MyClass:myMethod:143) {main}
08-17 17:33:30.248: V/GAV4(8968): Thread[main,5,main]: Dispatch call queued. Dispatch will run once initialization is complete.
08-17 17:33:30.248: V/GAV4(8968): Thread[main,5,main]: Passing exception to original handler.

...后面是堆栈跟踪我的异常,然后最后:

...followed by the stacktrace for my exception and then finally:

08-17 17:33:44.282: I/Process(8968): Sending signal. PID: 8968 SIG: 9

从LogCat中,它看起来像GA实际上从未调度例​​外,谷歌的服务器!

From LogCat it looks like GA never actually dispatches the exception to Google's servers!

如果有人已经设法获得未捕获的异常被报道在他们的谷歌Analytics(分析)控制台,将是非常美妙的,如果他们能与我们,他们是如何做到的分享,谢谢。我见过的其他人所以用这样的查询(例如,这里和<一href="http://stackoverflow.com/questions/23854534/analytics-v4-uncaught-exceptions-not-working">here)但没有确认捕获的异常被报道。

If someone has managed to get uncaught exceptions being reported in their Google Analytics Console it would be fantastic if they could share with us how they did it, please. I've seen other people on SO with queries like this (e.g., here and here) but no confirmation that uncaught exceptions are being reported.

我有屏幕视图显示了在GA控制台,所以我必须做一些正确的事情。但是,并非未捕获的异常。我假设一要根据行为>崩溃和异常寻找他们,我已经设定结束日期,今天,包括(它似乎被默认设置为昨天)。最后,在我的analytics_global_config.xml我有:

I've got screen views showing up in the GA Console so I must be doing something right. But not uncaught exceptions. I'm assuming one should be looking for them under Behavior > Crashes and Exceptions, and I've set the end date to include today (it seems to be set to yesterday by default). Finally, in my analytics_global_config.xml I have:

<integer name="ga_dispatchPeriod">1</integer>

,因为否则默认为1800秒,在这种情况下,我认为异常不会在GA控制台可以看出至少30分钟后,他们发生后。 ga_dryRun 是假的了。

推荐答案

由于@xitx好心指出,它看起来像的有更高版本安装在人的设备上的谷歌播放服务库的错误。因为当我跑我现有的code模拟器上进行一个比较旧的设备(API 9,和presumably运行旧谷歌播放服务库)崩溃的没有报告给GA控制台自动。下面是LogCat中说,坠机发生时:

As @xitx kindly pointed out, it looks like there's a bug in later versions of the Google Play Services library installed on people's devices. Because when I ran my existing code on an emulator for a relatively old device (API 9, and presumably running an old Google Play Services library) the crash did get reported to GA's console automatically. Here's what LogCat said when the crash occurred:

08-31 12:27:59.522: V/GAV4(335): Thread[GAThread,5,main]: Sending hit to store  PATH: https:  PARAMS: ul=en-us,  ht=1409484468454,  sr=480x800,  a=746864705,  sf=100.0,  aid=com.redula.vsavings,  cid=32da19a1-7e15-4c83-aaa9-f3f1d502b775,  av=1.2,  v=1,  t=exception,  an=Savings Organiser,  tid=UA-XXXXXXXX,  exd=NullPointerException (@HomeActivity:connectToInAppBillingService:202) {main},  _u=.2nKKhAAAL,  exf=1,  
08-31 12:27:59.622: V/GAV4(335): Thread[GAThread,5,main]: PowerSaveMode initiated.
08-31 12:27:59.652: V/GAV4(335): Thread[GAThread,5,main]: PowerSaveMode terminated.
08-31 12:27:59.652: V/GAV4(335): Thread[GAThread,5,main]: Dispatch running...
08-31 12:27:59.702: V/GAV4(335): Thread[GAThread,5,main]: User-Agent: GoogleAnalytics/3.0 (Linux; U; Android 2.3.1; en-us; sdk Build/GSI11)
08-31 12:27:59.702: V/GAV4(335): Host: ssl.google-analytics.com
08-31 12:27:59.702: V/GAV4(335): GET /collect?ul=en-us&ht=1409484468454&sr=480x800&a=746864705&sf=100.0&aid=com.redula.vsavings&cid=32da19a1-7e15-4c83-aaa9-f3f1d502b775&av=1.2&v=1&t=exception&an=Savings+Organiser&tid=UA-XXXXXXX&exd=NullPointerException+%28%40HomeActivity%3AconnectToInAppBillingService%3A202%29+%7Bmain%7D&_u=.2nKKhAAAL&_v=ma4.0.2&exf=1&qt=11249&z=2 HTTP/1.1
08-31 12:28:00.482: V/GAV4(335): Thread[GAThread,5,main]: sent 1 of 1 hits
08-31 12:28:00.492: V/GAV4(335): Thread[GAThread,5,main]: PowerSaveMode initiated.
08-31 12:32:48.562: I/Process(335): Sending signal. PID: 335 SIG: 9

这是什么GA控制台中一分钟左右的崩溃显示:

And this is what the GA Console showed within a minute or so of the crash:

我知道你只能得到堆栈跟踪的第一行,但会为我做的现在。其他各种人都有自己的办法获取整个堆栈跟踪(见上文@ xitx的意见和这里为例)。

I know you only get the first line of the stacktrace but that will do for me for now. Various other people have their own approaches for getting the whole stacktrace (see @xitx's comments above and here for example).

所以,我打算用我现有的code,等待谷歌运送修复他们的错误,在谷歌Play业务的更高版本。我的应用程序应该再正常工作,是一旦他们的解决方案发布。

So I plan to use my existing code and wait for Google to ship the fix to their bug in a later version of Google Play Service. My app should then work as-is once their fix is released.

有关的记录,我在我的跟踪器的XML文件(RES / XML / app_tracker_config.xml)使用这样的:

For the record, I am using this in my tracker's XML file (res/xml/app_tracker_config.xml):

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

我getTracker()实现的:

My getTracker() implementation:

public class MyApp extends Application {

 private static Tracker tracker = null;

 synchronized Tracker getTracker() {
    if (tracker == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        analytics.enableAutoActivityReports(this);
        tracker = analytics.newTracker(R.xml.app_tracker_config);
        tracker.enableAdvertisingIdCollection(true);
    }
    return tracker;
 }
}

然后在的onCreate()为我的主屏幕上的活动只是我这个初始化GA:

Then in onCreate() for my home screen's activity I just do this to initialise GA:

((MyApp) getApplication()).getTracker();

修改(额外的信息):全球配置文件,RES / XML / analytics_global_config.xml:

EDIT (extra info): Global config file, res/xml/analytics_global_config.xml:

<?xml version="1.0" encoding="utf-8"?>
  <resources>
    <string name="ga_logLevel">verbose</string>
    <integer name="ga_dispatchPeriod">1</integer>
    <bool name="ga_dryRun">false</bool>
</resources>

我的应用程序的清单引用此文件中的应用这个子标签元素:

    <meta-data
        android:name="com.google.android.gms.analytics.globalConfigResource"
        android:resource="@xml/analytics_global_config" />

这篇关于如何获得谷歌Analytics(分析)V4报告未捕获的异常(崩溃),我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆