Skip to content

Commit

Permalink
feat: Add a breadcrumb when the library starts (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali authored and robinmacharg committed Jan 29, 2020
1 parent 4a6361c commit 6bf1ecb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ Bugsnag Notifiers on other platforms.
* Swift: `try BugsnagConfiguration(_ apiKey)`
* Objective C: `[[BugsnagConfiguration alloc] initWithApiKey:error:]`

[#446](https://github.com/bugsnag/bugsnag-cocoa/pull/446)
[#446](https://github.com/bugsnag/bugsnag-cocoa/pull/446)

### Enhancements

TBD
* Add a breadcrumb when Bugsnag first starts with the message "Bugsnag loaded"
[#445](https://github.com/bugsnag/bugsnag-cocoa/pull/445)

## Bug fixes

Expand Down
6 changes: 6 additions & 0 deletions Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ - (id)initWithConfiguration:(BugsnagConfiguration *)initConfiguration {
NSString *const kRedoOperation = @"Redo Operation";
NSString *const kTableViewSelectionChange = @"TableView Select Change";
NSString *const kAppWillTerminate = @"App Will Terminate";
NSString *const BSGBreadcrumbLoadedMessage = @"Bugsnag loaded";

- (void)initializeNotificationNameMap {
notificationNameMap = @{
Expand Down Expand Up @@ -411,6 +412,11 @@ - (void)start {

[self.sessionTracker startNewSessionIfAutoCaptureEnabled];

[self addBreadcrumbWithBlock:^(BugsnagBreadcrumb *_Nonnull breadcrumb) {
breadcrumb.type = BSGBreadcrumbTypeState;
breadcrumb.name = BSGBreadcrumbLoadedMessage;
}];

// notification not received in time on initial startup, so trigger manually
[self willEnterForeground:self];
}
Expand Down
15 changes: 15 additions & 0 deletions features/breadcrumbs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: Attaching a series of notable events leading up to errors
A breadcrumb contains supplementary data which will be sent along with
events. Breadcrumbs are intended to be pieces of information which can
lead the developer to the cause of the event being reported.

Scenario: An app lauches and subsequently sends a manual event using notify()
When I run "HandledErrorScenario"
And I wait for a request
Then the event breadcrumbs contain "Bugsnag loaded" with type "state"

Scenario: An app lauches and subsequently crahes
When I crash the app using "BuiltinTrapScenario"
And I relaunch the app
And I wait for a request
Then the event breadcrumbs contain "Bugsnag loaded" with type "state"
9 changes: 9 additions & 0 deletions features/steps/ios_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
assert_true(delta.abs < threshold_secs, "Expected current timestamp, but received #{value}")
end

Then("the event breadcrumbs contain {string} with type {string}") do |string, type|
crumbs = read_key_path(find_request(0)[:body], "events.0.breadcrumbs")
assert_not_equal(0, crumbs.length, "There are no breadcrumbs on this event")
match = crumbs.detect do |crumb|
crumb["name"] == string && crumb["type"] == type
end
assert_not_nil(match, "No crumb matches the provided message and type")
end

Then("the event breadcrumbs contain {string}") do |string|
crumbs = read_key_path(find_request(0)[:body], "events.0.breadcrumbs")
assert_not_equal(0, crumbs.length, "There are no breadcrumbs on this event")
Expand Down

0 comments on commit 6bf1ecb

Please sign in to comment.