Skip to content

Fix undefined trackGaEvent and give row download buttons a busy state - #76

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog/fix-banner-track-event-and-download-feedback
Draft

Fix undefined trackGaEvent and give row download buttons a busy state#76
posthog[bot] wants to merge 1 commit into
mainfrom
posthog/fix-banner-track-event-and-download-feedback

Conversation

@posthog

@posthog posthog Bot commented Sep 9, 2026

Copy link
Copy Markdown

Why

The homepage recorded a large volume of $dead_click and $rageclick events on preset and download controls, flagged by a PostHog inbox report. Investigating turned up one real code defect named in the report, plus a genuine feedback gap on the download buttons.

What the data showed

Checking what happens immediately after each dead click:

  • Dead clicks on the slicer dropdown option are followed within ~30 ms by filter_changed, and dead clicks on Download Bundle (.bbsflmt) / Download Selected / Continue Download are followed by the matching download_* event.
  • So these controls do respond — the clicks are largely a detection artifact. A file download produces no DOM mutation, scroll, or selection change, which is exactly what dead-click detection looks for. Every affected event carries $dead_click_absolute_timeout with no mutation delay recorded.
  • Rage clicks are spread thin across filter dropdowns rather than concentrated on download buttons.

So the report's framing (controls that do not respond on the first click) does not hold as stated. Two things are still worth fixing.

Changes

1. trackGaEvent is not defined (app.js). The LayerHub banner CTA handler called trackGaEvent('banner_explore', ...), but no such function exists anywhere in the project — every click on the CTA threw a ReferenceError. Confirmed against the project: banner_explore has never been recorded, while filter_changed, download_single and download_bundle all flow normally. The banner's only measurement has been silently dead since it shipped, and the throw also bypassed the deliberate "blocked analytics must never break downloads" safety net that trackUsageEvent provides.

Fixed by routing it through trackUsageEvent, like every other event in the file.

2. Row download buttons have no busy state. JSON, BambuStudio JSON, and .bbsflmt all fetch (and sometimes zip) before the browser saves anything, with no visual feedback during the wait and no guard against a repeat click — each extra click starts another fetch and another zip. The bulk Download Selected / Download Bundle buttons already disable themselves and swap in a loading label; the per-row ones now get the equivalent via an is-busy class, aria-busy, and a currentColor spinner that works in both dark and wiki themes and respects prefers-reduced-motion. This closes the real feedback gap on the highest-volume download path, and as a side effect makes the click mutate the DOM, which should also clear the false-positive dead clicks.

The .bbsflmt path clears busy as soon as it hands off to downloadAsBbsflmt, whose own modals are the visible feedback from there — so the state cannot get stuck behind a modal.

Follow-up measurement

Saved as Preset download friction — dead clicks & rage clicks vs downloads so the effect can be checked after this ships.

Testing

npm test — 139 pass. The one failure, scripts/generate-seo.test.mjs, is pre-existing on main (missing posthog-node install in the sandbox) and unrelated.

Added tests/row-download-busy.test.js, and updated tests/banner-subscribe.test.js, which had been asserting the broken trackGaEvent call — it now asserts the string appears nowhere in app.js.


Created with PostHog Desktop from an inbox report

The LayerHub banner CTA called trackGaEvent, which is not defined anywhere
in the project, so every click threw a ReferenceError and the banner_explore
event was never recorded. Route it through trackUsageEvent like every other
event in app.js, which already swallows provider failures.

Row download buttons (JSON, BambuStudio JSON, .bbsflmt) fetch and sometimes
zip before the browser saves a file, with no feedback for the whole wait and
no guard against a repeat click. The bulk Download Selected / Download Bundle
buttons already disable themselves and show a loading label; the per-row ones
now get the equivalent through an is-busy class, aria-busy, and a spinner that
works in both themes and respects prefers-reduced-motion.


Generated-By: PostHog Desktop
Task-Id: bab76398-4c5b-411a-812f-ebc00953b582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants