简体   繁体   English

使用Google Analytics iOS跟踪崩溃

[英]Track crash using Google Analytics iOS

Hello 你好
I am using Google Analytics in one of my iPhone app . 我在我的一个iPhone app使用Google Analytics I am tracking the app installations, screen visits and click events. 我正在跟踪应用安装,屏幕访问和点击事件。
Now, I want to track the crashes & exceptions in the app with reason and its location(by location, I mean method name, line number or anything else). 现在,我想跟踪应用程序中的crashes & exceptions及其位置(按位置,我的意思是方法名称,行号或其他任何内容)。 I have read the the document provided by google, but didn't get anything useful. 我已阅读谷歌提供的文件,但没有得到任何有用的信息。
Can anyone help me with this? 谁能帮我这个? Any example would be really appreciated. 任何一个例子都会非常感激。


Update :- Here, I am attaching the screenshot link of GA dashboard. 更新 : - 这里,我附上了GA仪表板的屏幕截图链接。

在此输入图像描述

You can send the backtrace (already symbolicated). 您可以发送回溯(已经符号化)。 I set sendUncaughtExceptions = FALSE and manually send. 我设置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]];     

(model and version is optional) (型号和版本是可选的)

The backtrace will have < redacted > but the most important class and method will be symbolicate (where the crash occurred) and you will know where is 回溯将有<redacted>,但最重要的类和方法将是符号化的(崩溃发生的地方),你会知道在哪里

** EDIT ** **编辑**

How handle exception 如何处理异常

  1. Detail explanation 详细说明
  2. Download the example "UncaughtExceptions.zip" 下载示例“UncaughtExceptions.zip”
  3. On the UncaughtExceptionHandler.m , inside of the method " handleException:(NSException *)exception " you can do what you want, in my case i have other method to validate the exception and after that send to GAI UncaughtExceptionHandler.m上 ,在方法“ handleException:(NSException *)exception ”中你可以做你想要的,在我的情况下,我有其他方法来验证异常,然后发送到GAI

I have not used the Google Analytics crash reporting feature yet, but found this which could be helpful. 我还没有使用Google Analytics崩溃报告功能,但发现这可能会有所帮助。

You can have Google Analytics(v2) report uncaught exceptions ie crashes by using this code 您可以使用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.
}

I don't think these will be symbolicated crash reports as the device is unable to symbolicate it. 我不认为这些将是符号化的崩溃报告,因为设备无法对其进行符号化。 So you may have to symbolicate the received crash reports by yourself to understand the line number in code which caused this crash. 因此,您可能必须自己对收到的崩溃报告进行符号化,以了解导致此崩溃的代码中的行号。

Check out Where can I view the Google Analytics iOS crash logs? 查看我在哪里可以查看Google Analytics iOS崩溃日志?

Refer: Symbolicating iPhone App Crash Reports 参考: 符号化iPhone App崩溃报告

Hope that helps! 希望有所帮助!

斯威夫特3

    GAI.sharedInstance().trackUncaughtExceptions = true

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

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