Skip to content

Commit

Permalink
Merge pull request #318 from bugsnag/grouping-hash-exception
Browse files Browse the repository at this point in the history
Add bugsnag_grouping_hash to metadata module
  • Loading branch information
snmaynard authored Aug 20, 2016
2 parents 396cbb7 + 77e3897 commit 5204120
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bugsnag/meta_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module MetaData
attr_accessor :bugsnag_meta_data
attr_accessor :bugsnag_user_id
attr_accessor :bugsnag_context
attr_accessor :bugsnag_grouping_hash
end
end
3 changes: 3 additions & 0 deletions lib/bugsnag/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def deliver
if exception.bugsnag_context.is_a?(String)
self.context = exception.bugsnag_context
end
if exception.bugsnag_grouping_hash.is_a?(String)
self.grouping_hash = exception.bugsnag_grouping_hash
end
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ def gloops
}
end

it "accepts grouping_hash from an exception that mixes in Bugsnag::MetaData" do
exception = BugsnagTestExceptionWithMetaData.new("It crashed")
exception.bugsnag_grouping_hash = "exception_hash"

Bugsnag.notify(exception)

expect(Bugsnag).to have_sent_notification{ |payload|
event = get_event_from_payload(payload)
expect(event["groupingHash"]).to eq("exception_hash")
}
end

it "accept contexts from an exception that mixes in Bugsnag::MetaData, but override using the overrides" do

exception = BugsnagTestExceptionWithMetaData.new("It crashed")
Expand Down

0 comments on commit 5204120

Please sign in to comment.