Configure LedgeKit
Create one client with credentials, automatic recovery, and explicit recording control.
Create one client at your application's composition root and pass it to features that call models.
import LedgeKit
let client = try LedgeClient(
serviceName: "my-app",
writeKey: writeKey
)Load your app's write key before creating the client. To rotate the key, create a new client with the replacement key and the same service name and storage directory.
Startup and storage
The first trace or flush() automatically recovers interrupted work and schedules
pending delivery. Concurrent first calls share that initialization. To attempt
recovery at application launch, call await client.flush().
Default storage is in Application Support under LedgeKit/v1, using a stable hash
of the service name. Set localDirectory: to use another writable directory.
Give independent clients separate directories so they do not recover each
other's active work.
Disable recording
Set isEnabled: false when constructing the client. The same record and
respond calls continue to execute native model operations, without capture,
local file writes, or uploads.
Configuration errors
Client and agent construction throw for invalid names or versions. Names must contain non-whitespace text and fit within 256 characters; versions must be positive 32-bit integers. Empty write keys throw during client setup.
Telemetry capture and delivery failures are reported through onDiagnostic and
delivery summaries. Advanced callers can inject a
custom transport.