[RUBY] Introducing Bugsnag on Heroku

Heroku x Rails.

Add add-on → Get API key

You can operate it from the dashboard or from the command line.

When operating from the dashboard

--Access the Heroku dashboard --Open Resources tab --Enter'Bugsnag'in the search window under Add-ons -Click Provision --Open the Settings tab --Click Reveal Config Vars and check the Bugsnag API key

Operate from the command line

With the Heroku CLI installed, hit the following command

$ heroku addons:create bugsnag
$ heroku config:get BUGSNAG_API_KEY
70d9b0852a968b1d0d0e329b5507f287 #API key

Application side settings

Gemfile


gem 'bugsnag'
$ bundle install
$ rails generate bugsnag 70d9b0852a968b1d0d0e329b5507f287 #API key

config / initializers / bugsnag.rb is generated. By default, the API key is solid, so it is stored in an environment variable. I wrote the following using a gem called dotenv.

config/initializers/bugsnag.rb


Bugsnag.configure do |config|
  config.api_key = ENV['BUGSNAG_API_KEY'] #Fix
end

Fixed to work only in production environment

config/initializers/bugsnag.rb


Bugsnag.configure do |config|
  config.api_key = ENV['BUGSNAG_API_KEY']
  config.notify_release_stages = ['production'] #add to
end

Other

If you want to catch the exception you are raising by using raise etc., useBugsnag.notify (exception).

begin
  raise 'Something went wrong!'
rescue => exception
  Bugsnag.notify(exception)
end

reference

Recommended Posts

Introducing Bugsnag on Heroku
Introducing Basic Authentication on Heroku [Spring Framework]
Introducing New Relic to Rails apps on Heroku
Yay! I'm on Heroku!
Use Corretto 11 on Heroku
Error resolution on Heroku
Introducing New Relic to Java apps running on Heroku
Introduce Rails/Basic authentication on Heroku.
How to deploy on heroku
Introducing Let's Encrypt on CentOS 7
Use PG Backups on Heroku
Run puppeteer-core on Heroku (Docker edition)
Deploy a war file on Heroku
Deploy Flask's Docker image on Heroku
DB error on deploying with Heroku
Deploy Rails on Docker to heroku
Deploy your Rails app on Heroku
How to redo a deployment on Heroku
How to publish an application on Heroku
Introducing Docker Desktop for Windows on WSL2
Deploy to Heroku [Ruby on Rails] Beginner
Enable natto / mecab gem on Heroku environment
Deploy a Java web app on Heroku
Deploy a Tomcat-based Eclipse project on Heroku