Skip to content

feat(reader): add privacy-preserving reading insights#610

Open
d-oit wants to merge 2 commits into
mainfrom
docs-goap-missing-feature-tasks
Open

feat(reader): add privacy-preserving reading insights#610
d-oit wants to merge 2 commits into
mainfrom
docs-goap-missing-feature-tasks

Conversation

@d-oit

@d-oit d-oit commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Plan 102: Reading Insights feature with local-first active time tracking, coarse server sync, and UI display.

What's New

Privacy-Preserving Active Reading Timer

  • Tracks active reading time only when reader is visible, focused, loaded, and not idle
  • Pauses during hidden tabs, background windows, and idle periods (5-min timeout)
  • All counters computed and stored locally first

Storage

  • Local: New IndexedDB store readingInsights keyed by [bookId, date]
  • Server: New Turso migration 0004-reading-insights.sql for coarse per-book aggregates

API

  • GET /api/books/:bookId/insights — fetch user's insights
  • POST /api/books/:bookId/insights/sync — sync local buckets (tenant-isolated)

UI

  • Reading insights displayed in InfoPanel:
    • Total active reading time
    • Estimated time remaining (when confidence is sufficient)
    • Current reading streak
    • Recent activity (last 7 days)

Privacy Boundaries (per ADR-102)

  • Local-first by default; server sync is optional
  • Active time only — hidden/background/idle do not count
  • Coarse granularity — server-bound duration rounded to whole minutes
  • No raw reading locations (no CFI, chapter titles, or selected text)
  • No third-party analytics
  • Admin aggregation only

Test Coverage

  • 157 worker tests pass (2 new insights tests)
  • 15 web tests pass for modified files
  • Lint and typecheck pass across all packages

Related

  • plans/102-goap-missing-tasks-reading-insights-2026-06-19.md
  • plans/102-adr-reading-insights-privacy-boundaries.md
  • docs/reading-insights.md

@codacy-production

codacy-production Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 95 complexity · 8 duplication

Metric Results
Complexity 95
Duplication 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

🚀 Performance Report

⚡ Startup & Interaction

Metric Value (ms) Limit (ms) Trend Status
First Contentful Paint 216.00 1500 -
Chapter Switch Latency 0.00 300 -
Offline Rehydrate Time 221.10 800 -
DOM Interactive 19.80 - - -
Load Event End 141.50 - - -

🛠️ CI & Workflow

Metric Value Limit Status
Total CI Duration 5.92 min 15.00 min
Pnpm Cache Hit Hit -

Implements Plan 102: Reading Insights feature with local-first
active time tracking, coarse server sync, and UI display.

- Add ReadingTimer with visibility/focus/idle detection
- Add IndexedDB store for daily reading buckets
- Add Zod schemas for insight DTOs
- Add Worker routes for insight GET/sync
- Add Turso migration for reading_insights table
- Display insights in InfoPanel
- Add tests for timer, routes, and UI integration
- Add documentation in docs/reading-insights.md
@d-oit d-oit force-pushed the docs-goap-missing-feature-tasks branch from 3e9ccb5 to a5a2176 Compare June 19, 2026 11:12
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploying do-epub-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e04c47
Status: ✅  Deploy successful!
Preview URL: https://36d7275c.do-epub-studio.pages.dev
Branch Preview URL: https://docs-goap-missing-feature-ta.do-epub-studio.pages.dev

View logs

- Remove unnecessary null coalescing on typed row fields
- Refactor while(true) to use boolean flag
- Replace 'as any' with proper AuthContext type
- Add eslint-disable for Hono Response.json() type assertion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant