telemetry-kit

CLI Tool

Manage telemetry configuration and operations from the command line

Overview

The telemetry-kit CLI provides convenient commands for managing telemetry configuration and operations without writing code.

Installation

cargo install telemetry-kit --features cli

Commands

init - Interactive Setup

Initialize telemetry configuration for your project.

telemetry-kit init

Options:

  • -y, --yes - Skip prompts and use defaults
  • -n, --service-name <NAME> - Specify service name
  • -s, --service <NAME> - Override service globally

Example:

$ telemetry-kit init
 
๐Ÿ”ญ Telemetry Kit - Interactive Setup
 
Service name: my-app
 
Configure sync to telemetry-kit.dev? yes
 
Sync Configuration
 
Organization ID: acme-corp
Application ID: my-app
Auth Token: tk_abc123...
HMAC Secret: ********
 
Testing credentials...
โœ“ Credentials validated successfully!

The command will output code you can copy-paste into your application.

test - Validate Credentials

Test sync credentials and verify connectivity.

telemetry-kit test

Options:

  • -o, --org-id <ID> - Organization ID
  • -a, --app-id <ID> - Application ID
  • -t, --token <TOKEN> - Authentication token
  • -s, --secret <SECRET> - HMAC secret

Examples:

telemetry-kit test
# Prompts for all credentials

stats - View Statistics

View event statistics for a service.

telemetry-kit stats

Options:

  • -d, --detailed - Show detailed breakdown including file size
  • -s, --service <NAME> - Service name (defaults to current directory)

Example output:

๐Ÿ“Š Event Statistics

Service: my-app
Database: /Users/you/.telemetry-kit/my-app.db

Events:
  Total:      42
  Synced:     30
  Unsynced:   12

Sync rate: 71%

๐Ÿ’ก You have 12 unsynced events
   Run telemetry-kit sync to sync now

sync - Manual Synchronization

Manually trigger event synchronization.

telemetry-kit sync

Options:

  • -f, --force - Force sync even if auto-sync is enabled
  • -s, --service <NAME> - Service name

Currently a placeholder. Full implementation requires stored credential management.

validate - Validate Configuration

Validate telemetry configuration for a service.

telemetry-kit validate

Options:

  • -c, --config <PATH> - Path to configuration file (future use)
  • -s, --service <NAME> - Service name

Example:

โœ“ Validating Configuration

Service: my-app
โœ“ Database found: /Users/you/.telemetry-kit/my-app.db
โœ“ Telemetry initialization successful

โœ“ Configuration valid

clean - Clear Events

Clear local event database for a service.

telemetry-kit clean

Options:

  • -y, --yes - Skip confirmation prompt
  • --all - Also remove configuration files (future use)
  • -s, --service <NAME> - Service name

This operation is destructive. Unsynced events will be permanently lost.

Example:

$ telemetry-kit clean
 
๐Ÿงน Clean Local Events
 
Service: my-app
Current: 42 events (12 unsynced)
 
โš ๏ธ  You have 12 unsynced events that will be lost!
 
Are you sure you want to delete all local events? no
 
Cancelled

Global Options

Available on all commands:

  • -s, --service <NAME> - Service name to operate on
  • -h, --help - Show command help
  • -V, --version - Show version information

Workflows

Typical Developer Workflow

Initialize telemetry

cd my-app
telemetry-kit init

Add code to your application

Copy the generated code snippet into your main.rs.

Run your application

cargo run

View statistics

telemetry-kit stats

View detailed stats

telemetry-kit stats --detailed

Validate configuration

telemetry-kit validate

Clean up (optional)

telemetry-kit clean

Managing Multiple Services

# View stats for different services
telemetry-kit stats --service frontend
telemetry-kit stats --service backend
telemetry-kit stats --service worker
 
# Validate all services
for service in frontend backend worker; do
  echo "Validating $service..."
  telemetry-kit validate --service "$service"
done
 
# Clean specific service
telemetry-kit clean --service old-service --yes

User Experience

Colored Output

The CLI uses colors to improve readability:

  • Cyan - Command names, values, highlights
  • Green - Success messages, valid states
  • Yellow - Warnings, info messages
  • Red - Errors, failures
  • Dimmed - Less important information
  • Bold - Headers, important messages

Disable colors with the NO_COLOR=1 environment variable.

Interactive Prompts

  • Input - Text input with defaults
  • Password - Hidden input for secrets
  • Confirm - Yes/no questions
  • Progress - Spinners for long operations

Helpful Hints

The CLI provides contextual hints and next steps:

โœ“ Initialization complete!

Next steps:
  โ€ข telemetry-kit stats - View statistics
  โ€ข telemetry-kit test - Test sync
  โ€ข telemetry-kit validate - Validate config

Database Location

Event databases are stored in:

~/.telemetry-kit/<service-name>.db

Each service has its own SQLite database file.

Troubleshooting

"No telemetry data found"

# Make sure you've initialized telemetry in your app
telemetry-kit init
 
# Check the database path
ls ~/.telemetry-kit/

"Failed to initialize"

# Validate your configuration
telemetry-kit validate
 
# Check for database corruption
rm ~/.telemetry-kit/my-app.db
# Re-run your app

"Credentials test failed"

# Double-check your credentials
telemetry-kit test
 
# Verify network connectivity
ping telemetry-kit.dev

Examples

Quick Setup Script

#!/bin/bash
set -e
 
# Initialize telemetry with defaults
telemetry-kit init --yes --service-name my-app
 
# Validate setup
telemetry-kit validate
 
echo "โœ“ Telemetry setup complete!"

CI/CD Integration

# .github/workflows/telemetry.yml
name: Telemetry Stats
 
on:
  push:
    branches: [main]
 
jobs:
  stats:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
 
      - name: Install CLI
        run: cargo install telemetry-kit --features cli
 
      - name: View stats
        run: telemetry-kit stats --service my-app

Monitoring Script

#!/bin/bash
# monitor-telemetry.sh
 
while true; do
  clear
  telemetry-kit stats --detailed
  sleep 10
done

Future Enhancements

Planned features for future releases:

  • Configuration files - Store credentials securely in config files
  • Full sync implementation - CLI-based sync with stored credentials
  • Event filtering - View and filter specific events
  • Export/Import - Backup and restore event data
  • Batch operations - Operate on multiple services at once
  • Plugin system - Extend CLI with custom commands

See Also

On this page