There is a ruby gem called Action Tracker. I built and use it and it should do exactly what you need (since you use Rails and Devise).
The link is https://github.com/appprova/action_tracker
There are some contribution from outside our core team too (people are using it). You are welcome to try and send feedback!