openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

Add simpler Alert.raise interface to notify Bugsnag #12992

Open mkllnk opened 5 days ago

mkllnk commented 5 days ago

What? Why?

Bugsnag's API is great for general purpose but overly complex for our use. It also changes over time and we often make mistakes using it. So this class aims at:

In a previous PR, we tried to fix the syntax like this:

-        payload.add_metadata :order, order
+        payload.add_metadata :order, :order, order

But that didn't work. I think that the order object was converted to a hash before but newer versions of Bugsnag have less magic. And passing the order as value doesn't work either, it just got filtered out when I tested. So this pull request adds some logic to convert an ActiveRecord object to proper Bugsnag metadata. We may want to expand the functionality in the future but I didn't want to spend too much time on this now.

Hopefully this PR is enough to propagate correct use from now on.

What should we test?

Release notes

Changelog Category (reviewers may add a label for the release notes):

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates