User actions or activity log

Is it possible to create a user activity log with Wappler?
I want to build a very simple document management system which allows a user to login, view files like pdfs, and Admin should be able to see which files the user accessed and what time user logged in.

Is this something Wappler can do? If yes, which tutorials should i be looking at?

There is no out-of-the-box solution within Wappler, but the tools are available to enable and record user movements.

Have a look t this article https://www.cookiebot.com/en/website-tracking/ in particular https://www.cookiebot.com/en/gdpr/

Hi @enyonam
You can do this with Server Connect which stores the specific actions in a database table, so you can run it on click of a link, on page load, on login etc.
It’s a simple insert record, which inserts the information you need in your table :slight_smile:

Hi @Teodor thanks for the response. If I understand your reply, then it means this can be done by using the Dynamic Events section of Wappler. So for example, Just as I display a notification after a successful action, I can use the same process to insert a Db record. My question then is where do i pick the entries to be inserted.
Is there an existing similar tutorial on how to insert db record on success of form submission.
I have created a new table called useractions which has 4 columns namely :

  • actionID
  • actionName (eg: Login, logout, uploaded, clicked on)
  • actionTime (time the action happened)
  • actionUser. (the logged in user)

I have a working login form on a page. Now assuming I want to record/log all user logins into the useractions table, how will I will get this done. I believe with this example, I will be able to replicate it for all other things I want to log.

Many thanks in advance.

Server Connect:

  1. create an insert database action.

App Connect:

  1. create a form (bespoke for the action) with the required inputs (hidden), no submit button.
  2. on-trigger (like on-load or on-click), submit the form.

En passant: In principle I am dead set against stalking unless the subject knows of the practice, why it is being done and assured of privacy.

You can also do this without a form

Server connect

  1. Create a server action
  2. Add GET variables for every value you want to insert
  3. Create a database insert action and use the GET variables as values in the appropriate database columns for your database insert

On the page

  1. Add this server action on the page. Set it to NO AUTO LOAD
  2. Use the dynamic events > success to run your “insert log” server action. Add the values you need to the GET parameters (they will be listed as parameters for the server action)
2 Likes

Your solution worked for me. I am able to record some actions.
@Teodor i tried implementing your solution on another page but got stuck a point. Will pick it up again and revert.

A related question is, how do I get the logged in user’s username as part of the data to be stored in the db.

Please check the docs:

https://docs.wappler.io/t/getting-details-of-the-logged-in-user-and-binding-them-to-your-page/2850

1 Like

thank you this worked.

But another issue that arise is how to record a login action.
I followed the @ben recommendation with the hidden form.

I set up a hidden form with the fields i specified in my earlier post.

  • actionID
  • actionName (eg: Static Value)
  • actionTime (picking from the DateTime component)
  • actionUser. (I am picking this from the username field of the login form. i.e the entered value)

-The Login system works fine.
-The Error Alert on wrong details works fine.

  • the redirection based on accesslevel works fine.

I have added a dynamic event onSubmit of the Login Form, the data is inserted in the DB. This works fine with a glaring issue. Even when a wrong username is entered and the login throws the invalid errorAlert, the data is still inserted in the db.
I changed the Dynamic event from onSubmit to onSuccess and it didn’t work at all.
I know I am doing something wrong. Just don’t know what exactly.

How would I achieve this when i store this form in a SSI php include, eg. a navbar? App-Load or Ready doesn't trigger my INSERT then

EDIT: Nevermind, I figured some other solution. When using session variables instead of cn_getuserdetails to pull the values every time, the procedure works with Autosubmit forms as well.