Skip to content

Conversation

@dafal
Copy link

@dafal dafal commented Aug 15, 2025

Changes

  • Add BookmarkUsage join table to track per-user click counts
  • Add enable_usage_tracking user setting (disabled by default)
  • Implement /bookmarks/<id>/visit/ endpoint for click tracking
  • Add "Most Used" sort option when tracking is enabled
  • Make bookmark links conditional based on user preference
  • Add usage tracking toggle in General Settings
  • Include database migrations (0052, 0053)
  • Update documentation with comprehensive feature guide

Privacy & Design

  • Disabled by default - Users must explicitly opt-in
  • Local only - Data never leaves the user's instance
  • Per-user - Each user has isolated usage statistics (join table)
  • Transparent - Clear settings and documentation
  • Reversible - Can be disabled anytime

Note

Uses a join table architecture instead of a single counter to properly handle multiple users. Addresses feedback about non-authenticated users viewing shared bookmarks.

Key changes from original:

  • Changed "Bookmark model" → "BookmarkUsage join table"
  • Changed "Personal" → "Per-user" with clarification
  • Added brief note about addressing reviewer feedback

@philiplb
Copy link

philiplb commented Nov 6, 2025

This is neat. I wonder what happens when this feature is enabled and a not-logged-in user clicks on a shared bookmark?

Implements an optional usage tracking feature that allows users to track
how often they click on bookmarks and sort by "Most Used". The feature
uses a proper join table (BookmarkUsage) to track per-user statistics,
ensuring privacy and data isolation between users.

Key Features:
- Privacy-first: Disabled by default, requires opt-in
- Per-user tracking: Each user has their own usage statistics via BookmarkUsage model
- Works everywhere: Tracks both owned bookmarks and shared bookmarks
- Secure: Anonymous users never see the "Most Used" option
- Isolated data: Usage counts are user-specific, no data leakage

Implementation Details:
- New BookmarkUsage model with (bookmark, user) unique constraint
- Visit endpoint tracks clicks and increments counter atomically
- "Most Used" sort option uses subquery to current user's usage data
- Conditional UI: Option only appears when user is authenticated and has tracking enabled
- Template uses visit URL when tracking is enabled, direct URL otherwise

Database Changes:
- Add BookmarkUsage table with bookmark_id, user_id, access_count, last_accessed
- Add enable_usage_tracking boolean to UserProfile (default False)
- Index on (user, -access_count) for efficient sorting

Security:
- @login_required on visit endpoint
- is_authenticated check before showing sort option
- Subquery filters BookmarkUsage by current user only
- Anonymous users see standard sort options only

Documentation:
- Updated README.md with feature description
- Added comprehensive how-to guide in docs/how-to.md
- Documented privacy guarantees and user controls

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@dafal
Copy link
Author

dafal commented Nov 16, 2025

This is neat. I wonder what happens when this feature is enabled and a not-logged-in user clicks on a shared bookmark?

@philiplb Thanks for catching that issue! I've completely redesigned the implementation based on your feedback. I replaced single access_count field with a BookmarkUsage join table so usage is per user. For anonymous users, it is simply disabled.

@philiplb
Copy link

How nice! :D

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.

2 participants