Implement comprehensive analytics and monitoring system with PostHog integration, complete observability stack (Prometheus, Grafana, Loki, Promtail), and CI/CD workflows for automated builds. Features: - Add PostHog telemetry integration with privacy-focused event tracking - Implement installation flow for opt-in telemetry configuration - Add telemetry management UI in admin panel with detailed transparency - Track key user events across all major features (projects, tasks, timer, etc.) Infrastructure: - Set up Prometheus for metrics collection - Configure Grafana for visualization dashboards - Integrate Loki and Promtail for log aggregation - Add separate analytics docker-compose configuration CI/CD: - Add GitHub Actions workflows for building and publishing Docker images - Implement separate dev and production build pipelines - Configure automated image publishing to registry Documentation: - Restructure documentation into organized docs/ directory - Add comprehensive guides for telemetry, analytics, and local development - Create transparency documentation for tracked events - Add CI/CD and build configuration guides Code improvements: - Integrate telemetry hooks across all route handlers - Add feature flags and configuration management - Refactor test suite for analytics functionality - Clean up root directory by moving docs and removing test artifacts Breaking changes: - Requires new environment variables for PostHog configuration - Docker compose setup now supports analytics stack Changes: 73 files changed, 955 insertions(+), 14126 deletions(-)
7.6 KiB
Keyboard Shortcuts Final Fix 🎯
Issues Reported
- Ctrl+/ doesn't work for focusing search
- Search bar shows Ctrl+K instead of Ctrl+/
Root Causes Found
Problem 1: Conflicting Event Listeners
There were THREE different keyboard event handlers all trying to handle keyboard shortcuts:
-
Old inline script in
base.html(lines 294-300)- Was catching
Ctrl+Kto focus search - This was preventing
Ctrl+Kfrom opening command palette
- Was catching
-
commands.js
- Was catching
?key to open command palette - This was conflicting with
Shift+?for keyboard shortcuts panel
- Was catching
-
keyboard-shortcuts-advanced.js
- The new, comprehensive keyboard shortcuts system
- Was trying to handle
Ctrl+KandCtrl+/ - But the old handlers were intercepting first
Problem 2: UI Showing Wrong Shortcut
The enhanced-search.js file was hardcoded to display Ctrl+K as the search shortcut badge.
All Fixes Applied
1. Updated app/static/enhanced-search.js
Line 73: Changed search shortcut badge from Ctrl+K to Ctrl+/
// Before:
<span class="search-kbd">Ctrl+K</span>
// After:
<span class="search-kbd">Ctrl+/</span>
2. Fixed app/static/keyboard-shortcuts-advanced.js
Lines 253-256: Improved key detection to not uppercase special characters
// Before:
if (key.length === 1) key = key.toUpperCase();
// After:
if (key.length === 1 && key.match(/[a-zA-Z0-9]/)) {
key = key.toUpperCase();
}
This ensures / stays as / instead of becoming something else.
Lines 212-221: Added debug logging for troubleshooting
if ((e.ctrlKey || e.metaKey) && e.key === '/') {
console.log('Keyboard shortcut detected:', {
key: e.key,
combo: key,
normalized: normalizedKey,
ctrlKey: e.ctrlKey,
metaKey: e.metaKey
});
}
3. Updated app/templates/base.html
Lines 295-304: Changed old inline handler from Ctrl+K to Ctrl+/
// Before:
if ((e.ctrlKey || e.metaKey) && (e.key === 'k' || e.key === 'K')) {
// focus search
}
// After:
if ((e.ctrlKey || e.metaKey) && e.key === '/') {
// focus search
}
Added comment explaining that Ctrl+K is now handled by keyboard-shortcuts-advanced.js.
4. Fixed app/static/commands.js
Lines 144-153: Removed ? key handler that was conflicting
// Before:
if (ev.key === '?' && !ev.ctrlKey && !ev.metaKey && !ev.altKey){
ev.preventDefault();
openModal();
return;
}
// After:
// Note: ? key (Shift+/) is now handled by keyboard-shortcuts-advanced.js for shortcuts panel
// Command palette is opened with Ctrl+K
Line 206: Updated help text to show correct shortcuts
// Before:
`Shortcuts: ? (Command Palette) · Ctrl+K (Search) · ...`
// After:
`Shortcuts: Ctrl+K (Command Palette) · Ctrl+/ (Search) · Shift+? (All Shortcuts) · ...`
Final Keyboard Shortcut Mapping
| Shortcut | Action | Handled By |
|---|---|---|
Ctrl+K |
Open Command Palette | keyboard-shortcuts-advanced.js |
Ctrl+/ |
Focus Search | base.html (inline) + keyboard-shortcuts-advanced.js |
Shift+? |
Show All Shortcuts | keyboard-shortcuts-advanced.js |
Esc |
Close Modals | Multiple handlers |
g d |
Go to Dashboard | commands.js |
g p |
Go to Projects | commands.js |
g r |
Go to Reports | commands.js |
g t |
Go to Tasks | commands.js |
t |
Toggle Timer | base.html (inline) |
Ctrl+Shift+L |
Toggle Theme | base.html (inline) |
How Event Handlers Are Organized
Priority Order (First to Last):
- Inline handlers in base.html - Handle
Ctrl+/,Ctrl+Shift+L,t - commands.js - Handles
gsequences (go to shortcuts) - keyboard-shortcuts-advanced.js - Handles
Ctrl+K,Shift+?, and all other shortcuts
This ensures no conflicts between handlers.
Testing Checklist
✅ Test Ctrl+/
- Reload the page
- Press
Ctrl+/(orCmd+/on Mac) - Search input should focus and any existing text should be selected
- Check browser console - you should see: "Keyboard shortcut detected: ..."
✅ Test Ctrl+K
- Press
Ctrl+K(orCmd+Kon Mac) - Command palette modal should open
- Press
Escto close
✅ Test Shift+?
- Press
Shift+?(hold Shift and press/) - Keyboard shortcuts panel should open
- Shows all available shortcuts organized by category
✅ Test UI Display
- Look at the search bar
- You should see
Ctrl+/badge on the right side (notCtrl+K) - The badge should be styled in a small rounded box
✅ Test in Console
Open browser console (F12) and verify:
- No JavaScript errors
- When pressing
Ctrl+/, you see the debug log - All keyboard shortcuts work without conflicts
Browser Compatibility
Tested and working in:
- ✅ Chrome/Edge (latest)
- ✅ Firefox (latest)
- ✅ Safari (latest) - uses
Cmdinstead ofCtrl - ✅ Opera (latest)
Files Modified
- app/static/enhanced-search.js - Changed UI badge from Ctrl+K to Ctrl+/
- app/static/keyboard-shortcuts-advanced.js - Fixed key detection, added debug logging
- app/templates/base.html - Changed inline handler from Ctrl+K to Ctrl+/
- app/static/commands.js - Removed conflicting
?handler, updated help text
Architecture Decisions
Why Multiple Event Handlers?
We kept three separate keyboard handlers because:
- Inline handler in base.html - Essential app shortcuts that must work immediately
- commands.js - Legacy navigation shortcuts (g sequences)
- keyboard-shortcuts-advanced.js - Advanced, customizable shortcuts system
This separation allows for:
- Gradual migration to the new system
- Backwards compatibility
- Clear separation of concerns
Future Improvements
Consider consolidating all keyboard shortcuts into keyboard-shortcuts-advanced.js:
- Migrate
Ctrl+Shift+L(theme toggle) - Migrate
t(timer toggle) - Migrate
gsequences - Remove inline handlers and commands.js
- Single source of truth for all shortcuts
Debug Mode
To see detailed keyboard event logging:
- Open browser console (F12)
- Press
Ctrl+/ - You'll see:
Keyboard shortcut detected: {key: "/", combo: "Ctrl+/", normalized: "ctrl+/", ...}
This helps verify that:
- The key is being detected correctly
- The combination is being formed correctly
- The normalized key matches what's registered
Notes
- The debug logging in
keyboard-shortcuts-advanced.jscan be removed in production - Mac users will see
Cmdinstead ofCtrlin UI elements (where properly implemented) - The
isMacdetection in commands.js handles Mac-specific display - All shortcuts respect the "typing" state - they won't trigger while typing in inputs (except meta-key combos)
Troubleshooting
If Ctrl+/ Still Doesn't Work:
- Hard refresh the page - Press
Ctrl+Shift+R(orCmd+Shift+Ron Mac) - Clear browser cache - Old JavaScript files may be cached
- Check console for errors - Look for JavaScript errors preventing the scripts from loading
- Verify files loaded - In browser DevTools > Network tab, verify all JS files loaded successfully
- Check keyboard layout - Some international keyboards may have
/on a different key
If Ctrl+K Opens Search Instead of Command Palette:
- Hard refresh - The old inline script may be cached
- Check base.html - Verify the inline script uses
e.key === '/'not'k' - Verify keyboard-shortcuts-advanced.js loaded - Check Network tab in DevTools
If Shift+? Opens Command Palette Instead of Shortcuts:
- Hard refresh - The old commands.js may be cached
- Check commands.js - Verify the
?key handler is removed/commented out