Carbon Telemetry is a command-line interface tool that collects telemetry data from IBM projects using the Carbon Design System. It automatically tracks package installations and analyzes component usage patterns to help the Carbon team understand adoption patterns and prioritize development efforts.
npm install @carbon/telemetryThe primary way to use Carbon Telemetry is through the carbon-telemetry CLI command, which is automatically invoked during package installation:
# Automatic collection during package installation
carbon-telemetry collect --install
# Manual component usage analysis
carbon-telemetry collect --components
# Development/testing mode
carbon-telemetry collect --dev @carbon/icons-reactCarbon Telemetry is designed as a lightweight, privacy-focused telemetry system:
The main command interface for executing telemetry collection operations.
/**
* Carbon Telemetry CLI executable
* Entry point: carbon-telemetry [command] [options]
* Requires Node.js v12 or higher
*/Specifies attributes to be collected from consumer projects. This is the primary command for telemetry data collection.
/**
* Main collection command for telemetry data
* Usage: carbon-telemetry collect [options]
*/Collects package installation and version details when Carbon packages are installed.
# Collect installation data
carbon-telemetry collect --installData Collected:
Analyzes project files to collect component usage details and patterns.
# Collect component usage data
carbon-telemetry collect --componentsData Collected:
Development and testing mode for package-specific telemetry collection.
# Development mode for specific package
carbon-telemetry collect --dev <package-name>
# Example: carbon-telemetry collect --dev @carbon/reactStandard CLI options available for all commands.
# Show version information
carbon-telemetry --version
# Display help information
carbon-telemetry --help
# Show help for collect command
carbon-telemetry collect --helpEnvironment variables for controlling telemetry behavior.
/**
* Environment Variables:
* - CARBON_TELEMETRY_DEBUG: Enable debug mode for error reporting and logging
* - CARBON_TELEMETRY_DISABLED: Set to "1" to disable all telemetry collection
* - CARBON_TELEMETRY_ENDPOINT: Override default GraphQL endpoint URL
*/Environment Variable Usage:
# Enable debug mode
CARBON_TELEMETRY_DEBUG=1 carbon-telemetry collect --install
# Disable telemetry collection
CARBON_TELEMETRY_DISABLED=1 carbon-telemetry collect --install
# Use custom endpoint
CARBON_TELEMETRY_ENDPOINT=https://custom.endpoint.com carbon-telemetry collect --installCarbon Telemetry is typically integrated into Carbon packages via postinstall scripts:
{
"scripts": {
"postinstall": "carbon-telemetry collect --install"
}
}Used in Carbon packages:
For component usage analysis, the tool automatically:
Privacy Safeguards:
IBM Project Detection: The tool includes mechanisms to verify that data collection only occurs within IBM project environments.
By default, telemetry collection fails silently to avoid disrupting package installation:
// Errors are caught and suppressed unless debug mode is enabled
try {
// Telemetry collection logic
} catch (error) {
if (process.env.CARBON_TELEMETRY_DEBUG) {
throw error;
}
// Silent failure - installation continues normally
}Enable detailed error reporting and logging:
CARBON_TELEMETRY_DEBUG=1 carbon-telemetry collect --installDebug mode provides:
Uses Babel parser and traverse for JavaScript/TypeScript analysis:
/**
* File Analysis Capabilities:
* - JavaScript and TypeScript parsing
* - React component import detection
* - JSX element usage tracking
* - AST-based code analysis
*/GraphQL-based API communication for data submission:
/**
* GraphQL Mutations:
* - PackageInstall: Reports package installation events
* - CollectFileDetails: Submits file analysis data
*/Persistent local configuration using configstore:
/**
* Configuration Features:
* - Job tracking to prevent duplicate collection
* - Local storage for collection state
* - Cross-platform configuration directory
*/The package is distributed as a pre-bundled executable:
src/cli.js using esbuildcli.js file (~6.1MB) with all dependencies/**
* Runtime Node.js Version Check:
* - Validates Node.js version >= 12 on startup
* - Exits gracefully with status 0 if version requirement not met
* - Only logs version error when CARBON_TELEMETRY_DEBUG is set
*/