ankane / authtrail

Track Devise login activity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idea: Action Tracking

nhorton opened this issue · comments

Thanks again for the insane number of quality gems you have released!

I was just looking at getting more audit log history tracking and thought about authtrail.

In my perfect world, this would be having a method like "record_action" that takes:

  • the devise user
  • a string capturing the action (maybe enforce a slight convention there like path-style /-delimitation to do begin-with matching)
  • an object it was performed on (because there usually is such an object) as a string. Then one could use a GlobalID or a path_for.
  • a polymorphic association of an 'audit_scope' that is something like an Account or Tenant for multi-tenant SaaS products where there are many users in an account, and many accounts in the system.

That would cover virtually everything that was needed.

The bonus points here is that one could probably then make an around_action in the ApplicationController that called that method on any POST or PATCH and feed most of the data needed on it based off of the standard stuff in Current and in the request.

This has flavors of what the AuditLog gem does, but AuthTrail is an interesting place for it because you were wise to hook in closer to the user auth events which are so critical and you can't get without a ton of manual work with something like AuditLog.

Hi @nhorton, thanks for the suggestion. I may add more Devise-related activity in the future (#50), but for actions, I think it's simpler to create a separate model and add the recording logic directly in your application.