Painless user activity analytics based on public_activity, ActiveJob and chartkick.
Add this line to your application's Gemfile:
gem 'activity_monitor'
And then execute:
$ bundle
Or install it yourself as:
$ gem install activity_monitor
Install initializer and migrations
$ rails generate activity_monitor:install
Finally, run the migrations on database
$ rake db:migrate
See config/initializers/activity_monitor for options as:
ActivityMonitor.setup do |config|
# Set your users model name. 'User' by default
config.user_class = 'User'
#
#
# Set your current user method. 'current_user' by default
config.current_user_method = 'current_user'
#
#
# Set your method to authenticate user who can access monitor. Not authenticated by default
config.authentication_method = 'authenticate_admin'
end
Note, that authentication is NOT enabled by default. You should define authentication method to enable it.
To record any model's create/update/destroy actions, just add this to your model:
class Item < ApplicationRecord
monitor
end
All parameters of public_activity's 'tracked' method apply. you can use :only, :except and so on.
To record controller actions put this in your controller:
class PostsController < ApplicationController
monitor_actions :index
end
You can pass single action or an array of actions to be monitored
Navigate to '/monitor' to see available statistics and charts. Charts are powered by Chartkick and Highcharts (included in the gem)
The gem is available as open source under the terms of the MIT License.