Skip to content

Commit 99a09d0

Browse files
authored
Merge pull request #31 from CrashOps/0.3.12
v0.3.12 - bug fixes
2 parents c34f4b1 + f6e5afa commit 99a09d0

File tree

5 files changed

+66
-21
lines changed

5 files changed

+66
-21
lines changed

CrashOps.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "CrashOps"
19-
s.version = "0.3.11"
19+
s.version = "0.3.12"
2020
s.summary = "CrashOps monitors your app's stability and vulnerability."
2121

2222
# This description is used to generate tags and improve search results.

CrashOps/AppleFormatter/AppleCrashReportGenerator.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@ + (NSString *) generateIpsFile:(NSURL *)originalJsonReportPath {
10111011

10121012
NSString *filePath = [[CrashOpsController ipsFilesLibraryPath] stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.ips", fileName]];
10131013

1014+
if (!filePath) {
1015+
return filePath;
1016+
}
1017+
10141018
if ([[NSFileManager defaultManager] fileExistsAtPath: filePath]) {
10151019
return filePath;
10161020
}

CrashOps/Facade/CrashOps.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ @interface CrashOps()
2929
@implementation CrashOps
3030

3131
@synthesize appKey;
32-
@synthesize metadata;
3332
@synthesize isEnabled;
3433
@synthesize isTracingScreens;
3534

@@ -43,7 +42,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder {
4342
if (self) {
4443
isEnabled = YES;
4544
appKey = @"";
46-
metadata = [NSMutableDictionary new];
45+
_metadata = [NSMutableDictionary new];
4746
}
4847

4948
CrashOps* sdkInstance;
@@ -63,9 +62,9 @@ - (void)deleteOldReports {
6362
[[KSCrash sharedInstance] deleteAllReports];
6463
}
6564

66-
- (void)setMetadata:(NSMutableDictionary *)metadata {
65+
- (void)setMetadata:(NSMutableDictionary *) metadata {
6766
if ([metadata isKindOfClass: [NSDictionary class]]) {
68-
self.metadata = metadata;
67+
_metadata = metadata;
6968
}
7069
}
7170

@@ -86,7 +85,7 @@ +(BOOL)isRunningOnDebugMode {
8685
}
8786

8887
+ (NSString *)sdkVersion {
89-
return @"0.3.11";
88+
return @"0.3.12";
9089
}
9190

9291
- (void) crash {
@@ -153,7 +152,7 @@ +(void)initialize {
153152
@end
154153

155154
//! Project version number for CrashOps.
156-
//double CrashOpsVersionNumber = 0.0311;
155+
//double CrashOpsVersionNumber = 0.0312;
157156

158157
//! Project version string for CrashOps.
159-
//const unsigned char CrashOpsVersionString[] = "0.03.11";
158+
//const unsigned char CrashOpsVersionString[] = "0.03.12";

CrashOps/Logic/CrashOpsController.m

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,31 @@ + (NSMutableDictionary *) addCrashOpsConstantFields:(NSDictionary *) reportJson
976976

977977
NSMutableDictionary *reportCopy = [reportJson mutableCopy];
978978
reportCopy[@"devicePlatform"] = @"ios";
979+
NSMutableDictionary *system = [reportCopy[@"system"] mutableCopy];
980+
if (!system) {
981+
system = [NSMutableDictionary new];
982+
}
983+
984+
NSDictionary *appInfoDictionary = [[NSBundle mainBundle] infoDictionary];
985+
CODebugLog([appInfoDictionary description]);
986+
987+
NSString *appBuildNumberString;
988+
if (appInfoDictionary[@"CFBundleVersion"]) {
989+
NSInteger appBuildNumber = [appInfoDictionary[@"CFBundleVersion"] intValue];
990+
appBuildNumberString = [NSString stringWithFormat:@"%ld", (long) appBuildNumber];
991+
}
992+
993+
NSString *appVersionString;
994+
if (appInfoDictionary[@"CFBundleShortVersionString"]) {
995+
appVersionString = [appInfoDictionary[@"CFBundleShortVersionString"] description];
996+
}
997+
998+
[system co_setOptionalObject: NSBundle.mainBundle.bundleIdentifier forKey:@"CFBundleIdentifier"];
999+
[system co_setOptionalObject: appVersionString forKey:@"CFBundleShortVersionString"];
1000+
[system co_setOptionalObject: appBuildNumberString forKey:@"CFBundleVersion"];
1001+
1002+
reportCopy[@"system"] = system;
1003+
9791004
reportCopy[@"crashOpsSdkVersion"] = [CrashOps sdkVersion]; //[NSString stringWithCString:CrashOpsVersionString encoding: NSUTF8StringEncoding];
9801005
reportCopy[@"buildMode"] = [CrashOps isRunningOnDebugMode] ? @"DEBUG" : @"RELEASE";
9811006

@@ -1036,14 +1061,20 @@ -(void) onEventFileCreated:(NSString *) eventId {
10361061
NSLog(@"New event ID saved: %@", eventId);
10371062

10381063
NSString *eventIdFile = [[self eventsFolderPath] stringByAppendingPathComponent: eventId];
1064+
if (eventIdFile) {
1065+
NSData *eventIdData = [appSessionId dataUsingEncoding: NSUTF8StringEncoding];
1066+
[eventIdData writeToFile: eventIdFile options: NSDataWritingAtomic error: nil];
1067+
} else {
1068+
[CrashOpsController logInternalError: [NSString stringWithFormat:@"Failed to save session ID: %@", appSessionId]];
1069+
}
10391070

1040-
NSData *eventIdData = [appSessionId dataUsingEncoding: NSUTF8StringEncoding];
1041-
[eventIdData writeToFile: eventIdFile options: NSDataWritingAtomic error: nil];
1042-
10431071
NSString *sessionIdFile = [[self sessionsFolderPath] stringByAppendingPathComponent: appSessionId];
1044-
1045-
NSData *sessionIdData = [eventId dataUsingEncoding: NSUTF8StringEncoding];
1046-
[sessionIdData writeToFile: sessionIdFile options: NSDataWritingAtomic error: nil];
1072+
if (sessionIdFile) {
1073+
NSData *sessionIdData = [eventId dataUsingEncoding: NSUTF8StringEncoding];
1074+
[sessionIdData writeToFile: sessionIdFile options: NSDataWritingAtomic error: nil];
1075+
} else {
1076+
[CrashOpsController logInternalError: [NSString stringWithFormat:@"Failed to save event ID: %@", eventId]];
1077+
}
10471078
}
10481079

10491080
-(void) handleException:(NSException *) exception {
@@ -1085,19 +1116,26 @@ - (BOOL) logError:(NSDictionary *) errorDetails {
10851116
NSString *nowString = [CrashOpsController stringFromDate: now withFormat: @"yyyy-MM-dd-HH-mm-ss-SSS_ZZZ"];
10861117

10871118
NSString *filePath = [[self errorsFolderPath] stringByAppendingPathComponent: [NSString stringWithFormat:@"ios_error_%@_%@.log", nowString, [[NSUUID UUID] UUIDString]]];
1088-
1119+
if (!filePath) {
1120+
return;
1121+
}
1122+
10891123
NSArray *breadcrumbs = [ScreenTracer tracesReportForSessionId: sessionId];
10901124

10911125
NSDictionary *jsonDictionary = @{@"errorDetails": errorDetails,
1092-
@"report":@{@"id": [NSNumber numberWithInteger: timestamp],
1093-
@"time": nowString},
1126+
@"report":@{@"id": [[NSUUID UUID] UUIDString],
1127+
@"timestamp": [NSNumber numberWithInteger: timestamp],
1128+
@"time": nowString
1129+
},
10941130
//@"details": [self generateReport: [NSException exceptionWithName:@"Error" reason:@"" userInfo:@{@"isFatal": NO}]],
10951131
@"details": [self generateReport: nil],
10961132
@"screenTraces": breadcrumbs,
10971133
@"isFatal": @NO
10981134
};
1135+
1136+
NSMutableDictionary *crashOpsDictionary = [CrashOpsController addCrashOpsConstantFields: jsonDictionary];
10991137

1100-
NSData *errorData = [CrashOpsController toJsonData: jsonDictionary];
1138+
NSData *errorData = [CrashOpsController toJsonData: crashOpsDictionary];
11011139

11021140
NSError *error;
11031141
BOOL didSave = [errorData writeToFile: filePath options: NSDataWritingAtomic error: &error];
@@ -1362,10 +1400,14 @@ - (void) flushToDisk:(ScreenDetails *) screenDetails {
13621400
[[self coGlobalOperationQueue] addOperationWithBlock:^{
13631401
NSUInteger timestamp = screenDetails.timestamp;
13641402
NSString *filePath = [[[CrashOpsController shared] currentSessionTracesFolderPath] stringByAppendingPathComponent: [NSString stringWithFormat:@"%lu.log", (unsigned long) timestamp]];
1403+
BOOL didSave = NO;
1404+
1405+
if (filePath) {
1406+
NSData *traceData = [[CrashOpsController toJsonString: [screenDetails toDictionary]] dataUsingEncoding: NSUTF8StringEncoding];
13651407

1366-
NSData *traceData = [[CrashOpsController toJsonString: [screenDetails toDictionary]] dataUsingEncoding: NSUTF8StringEncoding];
1408+
didSave = [traceData writeToFile: filePath options: NSDataWritingAtomic error: nil];
1409+
}
13671410

1368-
BOOL didSave = [traceData writeToFile: filePath options: NSDataWritingAtomic error: nil];
13691411
if (!didSave) {
13701412
[CrashOpsController logInternalError: [NSString stringWithFormat:@"Failed to flush screen details to disk. Screen details: %@", screenDetails]];
13711413
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CrashOps lets you monitor your app's stability and vulnerability by giving you e
1212
You want to add `pod 'CrashOps'` similar to the following to your Podfile:
1313
```
1414
target 'MyApp' do
15-
pod 'CrashOps', '0.3.11'
15+
pod 'CrashOps', '0.3.12'
1616
end
1717
```
1818
Then run a `pod install` in your terminal, or from CocoaPods app.

0 commit comments

Comments
 (0)