Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling send(nil) when building rollbar_person_data #1127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions lib/rollbar/plugins/rails/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@ module ControllerMethods
include RequestDataExtractor

def rollbar_person_data
user = nil
unless Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)
user = send(Rollbar.configuration.person_method)
end
return {} if Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)

config = Rollbar.configuration
user = send(config.person_method)
return {} unless user

# include id, username, email if non-empty
if user
{
:id => (begin
user.send(Rollbar.configuration.person_id_method)
rescue StandardError
nil
end),
:username => (begin
user.send(Rollbar.configuration.person_username_method)
rescue StandardError
nil
end),
:email => (begin
user.send(Rollbar.configuration.person_email_method)
rescue StandardError
nil
end)
}
else
{}
end
{
:id => (begin
user.send(config.person_id_method) if config.person_id_method
rescue StandardError
nil
end),
:username => (begin
user.send(config.person_username_method) if config.person_username_method
rescue StandardError
nil
end),
:email => (begin
user.send(config.person_email_method) if config.person_email_method
rescue StandardError
nil
end)
}
rescue NameError
{}
end
Expand Down