openfoodfoundation / openfoodnetwork

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

Notify deploys to Bugsnag #3183

Open sauloperez opened 5 years ago

sauloperez commented 5 years ago

Description

Bugsnag would we much more useful if we could know:

This will also help us correlate issues when experiencing errors on production.

Possible fix

Bugsnag's documentation is quite good and has all the details we need.

In https://docs.bugsnag.com/platforms/ruby/rails/#tracking-releases we can find how to provide the app version to the Bugsnag client. This will definitely need an ENV var set at deployment time containing the release number.

None of the build & deploy integrations works for us but it is as simple as a performing an HTTP request with the required details, like follows:

$ curl https://build.bugsnag.com/ \
    --header "Content-Type: application/json" \
    --data '{
      "apiKey": "YOUR_API_KEY_HERE",
      "appVersion": "1.2.3",
      "releaseStage": "production",
      "builderName": "Joe Summer",
      "sourceControl": {
        "provider": "github",
        "repository": "https://github.com/owner/repo",
        "revision": "52097f461bf76a824212eb11de53467c094d0cd4"
      },
      "metadata": {"feature-93": "New settings page"}
    }'

See details: https://docs.bugsnag.com/build-integrations/#if-your-build-tool-is-not-supported.

We can also check out the implementation of their Capistrano integration

sauloperez commented 5 years ago

Notifying should be rather straightforward with Ansible's uri_module

sauloperez commented 5 years ago

Note however that appVersion cannot be provided yet because the version is not yet kept in the codebase. It's just a git tag.