Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initial report type #519

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) reports")
} 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
Loading