Skip to main content

Telemetry Service

The Telemetry Service (ITelemetryService) is a platform service that provides APIs for collecting telemetry data in Visual Studio Code. It respects user privacy settings and provides type-safe telemetry event logging with GDPR compliance.

Service Overview

The Telemetry Service is defined in src/vs/platform/telemetry/common/telemetry.ts:9 and manages the collection and transmission of telemetry events.

Service Identifier

Dependency Injection

Service Properties

Telemetry Level

Session Information

Logging Telemetry Events

string
required
The name of the telemetry event
StrictPropertyCheck<T, E>
The event data with GDPR annotations
Use publicLog2 for all new telemetry. It provides compile-time type checking and enforces GDPR classification annotations.

publicLog() - Legacy Telemetry (Deprecated)

publicLog() is deprecated. Use publicLog2() with proper GDPR annotations for new telemetry.

Error Telemetry

publicLogError() - Legacy Error Logging (Deprecated)

Error telemetry respects the sendErrorTelemetry property. If false, error events are not sent.

GDPR Compliance

Data Classifications

All telemetry must be classified according to GDPR requirements:

Complete Event Example

Experiment Properties

Common Use Cases

Feature Usage Tracking

Performance Monitoring

Error Reporting

User Action Tracking

Custom Endpoint Telemetry

Best Practices

Use publicLog2: Always use publicLog2() with proper GDPR classifications. Never use the deprecated publicLog().
Check Telemetry Level: Before collecting usage telemetry, check if the appropriate level is enabled with telemetryLevelEnabled().
No Personal Data: Never send personally identifiable information (PII) in telemetry. Use classifications carefully.
Event Naming: Use hierarchical event names with forward slashes (e.g., feature/action, editor/completion).
Error Context: Include enough context in error telemetry to diagnose issues, but avoid sensitive data.
Keep Events Small: Limit the amount of data per event. For large datasets, consider aggregation or sampling.

Configuration Settings

Users control telemetry through these settings:
  • ILogService - For diagnostic logging (not telemetry)
  • IConfigurationService - For reading telemetry settings
  • IEnvironmentService - For determining telemetry endpoints

See Also