diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e70d64c..28048023c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Source/Bugsnag.h b/Source/Bugsnag.h index dd2a1f3c1..0504ee512 100644 --- a/Source/Bugsnag.h +++ b/Source/Bugsnag.h @@ -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. * @@ -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 diff --git a/Source/Bugsnag.m b/Source/Bugsnag.m index 64d1b5bfb..3e02b53b9 100644 --- a/Source/Bugsnag.m +++ b/Source/Bugsnag.m @@ -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]; diff --git a/Source/Private.h b/Source/Private.h index a3dbf096c..1fec8adf7 100644 --- a/Source/Private.h +++ b/Source/Private.h @@ -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. diff --git a/Tests/BugsnagBaseUnitTest.m b/Tests/BugsnagBaseUnitTest.m index f51b76adf..24354f625 100644 --- a/Tests/BugsnagBaseUnitTest.m +++ b/Tests/BugsnagBaseUnitTest.m @@ -48,7 +48,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify return false; }]; } - [Bugsnag startBugsnagWithConfiguration:configuration]; + [Bugsnag startWithConfiguration:configuration]; } @end diff --git a/Tests/BugsnagBreadcrumbsTest.m b/Tests/BugsnagBreadcrumbsTest.m index 37fb54b76..0551373d1 100644 --- a/Tests/BugsnagBreadcrumbsTest.m +++ b/Tests/BugsnagBreadcrumbsTest.m @@ -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", @@ -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]; diff --git a/Tests/BugsnagClientMirrorTest.m b/Tests/BugsnagClientMirrorTest.m index 529122904..7af34e3f3 100644 --- a/Tests/BugsnagClientMirrorTest.m +++ b/Tests/BugsnagClientMirrorTest.m @@ -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", diff --git a/Tests/BugsnagClientTests.m b/Tests/BugsnagClientTests.m index 154b3e4af..4e5b7cb3f 100644 --- a/Tests/BugsnagClientTests.m +++ b/Tests/BugsnagClientTests.m @@ -51,7 +51,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify { return false; }]; } - [Bugsnag startBugsnagWithConfiguration:configuration]; + [Bugsnag startWithConfiguration:configuration]; } /** diff --git a/Tests/BugsnagConfigurationTests.m b/Tests/BugsnagConfigurationTests.m index 62578f6ac..88b9140a7 100644 --- a/Tests/BugsnagConfigurationTests.m +++ b/Tests/BugsnagConfigurationTests.m @@ -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]; } @@ -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]; @@ -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 @@ -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); @@ -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); } diff --git a/Tests/BugsnagOnBreadcrumbTest.m b/Tests/BugsnagOnBreadcrumbTest.m index ce88e529c..1dd1415b1 100644 --- a/Tests/BugsnagOnBreadcrumbTest.m +++ b/Tests/BugsnagOnBreadcrumbTest.m @@ -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]; } @@ -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 @@ -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]; @@ -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"]); @@ -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); diff --git a/Tests/BugsnagPluginTest.m b/Tests/BugsnagPluginTest.m index bac85657d..63b4d1bf6 100644 --- a/Tests/BugsnagPluginTest.m +++ b/Tests/BugsnagPluginTest.m @@ -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]; } @@ -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]; } diff --git a/Tests/BugsnagSinkTests.m b/Tests/BugsnagSinkTests.m index 275068721..909c5c53a 100644 --- a/Tests/BugsnagSinkTests.m +++ b/Tests/BugsnagSinkTests.m @@ -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]]; diff --git a/Tests/BugsnagTests.m b/Tests/BugsnagTests.m index 11056de9f..70b3fed63 100644 --- a/Tests/BugsnagTests.m +++ b/Tests/BugsnagTests.m @@ -48,7 +48,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify { return false; }]; } - [Bugsnag startBugsnagWithConfiguration:configuration]; + [Bugsnag startWithConfiguration:configuration]; } /** @@ -153,7 +153,7 @@ -(void)testBugsnagPauseSession { return false; }]; - [Bugsnag startBugsnagWithConfiguration:configuration]; + [Bugsnag startWithConfiguration:configuration]; // For now only test that the method exists [Bugsnag pauseSession]; @@ -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]; @@ -273,7 +273,7 @@ - (void)testRemoveOnSessionBlock { [configuration addOnSessionBlock:sessionBlock]; - [Bugsnag startBugsnagWithConfiguration:configuration]; + [Bugsnag startWithConfiguration:configuration]; [self waitForExpectations:@[expectation1] timeout:1.0]; [Bugsnag pauseSession]; @@ -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]; @@ -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]; diff --git a/UPGRADING.md b/UPGRADING.md index 7df6ccfd2..f59c33414 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -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:] @@ -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:) diff --git a/examples/objective-c-ios/Bugsnag Test App/AppDelegate.m b/examples/objective-c-ios/Bugsnag Test App/AppDelegate.m index 44109e637..bdc9fa73e 100644 --- a/examples/objective-c-ios/Bugsnag Test App/AppDelegate.m +++ b/examples/objective-c-ios/Bugsnag Test App/AppDelegate.m @@ -15,7 +15,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( NSString *apiKey = @""; BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:apiKey]; - [Bugsnag startBugsnagWithConfiguration:config]; + [Bugsnag startWithConfiguration:config]; return YES; } diff --git a/examples/objective-c-ios/Bugsnag Test App/ViewController.m b/examples/objective-c-ios/Bugsnag Test App/ViewController.m index 2b0e064b8..86c7bc64a 100644 --- a/examples/objective-c-ios/Bugsnag Test App/ViewController.m +++ b/examples/objective-c-ios/Bugsnag Test App/ViewController.m @@ -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; }]; } } diff --git a/examples/objective-c-osx/objective-c-osx/AppDelegate.m b/examples/objective-c-osx/objective-c-osx/AppDelegate.m index 20d46a616..e287ce090 100644 --- a/examples/objective-c-osx/objective-c-osx/AppDelegate.m +++ b/examples/objective-c-osx/objective-c-osx/AppDelegate.m @@ -23,7 +23,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSString *apiKey = @""; BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:apiKey]; - [Bugsnag startBugsnagWithConfiguration:config]; + [Bugsnag startWithConfiguration:config]; } diff --git a/examples/swift-ios/bugsnag-example/ViewController.swift b/examples/swift-ios/bugsnag-example/ViewController.swift index 205ab56a7..a286e7757 100644 --- a/examples/swift-ios/bugsnag-example/ViewController.swift +++ b/examples/swift-ios/bugsnag-example/ViewController.swift @@ -63,6 +63,7 @@ class ViewController: UITableViewController { Bugsnag.notifyError(error) { report in // modify report properties in the (optional) block report.severity = .info + return true } } } diff --git a/features/fixtures/ios-swift-cocoapods/iOSTestApp/scenarios/Scenario.m b/features/fixtures/ios-swift-cocoapods/iOSTestApp/scenarios/Scenario.m index 0eb67b3a5..366bef307 100644 --- a/features/fixtures/ios-swift-cocoapods/iOSTestApp/scenarios/Scenario.m +++ b/features/fixtures/ios-swift-cocoapods/iOSTestApp/scenarios/Scenario.m @@ -41,7 +41,7 @@ - (void)run { } - (void)startBugsnag { - [Bugsnag startBugsnagWithConfiguration:self.config]; + [Bugsnag startWithConfiguration:self.config]; } @end diff --git a/iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m b/iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m index b7c5af23e..d654fb09f 100644 --- a/iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m +++ b/iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m @@ -33,7 +33,7 @@ - (void)setUp { config.autoDetectErrors = NO; config.releaseStage = @"MagicalTestingTime"; - [Bugsnag startBugsnagWithConfiguration:config]; + [Bugsnag startWithConfiguration:config]; } - (void)testNilPathDoesNotCreateWatchdog {