Heroku x Rails.
You can operate it from the dashboard or from the command line.
--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
With the Heroku CLI installed, hit the following command
$ heroku addons:create bugsnag
$ heroku config:get BUGSNAG_API_KEY
70d9b0852a968b1d0d0e329b5507f287 #API key
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
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
Recommended Posts