Add analytics tracking and response data collection#63
Merged
jeremymanning merged 10 commits intomainfrom Apr 1, 2026
Merged
Conversation
… toggle - GoatCounter snippet in index.html for cookie-free visitor analytics - Response collection module (src/collection/collector.js): encodes tokens every N responses and POSTs to configurable GAS endpoint (fire-and-forget) - Tutorial consent step: "Contribute to science!" modal with opt-in/out buttons - About modal: data collection disclosure text and opt-out toggle switch - Offline decoder script (scripts/decode-tokens.js) for token→CSV/JSON - Feature-flagged: collection disabled when ENDPOINT_URL is empty Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Pass aggregatedQuestions (2500) to maybeCollect instead of questionIndex Map - buildIndex() now called inside collector for proper token encoding - renderMarkdownLite supports <i> and <em> tags (consent step HTML) - Move info icon to after "about button" in consent text - Verified: 10-question token round-trips with 100% fidelity via GAS endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Domain column removed from GAS payload (redundant — decoder derives per-question domain from question_ids) - Added navigator.sendBeacon on beforeunload to capture partial sessions that don't reach the N-response threshold - Track _lastSentCount to avoid duplicate sends on re-answers - Decoder now outputs domain derived from each question's domain_ids Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sendBeacon with JSON body fails silently on GAS endpoints (302 redirect). fetch with keepalive:true survives page unload and follows redirects. Verified: both interval (10 responses) and beforeunload (11 responses) rows appear in Google Sheet with correct tokens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collection is now OFF by default. Users opt in via the tutorial
consent step ("I'd like to help!") or the About modal toggle.
Updated HTML toggle initial state to match (aria-checked=false, thumb left).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Deep Dive and Exploring Domain-Specific steps: positionHint left→right so modal appears next to the quiz panel - Header button highlights (trophy, suggest, share): add overflow:visible rule for .header-right/.header-actions when child has tutorial-highlight, so the box-shadow page-dim effect isn't clipped by overflow-x:scroll Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use positionHint 'quiz-final' instead of 'right' so the tutorial modal appears to the left of the quiz panel without overlapping it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
setCollectionEnabled now dispatches a 'collect-pref-change' custom event. The About modal listens for it and updates the toggle in real-time, so opting in via the tutorial consent step immediately reflects in an already-open About modal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace PsyArXiv preprint link with published Nature Communications citation (Fitzpatrick, Heusser, Manning 2026) in both the About modal and the landing page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
scripts/decode-tokens.jsdecodes collected tokens to CSV/JSON with per-question domain derivationCollection is off by default — users opt in via the tutorial or About modal. No PII is collected (tokens contain only question indices and answer correctness). Feature-flagged via
CONFIG.ENABLEDandENDPOINT_URL.Test plan
🤖 Generated with Claude Code