Replace the single-page setup (telemetry + optional Google Calendar) with a guided wizard that collects all base settings before completion. Wizard steps: 1. Welcome - intro and Next 2. Region & time - timezone, date/time format, currency (Settings) 3. Company - name, address, email, optional phone/website (Settings) 4. System - allow self-registration, rounding minutes, single active timer, idle timeout (Settings) 5. Integrations (optional) - Google Calendar OAuth; can skip 6. Privacy & finish - telemetry opt-in; Complete Setup submits form Backend (app/routes/setup.py): - GET: pass settings and timezones to template for prefilling - POST: validate timezone, date_format, currency, rounding_minutes, idle_timeout_minutes; persist all fields to Settings and mark_setup_complete(telemetry_enabled) - Default timezone/currency to UTC/EUR when missing (keeps tests passing) Frontend: - initial_setup.html: 6 wizard steps, progress bar (Step X of 6), Back/Next and submit on last step - setup-wizard.js: step navigation, progress update, optional client-side validation for step 2 (timezone, currency required) Docs updated: TELEMETRY_QUICK_START.md, GETTING_STARTED.md, TELEMETRY_IMPLEMENTATION_SUMMARY.md.
8.2 KiB
Telemetry & Analytics Implementation Summary
Overview
Successfully implemented a comprehensive telemetry and analytics system for TimeTracker with the following features:
- ✅ Comprehensive Event Tracking - All major user actions are tracked
- ✅ Installation-Specific Salt Generation - Unique salt per installation, persisted across restarts
- ✅ First-Time Setup Page - Telemetry opt-in during initial setup
- ✅ Admin Telemetry Dashboard - View and manage telemetry settings
Implementation Details
1. Comprehensive Event Tracking
Added event tracking to all major routes across the application:
Routes Updated:
app/routes/invoices.py- Invoice creation/updatesapp/routes/clients.py- Client CRUD operationsapp/routes/tasks.py- Task CRUD and status changesapp/routes/comments.py- Comment CRUD operationsapp/routes/auth.py- Login/logout events (already implemented)app/routes/timer.py- Timer start/stop events (already implemented)app/routes/projects.py- Project creation events (already implemented)app/routes/reports.py- Report viewing and exports (already implemented)app/routes/admin.py- Admin actions and telemetry dashboard
Total Events Tracked: 30+ distinct event types
See docs/all_tracked_events.md for a complete list of tracked events.
2. Installation-Specific Salt Generation
File: app/utils/installation.py
Features:
- Unique Salt: Generated once per installation using
secrets.token_hex(32) - Persistent Storage: Stored in
data/installation.json - Automatic Generation: Created on first startup, reused thereafter
- Installation ID: Separate hashed installation identifier
- Telemetry Preference: User preference stored alongside salt
Updated Files:
app/utils/telemetry.py- Now uses installation config for saltapp/__init__.py- Integrated setup check middleware
3. First-Time Setup (Guided Wizard)
Files:
app/routes/setup.py- Setup route handler (GET: wizard with settings/timezones; POST: validate and save all steps)app/templates/setup/initial_setup.html- 6-step wizard UIapp/static/js/setup-wizard.js- Step navigation and optional client-side validation
Wizard steps:
- Welcome – Intro; Next to continue
- Region & time – Timezone, date format, time format, currency (saved to Settings)
- Company – Company name, address, email, optional phone/website (saved to Settings)
- System – Allow self-registration, rounding minutes, single active timer, idle timeout (saved to Settings)
- Integrations (optional) – Google Calendar OAuth credentials; can skip
- Privacy & finish – Telemetry opt-in; Complete Setup submits form and marks setup complete
Features:
- Guided flow: One form, single POST at the end; progress indicator (Step X of 6)
- Telemetry opt-in: Clear explanation of what is/isn't collected; opt-in by default (unchecked)
- Setup completion tracking: Stored in installation config; redirect to dashboard when complete
- Middleware: Unauthenticated users are redirected to
/setupif setup not complete
User experience:
- ✅ Modern UI with Tailwind CSS; Back/Next navigation
- ✅ Prefilled from existing Settings when re-rendered (e.g. validation error)
- ✅ Server-side validation (timezone, date format, currency, rounding, idle timeout)
- ✅ Links to privacy policy and GPL-3.0
4. Admin Telemetry Dashboard
Files Created:
app/templates/admin/telemetry.html- Dashboard UI- Routes added to
app/routes/admin.py:/admin/telemetry- View telemetry status/admin/telemetry/toggle- Toggle telemetry on/off
Dashboard Features:
- Telemetry Status: Shows if enabled/disabled
- Installation Info: Displays installation ID and fingerprint
- PostHog Status: Shows PostHog configuration
- Sentry Status: Shows Sentry configuration
- Data Collection Info: Lists what is/isn't collected
- Toggle Control: One-click enable/disable
- Documentation Links: Quick access to privacy docs
Configuration
Environment Variables
# PostHog (Product Analytics)
POSTHOG_API_KEY= # Empty by default (opt-in)
POSTHOG_HOST=https://app.posthog.com # Default host
# Sentry (Error Monitoring)
SENTRY_DSN= # Empty by default
SENTRY_TRACES_RATE=0.1 # 10% sampling
# Telemetry
ENABLE_TELEMETRY=false # Default: false (opt-in)
TELE_URL= # Telemetry endpoint
Installation Config
Stored in data/installation.json:
{
"telemetry_salt": "unique-64-char-hex-string",
"installation_id": "unique-16-char-id",
"setup_complete": true,
"telemetry_enabled": false,
"setup_completed_at": "2025-10-20T..."
}
Privacy & Security
Privacy-First Design
- ✅ Opt-In by Default: Telemetry disabled unless explicitly enabled
- ✅ Anonymous: Only numeric IDs, no PII
- ✅ Transparent: Clear documentation of all tracked events
- ✅ User Control: Can toggle on/off anytime in admin dashboard
- ✅ Self-Hosted: All data stays on user's server
What We Track
- ✅ Event types (e.g., "timer.started")
- ✅ Internal numeric IDs
- ✅ Timestamps
- ✅ Anonymous installation fingerprint
What We DON'T Track
- ❌ Email addresses or usernames
- ❌ Project names or descriptions
- ❌ Time entry notes or content
- ❌ Client information
- ❌ IP addresses
- ❌ Any personally identifiable information
Testing
Test the Setup Flow
- Delete
data/installation.json(if exists) - Start the application
- You should be redirected to
/setup - Complete the setup with telemetry enabled/disabled
- Verify you're redirected to the dashboard
Test the Admin Dashboard
- Login as admin
- Navigate to
/admin/telemetry - Verify all status cards show correct information
- Toggle telemetry and verify it updates
Test Event Tracking
- Enable telemetry in admin dashboard
- Perform various actions (create project, start timer, etc.)
- Check
logs/app.jsonlfor logged events - If PostHog API key is set, events will be sent to PostHog
Files Modified/Created
New Files (9)
app/utils/installation.py- Installation config managementapp/routes/setup.py- Setup routeapp/templates/setup/initial_setup.html- Setup pageapp/templates/admin/telemetry.html- Telemetry dashboarddocs/all_tracked_events.md- Event documentationTELEMETRY_IMPLEMENTATION_SUMMARY.md- This file
Modified Files (10)
app/__init__.py- Added setup check middleware, registered setup blueprintapp/utils/telemetry.py- Updated to use installation configapp/routes/admin.py- Added telemetry dashboard routesapp/routes/invoices.py- Added event trackingapp/routes/clients.py- Added event trackingapp/routes/tasks.py- Added event trackingapp/routes/comments.py- Added event trackingapp/routes/auth.py- (already had tracking)app/routes/timer.py- (already had tracking)app/routes/projects.py- (already had tracking)
Next Steps
For Production Deployment
-
Set PostHog API Key (if using PostHog):
export POSTHOG_API_KEY="your-api-key-here" -
Set Sentry DSN (if using Sentry):
export SENTRY_DSN="your-sentry-dsn-here" -
Deploy and Test:
- First user should see setup page
- Telemetry should be disabled by default
- Events should only be sent if opted in
For Self-Hosted Instances
Users can:
- Leave telemetry disabled (default)
- Enable for community support
- View exactly what's being sent in admin dashboard
- Disable anytime with one click
Documentation
- Analytics Documentation:
docs/analytics.md - All Tracked Events:
docs/all_tracked_events.md - Privacy Policy:
docs/privacy.md - Event Schema:
docs/events.md
Summary
✅ Requirement 1: All possible events are being logged to PostHog - COMPLETE ✅ Requirement 2: Salt is generated once at startup and stored - COMPLETE ✅ Requirement 3: Telemetry is default false, asked on first access - COMPLETE ✅ Requirement 4: Admin dashboard shows telemetry data - COMPLETE
All requirements have been successfully implemented with a privacy-first, user-friendly approach.