diff --git a/lib/bugsnag/meta_data.rb b/lib/bugsnag/meta_data.rb index f4584df0f..51fcb01ac 100644 --- a/lib/bugsnag/meta_data.rb +++ b/lib/bugsnag/meta_data.rb @@ -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 diff --git a/lib/bugsnag/notification.rb b/lib/bugsnag/notification.rb index 3fa4762c3..76a44ed86 100644 --- a/lib/bugsnag/notification.rb +++ b/lib/bugsnag/notification.rb @@ -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 diff --git a/spec/notification_spec.rb b/spec/notification_spec.rb index 3cc964a83..5b50ca18e 100644 --- a/spec/notification_spec.rb +++ b/spec/notification_spec.rb @@ -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")