Class: Bugsnag::Middleware::ClearanceUser
- Inherits:
-
Object
- Object
- Bugsnag::Middleware::ClearanceUser
- Defined in:
- lib/bugsnag/middleware/clearance_user.rb
Overview
Extracts and appends clearance user information
Constant Summary collapse
- COMMON_USER_FIELDS =
[:email, :name, :first_name, :last_name, :created_at, :id]
Instance Method Summary collapse
- #call(report) ⇒ Object
-
#initialize(bugsnag) ⇒ ClearanceUser
constructor
A new instance of ClearanceUser.
Constructor Details
#initialize(bugsnag) ⇒ ClearanceUser
Returns a new instance of ClearanceUser.
7 8 9 |
# File 'lib/bugsnag/middleware/clearance_user.rb', line 7 def initialize(bugsnag) @bugsnag = bugsnag end |
Instance Method Details
#call(report) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bugsnag/middleware/clearance_user.rb', line 11 def call(report) if report.request_data[:rack_env] && report.request_data[:rack_env][:clearance] && report.request_data[:rack_env][:clearance].signed_in? && report.request_data[:rack_env][:clearance].current_user # Extract useful user information user = {} user_object = report.request_data[:rack_env][:clearance].current_user if user_object # Build the bugsnag user info from the current user record COMMON_USER_FIELDS.each do |field| user[field] = user_object.send(field) if user_object.respond_to?(field) end end report.user = user unless user.empty? end @bugsnag.call(report) end |