简体   繁体   English

使用Easytracker进行谷歌分析时未捕获的异常

[英]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 使用EasyTracker
To automatically track all uncaught exceptions in your app using EasyTracker, add this line to your analytics.xml file: 要使用EasyTracker自动跟踪应用中所有未捕获的异常,请将此行添加到您的analytics.xml文件中:

<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. 使用自动异常跟踪跟踪异常后,EasyTracker会将异常传递给Thread的默认异常处理程序。

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. 通过自动异常跟踪跟踪的所有异常都会在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: 但是当我收到UncaughtException并且应用程序崩溃时,在Google Analytics描述中,它只显示:

An error occured while executing doInBackground()

not the Stack Trace as mentioned in the above points. 不是上面提到的堆栈跟踪。 Any thing needs to be added?? 什么东西需要添加?

Thank You 谢谢

I use an open source tool called ACRA for uncaught exception reporting. 我使用一个名为ACRA的开源工具来进行未捕获的异常报告。 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. 它提供了比Google Analytics或Flurry更多的信息,并向Google文档提交报告,您可以为每个报告添加电子邮件通知。

I use Google Analytics for the rest. 我其余部分使用Google Analytics。

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. 希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM