I want to implement a tracking system for monitoring users' activity within the application. The application is currently used within the business hours by about 600-2000 users.
I originally wanted to use a before_filter
to the ApplicationController
where every time a user would click a link, I'd save information such as user/admin id, params[:controller]
, params[:action]
and other params of actions to the database. (I know about gems like audited
- but not sure if I use them).
However I am wondering if I basically don't kill the app when for every click within the system will be called database to insert some data into it.
I was thinking of using a background method (sidekiq) for logging the action into the database.
Basically:
class ApplicationController
before_filter :log_request
def log_request
RequestLogger.perform_async(params[:controller], params[:action], current_user.id)
end
end
class RequestLogger
include Sidekiq::Worker
def perform(controller, action, user_id)
# Save data to the database
end
end
More or less.