lib/raygun/client.rb in raygun4ruby-2.5.0 vs lib/raygun/client.rb in raygun4ruby-2.6.0
- old
+ new
@@ -88,10 +88,12 @@
def rails_env
ENV["RAILS_ENV"]
end
def request_information(env)
+ Raygun.log('retrieving request information')
+
return {} if env.nil? || env.empty?
{
hostName: env["SERVER_NAME"],
url: env["PATH_INFO"],
httpMethod: env["REQUEST_METHOD"],
@@ -116,10 +118,12 @@
.split.map(&:capitalize).join(' ')
.sub(/ /, '-')
end
def form_params(env)
+ Raygun.log('retrieving form params')
+
params = action_dispatch_params(env) || rack_params(env) || {}
filter_params_with_blacklist(params, env["action_dispatch.parameter_filter"])
end
def action_dispatch_params(env)
@@ -130,14 +134,16 @@
request = Rack::Request.new(env)
request.params if env["rack.input"]
end
def raw_data(rack_env)
+ Raygun.log('retrieving raw data')
request = Rack::Request.new(rack_env)
return unless Raygun.configuration.record_raw_data
return if request.get?
+ Raygun.log('passed raw_data checks')
input = rack_env['rack.input']
if input && !request.form_data?
input.rewind
@@ -156,10 +162,11 @@
filter_params_with_blacklist(params, env["action_dispatch.parameter_filter"])
end
# see http://raygun.io/raygun-providers/rest-json-api?v=1
def build_payload_hash(exception_instance, env = {}, user = nil)
+ Raygun.log('building payload hash')
custom_data = filter_custom_data(env) || {}
exception_custom_data = if exception_instance.respond_to?(:raygun_custom_data)
exception_instance.raygun_custom_data
else
{}
@@ -178,19 +185,23 @@
configuration_tags = Raygun.configuration.tags.call(exception_instance, env)
else
configuration_tags = Raygun.configuration.tags
end
+ Raygun.log('set tags')
+
grouping_key = env.delete(:grouping_key)
configuration_custom_data = Raygun.configuration.custom_data
configured_custom_data = if configuration_custom_data.is_a?(Proc)
configuration_custom_data.call(exception_instance, env)
else
configuration_custom_data
end
+ Raygun.log('set custom data')
+
error_details = {
machineName: hostname,
version: version,
client: client_details,
error: error_details(exception_instance),
@@ -202,29 +213,36 @@
}
}
store = ::Raygun::Breadcrumbs::Store
error_details[:breadcrumbs] = store.stored.map(&:build_payload) if store.any?
+ Raygun.log('set details and breadcrumbs')
+
error_details.merge!(groupingKey: grouping_key) if grouping_key
user_details = if affected_user_present?(env)
user_information(env)
elsif user != nil
AffectedUser.information_hash(user)
end
error_details.merge!(user: user_details) unless user_details == nil
+ Raygun.log('set user details')
+
if Raygun.configuration.filter_payload_with_whitelist
+ Raygun.log('filtering payload with whitelist')
error_details = filter_payload_with_whitelist(error_details)
end
{
occurredOn: Time.now.utc.iso8601,
details: error_details
}
end
def create_entry(payload_hash)
+ Raygun.log('sending payload to api')
+
self.class.post("/entries", verify_peer: true, verify: true, headers: @headers, body: JSON.generate(payload_hash))
end
def filter_params_with_blacklist(params_hash = {}, extra_filter_keys = nil)
return params_hash if Raygun.configuration.filter_payload_with_whitelist