2013-08-29 43 views
5

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


更新: - 在这里,我附上GA仪表板的截图链接。

enter image description here

回答

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]];  

(型号和版本可选)

回溯将有<删节>,但最重要的类和方法将是symbolicate(崩溃发生的位置),你会知道哪里是

**编辑**

如何处理异常

  1. Detail explanation
  2. 下载示例 “UncaughtExceptions.zip”
  3. UncaughtExceptionHandler.m,该方法的内部 “handleException:(NSException *)异常” 你可以做你想做的,在我的情况我有另一种方法来验证异常,之后发送给GAI
+0

你是如何处理异常的?意味着我不想在每一个功能中都写下try-catch。 –

+2

我使用这个:http://www.cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html - 下载示例“UncaughtExceptions.zip”,并在“handleException:(NSException *)异常“你可以打电话给你想要的 – silvaric

1

我没有用过谷歌分析崩溃报告功能还,但found this这可能是有益的。

您可以通过使用此代码

- (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. 
} 

我不认为这会symbolicated崩溃报告的设备无法symbolicate它拥有谷歌分析(V2)报告捕获的异常,即崩溃。因此,您可能必须自己符号化收到的崩溃报告,以了解导致此崩溃的代码中的行号。

退房Where can I view the Google Analytics iOS crash logs?

参见:Symbolicating iPhone App Crash Reports

希望帮助!

+0

感谢您的回答。但是,我怎样才能用谷歌分析来实现这个(符号化崩溃报告)?我必须跟踪App Store上的应用程序崩溃。 – Piyush

+0

@Piyush您只需在应用程序的'application:didFinishLaunchingWithOptions:'函数中添加上面的代码行。如果您的应用已在应用商店中,则可能需要添加此功能并进行更新。 – Amar

+0

@Piyush在更新App Store上的IPA时,请保留'.dSYM'文件,因为它将用于表示您收到的崩溃报告。 – Amar

0

夫特3

GAI.sharedInstance().trackUncaughtExceptions = true 
相关问题