devise-activity

Track signed-in user sessions and site navigation in an easy to traverse format

MIT License

Downloads
11.6K
Stars
3
Committers
1

= DeviseActivity

Keep history of user page views and time spent on different pages in rails. This gem depends on devise gem and uses devise 'current_user' helper method which can be configured.

== Installation

Simply add trackstamps gem to your Gemfile.

gem 'devise-activity'

Install bundler gems

bundle install

Install trackstamps

rails generate devise_activity:install

You can change sessions and navigations table names from generated configuration file (config/initializers/devise_activity.rb) before generating migration. Generate migration on required model's table

rails generate devise_activity:migration

Include DeviseActivity module to application controller or admin etc for which you want to track user activities

class ApplicationController
    include DeviseActivity

    .....

end

Execute migrations

rake db:migrate

And now you are ready to track changes

== Usage

It will automatically keep of sign in's, sign out's and page views history in sessions and navigations table i.e.

DeviseActivity::Session.all

will return last account was created by which user. Similarily

DeviseActivity::Session.last.navigations

DeviseActivity::Session.where(user_id: 12).all

DeviseActivity::Session.where(user_id: 12).last.navigations

DeviseActivity::Navigation.count

DeviseActivity::Navigation.last.action

DeviseActivity::Navigation.last.controller

DeviseActivity also provide few handy model methods for Statistics

DeviseActivity::Stats.most_visits_by

DeviseActivity::Stats.least_visits_by

DeviseActivity::Stats.most_popular_controller

DeviseActivity::Stats.least_popular_controller

DeviseActivity::Stats.most_popular_action

DeviseActivity::Stats.least_popular_action

DeviseActivity::Stats.most_visited_page

DeviseActivity::Stats.least_visited_page

DeviseActivity::Stats.most_sign_ins_by

DeviseActivity::Stats.total_sign_ins(user)

== TODO

  • Mongoid ORM support

== Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Package Rankings
Top 27.26% on Rubygems.org
Related Projects