TelemetryService class
TelemetryService - Event tracking for RunAnywhere SDK
This service provides telemetry tracking for the Flutter SDK, aligned with Swift/Kotlin/React Native SDKs.
ARCHITECTURE:
- C++ telemetry manager handles core event logic (batching, JSON building, routing)
- Platform SDK provides HTTP transport via HTTPService
- Events are automatically tracked by C++ when using LLM/STT/TTS/VAD capabilities
This Dart service provides:
- A wrapper to send telemetry events via HTTPService
- Convenience methods that match the Swift/Kotlin/React Native API
- SDK-level events that Dart code can emit
Usage:
// Configure (called during SDK init)
TelemetryService.shared.configure(
deviceId: 'device-123',
environment: SDKEnvironment.production,
);
// Track events
TelemetryService.shared.trackSDKInit(
environment: 'production',
success: true,
);
// Flush pending events
await TelemetryService.shared.flush();
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEnabled → bool
-
Check if telemetry is enabled
no setter
- isInitialized → bool
-
Check if telemetry is initialized (configured with device ID)
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
configure(
{required String deviceId, required SDKEnvironment environment}) → void - Configure telemetry service
-
flush(
) → Future< void> - Flush pending telemetry events
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setEnabled(
bool enabled) → void - Enable or disable telemetry
-
shutdown(
) → Future< void> - Shutdown telemetry service
-
toString(
) → String -
A string representation of this object.
inherited
-
track(
String type, {TelemetryCategory category = TelemetryCategory.sdk, Map< String, dynamic> ? properties}) → void - Track a generic event
-
trackError(
{required String errorCode, required String errorMessage, Map< String, dynamic> ? context}) → void - Track error
-
trackGeneration(
{required String modelId, required int promptTokens, required int completionTokens, required int latencyMs, String? modelName, double? temperature, int? maxTokens, int? contextLength, double? tokensPerSecond, int? timeToFirstTokenMs, bool isStreaming = false}) → void - Track text generation
-
trackModelDownload(
{required String modelId, required bool success, int? downloadTimeMs, int? sizeBytes}) → void - Track model download
-
trackModelLoad(
{required String modelId, required String modelType, required bool success, int? loadTimeMs}) → void - Track model loading
-
trackSDKInit(
{required String environment, required bool success}) → void - Track SDK initialization
-
trackSynthesis(
{required String voiceId, required int textLength, required int audioDurationMs, required int latencyMs, String? modelName, int? sampleRate, int? audioSizeBytes}) → void - Track speech synthesis
-
trackTranscription(
{required String modelId, required int audioDurationMs, required int latencyMs, String? modelName, int? wordCount, double? confidence, String? language, bool isStreaming = false}) → void - Track transcription
-
trackVAD(
{required String eventType, Map< String, dynamic> ? properties}) → void - Track VAD event
-
trackVoiceAgentTurn(
{required String transcription, required String response, required int totalLatencyMs, int? sttLatencyMs, int? llmLatencyMs, int? ttsLatencyMs}) → void - Track voice agent turn
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
Get shared TelemetryService instance
no setter
Static Methods
-
resetForTesting(
) → void - Reset for testing