So recently I built a so-called analytics service for fun. If you don’t know, make sure you check out here once. Alright, so I put the base MVP version for testing with my last article randomly.
I thought, okay, let’s test how much data it can collect. I shared that article on Hacker News, Dev.to, WhatsApp, etc., around 10:30 AM. Everything was normal — the analytics dashboard started showing views, sessions, unique visitors, etc. I went for lunch in the afternoon, and when I came back, I saw a very big spike — almost 800 new sessions recorded. It looked like it was working crazy solid.
It was a nice serotonin hit until I saw the Activity Logs.
There were some scroll_depth requests from certain unique visitors, but the page_view request logs were completely missing for that visitor_id.
Something f**ked up.
If you haven’t realised yet what’s happening 😂, let me explain the logic first.
In the analytics service, when a new visitor lands on a webpage, a page_view event is called first, and then eventually scroll_depth happens (only if you love to scroll 🙂).
I found this bug because you always love scrolling, right 😉
Practically, the order should be:
(page_view → scroll_depth → and so on…)
This was happening majorly for some requests from the Europe/US region.
Even if it were a race condition, it would appear after the scroll event, but there was complete silence.
Continue Here

Top comments (0)