Over the last year I built AquaristSpecies.net using Django and deployed last summer. I’m now approaching 100 users and planning my 1st significant feature update. One thing I’d like to do is capture who’s doing what to better understand the user base.
Gathering site stats is a pretty common thing, but I thought asking here would be a good idea to see if there are established best practices?
Microsoft’s Copilot suggests I use Celery:
from celery import shared_task
from .models import UserActivity
How much if any of this data can safely go into the DB? A good friend and seasoned developer advised not to put any site stats into the db. Copilot say 'do it in a way that doesn’t bloat the db or cause performance issues (duh).
Advice and links to helpful tools/info appreciated.
<opinion>
I’m in the camp that logging information not directly relevant to the application does not belong in your application’s database.
We write logs to files, then read those files externally (e.g. nxlog) to submit the data to separate databases. (In some specific areas, I collect data in a redis cache that can be interrogated directly for more dynamic/real-time reporting, but that’s a slightly different use-case.) </opinion>
General rule-of-thumb: Don’t build something you can assemble from existing software components.
If the information you need can be retrieved from standard web server logs, the easiest way to gets started is to implement a log file analysis tool.
Or, you could create your own custom logs using the standard logging tools and build something more sophisticated - perhaps with more detail than what’s available in the common tools.
First decide what you need, then figure out if there’s something available to provide it.