A comprehensive demonstration of how to implement privacy-first telemetry in a TypeScript CLI application. This todo application showcases best practices for collecting anonymous usage analytics while respecting user privacy and providing full transparency and control.
This project demonstrates a complete privacy-respecting telemetry implementation with:
- π« Opt-out by Default: Telemetry is enabled by default but can be disabled at any time
- π§ Multiple Control Methods: Environment variables, configuration files, and CLI commands
- π First-Run Disclosure: Clear privacy notice before any data collection begins
- β‘ Non-blocking: Telemetry never interrupts or slows down the user experience
- π‘οΈ Fail-Safe: Silent failures ensure telemetry issues never break the application
The underlying todo CLI includes:
- β Add, list, complete, and delete todos
- π View statistics and productivity graphs
- π― Interactive mode for continuous use
- πΎ Persistent storage in
.todos.json
- π¨ Colorful terminal output
- π Timestamps for task creation and completion
Install globally via npm:
npm install -g @1984vc/telemetry-todo
Or run directly with npx (no installation required):
npx @1984vc/telemetry-todo <command>
-
Clone the repository:
git clone https://github.com/1984vc/telemetry-todo.git cd telemetry-todo
-
Install dependencies:
pnpm install
-
Build the project:
pnpm run build
-
Run the CLI:
node dist/main.js <command>
Run directly from TypeScript source:
pnpm run dev <command>
Control telemetry through environment variables:
# Disable all telemetry (respects DO_NOT_TRACK standard)
export DO_NOT_TRACK=1
# Application-specific telemetry control
export TELEMETRY_TODO_TELEMETRY=false
# Enable telemetry explicitly
export TELEMETRY_TODO_TELEMETRY=true
Manage telemetry settings directly:
# Check current telemetry status
npx @1984vc/telemetry-todo telemetry status
# Enable telemetry (with privacy disclosure)
npx @1984vc/telemetry-todo telemetry enable
# Disable telemetry
npx @1984vc/telemetry-todo telemetry disable
Settings are stored in .telemetry-config.json
:
{
"telemetryEnabled": true,
"firstRun": true,
"anonymousId": "4ff13743-eaeb-4f88-bb69-33fd3638c876"
}
- Command Usage: Which commands are executed (add, list, done, etc.)
- Performance Metrics: Command execution times for optimization
- Error Events: Anonymous error reporting for debugging
- System Info: Platform and Node.js version (no personal data)
- Country-Level Geographic Data: Country, continent, and timezone information only (for usage patterns)
- β IP addresses (not stored or logged)
- β Personal information or identifiers
- β Todo content or user data
- β File paths or system details
- β Network information
{
"api_key": "phc_IFaExYAUhS9kpVwk6zTBuk80H1D4Dr6QQdCfu",
"event": "command_executed",
"properties": {
"distinct_id": "4ff13743-eaeb-4f88-bb69-33fd3638c876",
"$referrer": "$direct",
"$referring_domain": "$direct",
"$lib": "telemetry-todo-cli",
"$lib_version": "1.0.0",
"$ip": "0.0.0.0",
"command": "add",
"platform": "darwin",
"node_version": "v24.4.1"
}
}
# Add a todo
npx @1984vc/telemetry-todo add "Your task here"
# List all todos
npx @1984vc/telemetry-todo list
# Mark a todo as complete
npx @1984vc/telemetry-todo done <number>
# Delete a todo
npx @1984vc/telemetry-todo delete <number>
# Clear all todos
npx @1984vc/telemetry-todo clear
# View statistics
npx @1984vc/telemetry-todo stats
# Interactive mode
npx @1984vc/telemetry-todo
# Help
npx @1984vc/telemetry-todo help
telemetry-todo/
βββ src/
β βββ main.ts # Main CLI with telemetry integration
β βββ telemetry.ts # Privacy-first telemetry module
βββ dist/ # Compiled JavaScript output
βββ .telemetry-config.json # User telemetry preferences
βββ package.json # Project configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This documentation
- Direct HTTPS Requests: Uses Node.js built-in
https
module instead of heavy SDKs - Timeout Protection: 1-second timeout prevents hanging requests
- Non-blocking Execution:
setImmediate()
ensures telemetry never blocks user operations - Error Resilience: Comprehensive error handling with silent failures
- TypeScript: Full type safety and modern async/await patterns
This demo uses PostHog as the analytics backend with privacy-first configuration:
- Endpoint:
https://us.i.posthog.com/capture/
- No IP Address: IP Adress is manually set to 0.0.0.0
This implementation follows privacy best practices:
- Transparent: Full disclosure of data collection practices
- User Control: Multiple ways to disable and control telemetry
- Data Minimization: Only collects essential anonymous usage metrics
pnpm run build
-
Check telemetry status (enabled by default):
npx @1984vc/telemetry-todo telemetry status
-
Execute commands and observe privacy-compliant requests:
npx @1984vc/telemetry-todo add "Test task" npx @1984vc/telemetry-todo list
-
If needed, enable or disable telemetry:
npx @1984vc/telemetry-todo telemetry enable npx @1984vc/telemetry-todo telemetry disable
The telemetry module logs request details (in development) showing:
- No personal or identifying information
This demo teaches:
- Privacy-First Design: How to collect useful analytics while protecting user privacy
- Transparent Telemetry: Best practices for user disclosure and consent
- Technical Implementation: Direct HTTP requests, error handling, and non-blocking execution
- User Experience: Ensuring telemetry never degrades application performance
This is a demonstration project showcasing privacy-respecting telemetry implementation. Feel free to:
- Study the code for educational purposes
- Adapt the privacy patterns for your own projects
- Suggest improvements to the privacy implementation
- Report any privacy concerns or issues
This project is provided as an educational demonstration of privacy-respecting telemetry implementation.
π Privacy Notice: This application collects anonymous usage analytics by default but respects your privacy. No personal information, IP addresses, or location data is ever collected. You can disable telemetry at any time using the commands above or environment variables.