TelemetryService class

Central telemetry service. Queue events via track, they are flushed to all configured sinks either on a timer or when the batch fills up.

Constructors

TelemetryService({required TelemetryConfig config})

Properties

hashCode int
The hash code for this object.
no setterinherited
performance PerformanceTracker
Access the performance tracker for timing operations.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionId String
Unique session identifier.
no setter
stats Map<String, int>
Statistics about this service instance.
no setter

Methods

dispose() Future<void>
Flush remaining events and release resources.
endSession({Map<String, dynamic>? metadata}) Future<void>
Record a session-end event and flush remaining events.
flush() Future<void>
Flush all pending events to every configured sink.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
optIn() → void
Re-enable telemetry after opting out.
optOut() Future<void>
Disable all telemetry collection. Pending events are flushed first.
startSession({Map<String, dynamic>? metadata}) → void
Record a session-start event.
toString() String
A string representation of this object.
inherited
track(TelemetryEvent event) → void
Queue a telemetry event. It will be sent on the next flush.
trackApiCall({required String model, required Duration latency, int? inputTokens, int? outputTokens, String? error}) → void
Track an API call with latency.
trackError({required String message, String? stackTrace, String? context, String? errorCode}) → void
Track an error with contextual information.
trackModelSwitch({required String fromModel, required String toModel, String? reason}) → void
Track a model switch.
trackPermission({required String tool, required bool granted, String? reason}) → void
Track a permission decision.
trackToolUse({required String toolName, required Duration duration, bool success = true, String? error}) → void
Track tool usage with duration.

Operators

operator ==(Object other) bool
The equality operator.
inherited