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

Remove unused APIs from Bugsnag interface #514

Merged
merged 6 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Bugsnag Notifiers on other platforms.

## Enhancements

* Remove unused APIs from `Bugsnag` interface
[#514](https://github.com/bugsnag/bugsnag-cocoa/pull/514)

* Enforce that `config.maxBreadcrumbs` must be between 0-100
[#511](https://github.com/bugsnag/bugsnag-cocoa/pull/511)

Expand Down
4 changes: 4 additions & 0 deletions Source/BSGOutOfMemoryWatchdog.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ @interface BSGOutOfMemoryWatchdog ()
@property(nonatomic, strong, readwrite) NSDictionary *lastBootCachedFileInfo;
@end

@interface Bugsnag ()
+ (NSDateFormatter *_Nonnull)payloadDateFormatter;
@end

@implementation BSGOutOfMemoryWatchdog

- (instancetype)init {
Expand Down
21 changes: 0 additions & 21 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#import "BugsnagMetadata.h"
#import "BugsnagPlugin.h"

static NSString *_Nonnull const BugsnagSeverityError = @"error";
static NSString *_Nonnull const BugsnagSeverityWarning = @"warning";
static NSString *_Nonnull const BugsnagSeverityInfo = @"info";
fractalwrench marked this conversation as resolved.
Show resolved Hide resolved

@interface Bugsnag : NSObject

/** Start listening for crashes.
Expand Down Expand Up @@ -159,21 +155,6 @@ static NSString *_Nonnull const BugsnagSeverityInfo = @"info";
andType:(BSGBreadcrumbType)type
NS_SWIFT_NAME(leaveBreadcrumb(_:metadata:type:));

/**
* Clear any breadcrumbs that have been left so far.
*/
+ (void)clearBreadcrumbs;

/**
* Set the maximum number of breadcrumbs to keep and sent to Bugsnag.
* By default, we'll keep and send the 20 most recent breadcrumb log
* messages.
*
* @param capacity max number of breadcrumb log messages to send
*/
+ (void)setBreadcrumbCapacity:(NSUInteger)capacity
__deprecated_msg("Use [BugsnagConfiguration setMaxBreadcrumbs:] instead");

// =============================================================================
// MARK: - Session
// =============================================================================
Expand Down Expand Up @@ -283,8 +264,6 @@ static NSString *_Nonnull const BugsnagSeverityInfo = @"info";
withKey:(NSString *_Nonnull)key
NS_SWIFT_NAME(clearMetadata(section:key:));

+ (NSDateFormatter *_Nonnull)payloadDateFormatter;

/**
* Replicates BugsnagConfiguration.context
*
Expand Down
12 changes: 0 additions & 12 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,6 @@ + (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message
}
}

+ (void)setBreadcrumbCapacity:(NSUInteger)capacity {
if ([self bugsnagStarted]) {
[self.client.configuration setMaxBreadcrumbs:capacity];
}
}

+ (void)clearBreadcrumbs {
if ([self bugsnagStarted]) {
[self.client clearBreadcrumbs];
}
}

+ (void)startSession {
if ([self bugsnagStarted]) {
[self.client startSession];
Expand Down
4 changes: 4 additions & 0 deletions Source/BugsnagBreadcrumb.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ BSGBreadcrumbType BSGBreadcrumbTypeFromString(NSString *value) {
}
}

@interface Bugsnag ()
+ (NSDateFormatter *_Nonnull)payloadDateFormatter;
@end

@implementation BugsnagBreadcrumb

- (instancetype)init {
Expand Down
5 changes: 0 additions & 5 deletions Source/BugsnagBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;

/**
* Clear all stored breadcrumbs.
*/
- (void)clearBreadcrumbs;

/** Breadcrumb object for a particular index or nil */
- (BugsnagBreadcrumb *_Nullable)objectAtIndexedSubscript:(NSUInteger)index;

Expand Down
10 changes: 1 addition & 9 deletions Source/BugsnagBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ - (void)setCapacity:(NSUInteger)capacity {
}
}

- (void)clearBreadcrumbs {
dispatch_barrier_sync(self.readWriteQueue, ^{
[self.breadcrumbs removeAllObjects];
});
}

- (NSUInteger)count {
return self.breadcrumbs.count;
}
Expand Down Expand Up @@ -183,9 +177,7 @@ - (NSArray *)arrayValue {
}

- (void)resizeToFitCapacity:(NSUInteger)capacity {
if (capacity == 0) {
[self clearBreadcrumbs];
} else if ([self count] > capacity) {
if ([self count] > capacity) {
dispatch_barrier_sync(self.readWriteQueue, ^{
[self.breadcrumbs
removeObjectsInRange:NSMakeRange(0, self.count - capacity)];
Expand Down
5 changes: 0 additions & 5 deletions Source/BugsnagClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
- (void)addBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;

/**
* Clear all stored breadcrumbs.
*/
- (void)clearBreadcrumbs;

/**
* Enable or disable crash reporting based on configuration state
*/
Expand Down
9 changes: 4 additions & 5 deletions Source/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ - (NSDictionary *_Nonnull)toDictionary;
@property(unsafe_unretained) id<BugsnagMetadataDelegate> _Nullable delegate;
@end

@interface Bugsnag ()
+ (NSDateFormatter *_Nonnull)payloadDateFormatter;
@end

@implementation BugsnagClient

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
Expand Down Expand Up @@ -811,11 +815,6 @@ - (void)addBreadcrumbWithBlock:
[self serializeBreadcrumbs];
}

- (void)clearBreadcrumbs {
[self.configuration.breadcrumbs clearBreadcrumbs];
[self serializeBreadcrumbs];
}

- (void)serializeBreadcrumbs {
BugsnagBreadcrumbs *crumbs = self.configuration.breadcrumbs;
NSArray *arrayValue = crumbs.count == 0 ? nil : [crumbs arrayValue];
Expand Down
16 changes: 3 additions & 13 deletions Tests/BugsnagBreadcrumbsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ - (void)testMaxMaxBreadcrumbs {
XCTAssertEqual(100, self.crumbs.capacity);
}

- (void)testClearBreadcrumbs {
[self.crumbs clearBreadcrumbs];
awaitBreadcrumbSync(self.crumbs);
XCTAssertTrue(self.crumbs.count == 0);
XCTAssertNil(self.crumbs[0]);
}

- (void)testEmptyCapacity {
self.crumbs.capacity = 0;
[self.crumbs addBreadcrumb:@"Clear notifications"];
Expand Down Expand Up @@ -176,8 +169,7 @@ - (void)testPersistentCrumbCustom {
}

- (void)testDefaultDiscardByType {
[self.crumbs clearBreadcrumbs];
awaitBreadcrumbSync(self.crumbs);
self.crumbs = [BugsnagBreadcrumbs new];
[self.crumbs addBreadcrumbWithBlock:^(BugsnagBreadcrumb *_Nonnull crumb) {
crumb.type = BSGBreadcrumbTypeState;
crumb.message = @"state";
Expand Down Expand Up @@ -223,8 +215,7 @@ - (void)testDefaultDiscardByType {
}

- (void)testAlwaysAllowManual {
[self.crumbs clearBreadcrumbs];
awaitBreadcrumbSync(self.crumbs);
self.crumbs = [BugsnagBreadcrumbs new];
self.crumbs.enabledBreadcrumbTypes = 0;
[self.crumbs addBreadcrumb:@"this is a test"];
awaitBreadcrumbSync(self.crumbs);
Expand All @@ -239,8 +230,7 @@ - (void)testAlwaysAllowManual {
* private and assumes filtering is already configured.
*/
- (void)testDiscardByTypeDoesNotApply {
[self.crumbs clearBreadcrumbs];
awaitBreadcrumbSync(self.crumbs);
self.crumbs = [BugsnagBreadcrumbs new];
self.crumbs.enabledBreadcrumbTypes = BSGEnabledBreadcrumbTypeProcess;
// Don't discard this
[self.crumbs addBreadcrumbWithBlock:^(BugsnagBreadcrumb *_Nonnull crumb) {
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ The exact error is available using the `BSGConfigurationErrorDomain` and
- Bugsnag.setBreadcrumbCapacity(40)
let config = try BugsnagConfiguration("YOUR API KEY HERE")
+ config.setMaxBreadcrumbs(40)

- Bugsnag.payloadDateFormatter()
- Bugsnag.clearBreadcrumbs()
```

#### Additions
Expand Down