Skip to content

Commit

Permalink
Merge branch 'v6' into v6-error-types
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 29, 2020
2 parents 3020c28 + b171078 commit 7f263a5
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Bugsnag Notifiers on other platforms.
* Add `unhandledRejections` to `BugsnagErrorTypes`
[#567](https://github.com/bugsnag/bugsnag-cocoa/pull/567)

* Rename `Bugsnag` start methods
[#566](https://github.com/bugsnag/bugsnag-cocoa/pull/566)

* Rename `OnSend` to `OnSendError`
[#562](https://github.com/bugsnag/bugsnag-cocoa/pull/562)

Expand Down
4 changes: 2 additions & 2 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*
* @param apiKey The API key from your Bugsnag dashboard.
*/
+ (BugsnagClient *_Nonnull)startBugsnagWithApiKey:(NSString *_Nonnull)apiKey;
+ (BugsnagClient *_Nonnull)startWithApiKey:(NSString *_Nonnull)apiKey;

/** Start listening for crashes.
*
Expand All @@ -63,7 +63,7 @@
*
* @param configuration The configuration to use.
*/
+ (BugsnagClient *_Nonnull)startBugsnagWithConfiguration:(BugsnagConfiguration *_Nonnull)configuration;
+ (BugsnagClient *_Nonnull)startWithConfiguration:(BugsnagConfiguration *_Nonnull)configuration;

/**
* @return YES if Bugsnag has been started and the previous launch crashed
Expand Down
6 changes: 3 additions & 3 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ - (NSDictionary *_Nonnull)toDictionary;

@implementation Bugsnag

+ (BugsnagClient *_Nonnull)startBugsnagWithApiKey:(NSString *)apiKey {
+ (BugsnagClient *_Nonnull)startWithApiKey:(NSString *_Nonnull)apiKey {
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:apiKey];
return [self startBugsnagWithConfiguration:configuration];
return [self startWithConfiguration:configuration];
}

+ (BugsnagClient *_Nonnull)startBugsnagWithConfiguration:(BugsnagConfiguration *)configuration {
+ (BugsnagClient *_Nonnull)startWithConfiguration:(BugsnagConfiguration *_Nonnull)configuration {
@synchronized(self) {
bsg_g_bugsnag_client =
[[BugsnagClient alloc] initWithConfiguration:configuration];
Expand Down
4 changes: 2 additions & 2 deletions Source/Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

/** Get the current Bugsnag configuration.
*
* This method returns nil if called before +startBugsnagWithApiKey: or
* +startBugsnagWithConfiguration:, and otherwise returns the current
* This method returns nil if called before +startWithApiKey: or
* +startWithConfiguration:, and otherwise returns the current
* configuration for Bugsnag.
*
* @return The configuration, or nil.
Expand Down
2 changes: 1 addition & 1 deletion Tests/BugsnagBaseUnitTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify
return false;
}];
}
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];
}

@end
4 changes: 2 additions & 2 deletions Tests/BugsnagBreadcrumbsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ - (void)testCallbackFreeConstructors2 {
[configuration addOnSendErrorBlock:^BOOL(BugsnagEvent *_Nonnull event) {
return false;
}];
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];

NSDictionary *md1 = @{ @"x" : @"y"};
NSDictionary *md2 = @{ @"a" : @"b",
Expand Down Expand Up @@ -374,7 +374,7 @@ - (void)testCallbackFreeConstructors3 {
[configuration addOnSendErrorBlock:^BOOL(BugsnagEvent *_Nonnull event) {
return false;
}];
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];

[Bugsnag leaveBreadcrumbWithMessage:@"message1"];
[Bugsnag leaveBreadcrumbWithMessage:@"message2" metadata:nil andType:BSGBreadcrumbTypeUser];
Expand Down
4 changes: 2 additions & 2 deletions Tests/BugsnagClientMirrorTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ - (void)setUp {
// the following methods are implemented on Bugsnag but do not need to
// be mirrored on BugsnagClient
self.clientWhitelist = [NSSet setWithArray:@[
@"startBugsnagWithApiKey: @24@0:8@16",
@"startBugsnagWithConfiguration: @24@0:8@16",
@"startWithApiKey: @24@0:8@16",
@"startWithConfiguration: @24@0:8@16",
@"payloadDateFormatter @16@0:8",
@"updateCodeBundleId: v24@0:8@16",
@"instance @16@0:8",
Expand Down
2 changes: 1 addition & 1 deletion Tests/BugsnagClientTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify {
return false;
}];
}
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Tests/BugsnagConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ - (void)testAddOnSessionBlock {
XCTAssertEqual([[config onSessionBlocks] count], 1);

// Call onSession blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}

Expand Down Expand Up @@ -150,7 +150,7 @@ - (void)testRemoveOnSessionBlock {
[config removeOnSessionBlock:sessionBlock];
XCTAssertEqual([[config onSessionBlocks] count], 0);

[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];

// Wait a second NOT to be called
[self waitForExpectationsWithTimeout:1.0 handler:nil];
Expand Down Expand Up @@ -199,7 +199,7 @@ - (void)testAddOnSessionBlockThenRemove {
XCTAssertEqual([[config onSessionBlocks] count], 1);

// Call onSession blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[self waitForExpectations:@[expectation1] timeout:1.0];

// Check it's called on new session start
Expand Down Expand Up @@ -772,7 +772,7 @@ - (void) testRemoveOnSendBlock {
BugsnagOnSendErrorBlock block = ^BOOL(BugsnagEvent * _Nonnull event) { return false; };

[configuration addOnSendErrorBlock:block];
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];

XCTAssertEqual([[configuration onSendBlocks] count], 1);

Expand All @@ -794,8 +794,8 @@ - (void) testClearOnSendBlock {
// Add more than one
[configuration addOnSendErrorBlock:block1];
[configuration addOnSendErrorBlock:block2];
[Bugsnag startBugsnagWithConfiguration:configuration];

[Bugsnag startWithConfiguration:configuration];

XCTAssertEqual([[configuration onSendBlocks] count], 2);
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/BugsnagOnBreadcrumbTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (void)testAddOnBreadcrumbBlock {
XCTAssertEqual([[config onBreadcrumbBlocks] count], 1);

// Call onbreadcrumb blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[Bugsnag leaveBreadcrumbWithMessage:@"Hello"];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
Expand Down Expand Up @@ -86,7 +86,7 @@ - (void)testRemoveOnBreadcrumbBlock {
[config removeOnBreadcrumbBlock:crumbBlock];
XCTAssertEqual([[config onBreadcrumbBlocks] count], 0);

[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[Bugsnag leaveBreadcrumbWithMessage:@"Hello"];

// Wait a second NOT to be called
Expand Down Expand Up @@ -126,7 +126,7 @@ - (void)testAddOnBreadcrumbBlockThenRemove {
XCTAssertEqual([[config onBreadcrumbBlocks] count], 1);

// Call onbreadcrumb blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[Bugsnag leaveBreadcrumbWithMessage:@"Hello"];
[self waitForExpectations:@[expectation1] timeout:1.0];

Expand Down Expand Up @@ -183,7 +183,7 @@ - (void)testAddOnBreadcrumbMutation {
}];

// Call onbreadcrumb blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
XCTAssertEqual([[config onBreadcrumbBlocks] count], 1);
NSDictionary *crumb = [[[[[Bugsnag client] configuration] breadcrumbs] arrayValue] firstObject];
XCTAssertEqualObjects(@"Foo", crumb[@"name"]);
Expand All @@ -201,7 +201,7 @@ - (void)testAddOnBreadcrumbRejection {
}];

// Call onbreadcrumb blocks
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
XCTAssertEqual([[config breadcrumbs].breadcrumbs count], 0);
[Bugsnag leaveBreadcrumbWithMessage:@"Hello"];
XCTAssertEqual([[config breadcrumbs].breadcrumbs count], 0);
Expand Down
4 changes: 2 additions & 2 deletions Tests/BugsnagPluginTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (void)testPluginLoaded {

BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[config addPlugin:plugin];
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[self waitForExpectations:@[expectation] timeout:3.0];
}

Expand All @@ -69,7 +69,7 @@ - (void)testCrashyPluginDoesNotCrashApp {

BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[config addPlugin:plugin];
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
[self waitForExpectations:@[expectation] timeout:3.0];
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/BugsnagSinkTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (void)setUp {
// set a dummy endpoint, avoid hitting production
config.endpoints = [[BugsnagEndpointConfiguration alloc] initWithNotify:@"http://localhost:1234"
sessions:@"http://localhost:1234"];
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
BugsnagEvent *report =
[[BugsnagEvent alloc] initWithKSReport:self.rawReportData];
self.processedData = [[BugsnagSink new] getBodyFromEvents:@[report]];
Expand Down
18 changes: 9 additions & 9 deletions Tests/BugsnagTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify {
return false;
}];
}
[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];
}

/**
Expand Down Expand Up @@ -153,7 +153,7 @@ -(void)testBugsnagPauseSession {
return false;
}];

[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];

// For now only test that the method exists
[Bugsnag pauseSession];
Expand All @@ -171,8 +171,8 @@ - (void)testMutableContext {
[configuration addOnSendErrorBlock:^BOOL(BugsnagEvent *_Nonnull event) {
return false;
}];
[Bugsnag startBugsnagWithConfiguration:configuration];

[Bugsnag startWithConfiguration:configuration];

NSException *exception1 = [[NSException alloc] initWithName:@"exception1" reason:@"reason1" userInfo:nil];

Expand Down Expand Up @@ -273,7 +273,7 @@ - (void)testRemoveOnSessionBlock {

[configuration addOnSessionBlock:sessionBlock];

[Bugsnag startBugsnagWithConfiguration:configuration];
[Bugsnag startWithConfiguration:configuration];
[self waitForExpectations:@[expectation1] timeout:1.0];

[Bugsnag pauseSession];
Expand Down Expand Up @@ -317,8 +317,8 @@ - (void)testAddOnSessionBlock {
// NOTE: Due to test conditions the state of the Bugsnag/client class is indeterminate.
// We *should* be able to test that pre-start() calls to add/removeOnSessionBlock()
// do nothing, but actually we can't guarantee this. For now we don't test this.
[Bugsnag startBugsnagWithConfiguration:configuration];

[Bugsnag startWithConfiguration:configuration];
[Bugsnag pauseSession];

[Bugsnag addOnSessionBlock:sessionBlock];
Expand Down Expand Up @@ -411,8 +411,8 @@ - (void) testOnSendBlocks {
};

// Can't check for block behaviour before start(), so we don't
[Bugsnag startBugsnagWithConfiguration:configuration];

[Bugsnag startWithConfiguration:configuration];

[Bugsnag addOnSendErrorBlock:block1];
[Bugsnag addOnSendErrorBlock:block2];
Expand Down
13 changes: 12 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,19 @@ Bugsnag.getMetadata("section" key:"key")
[Bugsnag getMetadata:@"section" key:@"key"];
```

`startBugsnagWithApiKey` and `startBugsnagWithConfiguration` now return a `BugsnagClient`.
`startWithApiKey` and `startWithConfiguration` now return a `BugsnagClient`.

#### Renames

```diff
ObjC:

- [Bugsnag startBugsnagWithApiKey]
+ [Bugsnag startWithApiKey]

- [Bugsnag startBugsnagWithConfiguration]
+ [Bugsnag startWithConfiguration]

- [Bugsnag configuration]
+ [Bugsnag setUser:withEmail:andName:]

Expand All @@ -155,6 +161,11 @@ ObjC:
+ [Bugsnag notify:block:]

Swift:
- Bugsnag.startBugsnagWith(:apiKey)
+ Bugsnag.startWith(:apiKey)

- Bugsnag.startBugsnagWith(:configuration)
+ Bugsnag.startWith(:configuration)

- Bugsnag.configuration()
+ Bugsnag.setUser(_:email:name:)
Expand Down
2 changes: 1 addition & 1 deletion examples/objective-c-ios/Bugsnag Test App/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

NSString *apiKey = @"<YOUR_APIKEY_HERE>";
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:apiKey];
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];

return YES;
}
Expand Down
3 changes: 2 additions & 1 deletion examples/objective-c-ios/Bugsnag Test App/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ - (IBAction)nonFatalException:(id)sender {
[NSJSONSerialization dataWithJSONObject:actuallyReallyJSON options:0 error:nil];
}
@catch (NSException *exception) {
[Bugsnag notify:exception block:^(BugsnagEvent * _Nonnull report) {
[Bugsnag notify:exception block:^BOOL(BugsnagEvent * _Nonnull report) {
[report addMetadata:@{@"user": @"Bob Loblaw"} toSection:@"tab"];
return true;
}];
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/objective-c-osx/objective-c-osx/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

NSString *apiKey = @"<YOUR_APIKEY_HERE>";
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:apiKey];
[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];

}

Expand Down
1 change: 1 addition & 0 deletions examples/swift-ios/bugsnag-example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ViewController: UITableViewController {
Bugsnag.notifyError(error) { report in
// modify report properties in the (optional) block
report.severity = .info
return true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (void)run {
}

- (void)startBugsnag {
[Bugsnag startBugsnagWithConfiguration:self.config];
[Bugsnag startWithConfiguration:self.config];
}

@end
2 changes: 1 addition & 1 deletion iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)setUp {
config.autoDetectErrors = NO;
config.releaseStage = @"MagicalTestingTime";

[Bugsnag startBugsnagWithConfiguration:config];
[Bugsnag startWithConfiguration:config];
}

- (void)testNilPathDoesNotCreateWatchdog {
Expand Down

0 comments on commit 7f263a5

Please sign in to comment.