I have developed a website in Django where users can randomly pop into rooms to have a conversation. Imagine something like a video reddit
This is more of an architecture question than a code question. How do I measure usage? I want to track how long users spend in each room, which rooms are popular, get a history of every room that a user has visited to understand their user profile
The most naive thing that I can think of is to create a new table in the database called usage where I log every event such as user entering a room with timestamp, user leaving a room with timestamp that would look something like this for eg -
user | room | event | timestamp |
---|---|---|---|
1 | bitcoin | join_room | 1620632092 |
2 | comedy | join_room | 1620632094 |
1 | bitcoin | leave_room | 1620632292 |
3 | politics | join_room | 1620632295 |
3 | politics | leave_room | 1620632296 |
4 | dogs | join_room | 1620632296 |
5 | python | join_room | 1620632296 |
4 | dogs | leave_room | 1620632296 |
5 | python | leave_room | 1620632296 |
With this database architecture, I would have to run really complex SQL queries to understand how much time users spend in each room.
Is there a better way to do this?
No comments:
Post a Comment