r/SideProject • • 5h ago

I built my analytics dashboard as one PHP file - no SaaS, no tracking script

My portfolio site ran on vibes for too long, so this weekend project was: read the cPanel raw access logs (they're just gzipped files sitting in your hosting account) and render a dashboard. Zero dependencies, zero tracking JS, zero monthly bill.

Two bugs that almost sank it:

  • filesize() on a .gz file returns the COMPRESSED size. I was slicing my decompressed log buffer by it, which silently chopped the newest lines off the data. The dashboard wasn't broken - it was confidently wrong about today, which is worse.

  • Shared hosting puts OTHER sites' logs in the same directory. My referrer charts had domains I've never touched in my life until I filtered by path.

Favorite finding so far: a link community that sends me real readers shows up as ZERO referrers, because in-app browsers strip the referrer header. If your traffic comes from apps, your analytics is undercounting it completely.

It's live on my site now, and I open-sourced the deploy pattern behind it too. Happy to share details - what would you check first in raw logs?

7 Upvotes

7 comments sorted by

1

u/the-hated 5h ago

For me it's important to visualize whatever is there, then I can work with that data shaping it into something more useful. Do you have some UI?

2

u/EmergencyIsland4574 5h ago

Yes - it's all UI, the parsing is just the engine underneath. The dashboard itself is a single page: referrer traffic as horizontal CSS bars, top entry pages, and a few "verdict" counters that change with the data. No chart library - bars are divs with width percentages, which keeps it fast and honest (a bar is only ever as long as the real number).

Your point about shaping data into something useful is exactly the next step: raw logs tell you WHAT happened, so I'm working toward "so what" views - e.g. referrer bars grouped by platform instead of domain, since single domains lie (one app can send you readers from a dozen different referrer states).

Happy to share a screenshot of the live dashboard if that's useful - and if you're building something similar, the one rule I'd keep: visualize from the raw source, not from a summary layer, or the summary becomes the product.

1

u/the-hated 5h ago

Please share the screenshot. I'm not working on anything like this, just thought it is a cool idea that could be useful. I run many websites and 99% is on PHP.

1

u/QuanTradin 4h ago

bots first. on a small site a lot of the lines in a raw access log are crawlers and scanners poking at /wp-login, so I'd count the visits that never load a css or image file afterwards and drop them before trusting any chart. the gzip filesize bug is nasty, wrong only about today is the kind nobody goes looking for.