Fix flash counter: count completions via state-changed event + Abacus (no session dedup) - #40
Merged
Conversation
Two fixes: 1. Count completions not clicks: listen for ESP Web Tools' public "state-changed" CustomEvent on ewt-install-dialog, increment only on "finished" state. Replaces the fragile _installState accessor hack. 2. No session dedup: Abacus (abacus.jasoncameron.dev) is a free stateless counting API with CORS support. Each /hit increments by 1 with no per-session deduplication (unlike GoatCounter pageviews which counted N boards in one sitting as 1). GoatCounter is still used for site-wide analytics (pageviews, feedback ratings) — only the flash completion counter changed.
Remove literal backslash-n accidentally appended to continue; line, causing a JS syntax error that would break release list population.
DrewFerg11
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The flash counter on the web flasher page has two accuracy issues:
Counts clicks, not completions — the counter fires on button click, not on successful flash completion. Someone who clicks Install but cancels the dialog still gets counted.
Session deduplication — the counter uses GoatCounter pageviews, which deduplicate per visitor session (8h). Flashing 3 boards in one sitting counts as 1.
The completion detection was also fragile: it wrapped Lit's private
_installStateaccessor on theewt-install-dialogprototype, which would silently break on any ESP Web Tools version update that renames the property.Fix
1. Count completions via public
state-changedeventESP Web Tools'
ewt-install-dialogdispatches a publicstate-changedCustomEvent withdetailbeing the state string (initializing,preparing,erasing,writing,finished,error). This is a stable public API — no private property hacking.The new code:
document.bodyforewt-install-dialogelements (appended by ESP Web Tools when a flash starts)state-changedevents on each dialogstate === "finished""— actual successful completions, not clicks or cancelled dialogs2. Abacus replaces GoatCounter for flash counting
Abacus is a free, stateless counting API with CORS support. Each
/hitcall increments by 1 — no session deduplication. Flashing 3 boards in one sitting now counts as 3.The badge reads the Abacus counter on page load and displays the total without the old "at least" qualifier (since the count is now accurate, not a floor).
GoatCounter stays for site analytics
GoatCounter is still loaded site-wide for pageviews and feedback ratings (via
overrides/partials/integrations/analytics/custom.html). Only the flash completion counter moved to Abacus.What changed
docs/firmware/install-web-flasher.md— replaced the GoatCounter flash counter script (220 lines) with a 100-line Abacus +state-changedscript. All other scripts (erase dialog, version picker, keyboard fix) are untouched.Trade-offs
/flash/finished/factory,/flash/failed/factory) which showed success/failure ratios in the GoatCounter dashboard are removed. If you want those back, they can be added as GoatCounter events alongside the Abacus counter.