Skip to content

Add usage statistics tracking with NDJSON storage#298

Open
kevintraver wants to merge 2 commits intomikker:mainfrom
kevintraver:feat/usage-stats
Open

Add usage statistics tracking with NDJSON storage#298
kevintraver wants to merge 2 commits intomikker:mainfrom
kevintraver:feat/usage-stats

Conversation

@kevintraver
Copy link

@kevintraver kevintraver commented Dec 17, 2025

Summary

Adds a new Stats tab in settings to help users identify their most-used actions and optimize their keyboard shortcut configurations.

Features

  • Action tracking: Records every action execution with timestamps and key paths
  • Visual analytics: Progress bars show relative usage across all actions
  • Hierarchical display: Nested group support with expandable/collapsible UI
  • Rich presentation: Shows keyboard shortcuts, app icons, and usage counts inline
  • Total count: Displays aggregate execution count across all tracked actions
  • Data management: Clear all stats with confirmation dialog

Implementation

  • Storage: NDJSON format (newline-delimited JSON) for fast append-only writes and human-readable storage
  • Performance: In-memory caching for instant query responses
  • UI: SwiftUI hierarchical tree view with proper icon/key badge alignment at all nesting levels
  • Integration: Hooks into `Controller.runAction()` to capture full key paths

Stats are stored at `~/Library/Application Support/Leader Key/stats.jsonl`

Screenshot

image

The Stats pane displays a hierarchical view with:

  • Expandable groups showing nested actions
  • Visual progress bars indicating relative usage
  • Keyboard shortcuts and app icons
  • Usage counts for each action and group

Testing

  • ✅ Tracks individual action executions
  • ✅ Aggregates stats by group (including nested groups)
  • ✅ Progress bars scale correctly relative to max count
  • ✅ Expand/collapse works for all group levels
  • ✅ Icons and shortcuts display correctly for all action types (apps, URLs, commands)
  • ✅ Clear stats removes all data and refreshes UI

kevintraver and others added 2 commits December 16, 2025 18:46
Add a new Stats tab in settings to help users identify their most-used
actions and optimize their keyboard shortcut configurations.

Features:
- Track every action execution with timestamps and key paths
- Store stats in NDJSON format (newline-delimited JSON)
- Display grouped stats with visual progress bars showing relative usage
- Support nested group hierarchies with expandable/collapsible UI
- Show keyboard shortcuts, app icons, and usage counts inline
- Display total execution count across all actions
- Clear all stats with confirmation dialog

Implementation:
- StatsManager.swift: Singleton for recording executions and querying
  aggregated statistics with in-memory caching
- StatsPane.swift: SwiftUI settings pane with hierarchical tree view,
  progress bars, and proper icon/key badge alignment at all nesting
levels
- Hook stats recording into Controller.runAction() with full key path
- NDJSON format enables fast append-only writes and human-readable
storage

Stats stored at ~/Library/Application Support/Leader Key/stats.jsonl

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update StatsPane to properly wrap content in Settings.Section components
with required title parameter, fixing build errors after Settings library
update.
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.

1 participant

Comments