Created
March 24, 2014 16:36
-
-
Save niallsmart/9743968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Honeybadger | |
IGNORED_NOT_FOUND_PATHS = %w{ | |
/apple-touch-icon-72x72.png | |
/apple-touch-icon-72x72-precomposed.png | |
/apple-touch-icon-114x114.png | |
/apple-touch-icon-114x114-precomposed.png | |
/apple-touch-icon-120x120.png | |
/apple-touch-icon-120x120-precomposed.png | |
/apple-touch-icon-152x152.png | |
/apple-touch-icon-152x152-precomposed.png | |
/apple-touch-icon-precomposed.png | |
/browserconfig.xml | |
} | |
class << self | |
def notify_or_ignore_with_component(ex, opts = {}) | |
env = opts.fetch(:rack_env, {}) | |
request = ::Rack::Request.new(env) | |
session = request.session[:active] | |
if ex.is_a? ActionController::RoutingError | |
return if request.request_method == "OPTIONS" | |
return if request.path.in?(IGNORED_NOT_FOUND_PATHS) | |
opts[:component] ||= request.url | |
end | |
if session.present? | |
context = { | |
effective_user_id: session.effective_user.id, | |
effective_user_name: session.effective_user.name, | |
effective_user_email: session.effective_user.email | |
} | |
if session.login_as? | |
context.merge! \ | |
real_user_id: session.real_user.id, | |
real_user_name: session.real_user.name, | |
real_user_email: session.real_user.email | |
end | |
Honeybadger.context context | |
end | |
notify_or_ignore_without_component(ex, opts) | |
end | |
alias_method_chain :notify_or_ignore, :component | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment