Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strategy for tracking user recent activity

Our customer would like to know who is online and currently using the custom application we wrote for them. I discussed it with them and this does not need to be exact, more of a guestimate will work.

So my thought is a 15 minute time interval to determine user activity. Some ideas I have for doing this are as follows:

  1. Stamp their user record with a date and time of their last activity every time they do something that hits the database, or requests a web page ... this though could be quite database intensive.

  2. Send out a "who is online request" from our software, looking for responses, this could be done at a scheduled interval, and then stamp the user record with the current date and time for each response I received.

What are your thoughts? And how would you handle this situation?

Clarification

I would like to use the same architecture for both Windows or the Web if possible. I have a single business logic layer that multiple user interfaces interact with, could be Windows or the Web.

By Windows I would mean client-server.

Clarification

I am using an n-tier architecture so my business objects handle all the interaction with the presentation layer. That presentation layer could be feeding a client-server Windows application, Web application, Web Service and so on.

It is not a high traffic application, as it was developed for a customer of ours, maybe 100 users at most.

like image 259
mattruma Avatar asked Oct 06 '08 13:10

mattruma


People also ask

What are the techniques do programs use to track user activity?

There are various methods implemented to monitor and manage user activity such as: Video recordings of sessions. Log collection and analysis. Network packet inspection.

Why is it a good idea to track user activity?

User Activity Monitoring is a type of proactive surveillance that helps to prevent misuse of access privileges.

Which is used to track user activity and API usage?

CloudTrail is a service that is used to track user activity and API usage in AWS cloud. It enables auditing and governance of the AWS account. With it, you can monitor what is happening in your AWS account and continuously monitor them. It provides event history which tracks resource changes.

How do I track user activity on Wordpress?

To track the logged in users on your site, you need to go to the WP Activity Log » Logged In Users page. From here you will see all the users who are logged into your site. You can view all the activity of a certain user, or force someone to log out by clicking on the Terminate Session button.


1 Answers

Our solution is to maintain a "Transaction" table (which follows what was done), in addition to our "Session" table (which follows who was here). UPDATE, INSERT and DELETE instructions are all managed through a "Transaction" object and each of these SQL instruction is stored in the "Transaction" table once it has been successfully executed on the database (depending on tables updated: we have the possibility to specifically follow some tables and ignore others). This "Transaction" table has other fields such as transactiontType (I for INSERT, D for DELETE, U for UPDATE), transactionDateTime, etc, and a foreign key "sessionId", telling us finally who sent the instruction. It is even possible, through some code, to identify who did what and when (Gus created the record on monday, Tim changed the Unit Price on tuesday, Liz added an extra discount on thursday, etc).

Pros for this solution are:

  1. you're able to tell "what who and when", and to show it to your users! (you'll need some code to analyse SQL statements)
  2. if your data is replicated, and replication fails, you can rebuild your database through this table

Cons are

  1. 100 000 data updates per month mean 100 000 records in Tbl_Transaction
  2. Finally, this table tends to be 99% of your database volume

Our choice: all records older than 90 days are automatically deleted every morning

like image 84
Philippe Grondier Avatar answered Oct 29 '22 11:10

Philippe Grondier