Files
TimeTracker/docs/admin/monitoring/TELEMETRY_IMPLEMENTATION_SUMMARY.md
T
Dries Peeters 29f7186ee8 docs: Reorganize documentation structure for better navigation
Complete reorganization of project documentation to improve discoverability,
navigation, and maintainability. All documentation has been restructured into
a clear, role-based hierarchy.

## Major Changes

### New Directory Structure
- Created `docs/api/` for API documentation
- Created `docs/admin/` with subdirectories:
  - `admin/configuration/` - Configuration guides
  - `admin/deployment/` - Deployment guides
  - `admin/security/` - Security documentation
  - `admin/monitoring/` - Monitoring and analytics
- Created `docs/development/` for developer documentation
- Created `docs/guides/` for user-facing guides
- Created `docs/reports/` for analysis reports and summaries
- Created `docs/changelog/` for detailed changelog entries (ready for future use)

### File Organization

#### Moved from Root Directory (40+ files)
- Implementation notes → `docs/implementation-notes/`
- Test reports → `docs/testing/`
- Analysis reports → `docs/reports/`
- User guides → `docs/guides/`

#### Reorganized within docs/
- API documentation → `docs/api/`
- Administrator documentation → `docs/admin/` (with subdirectories)
- Developer documentation → `docs/development/`
- Security documentation → `docs/admin/security/`
- Telemetry documentation → `docs/admin/monitoring/`

### Documentation Updates

#### docs/README.md
- Complete rewrite with improved navigation
- Added visual documentation map
- Organized by role (Users, Administrators, Developers)
- Better categorization and quick links
- Updated all internal links to new structure

#### README.md (root)
- Updated all documentation links to reflect new structure
- Fixed 8 broken links

#### app/templates/main/help.html
- Enhanced "Where can I get additional help?" section
- Added links to new documentation structure
- Added documentation index link
- Added admin documentation link for administrators
- Improved footer with organized documentation links
- Added "Complete Documentation" section with role-based links

### New Index Files
- Created README.md files for all new directories:
  - `docs/api/README.md`
  - `docs/guides/README.md`
  - `docs/reports/README.md`
  - `docs/development/README.md`
  - `docs/admin/README.md`

### Cleanup
- Removed empty `docs/security/` directory (moved to `admin/security/`)
- Removed empty `docs/telemetry/` directory (moved to `admin/monitoring/`)
- Root directory now only contains: README.md, CHANGELOG.md, LICENSE

## Results

**Before:**
- 45+ markdown files cluttering root directory
- Documentation scattered across root and docs/
- Difficult to find relevant documentation
- No clear organization structure

**After:**
- 3 files in root directory (README, CHANGELOG, LICENSE)
- Clear directory structure organized by purpose and audience
- Easy navigation with role-based organization
- All documentation properly categorized
- Improved discoverability

## Benefits

1. Better Organization - Documentation grouped by purpose and audience
2. Easier Navigation - Role-based sections (Users, Admins, Developers)
3. Improved Discoverability - Clear structure with README files in each directory
4. Cleaner Root - Only essential files at project root
5. Maintainability - Easier to add and organize new documentation

## Files Changed

- 40+ files moved from root to appropriate docs/ subdirectories
- 15+ files reorganized within docs/
- 3 major documentation files updated (docs/README.md, README.md, help.html)
- 5 new README index files created
- 2 empty directories removed

All internal links have been updated to reflect the new structure.
2025-12-14 07:56:07 +01:00

7.4 KiB

Telemetry & Analytics Implementation Summary

Overview

Successfully implemented a comprehensive telemetry and analytics system for TimeTracker with the following features:

  1. Comprehensive Event Tracking - All major user actions are tracked
  2. Installation-Specific Salt Generation - Unique salt per installation, persisted across restarts
  3. First-Time Setup Page - Telemetry opt-in during initial setup
  4. 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/updates
  • app/routes/clients.py - Client CRUD operations
  • app/routes/tasks.py - Task CRUD and status changes
  • app/routes/comments.py - Comment CRUD operations
  • app/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 salt
  • app/__init__.py - Integrated setup check middleware

3. First-Time Setup Page

Files Created:

  • app/routes/setup.py - Setup route handler
  • app/templates/setup/initial_setup.html - Beautiful setup page

Features:

  • Welcome Screen: Professional, user-friendly design
  • Telemetry Opt-In: Clear explanation of what's collected
  • Privacy Transparency: Detailed list of what is/isn't collected
  • Setup Completion Tracking: Prevents re-showing after completion
  • Middleware Integration: Redirects to setup if not complete

User Experience:

  • Modern, clean UI with Tailwind CSS
  • Clear privacy explanations
  • Opt-in by default (unchecked checkbox)
  • Links to privacy policy and documentation
  • Easy to understand language

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

  1. Delete data/installation.json (if exists)
  2. Start the application
  3. You should be redirected to /setup
  4. Complete the setup with telemetry enabled/disabled
  5. Verify you're redirected to the dashboard

Test the Admin Dashboard

  1. Login as admin
  2. Navigate to /admin/telemetry
  3. Verify all status cards show correct information
  4. Toggle telemetry and verify it updates

Test Event Tracking

  1. Enable telemetry in admin dashboard
  2. Perform various actions (create project, start timer, etc.)
  3. Check logs/app.jsonl for logged events
  4. If PostHog API key is set, events will be sent to PostHog

Files Modified/Created

New Files (9)

  1. app/utils/installation.py - Installation config management
  2. app/routes/setup.py - Setup route
  3. app/templates/setup/initial_setup.html - Setup page
  4. app/templates/admin/telemetry.html - Telemetry dashboard
  5. docs/all_tracked_events.md - Event documentation
  6. TELEMETRY_IMPLEMENTATION_SUMMARY.md - This file

Modified Files (10)

  1. app/__init__.py - Added setup check middleware, registered setup blueprint
  2. app/utils/telemetry.py - Updated to use installation config
  3. app/routes/admin.py - Added telemetry dashboard routes
  4. app/routes/invoices.py - Added event tracking
  5. app/routes/clients.py - Added event tracking
  6. app/routes/tasks.py - Added event tracking
  7. app/routes/comments.py - Added event tracking
  8. app/routes/auth.py - (already had tracking)
  9. app/routes/timer.py - (already had tracking)
  10. app/routes/projects.py - (already had tracking)

Next Steps

For Production Deployment

  1. Set PostHog API Key (if using PostHog):

    export POSTHOG_API_KEY="your-api-key-here"
    
  2. Set Sentry DSN (if using Sentry):

    export SENTRY_DSN="your-sentry-dsn-here"
    
  3. 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.