lib/timber/events/controller_call.rb in timber-2.0.0 vs lib/timber/events/controller_call.rb in timber-2.0.1

- old
+ new

@@ -5,16 +5,18 @@ # Processing by PagesController#home as HTML # # @note This event should be installed automatically through integrations, # such as the {Integrations::ActionController::LogSubscriber} integration. class ControllerCall < Timber::Event + PASSWORD_NAME = 'password'.freeze + attr_reader :controller, :action, :params, :format def initialize(attributes) @controller = attributes[:controller] || raise(ArgumentError.new(":controller is required")) @action = attributes[:action] || raise(ArgumentError.new(":action is required")) - @params = attributes[:params] + @params = sanitize_params(attributes[:params]) @format = attributes[:format] end def to_hash {controller: controller, action: action, params_json: params_json} @@ -40,9 +42,25 @@ def params_json @params_json ||= if params.nil? || params == {} nil else params.to_json + end + end + + def sanitize_params(params) + if params.is_a?(::Hash) + params.each_with_object({}) do |(k, v), h| + k = k.to_s.downcase + case k + when PASSWORD_NAME + h[k] = SANITIZED_VALUE + else + h[k] = v + end + end + else + params end end end end end \ No newline at end of file