mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2025-12-30 15:49:44 -06:00
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(-)
121 lines
3.5 KiB
YAML
121 lines
3.5 KiB
YAML
version: '3.8'
|
|
|
|
# Analytics-enabled Docker Compose configuration
|
|
# This extends the base docker-compose.yml with analytics services and configuration
|
|
|
|
services:
|
|
timetracker:
|
|
environment:
|
|
# Sentry Error Monitoring
|
|
- SENTRY_DSN=${SENTRY_DSN:-}
|
|
- SENTRY_TRACES_RATE=${SENTRY_TRACES_RATE:-0.0}
|
|
|
|
# PostHog Product Analytics
|
|
- POSTHOG_API_KEY=${POSTHOG_API_KEY:-}
|
|
- POSTHOG_HOST=${POSTHOG_HOST:-https://app.posthog.com}
|
|
|
|
# Telemetry (opt-in, uses PostHog)
|
|
- ENABLE_TELEMETRY=${ENABLE_TELEMETRY:-false}
|
|
- TELE_SALT=${TELE_SALT:-change-me}
|
|
- APP_VERSION=${APP_VERSION:-1.0.0}
|
|
|
|
volumes:
|
|
# Mount logs directory for persistent JSON logs
|
|
- ./logs:/app/logs
|
|
# Mount data directory for telemetry marker files
|
|
- ./data:/app/data
|
|
|
|
# Expose metrics endpoint (optional, for Prometheus scraping)
|
|
# ports:
|
|
# - "8000:8000" # Already exposed in base compose
|
|
|
|
# Optional: Self-hosted Prometheus for metrics collection
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
container_name: timetracker-prometheus
|
|
profiles:
|
|
- monitoring
|
|
volumes:
|
|
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
- prometheus_data:/prometheus
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--storage.tsdb.retention.time=30d'
|
|
ports:
|
|
- "9090:9090"
|
|
restart: unless-stopped
|
|
|
|
# Optional: Grafana for metrics visualization
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
container_name: timetracker-grafana
|
|
profiles:
|
|
- monitoring
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./grafana/provisioning:/etc/grafana/provisioning
|
|
ports:
|
|
- "3000:3000"
|
|
depends_on:
|
|
- prometheus
|
|
restart: unless-stopped
|
|
|
|
# Optional: Grafana Loki for log aggregation
|
|
loki:
|
|
image: grafana/loki:latest
|
|
container_name: timetracker-loki
|
|
profiles:
|
|
- logging
|
|
volumes:
|
|
- ./loki/loki-config.yml:/etc/loki/local-config.yaml
|
|
- loki_data:/loki
|
|
ports:
|
|
- "3100:3100"
|
|
command: -config.file=/etc/loki/local-config.yaml
|
|
restart: unless-stopped
|
|
|
|
# Optional: Promtail for log shipping to Loki
|
|
promtail:
|
|
image: grafana/promtail:latest
|
|
container_name: timetracker-promtail
|
|
profiles:
|
|
- logging
|
|
volumes:
|
|
- ./logs:/var/log/timetracker:ro
|
|
- ./promtail/promtail-config.yml:/etc/promtail/config.yml
|
|
command: -config.file=/etc/promtail/config.yml
|
|
depends_on:
|
|
- loki
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
prometheus_data:
|
|
driver: local
|
|
grafana_data:
|
|
driver: local
|
|
loki_data:
|
|
driver: local
|
|
|
|
# Usage:
|
|
#
|
|
# 1. Base setup with analytics enabled (Sentry, PostHog):
|
|
# docker-compose -f docker-compose.yml -f docker-compose.analytics.yml up -d
|
|
#
|
|
# 2. With self-hosted monitoring (Prometheus + Grafana):
|
|
# docker-compose -f docker-compose.yml -f docker-compose.analytics.yml --profile monitoring up -d
|
|
#
|
|
# 3. With log aggregation (Loki + Promtail):
|
|
# docker-compose -f docker-compose.yml -f docker-compose.analytics.yml --profile logging up -d
|
|
#
|
|
# 4. With everything (monitoring + logging):
|
|
# docker-compose -f docker-compose.yml -f docker-compose.analytics.yml --profile monitoring --profile logging up -d
|
|
#
|
|
# Configuration:
|
|
# - Copy env.example to .env and configure analytics variables
|
|
# - See docs/analytics.md for detailed configuration instructions
|
|
|