LedgeKitDocs
API referenceSwift SDK
Developer documentation

Client, credentials, and agents

Configure one client and stable agent identities.

LedgeClient

public init(
    serviceName: String,
    credentials: LedgeCredentials,
    isEnabled: Bool = true,
    localDirectory: URL? = nil,
    onDiagnostic: (@Sendable (LedgeDiagnostic) -> Void)? = nil
) throws

A shared actor with automatic outbox recovery and delivery. The advanced initializer accepts transport: any LedgeTransport in place of credentials. isEnabled is immutable. A disabled client executes native requests without recording or touching storage. Recovery begins on the first startTrace, recorded model call, or flush.

record(nativeSession, agent:) returns LedgeSession without suspension. withTrace scopes completion; startTrace returns a manually owned LedgeTrace. flush() async -> LedgeDeliverySummary attempts delivery and leaves active traces open. See trace lifecycle and delivery.

LedgeCredentials

case apiKey(String)
case tokenProvider(@Sendable () async throws -> String)

One credential type is shared by runtime, dataset, and report clients. Tokens are resolved on each HTTP attempt. Select a key with the required read/write access. Empty credentials throw LedgeConfigurationError.missingAPIKey.

LedgeAgent

public init(name: String, version: Int) throws

Immutable name and version, with Codable, Equatable, and Sendable conformance. Names require non-whitespace text and at most 256 characters; versions are positive 32-bit integers. Invalid setup throws LedgeConfigurationError.invalidName or .invalidVersion, including when decoding an agent.

LedgeClient.sdkVersion identifies the installed SDK version (1.0.0 for this release).

On this page