usefathom / fathom

Fathom Lite. Simple, privacy-focused website analytics. Built with Golang & Preact.
https://usefathom.com/
MIT License
7.55k stars 368 forks source link

Inaccurate page views due to race condition #278

Closed jlongster closed 2 years ago

jlongster commented 5 years ago

It's possible to have multiple page views with IsFinished marked as 0 if you switch between pages fast enough.

This is due to the code here: https://github.com/usefathom/fathom/blob/master/pkg/api/collect.go#L89

It's querying the store to see if the previous pageview exists, but because of buffering, the previous page view may not have been committed yet. This code also needs to somehow check the buffered contents or figure out a way to see if the pageview exists but has not been committed yet.

This skews the realtime visitor count, bounce rate, and anything else depending on active page views.

jlongster commented 5 years ago

Currently the fix is to reduce the buffer capacity to 1. But it would be nice to have a proper fix.