使用Google Analytics iOS跟踪崩溃

时间:2013-08-29 06:29:50

标签: iphone ios crash google-analytics

您好我在Google Analytics之一使用了iPhone app。我正在跟踪应用安装,屏幕访问和点击事件。
现在,我想跟踪应用程序中crashes & exceptions的原因及其位置(按位置,我的意思是方法名称,行号或其他任何内容)。我已阅读谷歌提供的文件,但没有得到任何有用的信息。
任何人都可以帮我这个吗?任何一个例子都会非常感激。


更新: - 此处,我附上了GA信息中心的屏幕截图链接。

enter image description here

3 个答案:

答案 0 :(得分:7)

您可以发送回溯(已经过符号化)。 我设置sendUncaughtExceptions = FALSE并手动发送。

id tracker = [[GAI sharedInstance] defaultTracker];

NSString * model = [[UIDevice currentDevice] model];
NSString * version = [[UIDevice currentDevice] systemVersion];
NSArray * backtrace = [exception callStackSymbols];
NSString * description = [NSString stringWithFormat:@"%@.%@.%@.Backtrace:%@",
                          model,
                          version,
                          exception.description,
                          backtrace];

[tracker send:[[GAIDictionaryBuilder
                createExceptionWithDescription:description  // Exception description. May be truncated to 100 chars.
                withFatal:NO] build]];     

(型号和版本是可选的)

回溯将具有<编辑>但最重要的类和方法将是符号(崩溃发生的地方),你会知道在哪里

**编辑**

如何处理异常

  1. Detail explanation
  2. 下载示例“UncaughtExceptions.zip”
  3. UncaughtExceptionHandler.m 上,方法“ handleException:(NSException *)exception ”里面你可以做你想要的,在我的情况下,我有其他的方法验证例外,然后发送给GAI

答案 1 :(得分:1)

我尚未使用Google Analytics崩溃报告功能,但found this可能会有所帮助。

您可以使用Google Analytics(v2)报告未捕获的异常,即使用此代码崩溃

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GAI sharedInstance].sendUncaughtExceptions = YES; // Enable 

  // ... the rest of your code, include other GAI properties you want to set.
}

我不认为这些将是符号化崩溃报告,因为设备无法对其进行符号化。因此,您可能需要自己对收到的崩溃报告进行符号化,以了解导致此崩溃的代码中的行号。

查看Where can I view the Google Analytics iOS crash logs?

参考:Symbolicating iPhone App Crash Reports

希望有所帮助!

答案 2 :(得分:0)

Swift 3

    GAI.sharedInstance().trackUncaughtExceptions = true