Commit 3c73874d746a1a244df97342db54952616d1140f

Authored by Michał Młoźniak
1 parent b91851a4
Exists in master and in 1 other branch production

Make errbit to play with v3 api clients

This change allow errbit to accept v3 api calls from airbrake ruby client
and propably some other clients that I've no idea of. This is tiny change
but it took me some time to investigate this, so I want to explain how
to set everything up.

It appears that there is a bug in airbrake gem that causes airbrake to not
send api key in the request. The only way around this is to set project_id
to the value of api key. I've opened an issue for this.

https://github.com/airbrake/airbrake/issues/364

To test it you need to add project_id option to airbrake initializer and also
monkey patch Aibrake::Sender class. Airbrake uses v3 api only when host
is set to collect.airbrake.io and project id is present.

Your airbrake initializer should looks like this:

Airbrake.configure do |config|
  config.api_key    = ENV['airbrake_api_key']
  config.host       = ENV['airbrake_host']
  config.port       = ENV['airbrake_port'].to_i
  config.project_id = ENV['airbrake_api_key']
  config.secure     = false
end

class Airbrake::Sender
  def json_api_enabled?
    true
  end
end
Showing 1 changed file with 2 additions and 3 deletions   Show diff stats
lib/json_parser.rb
... ... @@ -14,10 +14,9 @@ class JsonParser
14 14 backtrace: backtrace,
15 15 request: request,
16 16 server_environment: server_environment,
17   - api_key: params['key'],
  17 + api_key: params['project_id'] || params['key'],
18 18 notifier: params['notifier'],
19   - user_attributes: user_attributes,
20   - framework: 'Javascript'
  19 + user_attributes: user_attributes
21 20 }
22 21  
23 22 ErrorReport.new(attributes)
... ...