Skip to content

Commit

Permalink
Add reportCleanupPolicy to KSCrashReportStoreConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed Oct 27, 2024
1 parent c3bbb72 commit 566b1ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Sources/KSCrashRecording/KSCrashConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ - (instancetype)init
if (self != nil) {
_appName = nil;
_reportsPath = nil;
_reportCleanupPolicy = KSCrashReportCleanupPolicyAlways;

KSCrashReportStoreCConfiguration cConfig = KSCrashReportStoreCConfiguration_Default();
_maxReportCount = (NSInteger)cConfig.maxReportCount;
Expand Down Expand Up @@ -204,6 +205,7 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone
copy.reportsPath = [self.reportsPath copyWithZone:zone];
copy.appName = [self.appName copyWithZone:zone];
copy.maxReportCount = self.maxReportCount;
copy.reportCleanupPolicy = self.reportCleanupPolicy;
return copy;
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/KSCrashRecording/KSCrashReportStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ - (nullable instancetype)initWithConfiguration:(KSCrashReportStoreConfiguration
{
self = [super init];
if (self != nil) {
_cConfig = [(configuration ?: [KSCrashReportStoreConfiguration new]) toCConfiguration];
_reportCleanupPolicy = KSCrashReportCleanupPolicyAlways;
KSCrashReportStoreConfiguration *resolvedConfiguration = configuration ?: [KSCrashReportStoreConfiguration new];
_cConfig = [resolvedConfiguration toCConfiguration];
_reportCleanupPolicy = resolvedConfiguration.reportCleanupPolicy;

kscrs_initialize(&_cConfig);
}
Expand Down
14 changes: 14 additions & 0 deletions Sources/KSCrashRecording/include/KSCrashConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#import <Foundation/Foundation.h>
#import "KSCrashMonitorType.h"
#import "KSCrashReportStore.h"
#import "KSCrashReportWriter.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -191,6 +192,19 @@ NS_SWIFT_NAME(CrashReportStoreConfiguration)
*/
@property(nonatomic, assign) NSInteger maxReportCount;

/** What to do after sending reports via `-[KSCrashReportStore sendAllReportsWithCompletion:]`.
*
* - Use `KSCrashReportCleanupPolicyNever` if you manually manage the reports.
* - Use `KSCrashReportCleanupPolicyAlways` if you are using an alert confirmation
* (otherwise it will nag the user incessantly until he selects "yes").
* - Use `KSCrashReportCleanupPolicyOnSucess` for all other situations.
*
* Can be updated after creation of report store / installation of KSCrash.
*
* **Default**: `KSCrashReportCleanupPolicyAlways`
*/
@property(nonatomic, assign) KSCrashReportCleanupPolicy reportCleanupPolicy;

@end

NS_ASSUME_NONNULL_END
11 changes: 6 additions & 5 deletions Sources/KSCrashRecording/include/KSCrashReportStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ NS_SWIFT_NAME(CrashReportStore)
*/
@property(nonatomic, readwrite, strong, nullable) id<KSCrashReportFilter> sink;

/** What to do after sending reports via sendAllReportsWithCompletion:
/** What to do after sending reports via `-[KSCrashReportStore sendAllReportsWithCompletion:]`.
*
* - Use KSCrashReportCleanupPolicyNever if you manually manage the reports.
* - Use KSCrashReportCleanupPolicyAlways if you are using an alert confirmation
* - Use `KSCrashReportCleanupPolicyNever` if you manually manage the reports.
* - Use `KSCrashReportCleanupPolicyAlways` if you are using an alert confirmation
* (otherwise it will nag the user incessantly until he selects "yes").
* - Use KSCrashReportCleanupPolicyOnSucess for all other situations.
* - Use `KSCrashReportCleanupPolicyOnSucess` for all other situations.
*
* Default: KSCrashReportCleanupPolicyAlways
* Initial value is provided from store configuration.
* If no configuration is provided, the default value from `KSCrashReportStoreConfiguration` is used.
*/
@property(nonatomic, assign) KSCrashReportCleanupPolicy reportCleanupPolicy;

Expand Down

0 comments on commit 566b1ec

Please sign in to comment.