how to save last user activity in database

hello everybody!

what is the best place in the application to add features that save information on recent user activity in database?

regards sean