ibm-bluemix-mobile-services / bms-clientsdk-swift-analytics

Bluemix Mobile Services Analytics SDK
Apache License 2.0
6 stars 10 forks source link

iOS Crash Analytics not being collected. #44

Open bigkinglsu opened 6 years ago

bigkinglsu commented 6 years ago

Attempting to crash app using the following methods.

  1. - (void) overflow
    {
    char *dest;
    
    strcpy(dest, "test");
    
    [self overflow];
    }
  2. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
    NSDate *current = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
    NSString *currentTime = [dateFormatter stringFromDate:current];
    [userInfo setObject:@"Crash Time" forKey:currentTime];
    NSException *ex = [[NSException alloc] initWithName:@"BookmartCrashException" reason:@"User crashed!" userInfo:userInfo];
    [ex raise];
  3. while(true)
    {
     malloc(sizeof(int)*10000);
    }

Methods 1 and 3 will not be consisting captured unless they are executed on the main thread using dispatch_async(dispatch_get_main_queue().

mohlogan commented 6 years ago

@bigkinglsu Hi Robert, Can you please check with the changes done via branch 'mohlogan_issue44'. Make sure you made following changing to your Podfile for testing

pod 'BMSAnalytics', :git => 'https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-analytics.git', :branch => 'mohlogan_issue44'

Please confirm whether you are still seeing the issue. Further to your confirmation i will release it as new level

Thanks and Regards, Mohan

mohlogan commented 6 years ago

@bigkinglsu Hi Robert, Can you please check the above and let me know your results? Thanks

bigkinglsu commented 6 years ago

@mohlogan, I applied your change. I consistently see the crash being captured and is showing up in the bmssdk.logger.log file but I am not seeing the data showing up in the analytics console. Probably due to issue 45? I'm not sure. Also, keep in mind, per issue 43 we are using the previous version of the POD. Thanks.

mohlogan commented 6 years ago

@bigkinglsu, Thanks for confirming that the fix works. I will release this fix and let you know.

Issue #45 may not be the cause for not sending the logs since i have noted these messages are printed during the initialization of analytics. Can you check whether BMSAnalytics.send() or BMSLogger.send() called prior to initialization? Also check whether the intialisation for analytics succeeded. If thats the case session level details should be updated in the analytics dashboard. For a cleaner run please clean your logs of your installation and retry.

Thanks and Regards, Mohan

bigkinglsu commented 6 years ago

Looks like I was wrong. I checked the dashboard again this morning and the crashes that were captured on Friday and that I observed being sent are just now showing up in the dashboard. They were not there as of yesterday. Please note that I did not get that null header error when I observed the captures that showed up in the console being sent. They just took a long time to show up for some reason.

BMSAnalytics.send() and BMSLogger.send() are called after BMSAnalytics.initialize and BMSAnalytics.initialize. See below. Is that not correct?

See below for screen capture of output window. I see both BMSClient: Success and Success: BMSAnalytics. Thanks.

image
        if (BMSAnalytics) {
            var bmsApplicationName = "DelhaizefoodLionApp";
            var bmsAnalyticsKey = appConstants.getConstants().ANALYTICSAPIKEY;
            var hasUserContext = false;
            var collectLocation = false;
            var deviceEvents = [BMSAnalytics.ALL];

            BMSClient.initialize(BMSClient.REGION_US_SOUTH);

            BMSAnalytics.initialize(bmsApplicationName, bmsAnalyticsKey, hasUserContext, collectLocation, deviceEvents)
            BMSAnalytics.enable();
            BMSAnalytics.send();

            BMSLogger.storeLogs(true);
            BMSLogger.send();
        }
image
bigkinglsu commented 6 years ago

@mohlogan is there an update?

bigkinglsu commented 6 years ago

@mohlogan, any update?