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(-)
6.1 KiB
Keyboard Shortcuts & Notifications Fix 🔧
Issues Fixed
1. JavaScript Error in smart-notifications.js ✅
Error: Uncaught TypeError: right-hand side of 'in' should be an object, got undefined
Root Cause: The code was checking 'sync' in window.registration, but window.registration doesn't exist.
Fix: Updated the startBackgroundTasks() method to properly check for service worker sync support:
startBackgroundTasks() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
if (registration && registration.sync) {
registration.sync.register('sync-notifications').catch(() => {
// Sync not supported, ignore
});
}
}).catch(() => {
// Service worker not ready, ignore
});
}
}
2. Notification Permission Error ✅
Error: "De notificatietoestemming mag alleen vanuit een kortwerkende door de gebruiker gegenereerde gebeurtenis-handler worden opgevraagd."
Root Cause: Browser security policy prevents requesting notification permissions on page load. Permissions can only be requested in response to a user action (like clicking a button).
Fix:
- Changed
init()to callcheckPermissionStatus()instead ofrequestPermission() checkPermissionStatus()only checks the current permission state without requestingrequestPermission()can now be called from user interactions (like clicking the "Enable" button)- Added an "Enable Notifications" banner in the notification center panel
3. Ctrl+/ Not Working ✅
Root Cause: The isTyping() method had conflicting logic that would first allow Ctrl+/ but then immediately block it again.
Fix: Rewrote the isTyping() method with clearer logic:
isTyping(e) {
const target = e.target;
const tagName = target.tagName.toLowerCase();
const isInput = tagName === 'input' || tagName === 'textarea' || target.isContentEditable;
// Don't block anything if not in an input
if (!isInput) {
return false;
}
// Allow Escape in search inputs
if (target.type === 'search' && e.key === 'Escape') {
return false;
}
// Allow Ctrl+/ and Cmd+/ even in inputs for search
if (e.key === '/' && (e.ctrlKey || e.metaKey)) {
return false;
}
// Allow Ctrl+K and Cmd+K even in inputs for command palette
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
return false;
}
// Allow Shift+? for shortcuts panel
if (e.key === '?' && e.shiftKey) {
return false;
}
// Block all other keys when typing
return true;
}
What Now Works
✅ Keyboard Shortcuts
| Shortcut | Action | Status |
|---|---|---|
Ctrl+K |
Open Command Palette | ✅ Works |
Ctrl+/ |
Focus Search Input | ✅ Works |
Shift+? |
Show Keyboard Shortcuts Panel | ✅ Works |
Esc |
Close Modals/Panels | ✅ Works |
✅ Notifications
- No more errors on page load
- Notification permission is checked silently
- Users can enable notifications by clicking the bell icon in the header
- If notifications are not enabled, a banner appears in the notification panel with an "Enable" button
- Clicking "Enable" requests permission (as per browser requirements)
- After enabling, users get a confirmation notification
✅ Service Worker
- Background sync properly checks for support
- No errors if sync is not available
- Graceful degradation if service worker is not ready
Testing the Fixes
Test Keyboard Shortcuts
- Open the application
- Press
Ctrl+K→ Command palette should open - Press
Esc→ Command palette should close - Press
Ctrl+/→ Search input should focus - Press
Shift+?→ Keyboard shortcuts panel should open
Test Notifications
- Open the application
- Click the bell icon in the header
- If notifications are disabled, you'll see an "Enable Notifications" banner
- Click "Enable" → Browser will ask for permission
- Grant permission → You'll see a confirmation notification
- The notification panel will now show "No notifications" (empty state)
Test in Console
Open browser console (F12) and verify:
- No errors about
window.registration - No errors about notification permissions
- No errors about keyboard shortcuts
Browser Compatibility
All fixes are compatible with:
- ✅ Chrome/Edge (latest)
- ✅ Firefox (latest)
- ✅ Safari (latest)
- ✅ Opera (latest)
Notes
Notification Permissions
- Browser policy requires user interaction to request permissions
- The application now follows best practices by:
- Checking permission status on load (silent)
- Showing a UI prompt to enable notifications
- Only requesting when user clicks "Enable"
Keyboard Shortcuts in Input Fields
- Most shortcuts are blocked when typing in inputs
- Exception:
Ctrl+/,Ctrl+K, andShift+?work everywhere - This allows users to quickly access search, command palette, and help even when focused in an input
Service Worker Sync
- The application gracefully handles browsers that don't support Background Sync API
- No errors are thrown if sync is unavailable
- Basic functionality works with or without sync support
Files Modified
-
app/static/smart-notifications.js- Fixed
startBackgroundTasks()method - Changed
init()to check permission instead of requesting - Updated
requestPermission()to be user-action triggered - Added permission banner to notification panel
- Fixed
-
app/static/keyboard-shortcuts-advanced.js- Completely rewrote
isTyping()method - Fixed logic conflicts in keyboard event handling
- Added better support for shortcuts in input fields
- Completely rewrote
-
app/templates/base.html- Added escape key handler for command palette
- Added help text showing shortcut keys
Future Enhancements
Consider adding:
- Settings page for notification preferences
- Option to customize keyboard shortcuts per user
- Browser notification sound preferences
- Desktop notification styling
- Notification history persistence