mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #14803] [CLOSED] User level activity through time for app metrics #46648
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/14803
Author: @rragundez
Created: 6/9/2025
Status: ❌ Closed
Base:
dev← Head:user-historical-events📝 Commits (4)
3572c7aAdd table for registering the last user tampstamp per hour2f81351Add trigger listener from user action to user historical events5143d6eRegister new table and triggere5268a8Add alembic migration logic📊 Changes
4 files changed (+80 additions, -4 deletions)
View changed files
📝
backend/open_webui/main.py(+4 -0)➕
backend/open_webui/migrations/versions/757136e86672_add_userhistoricalevents_table.py(+33 -0)📝
backend/open_webui/models/users.py(+17 -4)➕
backend/open_webui/utils/event_listener.py(+26 -0)📄 Description
Currently there is no way of retrieving historical usage data from the application simply/natively. The only related information in the database is the
last_active_atfield in theusertable, but that only acts as a sort of sliding window as the users use the application.This is a major metric to assess the use, success and cost per user per month of the application. And the information is normally use to make decisions if to continue using the application or buy a SAAS.
This PR adds an extra table that keeps the historical activity time grouped by user and hour. WIth this change is easy to see users per hour or day or per month.
This implementation does not introduce any change in the application backend logic but it is based on setting a trigger on the existing database such that an entry is generated every time the
user.last_active_atgets updated. The logic also makes sure there is a maximum a 1 entry per user-hour combination to avoid the table blowing up.With this change it becomes very easy to retrieve user usage through time in external tools like Grafana for example. I did test the change and can see the entry being updated every hour if I make an action in the application.
I know there are some issues open asking for this but I did not have the time to go into them.
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.