lib/wat_catcher/report.rb in wat_catcher-0.4.1 vs lib/wat_catcher/report.rb in wat_catcher-0.5.0
- old
+ new
@@ -1,22 +1,28 @@
module WatCatcher
class Report
- attr_accessor :exception, :request, :sidekiq
+ attr_accessor :exception, :request, :sidekiq, :user
- def initialize(exception, request: nil, sidekiq: nil)
+ def initialize(exception, user: nil, request: nil, sidekiq: nil)
self.exception = exception
self.request = request
self.sidekiq = sidekiq
+ self.user = user
send_report
end
def send_report
::WatCatcher::SidekiqPoster.perform_async("#{WatCatcher.configuration.host}/wats", params)
end
def params
- { wat: base_description.merge(exception_description).merge(request_description).merge(worker_description).merge(param_exception_description) }
+ { wat: base_description
+ .merge(user_description)
+ .merge(exception_description)
+ .merge(request_description)
+ .merge(worker_description)
+ .merge(param_exception_description) }
end
def param_exception_description
return {} if exception || request.blank?
request.params[:wat].merge(request_params: nil)
@@ -26,9 +32,17 @@
{
app_env: ::Rails.env.to_s,
app_name: ::Rails.application.class.parent_name,
language: "ruby"
}
+ end
+
+ def user_description
+ u = nil
+ begin
+ u = user.as_json
+ rescue; end
+ { app_user: u }
end
def exception_description
return {} unless exception
{