Telemetry Architecture & Key Decisions

January 6, 2026 · View on GitHub

Document Status: Living Document Last Updated: December 2024 Owner: Autohand Core Team


Overview

Autohand CLI includes an optional telemetry system designed to help improve the product while respecting user privacy. This document outlines what data is collected, how it's handled, and how users can control their data.

Guiding Principles:

  1. Privacy First - No personally identifiable information (PII) is ever collected
  2. Transparency - Users know exactly what's collected
  3. User Control - Easy opt-out, data deletion on request
  4. Offline Resilient - Works without internet, syncs when available

Data Collection Summary

What We Collect

CategoryData PointsPurpose
SessionStart/end time, duration, statusUnderstand usage patterns
ToolsWhich tools used, success/failure, durationImprove tool reliability
ErrorsError type, sanitized messageFix bugs faster
CommandsSlash commands usedPrioritize feature development
EnvironmentOS, Node version, CLI versionEnsure compatibility

What We Do NOT Collect

  • File contents or names
  • User prompts or conversations
  • API keys or credentials
  • IP addresses (hashed on server)
  • Usernames, emails, or any PII
  • Code, diffs, or patches
  • Workspace paths (sanitized)

Event Types

1. session_start

Triggered when a user starts or resumes a session.

{
  eventType: 'session_start',
  sessionId: 'uuid',
  deviceId: 'uuid',
  eventData: {
    model: 'claude-3.5-sonnet',
    provider: 'openrouter'
  },
  platform: 'darwin',
  cliVersion: '0.1.0',
  timestamp: 'ISO-8601'
}

Frequency: Once per session start

2. session_end

Triggered when a session ends (quit, crash, or abandoned).

{
  eventType: 'session_end',
  eventData: {
    status: 'completed' | 'crashed' | 'abandoned',
    duration: 1234, // seconds
    model: 'claude-3.5-sonnet',
    provider: 'openrouter'
  },
  interactionCount: 15,
  toolsUsed: ['read_file', 'write_file', 'run_command'],
  errorsCount: 0
}

Frequency: Once per session end

3. tool_use

Triggered when any tool is executed.

{
  eventType: 'tool_use',
  eventData: {
    tool: 'write_file',
    success: true,
    duration: 45 // milliseconds
  }
}

Frequency: Per tool execution (batched)

4. error

Triggered on unexpected errors.

{
  eventType: 'error',
  eventData: {
    type: 'interactive_loop_error',
    message: 'Connection timeout',
    stack: '...sanitized...',
    context: 'Interactive loop'
  }
}

Stack Trace Sanitization:

  • /Users/<username>//Users/***/
  • /home/<username>//home/***/
  • C:\Users\<username>\C:\Users\***\

Frequency: Per error occurrence

5. model_switch

Triggered when user changes the AI model.

{
  eventType: 'model_switch',
  eventData: {
    fromModel: 'gpt-4',
    toModel: 'claude-3.5-sonnet',
    provider: 'openrouter'
  }
}

Frequency: Per model change

6. command_use

Triggered when slash commands are used.

{
  eventType: 'command_use',
  eventData: {
    command: '/model'
  }
}

Frequency: Per slash command

7. heartbeat

Periodic check-in for long sessions.

{
  eventType: 'heartbeat',
  eventData: {
    uptime: 3600 // seconds
  }
}

Frequency: Every 5 minutes during active sessions

8. session_sync

Session data uploaded for cloud sync feature.

{
  eventType: 'session_sync',
  eventData: {
    messageCount: 45,
    totalTokens: 12500
  }
}

Frequency: On session end (if enabled)


Data Flow Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Autohand CLI                            │
│  ┌─────────────────────────────────────────────────────┐    │
│  │              TelemetryManager                        │    │
│  │  • Captures events                                   │    │
│  │  • Sanitizes data                                    │    │
│  │  • Manages session state                             │    │
│  └────────────────────┬────────────────────────────────┘    │
│                       │                                      │
│  ┌────────────────────▼────────────────────────────────┐    │
│  │              TelemetryClient                         │    │
│  │  • Batches events (max 20)                          │    │
│  │  • Persists queue to disk                           │    │
│  │  • Retries on failure (3 attempts)                  │    │
│  │  • Flushes every 60 seconds                         │    │
│  └────────────────────┬────────────────────────────────┘    │
│                       │                                      │
│  ┌────────────────────▼────────────────────────────────┐    │
│  │           ~/.autohand/telemetry/                 │    │
│  │  • queue.json (pending events)                      │    │
│  │  • session-sync-queue.json (pending sessions)       │    │
│  └────────────────────┬────────────────────────────────┘    │
└───────────────────────┼─────────────────────────────────────┘
                        │ HTTPS (when online)

