Developer Builds Lightweight SaaS to Track User Behavior With Privacy Focus
A developer is building a privacy-focused SaaS tool that records user interactions entirely within the browser, sending a compact summary to a Cloudflare Worker and D1 database only when the page is hidden or closed. The tool uses navigator.sendBeacon as the primary data transmission method, with a fetch-based keepalive fallback if the beacon fails. A key challenge arose around tab-switching: when users return to a tab, the system must reset its sent-state flag so it can transmit updated session data again later. This created a risk of duplicate database entries for the same session ID, which the developer resolved by using an INSERT OR REPLACE strategy that overwrites older records with the latest session data. The project is open source and also available as a live SaaS product.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in