Skip to content

Add privacy-conscious, offline-resilient analytics - #136

Draft
dewana-sl wants to merge 9 commits into
KittenML:mainfrom
dewana-sl:implement-analytics
Draft

Add privacy-conscious, offline-resilient analytics#136
dewana-sl wants to merge 9 commits into
KittenML:mainfrom
dewana-sl:implement-analytics

Conversation

@dewana-sl

@dewana-sl dewana-sl commented May 21, 2026

Copy link
Copy Markdown

Summary

Adds dependency-free generation analytics to the Python SDK with durable, bounded delivery for offline and short-lived workloads.

Data contract

  • Sends one event for each generate, generate_to_file, or completed generate_stream invocation.
  • Records SDK and Python versions, OS, model and model version, selected voice, generation type, asset source, and a coarse SDK error code.
  • Uses a random installation UUID and a per-event UUID.
  • Never records or sends input text, generated audio, stack traces, file paths, hostnames, usernames, or project names.
  • Sends only to the KittenTTS intake; no PostHog SDK or vendor dependency is added.

Offline and failure behavior

  • Persists the small metadata event before starting daemon background delivery.
  • KITTENTTS_OFFLINE=1 and HF_HUB_OFFLINE=1 make zero analytics network requests while keeping bounded pending events for a later retry.
  • Pending storage is capped at 1,000 events and 30 days, with oldest events discarded first.
  • Transient timeouts, 429, and server failures remain queued; non-retryable client errors are discarded.
  • Analytics delivery never raises through or blocks the public TTS API.

Privacy and controls

  • Disable per model with analytics=False or globally with KITTENTTS_ANALYTICS=0.
  • Also respects HF_HUB_DISABLE_TELEMETRY=1 and DO_NOT_TRACK=1.
  • Opting out removes unsent KittenTTS analytics events.
  • Documentation describes the installation ID as pseudonymous rather than claiming it is untraceable.
  • The intake forwards only a coarse country code and no raw IP, user agent, or city-level location after the related worker change.

Rollout dependency

Deploy dewana-sl/kittentts-analytics-worker#1 before merging this PR. It accepts stream, deduplicates retries with PostHog $insert_id, adds bounded validation and rate limiting, and returns retryable failures when upstream delivery is unavailable.

Validation

  • python3 -m unittest -q (28 passing)
  • python3 -m compileall -q kittentts tests
  • git diff --check

The production intake currently returns 400 for generation: stream; the worker PR fixes that contract mismatch before SDK rollout.

@dewana-sl dewana-sl changed the title Add privacy-conscious generation analytics Add privacy-conscious, offline-resilient analytics Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants