Skip to content

Commit

Permalink
Fix initial report type
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed Jun 26, 2024
1 parent 989497e commit c08c2cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Samples/Common/Sources/LibraryBridge/ReportingSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import KSCrashSinks
public class ReportingSample {
public static func logToConsole() {
KSCrash.shared().sink = CrashReportSinkConsole.filter().defaultCrashReportFilterSet()
KSCrash.shared().sendAllReports()
KSCrash.shared().sendAllReports { reports, isSuccess, error in
if isSuccess, let reports {
print("Logged \(reports.count) reoprts")
} else {
print("Failed to log reports: \(error?.localizedDescription ?? "")")
}
}
}
}
11 changes: 6 additions & 5 deletions Sources/KSCrashRecording/KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#import "KSCrashMonitor_System.h"
#import "KSSystemCapabilities.h"
#import "KSCrashMonitor_Memory.h"
#import "KSCrashReport.h"

//#define KSLogger_LocalLevel TRACE
#import "KSLogger.h"
Expand Down Expand Up @@ -427,7 +428,7 @@ - (void) doctorReport:(NSMutableDictionary*) report
return [reportIDs copy];
}

- (NSDictionary*) reportForID:(int64_t) reportID
- (KSCrashReport*) reportForID:(int64_t) reportID
{
NSData* jsonData = [self loadCrashReportJSONWithID:reportID];
if(jsonData == nil)
Expand All @@ -452,18 +453,18 @@ - (NSDictionary*) reportForID:(int64_t) reportID
}
[self doctorReport:crashReport];

return [crashReport copy];
return [KSCrashReport reportWithDictionary:crashReport];
}

- (NSArray*) allReports
- (NSArray<KSCrashReport*>*) allReports
{
int reportCount = kscrash_getReportCount();
int64_t reportIDs[reportCount];
reportCount = kscrash_getReportIDs(reportIDs, reportCount);
NSMutableArray* reports = [NSMutableArray arrayWithCapacity:(NSUInteger)reportCount];
NSMutableArray<KSCrashReport*>* reports = [NSMutableArray arrayWithCapacity:(NSUInteger)reportCount];
for(int i = 0; i < reportCount; i++)
{
NSDictionary* report = [self reportForID:reportIDs[i]];
KSCrashReport* report = [self reportForID:reportIDs[i]];
if(report != nil)
{
[reports addObject:report];
Expand Down
4 changes: 2 additions & 2 deletions Sources/KSCrashRecording/include/KSCrash.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param reportID An ID of report.
*
* @return A dictionary with report fields. See KSCrashReportFields.h for available fields.
* @return A crash report with a dictionary value. The dectionary fields are described in KSCrashReportFields.h.
*/
- (nullable NSDictionary<NSString*, id>*) reportForID:(int64_t) reportID NS_SWIFT_NAME(report(for:));
- (nullable KSCrashReport*) reportForID:(int64_t) reportID NS_SWIFT_NAME(report(for:));

/** Delete all unsent reports.
*/
Expand Down

0 comments on commit c08c2cd

Please sign in to comment.