Skip to content

Commit

Permalink
Fix Bugsnag call to notify
Browse files Browse the repository at this point in the history
  • Loading branch information
rioug committed Nov 6, 2024
1 parent 9afd545 commit eb66244
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/order_completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def order_invalid_for_checkout?

def order_invalid!
Bugsnag.notify("Notice: invalid order loaded during checkout") do |payload|
payload.add_metadata :order, @order
payload.add_metadata :order, :order, @order
end

flash[:error] = t('checkout.order_not_loaded')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/order_stock_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def check_order_cycle_expiry
return unless current_order_cycle&.closed?

Bugsnag.notify("Notice: order cycle closed during checkout completion") do |payload|
payload.add_metadata :order, current_order
payload.add_metadata :order, :order, current_order
end
current_order.empty!
current_order.set_order_cycle! nil
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def not_found
Bugsnag.notify("404") do |event|
event.severity = "info"

event.add_metadata(:request, request.env)
event.add_metadata(:request, :request, request.env)
end
render status: :not_found, formats: :html
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/spree/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ def set_stock_levels(product, on_hand, on_demand)

def notify_bugsnag(error, product, variant)
Bugsnag.notify(error) do |report|
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?
report.add_metadata(:product,
{ product: product.attributes, variant: variant.attributes })
report.add_metadata(:product, :product_error, product.errors.first) unless product.valid?
report.add_metadata(:product, :variant_error, variant.errors.first) unless variant.valid?
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/backorder_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.check_stock(order)
# Errors here shouldn't affect the checkout. So let's report them
# separately:
Bugsnag.notify(e) do |payload|
payload.add_metadata(:order, order)
payload.add_metadata(:order, :order, order)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/jobs/stock_sync_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.sync_linked_catalogs(order)
# Errors here shouldn't affect the shopping. So let's report them
# separately:
Bugsnag.notify(e) do |payload|
payload.add_metadata(:order, order)
payload.add_metadata(:order, :order, order)
end
end

Expand All @@ -30,7 +30,7 @@ def self.sync_linked_catalogs_now(order)
# Errors here shouldn't affect the shopping. So let's report them
# separately:
Bugsnag.notify(e) do |payload|
payload.add_metadata(:order, order)
payload.add_metadata(:order, :order, order)
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/jobs/subscription_confirm_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def confirm_order!(order)
send_failed_payment_email(order)
else
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
payload.add_metadata :order, :order, order
end
send_failed_payment_email(order, e.message)
end
Expand Down Expand Up @@ -109,8 +109,7 @@ def send_failed_payment_email(order, error_message = nil)
SubscriptionMailer.failed_payment_email(order).deliver_now
rescue StandardError => e
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
payload.add_metadata :error_message, error_message
payload.add_metadata :subscription_data, { order:, error_message: }
end
end
end
5 changes: 2 additions & 3 deletions app/services/place_proxy_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def call
rescue StandardError => e
summarizer.record_and_log_error(:processing, order, e.message)
Bugsnag.notify(e) do |payload|
payload.add_metadata :order, order
payload.add_metadata :order, :order, order
end
end

Expand Down Expand Up @@ -57,8 +57,7 @@ def initialise_order
true
rescue StandardError => e
Bugsnag.notify(e) do |payload|
payload.add_metadata :subscription, subscription
payload.add_metadata :proxy_order, proxy_order
payload.add_metadata(:proxy_order, { subscription:, proxy_order: })
end
false
end
Expand Down
10 changes: 5 additions & 5 deletions app/services/sets/product_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def count_result(saved)

def notify_bugsnag(error, product, variant, variant_attributes)
Bugsnag.notify(error) do |report|
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?
report.add_metadata( :product_set,
{ product: product.attributes, variant_attributes:,
variant: variant.attributes } )
report.add_metadata(:product_set, :product_error, product.errors.first) if !product.valid?
report.add_metadata(:product_set, :variant_error, variant.errors.first) if !variant.valid?
end
end
end
Expand Down

0 comments on commit eb66244

Please sign in to comment.