Merge pull request #8872 from Matt-Yorkley/bugsnag-data

Update Bugsnag error data
This commit is contained in:
jibees
2022-10-20 17:30:14 +02:00
committed by GitHub
8 changed files with 36 additions and 20 deletions

View File

@@ -50,7 +50,9 @@ module OrderCompletion
end
def order_invalid!
Bugsnag.notify("Notice: invalid order loaded during checkout", order: @order)
Bugsnag.notify("Notice: invalid order loaded during checkout") do |payload|
payload.add_metadata :order, @order
end
flash[:error] = t('checkout.order_not_loaded')
redirect_to main_app.shop_path
@@ -81,7 +83,9 @@ module OrderCompletion
end
def processing_failed(error = RuntimeError.new(order_processing_error))
Bugsnag.notify(error, order: @order)
Bugsnag.notify(error) do |payload|
payload.add_metadata :order, @order
end
flash[:error] = order_processing_error if flash.blank?
Checkout::PostCheckoutActions.new(@order).failure
end

View File

@@ -21,7 +21,9 @@ module OrderStockCheck
def check_order_cycle_expiry
return unless current_order_cycle&.closed?
Bugsnag.notify("Notice: order cycle closed during checkout completion", order: current_order)
Bugsnag.notify("Notice: order cycle closed during checkout completion") do |payload|
payload.add_metadata :order, current_order
end
current_order.empty!
current_order.set_order_cycle! nil

View File

@@ -227,10 +227,10 @@ module Spree
def notify_bugsnag(error, product, variant)
Bugsnag.notify(error) do |report|
report.add_tab(:product, product.attributes)
report.add_tab(:product_error, product.errors.first) unless product.valid?
report.add_tab(:variant, variant.attributes)
report.add_tab(:variant_error, variant.errors.first) unless variant.valid?
report.add_metadata(:product, product.attributes)
report.add_metadata(:product_error, product.errors.first) unless product.valid?
report.add_metadata(:variant, variant.attributes)
report.add_metadata(:variant_error, variant.errors.first) unless variant.valid?
end
end

View File

@@ -55,7 +55,9 @@ class SubscriptionConfirmJob < ActiveJob::Base
if order.errors.any?
send_failed_payment_email(order)
else
Bugsnag.notify(e, order: order)
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
end
send_failed_payment_email(order, e.message)
end
end
@@ -106,6 +108,9 @@ class SubscriptionConfirmJob < ActiveJob::Base
record_and_log_error(:failed_payment, order, error_message)
SubscriptionMailer.failed_payment_email(order).deliver_now
rescue StandardError => e
Bugsnag.notify(e, order: order, error_message: error_message)
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
payload.add_metadata :error_message, error_message
end
end
end

View File

@@ -540,9 +540,9 @@ module Spree
# And the shipping fee is already up-to-date when this error occurs.
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3924
Bugsnag.notify(e) do |report|
report.add_tab(:order, attributes)
report.add_tab(:shipment, shipment.attributes)
report.add_tab(:shipment_in_db, Spree::Shipment.find_by(id: shipment.id).attributes)
report.add_metadata(:order, attributes)
report.add_metadata(:shipment, shipment.attributes)
report.add_metadata(:shipment_in_db, Spree::Shipment.find_by(id: shipment.id).attributes)
end
end

View File

@@ -24,7 +24,9 @@ class PlaceProxyOrder
send_placement_email
rescue StandardError => e
summarizer.record_and_log_error(:processing, order, e.message)
Bugsnag.notify(e, order: order)
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
end
end
private
@@ -54,7 +56,10 @@ class PlaceProxyOrder
true
rescue StandardError => e
Bugsnag.notify(e, subscription: subscription, proxy_order: proxy_order)
Bugsnag.notify(e) do |payload|
payload.add_metadata :subscription, subscription
payload.add_metadata :proxy_order, proxy_order
end
false
end

View File

@@ -132,11 +132,11 @@ module Sets
def notify_bugsnag(error, product, variant, variant_attributes)
Bugsnag.notify(error) do |report|
report.add_tab(:product, product.attributes)
report.add_tab(:product_error, product.errors.first) unless product.valid?
report.add_tab(:variant_attributes, variant_attributes)
report.add_tab(:variant, variant.attributes)
report.add_tab(:variant_error, variant.errors.first) unless variant.valid?
report.add_metadata(:product, product.attributes)
report.add_metadata(:product_error, product.errors.first) unless product.valid?
report.add_metadata(:variant_attributes, variant_attributes)
report.add_metadata(:variant, variant.attributes)
report.add_metadata(:variant_error, variant.errors.first) unless variant.valid?
end
end

View File

@@ -37,7 +37,7 @@ describe PlaceProxyOrder do
order.line_items << build(:line_item)
expect(summarizer).to receive(:record_and_log_error).with(:processing, order, kind_of(String))
expect(Bugsnag).to receive(:notify).with(kind_of(StandardError), order: order)
expect(Bugsnag).to receive(:notify).with(kind_of(StandardError))
subject.call
end