┌─────────────────────────────────────────────────────────────┐
│              api.autohand.ai (Cloudflare Workers)            │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  POST /v1/telemetry/batch                           │    │
│  │  POST /v1/history/keeping                           │    │
│  └────────────────────┬────────────────────────────────┘    │
│                       │                                      │
│  ┌────────────────────▼────────────────────────────────┐    │
│  │              Data Storage                            │    │
│  │  • D1 (SQLite) - Structured metrics                 │    │
│  │  • R2 (Object) - Raw event data                     │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

Frequency & Batching

Event Batching

SettingValueConfigurable
Batch size20 eventsNo
Flush interval60 secondsNo
Max queue size500 eventsNo
Retry attempts3No
Retry backoff1s, 2s, 3sNo

Network Behavior

  • Online: Events sent in batches every 60 seconds or when batch size reached
  • Offline: Events queued to disk, synced when connection restored
  • Startup: Attempts to flush any queued events from previous sessions

Opt-In / Opt-Out

Default Behavior

Telemetry is disabled by default. Users must explicitly opt-in to enable telemetry.

How to Opt-In

Option 1: Config File

Edit ~/.autohand/config.json:

{
  "telemetry": {
    "enabled": true
  }
}

Option 2: Environment Variable

AUTOHAND_TELEMETRY=true autohand

What Happens When Disabled (Default)

  • No events are captured or sent
  • No network requests to telemetry endpoints
  • Session sync is disabled
  • Local session files still created

Enabling Session Sync

Enable both telemetry and cloud session sync:

{
  "telemetry": {
    "enabled": true,
    "enableSessionSync": true
  }
}

Device Identification

Anonymous Device ID

  • Generated on first run: crypto.randomUUID()
  • Stored in ~/.autohand/device-id
  • Never changes unless manually deleted
  • Not linked to any user account

Session ID

  • Generated per session: crypto.randomUUID()
  • Links events within a single session
  • Enables session resume from cloud

Data Retention

On-Device

DataLocationRetention
Event queue~/.autohand/telemetry/queue.jsonUntil synced
Session sync queue~/.autohand/telemetry/session-sync-queue.jsonUntil synced (max 10)
Device ID~/.autohand/device-idPermanent

Server-Side

DataStorageRetention
Telemetry eventsD1 + R290 days
Session dataR290 days
Aggregated metricsD1Indefinite

Enterprise Features

Standard (Free)

  • All telemetry collection
  • Opt-out capability
  • Local session storage
  • Cloud session sync

Enterprise (Planned)

FeatureDescription
Private Telemetry EndpointSelf-hosted API for complete data control
Data ResidencyChoose region for data storage (EU, US, APAC)
Extended RetentionCustom retention periods up to 2 years
Audit LogsDetailed logs of all data access
SSO IntegrationLink telemetry to enterprise identity
Team AnalyticsAggregated usage across team members
Custom DashboardsBuild custom analytics views
Export APIProgrammatic access to raw telemetry
Compliance ReportsSOC2, GDPR, HIPAA compliance documentation
Data Deletion APIProgrammatic GDPR deletion requests

Enterprise Configuration

{
  "telemetry": {
    "enabled": true,
    "apiBaseUrl": "https://telemetry.your-company.com",
    "enableSessionSync": true,
    "enterprise": {
      "organizationId": "org_xxx",
      "apiKey": "ent_xxx",
      "dataResidency": "eu-west-1"
    }
  }
}

Privacy & Compliance

GDPR Compliance

  • Lawful Basis: Legitimate interest (product improvement)
  • Data Minimization: Only essential data collected
  • Right to Access: Request data export via support
  • Right to Erasure: Request deletion via support
  • Data Portability: JSON export available

Data Processing

RoleEntity
Data ControllerAutohand AI LLC
Data ProcessorCloudflare (hosting)
Sub-processorsNone

Security Measures

  • TLS 1.3 for all transmissions
  • Data encrypted at rest (Cloudflare D1/R2)
  • No logs contain PII
  • Regular security audits
  • IP addresses hashed with rotating salt

Debugging & Transparency

View Queued Events

cat ~/.autohand/telemetry/queue.json | jq

View Device ID

cat ~/.autohand/device-id

Clear All Telemetry Data

rm -rf ~/.autohand/telemetry/
rm ~/.autohand/device-id

Verify Opt-Out

When telemetry is disabled, no network requests are made to api.autohand.ai. Verify with:

# macOS/Linux
sudo tcpdump -i any host api.autohand.ai

Changelog

DateChange
2024-12Initial telemetry system implementation
2024-12Added offline batching and sync
2024-12Added session cloud sync
2024-12Added enterprise feature planning

Questions & Contact

For telemetry-related questions or data requests:


This document is part of the Autohand CLI open-source project and is subject to the Apache-2.0 license.