I want made that all log will store database. therefore I try setup Ahoy gem in my Rails Api only Project. Ahoy is awesome gem. but there is not Best pratice on README.md of Ahoy github.
i hope store http request header, reponse header and body with Ahoy. this code is track_action for storing event in ApplicationController.
class ApplicationController < ActionController::Base
after_action :track_action
protected
def track_action
ahoy.track "Viewed #{controller_name}##{action_name}", { request: { header: request.headers },
response: { headers: response.headers, body: JSON.parse(response.body) } }
end
end
but i got error.
Completed 500 Internal Server Error in 493ms (Views: 34.8ms | ActiveRecord: 89.1ms | Allocations: 317174)
SystemStackError (stack level too deep):
app/controllers/application_controller.rb:14:in `track_action'
What is Best practice ahoy.track for storing all request, response log?
storing all http request, response with Ahoy gem