Skip to content

Commit

Permalink
Merge pull request #496 from bugsnag/v6-remove-config-apis
Browse files Browse the repository at this point in the history
Remove unused APIs from BugsnagConfiguration interface
  • Loading branch information
fractalwrench authored Mar 27, 2020
2 parents 8872d7d + 6fd42e5 commit 3a0945e
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 76 deletions.
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 `BugsnagConfiguration` interface
[#496](https://github.com/bugsnag/bugsnag-cocoa/pull/496)

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

Expand Down
5 changes: 5 additions & 0 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@

static BugsnagClient *bsg_g_bugsnag_client = NULL;

@interface BugsnagConfiguration ()
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
@property(readwrite, retain, nullable) BugsnagMetadata *config;
@end

@interface Bugsnag ()
+ (BugsnagClient *)client;
+ (BOOL)bugsnagStarted;
Expand Down
4 changes: 4 additions & 0 deletions Source/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ @interface BugsnagClient ()

@interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableSet *plugins;
@property(readonly, retain, nullable) NSURL *notifyURL;
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
@property(readwrite, retain, nullable) BugsnagMetadata *config;
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
@end

@implementation BugsnagClient
Expand Down
75 changes: 0 additions & 75 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#import "BugsnagMetadata.h"
#import "BugsnagPlugin.h"

@class BugsnagBreadcrumbs;
@class BugsnagUser;

/**
Expand Down Expand Up @@ -68,18 +67,6 @@ typedef bool (^BugsnagOnSendBlock)(BugsnagEvent *_Nonnull event);
*/
typedef void(^BugsnagOnSessionBlock)(NSMutableDictionary *_Nonnull sessionPayload);

/**
* A handler for modifying data before sending it to Bugsnag
*
* @param rawEventReports The raw event data written at crash time. This
* includes data added in onError.
* @param report The default report payload
*
* @return the report payload intended to be sent or nil to cancel sending
*/
typedef NSDictionary *_Nullable (^BugsnagBeforeNotifyHook)(
NSArray *_Nonnull rawEventReports, NSDictionary *_Nonnull report);

typedef NS_OPTIONS(NSUInteger, BSGErrorType) {
BSGErrorTypesNone NS_SWIFT_NAME(None) = 0,
BSGErrorTypesOOMs NS_SWIFT_NAME(OOMs) = 1 << 0,
Expand Down Expand Up @@ -127,21 +114,6 @@ typedef NS_OPTIONS(NSUInteger, BSGErrorType) {
*/
@property(retain, nullable) BugsnagUser *currentUser;

/**
* Additional information about the state of the app or environment at the
* time the report was generated
*/
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
/**
* Meta-information about the state of Bugsnag
*/
@property(readwrite, retain, nullable) BugsnagMetadata *config;
/**
* Rolling snapshots of user actions leading up to a crash report
*/
@property(readonly, strong, nullable)
BugsnagBreadcrumbs *breadcrumbs;

/**
* Optional handler invoked when an error or crash occurs
*/
Expand All @@ -160,36 +132,11 @@ BugsnagBreadcrumbs *breadcrumbs;
*/
@property BOOL autoTrackSessions;

/**
* Whether the app should report out of memory events which terminate the app
* while the app is in the background. Setting this property has no effect.
*/
@property BOOL reportBackgroundOOMs
__deprecated_msg("This detection option is unreliable and should no longer be used.");

/**
* The types of breadcrumbs which will be captured. By default, this is all types.
*/
@property BSGEnabledBreadcrumbType enabledBreadcrumbTypes;

/**
* Retrieves the endpoint used to notify Bugsnag of errors
*
* NOTE: If you want to set this value, you should do so via setEndpointsForNotify:sessions: instead.
*
* @see setEndpointsForNotify:sessions:
*/
@property(readonly, retain, nullable) NSURL *notifyURL;

/**
* Retrieves the endpoint used to send tracked sessions to Bugsnag
*
* NOTE: If you want to set this value, you should do so via setEndpointsForNotify:sessions: instead.
*
* @see setEndpointsForNotify:sessions:
*/
@property(readonly, retain, nullable) NSURL *sessionURL;

@property(retain, nullable) NSString *codeBundleId;
@property(retain, nullable) NSString *notifierType;

Expand All @@ -200,18 +147,6 @@ BugsnagBreadcrumbs *breadcrumbs;
*/
@property NSUInteger maxBreadcrumbs;

/**
* Determines whether app sessions should be tracked automatically. By default this value is true.
* If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions
* will be captured.
*/
@property BOOL shouldAutoCaptureSessions __deprecated_msg("Use autoTrackSessions instead");

/**
* YES if uncaught exceptions should be reported automatically
*/
@property BOOL autoNotify __deprecated_msg("Use autoDetectErrors instead");

/**
* Whether User information should be persisted to disk between application runs.
* Defaults to True.
Expand Down Expand Up @@ -307,16 +242,6 @@ BugsnagBreadcrumbs *breadcrumbs;
*/
- (void)removeOnSendBlock:(BugsnagOnSendBlock _Nonnull )block;

/**
* Whether reports shoould be sent, based on release stage options
*
* @return YES if reports should be sent based on this configuration
*/
- (BOOL)shouldSendReports;

- (NSDictionary *_Nonnull)errorApiHeaders;
- (NSDictionary *_Nonnull)sessionApiHeaders;

- (void)addPlugin:(id<BugsnagPlugin> _Nonnull)plugin;

/**
Expand Down
23 changes: 23 additions & 0 deletions Source/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ @interface BugsnagConfiguration ()
*/
@property(nonatomic, readwrite, strong) NSMutableArray *onSessionBlocks;
@property(nonatomic, readwrite, strong) NSMutableSet *plugins;
@property(readonly, retain, nullable) NSURL *notifyURL;
@property(readonly, retain, nullable) NSURL *sessionURL;

/**
* Additional information about the state of the app or environment at the
* time the report was generated
*/
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;

/**
* Meta-information about the state of Bugsnag
*/
@property(readwrite, retain, nullable) BugsnagMetadata *config;

/**
* Rolling snapshots of user actions leading up to a crash report
*/
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
@end

@implementation BugsnagConfiguration
Expand Down Expand Up @@ -160,6 +178,11 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
// MARK: - Instance Methods
// -----------------------------------------------------------------------------

/**
* Whether reports should be sent, based on release stage options
*
* @return YES if reports should be sent based on this configuration
*/
- (BOOL)shouldSendReports {
return self.notifyReleaseStages.count == 0 ||
[self.notifyReleaseStages containsObject:self.releaseStage];
Expand Down
2 changes: 2 additions & 0 deletions Source/BugsnagEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ - (instancetype)initWithClass:(NSString *_Nonnull)errorClass message:(NSString *

@interface BugsnagConfiguration (BugsnagEvent)
+ (BOOL)isValidApiKey:(NSString *_Nullable)apiKey;
- (BOOL)shouldSendReports;
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
@end

@interface BugsnagEvent ()
Expand Down
4 changes: 4 additions & 0 deletions Source/BugsnagSessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

NSString *const BSGSessionUpdateNotification = @"BugsnagSessionChanged";

@interface BugsnagConfiguration ()
@property(readonly, retain, nullable) NSURL *sessionURL;
@end

@interface BugsnagSessionTracker ()
@property (weak, nonatomic) BugsnagConfiguration *config;
@property (strong, nonatomic) BugsnagSessionFileStore *sessionStore;
Expand Down
1 change: 1 addition & 0 deletions Source/BugsnagSessionTrackingApiClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableArray *onSessionBlocks;
@property(readonly, retain, nullable) NSURL *sessionURL;
@end


Expand Down
4 changes: 4 additions & 0 deletions Source/BugsnagSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ + (BugsnagClient *)client;

@interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableArray *onSendBlocks;
- (NSDictionary *_Nonnull)errorApiHeaders;
- (NSDictionary *_Nonnull)sessionApiHeaders;
@property(readonly, retain, nullable) NSURL *sessionURL;
@property(readonly, retain, nullable) NSURL *notifyURL;
@end

@implementation BugsnagSink
Expand Down
4 changes: 4 additions & 0 deletions Tests/BugsnagBreadcrumbsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ @interface BugsnagBreadcrumbsTest : XCTestCase
@property(nonatomic, strong) BugsnagBreadcrumbs *crumbs;
@end

@interface BugsnagConfiguration ()
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
@end

@interface BugsnagBreadcrumb ()
+ (instancetype _Nullable)breadcrumbWithBlock:
(BSGBreadcrumbConfiguration _Nonnull)block;
Expand Down
5 changes: 5 additions & 0 deletions Tests/BugsnagConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ @interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableArray *onSendBlocks;
@property(nonatomic, readwrite, strong) NSMutableArray *onSessionBlocks;
- (void)deletePersistedUserData;
- (BOOL)shouldSendReports;
- (NSDictionary *_Nonnull)errorApiHeaders;
- (NSDictionary *_Nonnull)sessionApiHeaders;
@property(readonly, retain, nullable) NSURL *sessionURL;
@property(readonly, retain, nullable) NSURL *notifyURL;
@end

@interface BugsnagCrashSentry ()
Expand Down
1 change: 1 addition & 0 deletions Tests/BugsnagTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ + (BugsnagConfiguration *)configuration;

@interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableArray *onSendBlocks;
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
@end

@interface BugsnagTests : XCTestCase
Expand Down
17 changes: 17 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ The exact error is available using the `BSGConfigurationErrorDomain` and
+ config.enabledErrorTypes
```

#### Removals

```diff
- BugsnagBeforeNotifyHook
- config.metadata
- config.config
- config.breadcrumbs
- config.reportBackgroundOOMs
- config.notifyURL
- config.sessionURL
- config.shouldAutoCaptureSessions
- config.autoNotify
- config.shouldSendReports
- config.errorApiHeaders
- config.sessionApiHeaders
```

### `Bugsnag` class

#### Removals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@implementation OOMScenario

- (void)startBugsnag {
self.config.shouldAutoCaptureSessions = NO;
self.config.autoTrackSessions = NO;
self.config.releaseStage = @"alpha";
[self.config addOnSendBlock:^bool(BugsnagEvent * _Nonnull report) {
NSMutableDictionary *metadata = [report.metadata mutableCopy];
Expand Down

0 comments on commit 3a0945e

Please sign in to comment.