Skip to content

Add analytics integration for usage tracking #120

Description

@StephanMeijer

Context

Find processes document indexing and search requests across multiple services, but there is currently no analytics infrastructure to track usage patterns. Understanding how the API is used - which services index the most documents, search query patterns, peak usage times - would help with capacity planning and feature prioritization.

Requirements

  • Implement event tracking for key operations:
    • index events: service name, document count (single vs bulk), language distribution
    • search events: service name, query characteristics (length, filters used), result count, response time
    • delete events: service name, document count
  • Support integration with common analytics backends (e.g., PostHog, Amplitude, Segment, or a generic webhook)
  • Make analytics configurable via environment variables (enable/disable, backend selection, endpoint URL)
  • Ensure user privacy - do not track actual query content or document data, only aggregate metadata
  • Events should be sent asynchronously to avoid impacting API latency (consider using the existing Celery infrastructure)

Technical notes

  • The three main views to instrument are in core/views.py: IndexDocumentView, SearchDocumentView, DeleteDocumentsView
  • Celery is already configured (CELERY_BROKER_URL in settings) and could be used for async event dispatch
  • Consider a simple abstraction layer so different analytics backends can be swapped without code changes
  • Existing logging already captures some of this data - analytics could complement rather than replace logging

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions