module Ownership::Honeybadger

Attributes

api_keys[R]

Public Class Methods

api_keys=(api_keys) click to toggle source
# File lib/ownership/honeybadger.rb, line 6
def api_keys=(api_keys)
  @api_keys = api_keys
  @configuration ||= configure
  api_keys
end

Private Class Methods

add_owner_as_tag(notice, current_owner) click to toggle source
# File lib/ownership/honeybadger.rb, line 14
def add_owner_as_tag(notice, current_owner)
  return unless current_owner

  notice.tags << current_owner.to_s
end
configure() click to toggle source
# File lib/ownership/honeybadger.rb, line 20
def configure
  ::Honeybadger.configure do |config|
    config.before_notify do |notice|
      current_owner = notice.exception.owner if notice.exception.is_a?(Exception)
      current_owner ||= Ownership.owner

      add_owner_as_tag(notice, current_owner)
      use_owner_api_key(notice, current_owner)
    end
  end
end
owner_api_key(current_owner) click to toggle source
# File lib/ownership/honeybadger.rb, line 32
def owner_api_key(current_owner)
  api_keys.respond_to?(:call) ? api_keys.call(current_owner) : api_keys[current_owner]
end
use_owner_api_key(notice, current_owner) click to toggle source
# File lib/ownership/honeybadger.rb, line 36
def use_owner_api_key(notice, current_owner)
  return unless current_owner

  if (api_key = owner_api_key(current_owner))
    notice.api_key = api_key
  else
    warn "[ownership] Missing Honeybadger API key for owner: #{current_owner}"
  end
end