UsageRecorder class

Bounded ring of ToolEvents with FNM-style correlation IDs, backed by UsageEventStore when a data dir is configured. One process-wide instance; tool handlers call record post-call.

Constructors

UsageRecorder.config({required bool enabled, int gapMs = 60000, int capacity = 50000, String? dataDir})
UsageRecorder.fromEnv()
Default constructor reads env: GLINT_NO_TELEMETRY / GLINT_NO_USAGE disable; GLINT_USAGE_GAP_MS overrides the gap.
factory

Properties

capacity → int
final
enabled → bool
final
gapMs → int
final
hashCode → int
The hash code for this object.
no setterinherited
length → int
no setter
maxEventId → int
The highest id recorded; 0 when nothing has been.
no setter
maxId → int
Highest id ever assigned in this store (0 when empty).
no setter
nextId → int
no setter
persists → bool
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
store → UsageEventStore?
Null when persistence is off (disabled, or no data dir).
final

Methods

clearForTest() → void
correlationIdFor(int nowMs) → String
Rolls over after the idle gap. Public so it's unit-testable.
eventsAfter(int afterId, {required int limit}) → List<Map<String, Object?>>
What the shipper reads: the base columns only, so the diagnostic fields never leave this machine.
eventsAfterId(int afterId, {int limit = 50000}) → List<Map<String, Object?>>
Rows newer than afterId, in insertion order. Reads the persisted store when there is one (so events from earlier processes are included).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
record({required String tool, required ToolOutcome outcome, required List<String> argKeys, required int durationMs, required int resultBytes, String? errorKind, Map<String, Object?> diagnostics = const {}}) → void
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

argKeysFrom(Map<String, Object?>? args) → List<String>
outcomeFrom({required bool isError, Map<String, Object?>? structured}) → ToolOutcome
underTestRunner() → bool
True inside dart test: unit tests build real sessions, and their synthetic calls must never land in the user's usage store.