sandbox-reports/README.md
DJP facacc94d4 Update AI Tools Usage Report System - Multi-Tool Support
Enhanced the VEO3 usage report system to support all AI tool types:
- Added support for 6 tool types: VEO3, TEXT2IMAGE, TEXT2VOICE, SPEECH2SPEECH, DOCUMENT_TRANSLATION, VIDEOQUERY
- Updated Python report generator (veo3_report.py) with dynamic tool detection
- Updated PHP report page (report.php) with tool usage breakdown section
- Changed all "Prompts" references to "Requests" for clarity
- Updated refresh button to fetch only last 12 weeks (84 days) for better performance
- Made system dynamic to handle unknown tool types automatically
- Renamed report titles from "VEO3 Usage Report" to "AI Tools Usage Report"

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-01-08 14:50:04 -05:00

4.2 KiB

VEO3 Usage Report System

Automated reporting system for VEO3 video generation usage analytics with Microsoft Azure AD Single Sign-On.

Features

  • PHP Web Interface: Interactive dashboard for viewing usage reports
  • SSO Authentication: Microsoft Azure AD (MSAL) integration for secure access
  • Python Automation: Automated daily/weekly/monthly email reports via SMTP (Mailgun)
  • Granular Analytics:
    • Last 24 hours activity
    • Last 7 days trends
    • Last 30 days overview
    • Top 25 users per period
  • Professional Styling: Montserrat font, custom yellow (#FFC407) branding

Setup

PHP Web Reports with SSO

  1. Install PHP dependencies:

    composer install
    
  2. Configure SSO (see SSO-SETUP.md):

    cp .env.example .env
    nano .env  # Add Azure AD tenant and client IDs
    
  3. For local development (disable SSO):

    # In .env
    SSO_ENABLED=false
    
  4. Start PHP development server:

    php -S localhost:8000
    
  5. Access the interfaces:

    • http://localhost:8000/webhook_caller.php - Fetch data from webhook
    • http://localhost:8000/report.php - View full report

Python Email Reports

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Configure environment variables:

    cp .env.example .env
    # Edit .env with your SMTP credentials
    
  3. Run the report generator:

    python veo3_report.py
    

Configuration (.env)

# Webhook URL
WEBHOOK_URL=https://hook.us1.make.celonis.com/...

# SMTP Settings (Mailgun SMTP)
SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_USER=your-mailgun-smtp-user@your-domain.com
SMTP_PASSWORD=your-smtp-password
SENDER_EMAIL=reports@your-domain.com

# Recipients (comma-separated)
REPORT_RECIPIENTS=user1@example.com,user2@example.com

Scheduling Automated Reports

For production servers, use the included systemd service instead of cron:

  1. Deploy to server:

    # Upload files to server
    scp veo3_report.py veo3_scheduler.py requirements.txt .env \
        veo3-report.service deploy.sh user@your-server:/tmp/veo3-deploy/
    
    # Run deployment script
    ssh user@your-server
    cd /tmp/veo3-deploy
    chmod +x deploy.sh
    sudo ./deploy.sh
    
  2. Service will run automatically at 7:00 PM EST daily

Benefits:

  • Auto-restart on failure
  • Starts on server boot
  • Better logging with journalctl
  • No cron dependency
  • Easy status monitoring

See DEPLOYMENT.md for full deployment guide.

Alternative: Manual Scheduling

macOS/Linux (cron)

# Daily report at 9 AM
0 9 * * * cd /path/to/VEO3-REPORT && /usr/bin/python3 veo3_report.py

Windows (Task Scheduler)

Create a scheduled task that runs:

python C:\path\to\VEO3-REPORT\veo3_report.py

Report Output

The Python script:

  • Fetches data from webhook
  • Analyzes three time periods (24h, 7d, 30d)
  • Generates HTML report saved as email_report.html
  • Sends email via SMTP to configured recipients

Files

Web Interface

  • webhook_caller.php - Web interface for fetching webhook data
  • report.php - Interactive web dashboard with collapsible sections

Python Automation

  • veo3_report.py - Automated email report generator
  • veo3_scheduler.py - Scheduler daemon service (runs continuously)
  • requirements.txt - Python dependencies

Deployment

  • deploy.sh - Automated server deployment script
  • veo3-report.service - systemd service configuration
  • DEPLOYMENT.md - Complete deployment guide

Configuration

  • .env.example - Configuration template
  • .env - Your configuration (not in git)
  • config.php - SSO and session configuration
  • env_loader.php - Environment variable loader

SSO Files

  • AuthMiddleware.php - Main authentication class
  • JWTValidator.php - JWT token validator
  • auth.php - Authentication API endpoint
  • composer.json - PHP dependencies
  • SSO-SETUP.md - Complete SSO setup guide

Generated Files

  • webhook_response.json - Cached webhook data (auto-generated)
  • email_report.html - Latest email report (auto-generated)
  • logs/ - Application logs (auto-generated)