data/services/analytics_service library

Classes

AnalyticsConfig
Check if analytics operations should be disabled.
AnalyticsController
Main analytics controller that queues events until a sink is attached, then drains the queue and routes all future events through the sink.
AnalyticsSink
Sink interface for the analytics backend.
DatadogLog
A single Datadog log entry.
DatadogService
Datadog event tracking service with batched log dispatch.
EnvContext
Environment context metadata included with analytics events.
EventMetadata
Core event metadata shared across all analytics systems.
EventSampleRate
FirstPartyBatchConfig
Batch configuration for the first-party event logger.
FirstPartyEvent
A first-party event ready for export.
FirstPartyEventLogger
First-party event logging service with batched export and retry.
GrowthBookExperimentData
GrowthBook experiment data for logging.
GrowthBookService
Simplified GrowthBook feature flag service.
GrowthBookUserAttributes
GrowthBook user attributes for targeting.
McpToolDetails
Extract MCP server and tool names from a full MCP tool name. MCP tool names follow the format: mcp__<server>__<tool>
ProcessMetrics
Process metrics included with all analytics events.
SinkKillswitch
Per-sink analytics killswitch backed by a dynamic config.

Enums

SinkName
Names of analytics sinks that can be individually killed.

Functions

extractMcpToolDetails(String toolName) McpToolDetails?
Parse MCP tool details from a full tool name. Returns null if not an MCP tool.
extractSkillName(String toolName, Object? input) AnalyticsVerifiedString?
Extract skill name from Skill tool input.
extractToolInputForTelemetry(Object? input, {required bool isToolDetailsLoggingEnabled}) String?
Serialize a tool's input arguments for the OTel tool_result event. Truncates long strings and deep nesting to keep the output bounded. Returns null when tool details logging is not enabled.
getFileExtensionForAnalytics(String filePath) AnalyticsVerifiedString?
Extracts and sanitises a file extension for analytics logging.
getFileExtensionsFromBashCommand(String command, [String? simulatedSedEditFilePath]) AnalyticsVerifiedString?
Extracts file extensions from a bash command for analytics.
sanitizeToolNameForAnalytics(String toolName) AnalyticsVerifiedString
Sanitises tool names for analytics logging to avoid PII exposure.
shouldSampleEvent(String eventName, EventSamplingConfig config) double?
Determine if an event should be sampled based on its sample rate. Returns the sample rate if sampled, null if not configured, 0 if dropped.
stripProtoFields<V>(Map<String, V> metadata) Map<String, V>
Strip _PROTO_* keys from a payload destined for general-access storage. Returns the input unchanged when no PROTO keys present.

Typedefs

AnalyticsPiiTaggedString = String
Marker for values routed to PII-tagged proto columns.
AnalyticsVerifiedString = String
Marker verifying analytics metadata contains no code or file paths.
EventSamplingConfig = Map<String, EventSampleRate>
Configuration for sampling individual event types. Each event name maps to an object containing sample_rate (0–1). Events not in the config are logged at 100% rate.
LogEventMetadata = Map<String, Object?>
Internal metadata type for logEvent — intentionally excludes raw strings to avoid accidentally logging code / file paths.