This guide helps you build privacy-compliant applications using telemetry-kit, with specific guidance for GDPR (EU) and CCPA (California) regulations.
Disclaimer: This guide provides technical implementation guidance. Consult with legal counsel for compliance advice specific to your jurisdiction and use case.
use telemetry_kit::prelude::*;#[tokio::main]async fn main() -> telemetry_kit::Result<()> { // Initialize with consent requirement let telemetry = TelemetryKit::builder() .service_name("my-app")? .service_version(env!("CARGO_PKG_VERSION")) .strict_privacy() // Enables GDPR-compliant defaults .build()?; // Events will be silently ignored until consent is granted Ok(())}
# Privacy Notice## Data Controller[Your Organization Name][Address][Contact Email]## Data We CollectWe collect anonymous usage telemetry to improve our software:- Command usage and feature utilization- Success/failure status of operations- Performance metrics (timing, not content)- Operating system and architecture## Legal BasisConsent (GDPR Article 6(1)(a))## Data Processing- All data is anonymized using SHA-256 hashing- File paths are sanitized to remove usernames- Email addresses are hashed if detected- No personal identifiable information (PII) is collected## Data RetentionTelemetry data is retained for 30 days and then automatically deleted.## Your RightsYou have the right to:- **Access** your data: `telemetry-kit events export`- **Delete** your data: `telemetry-kit events clear`- **Withdraw consent**: `telemetry-kit consent deny`- **Opt out**: Set `DO_NOT_TRACK=1` environment variable## Data Transfers[If applicable, describe any data transfers outside EU]## ContactFor privacy inquiries: privacy@example.comData Protection Officer: dpo@example.com## Last Updated[Date]
CCPA requires informing users at or before data collection.
use telemetry_kit::prelude::*;fn show_ccpa_notice() { println!(r#"NOTICE OF DATA COLLECTION (CCPA)We collect the following categories of information: • Usage data (commands, features used) • Performance metrics (timing, success/failure) • Device information (OS, architecture)Purpose: Improve software quality and user experienceYour Rights: • Right to Know: telemetry-kit events export • Right to Delete: telemetry-kit events clear • Right to Opt-Out: export DO_NOT_TRACK=1For more information: privacy@example.com"#);}#[tokio::main]async fn main() -> telemetry_kit::Result<()> { // Show notice on first run let consent_file = dirs::home_dir() .unwrap() .join(".telemetry-kit") .join("consent.json"); if !consent_file.exists() { show_ccpa_notice(); } let telemetry = TelemetryKit::builder() .service_name("my-app")? .build()?; // Your application logic telemetry.shutdown().await?; Ok(())}
## How to Opt Out of TelemetrySet the DO_NOT_TRACK environment variable:bash# Permanently (add to ~/.bashrc or ~/.zshrc)export DO_NOT_TRACK=1# For a single commandDO_NOT_TRACK=1 my-app build
use telemetry_kit::prelude::*;async fn handle_data_request(telemetry: &TelemetryKit) -> telemetry_kit::Result<()> { println!("Exporting your telemetry data..."); let events = telemetry.export_events().await?; let json = serde_json::to_string_pretty(&events)?; std::fs::write("my-telemetry-data.json", json)?; println!("✓ Data exported to my-telemetry-data.json"); Ok(())}
async fn handle_deletion_request(telemetry: &TelemetryKit) -> telemetry_kit::Result<()> { println!("Deleting all your telemetry data..."); telemetry.clear_all_events().await?; telemetry.deny_consent()?; println!("✓ All data deleted and future collection disabled"); Ok(())}
let telemetry = TelemetryKit::builder() .service_name("my-app")? .endpoint("https://telemetry.yourcompany.com")? // Your server .token("token")? .secret("secret")? .build()?;