Skip to content

Add client tracking and analytics for multiple apps #41

@ebowwa

Description

@ebowwa

Feature Request: Client Tracking System

Summary

Implement client identification and tracking to monitor usage across different applications using the CaringMind API server.

Known Clients

  • CaringMind iOS App - IP: 100.86.17.119 (mobile)
  • PrintPeer Web App (Vite) - TBD
  • Future clients - Need flexible system

Current State

Server logs show IP addresses but don't identify which client/app is making requests:

INFO:     100.86.17.119:0 - "POST /api/chat/completions HTTP/1.1" 200 OK

Proposed Implementation

Option 1: Server-side tracking (Recommended)

Add client tracking module to CaringMind server:

# backend-python/src/client_tracker.py
class ClientTracker:
    def track_request(self, ip, user_agent, endpoint, model):
        # Identify client from IP, User-Agent, or API key prefix
        # Track: last_seen, request_count, features_used, models_used
        # Store in Redis/SQLite for persistence

Option 2: Extend ai-proxy-core telemetry

  • Could add to existing telemetry in ai-proxy-core
  • But cleaner to keep deployment-specific tracking separate

Tracking Features Needed

  • Client identification (by IP range, User-Agent, API key prefix)
  • Request counting per client
  • Feature/endpoint usage tracking
  • Model usage per client (Gemini 2.0, 1.5, etc.)
  • Error rate per client
  • Audio vs text request ratio
  • Response time analytics per client

Benefits

  • Monitor which apps are actively using the API
  • Track feature adoption across different clients
  • Identify performance issues per client
  • Better capacity planning
  • Usage-based insights for each app

Quick Implementation for MVP

For now, could just add client identification to logs:

if request.client.host.startswith("100.86.17"):
    client_name = "ios-caringmind"
elif "printpeer" in request.headers.get("origin", "").lower():
    client_name = "vite-printpeer"
logger.info(f"Client: {client_name} - {endpoint}")

Related

  • Doppler secrets management (Add OpenAI API support #6)
  • Uptime Kuma monitoring (existing)
  • Could integrate with existing telemetry infrastructure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions