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

Rename notifyReleaseStages to enabledReleaseStages #509

Merged
merged 3 commits into from
Mar 30, 2020
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
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

* Rename `notifyReleaseStages` to `enabledReleaseStages`
[#509](https://github.com/bugsnag/bugsnag-cocoa/pull/509)

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

Expand Down
2 changes: 1 addition & 1 deletion Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ typedef NS_OPTIONS(NSUInteger, BSGErrorType) {
/**
* Release stages which are allowed to notify Bugsnag
*/
@property(readwrite, retain, nullable) NSArray *notifyReleaseStages;
@property(readwrite, retain, nullable) NSArray *enabledReleaseStages;
/**
* A general summary of what was occuring in the application
*/
Expand Down
22 changes: 11 additions & 11 deletions Source/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
_onSessionBlocks = [NSMutableArray new];
_onBreadcrumbBlocks = [NSMutableArray new];
_plugins = [NSMutableSet new];
_notifyReleaseStages = nil;
_enabledReleaseStages = nil;
_breadcrumbs = [BugsnagBreadcrumbs new];
_autoTrackSessions = YES;
// Default to recording all error types
Expand Down Expand Up @@ -186,8 +186,8 @@ - (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
* @return YES if reports should be sent based on this configuration
*/
- (BOOL)shouldSendReports {
return self.notifyReleaseStages.count == 0 ||
[self.notifyReleaseStages containsObject:self.releaseStage];
return self.enabledReleaseStages.count == 0 ||
[self.enabledReleaseStages containsObject:self.releaseStage];
}

- (void)setUser:(NSString *_Nullable)userId
Expand Down Expand Up @@ -471,21 +471,21 @@ - (void)setAutoNotify:(BOOL)autoNotify {

// MARK: -

@synthesize notifyReleaseStages = _notifyReleaseStages;
@synthesize enabledReleaseStages = _enabledReleaseStages;

- (NSArray *)notifyReleaseStages {
- (NSArray *)enabledReleaseStages {
@synchronized (self) {
return _notifyReleaseStages;
return _enabledReleaseStages;
}
}

- (void)setNotifyReleaseStages:(NSArray *)newNotifyReleaseStages;
- (void)setEnabledReleaseStages:(NSArray *)newReleaseStages;
{
@synchronized (self) {
NSArray *notifyReleaseStagesCopy = [newNotifyReleaseStages copy];
_notifyReleaseStages = notifyReleaseStagesCopy;
[self.config addAttribute:BSGKeyNotifyReleaseStages
withValue:notifyReleaseStagesCopy
NSArray *releaseStagesCopy = [newReleaseStages copy];
_enabledReleaseStages = releaseStagesCopy;
[self.config addAttribute:BSGKeyEnabledReleaseStages
withValue:releaseStagesCopy
toTabWithName:BSGKeyConfig];
}
}
Expand Down
11 changes: 6 additions & 5 deletions Source/BugsnagEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import "Private.h"
#import "BSG_RFC3339DateTool.h"
#import "Private.h"
#import "BugsnagKeys.h"

@interface BugsnagBreadcrumb ()
+ (instancetype _Nullable)breadcrumbWithBlock:
Expand Down Expand Up @@ -271,7 +272,7 @@ - (BOOL)shouldBeSent;
/**
* The release stages used to notify at the time this report is captured
*/
@property(readwrite, copy, nullable) NSArray *notifyReleaseStages;
@property(readwrite, copy, nullable) NSArray *enabledReleaseStages;

/**
* Property overrides
Expand Down Expand Up @@ -324,7 +325,7 @@ - (instancetype)initWithKSReport:(NSDictionary *)report {
}
}
} else {
_notifyReleaseStages = BSGLoadConfigValue(report, @"notifyReleaseStages");
_enabledReleaseStages = BSGLoadConfigValue(report, BSGKeyEnabledReleaseStages);
_releaseStage = BSGParseReleaseStage(report);
_threads = [report valueForKeyPath:@"crash.threads"];
RegisterErrorData *data = [RegisterErrorData errorDataFromThreads:_threads];
Expand Down Expand Up @@ -397,7 +398,7 @@ - (instancetype)initWithKSReport:(NSDictionary *)report {
_overrides = [NSDictionary new];
_metadata = metadata ?: [NSDictionary new];
_releaseStage = config.releaseStage;
_notifyReleaseStages = config.notifyReleaseStages;
_enabledReleaseStages = config.enabledReleaseStages;
// Set context based on current values. May be nil.
_context = metadata[BSGKeyContext] ?: [[Bugsnag configuration] context];
NSMutableArray *crumbs = [NSMutableArray new];
Expand Down Expand Up @@ -529,8 +530,8 @@ - (void)setApiKey:(NSString *)apiKey {
}

- (BOOL)shouldBeSent {
return [self.notifyReleaseStages containsObject:self.releaseStage] ||
(self.notifyReleaseStages.count == 0 &&
return [self.enabledReleaseStages containsObject:self.releaseStage] ||
(self.enabledReleaseStages.count == 0 &&
[[Bugsnag configuration] shouldSendReports]);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/BugsnagKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static NSString *const BSGKeyReleaseStage = @"releaseStage";
static NSString *const BSGKeyConfig = @"config";
static NSString *const BSGKeyContext = @"context";
static NSString *const BSGKeyAppVersion = @"appVersion";
static NSString *const BSGKeyNotifyReleaseStages = @"notifyReleaseStages";
static NSString *const BSGKeyEnabledReleaseStages = @"notifyReleaseStages";
static NSString *const BSGKeyApiKey = @"apiKey";
static NSString *const BSGKeyNotifier = @"notifier";
static NSString *const BSGKeyEvents = @"events";
Expand Down
10 changes: 5 additions & 5 deletions Source/BugsnagSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ - (instancetype)initWithApiClient:(BugsnagErrorReportApiClient *)apiClient {

// Entry point called by BSG_KSCrash when a report needs to be sent. Handles
// report filtering based on the configuration options for
// `notifyReleaseStages`. Removes all reports not meeting at least one of the
// `enabledReleaseStages`. Removes all reports not meeting at least one of the
// following conditions:
// - the report-specific config specifies the `notifyReleaseStages` property and
// - the report-specific config specifies the `enabledReleaseStages` property and
// it contains the current stage
// - the report-specific and global `notifyReleaseStages` properties are unset
// - the report-specific `notifyReleaseStages` property is unset and the global
// `notifyReleaseStages` property
// - the report-specific and global `enabledReleaseStages` properties are unset
// - the report-specific `enabledReleaseStages` property is unset and the global
// `enabledReleaseStages` property
// and it contains the current stage
- (void)filterReports:(NSDictionary <NSString *, NSDictionary *> *)reports
onCompletion:(BSG_KSCrashReportFilterCompletion)onCompletion {
Expand Down
22 changes: 11 additions & 11 deletions Tests/BugsnagConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,43 +246,43 @@ - (void)testRemoveNonexistentOnSessionBlocks {
// MARK: - Release stage-related
// =============================================================================

- (void)testNotifyReleaseStagesDefaultSends {
- (void)testEnabledReleaseStagesDefaultSends {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
XCTAssertTrue([config shouldSendReports]);
}

- (void)testNotifyReleaseStagesNilSends {
- (void)testEnabledReleaseStagesNilSends {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.releaseStage = @"beta";
config.notifyReleaseStages = nil;
config.enabledReleaseStages = nil;
XCTAssertTrue([config shouldSendReports]);
}

- (void)testNotifyReleaseStagesEmptySends {
- (void)testEnabledReleaseStagesEmptySends {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.releaseStage = @"beta";
config.notifyReleaseStages = @[];
config.enabledReleaseStages = @[];
XCTAssertTrue([config shouldSendReports]);
}

- (void)testNotifyReleaseStagesIncludedSends {
- (void)testEnabledReleaseStagesIncludedSends {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.releaseStage = @"beta";
config.notifyReleaseStages = @[ @"beta" ];
config.enabledReleaseStages = @[ @"beta" ];
XCTAssertTrue([config shouldSendReports]);
}

- (void)testNotifyReleaseStagesIncludedInManySends {
- (void)testEnabledReleaseStagesIncludedInManySends {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.releaseStage = @"beta";
config.notifyReleaseStages = @[ @"beta", @"production" ];
config.enabledReleaseStages = @[ @"beta", @"production" ];
XCTAssertTrue([config shouldSendReports]);
}

- (void)testNotifyReleaseStagesExcludedSkipsSending {
- (void)testEnabledReleaseStagesExcludedSkipsSending {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.releaseStage = @"beta";
config.notifyReleaseStages = @[ @"production" ];
config.enabledReleaseStages = @[ @"production" ];
XCTAssertFalse([config shouldSendReports]);
}

Expand Down
8 changes: 4 additions & 4 deletions Tests/BugsnagEventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ @interface BugsnagEventTests : BugsnagBaseUnitTest

@implementation BugsnagEventTests

- (void)testNotifyReleaseStagesSendsFromConfig {
- (void)testEnabledReleaseStagesSendsFromConfig {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.notifyReleaseStages = @[ @"foo" ];
config.enabledReleaseStages = @[ @"foo" ];
config.releaseStage = @"foo";
BugsnagHandledState *state =
[BugsnagHandledState handledStateWithSeverityReason:HandledException];
Expand All @@ -57,9 +57,9 @@ - (void)testNotifyReleaseStagesSendsFromConfig {
XCTAssertTrue([event shouldBeSent]);
}

- (void)testNotifyReleaseStagesSkipsSendFromConfig {
- (void)testEnabledReleaseStagesSkipsSendFromConfig {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.notifyReleaseStages = @[ @"foo", @"bar" ];
config.enabledReleaseStages = @[ @"foo", @"bar" ];
config.releaseStage = @"not foo or bar";

BugsnagHandledState *state =
Expand Down
5 changes: 4 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ The exact error is available using the `BSGConfigurationErrorDomain` and

- config.notifierType
+ config.appType

- config.notifyReleaseStages
+ config.enabledReleaseStages
```

#### Removals
Expand Down Expand Up @@ -224,7 +227,7 @@ of the removed `addAttribute`:
- [event shouldBeSent:]
- [event toJson:]
- [event enhancedErrorMessageForThread:]
- event.notifyReleaseStages
- event.enabledReleaseStages
- event.handledState
- event.overrides
- event.depth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NotifyWhenReleaseStageInNotifyReleaseStages : Scenario {
override func startBugsnag() {
self.config.autoTrackSessions = false;
self.config.releaseStage = "prod"
self.config.notifyReleaseStages = ["dev", "prod"]
self.config.enabledReleaseStages = ["dev", "prod"]
super.startBugsnag()
}

Expand All @@ -23,7 +23,7 @@ class CrashWhenReleaseStageInNotifyReleaseStages : Scenario {
override func startBugsnag() {
self.config.autoTrackSessions = false;
self.config.releaseStage = "prod"
self.config.notifyReleaseStages = ["dev", "prod"]
self.config.enabledReleaseStages = ["dev", "prod"]
super.startBugsnag()
}

Expand All @@ -43,7 +43,7 @@ class CrashWhenReleaseStageInNotifyReleaseStagesChanges : Scenario {
// A crash will occur
self.config.releaseStage = "prod"
}
self.config.notifyReleaseStages = ["dev", "prod"]
self.config.enabledReleaseStages = ["dev", "prod"]
super.startBugsnag()
}

Expand All @@ -63,7 +63,7 @@ class CrashWhenReleaseStageNotInNotifyReleaseStagesChanges : Scenario {
// A crash will occur
self.config.releaseStage = "test"
}
self.config.notifyReleaseStages = ["dev", "prod"]
self.config.enabledReleaseStages = ["dev", "prod"]
super.startBugsnag()
}

Expand All @@ -77,7 +77,7 @@ class NotifyWhenReleaseStageNotInNotifyReleaseStages : Scenario {
override func startBugsnag() {
self.config.autoTrackSessions = false;
self.config.releaseStage = "dev"
self.config.notifyReleaseStages = ["prod"]
self.config.enabledReleaseStages = ["prod"]
super.startBugsnag()
}

Expand All @@ -93,7 +93,7 @@ class CrashWhenReleaseStageNotInNotifyReleaseStages : Scenario {
override func startBugsnag() {
self.config.autoTrackSessions = false;
self.config.releaseStage = "dev"
self.config.notifyReleaseStages = ["prod"]
self.config.enabledReleaseStages = ["prod"]
super.startBugsnag()
}

Expand Down
8 changes: 4 additions & 4 deletions iOS/BugsnagTests/BugsnagEventFromKSCrashReportTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @interface BugsnagEventFromKSCrashReportTest : XCTestCase
@interface BugsnagEvent ()
- (NSDictionary *_Nonnull)toJson;
- (BOOL)shouldBeSent;
@property(readwrite, copy, nullable) NSArray *notifyReleaseStages;
@property(readwrite, copy, nullable) NSArray *enabledReleaseStages;
@property(readwrite) NSUInteger depth;
@end

Expand Down Expand Up @@ -49,12 +49,12 @@ - (void)testReadReleaseStage {
XCTAssertEqualObjects(self.report.releaseStage, @"production");
}

- (void)testReadNotifyReleaseStages {
XCTAssertEqualObjects(self.report.notifyReleaseStages,
- (void)testReadEnabledReleaseStages {
XCTAssertEqualObjects(self.report.enabledReleaseStages,
(@[ @"production", @"development" ]));
}

- (void)testReadNotifyReleaseStagesSends {
- (void)testReadEnabledReleaseStagesSends {
XCTAssertTrue([self.report shouldBeSent]);
}

Expand Down