LedgeKitDocs
API referenceSwift SDK
Developer documentation

Delivery and transport APIs

Observe delivery state and inject another durable transport.

Summary and diagnostics

await client.flush() returns LedgeDeliverySummary with cumulative delivered, rejected, dropped, and persistenceFailures counts plus inspected pending and active file counts. It does not finish open traces.

LedgeDiagnostic exposes code, message, and optional errorDescription through the client's onDiagnostic hook. See delivery behavior for codes, retry rules, recovery, and storage limits.

LedgeHTTPTransport

public init(credentials: LedgeCredentials, session: URLSession = .shared)
public func upload(_ upload: LedgeUpload) async throws

Normally constructed internally by LedgeClient. Uploads target /v1/traces, reject redirects, and send the persisted bytes with a bearer write key and trace-ID idempotency header. schemaVersion identifies the contract in the JSON body.

Custom transports

LedgeTransport: Sendable requires upload(_ upload: LedgeUpload) async throws. The upload exposes id: UUID and payloadURL: URL; serialization is internal. Return only after durable acceptance. The outbox deletes the file after success.

LedgeTransportFailure.isRetryable classifies permanent and temporary failures. Unclassified errors are treated as temporary.

LedgeHTTPTransportErrorRetryable
unreadablePayloadYes
payloadTooLarge(payloadBytes:maximumPayloadBytes:)No
invalidResponseYes
rejected(statusCode:responseBody:)HTTP 408, 425, 429, and 5xx

LedgeLimits.maximumTracePayloadBytes is 4 MiB. See custom transports.

On this page