Skip to content

Error Capture

Swift does not expose a global hook for every thrown Error, and Apple platform crash capture has sharp edges. The Swift SDK keeps automatic capture opt-in and uses Apple-native diagnostics where possible.

try Auralog.initialize(
apiKey: "aura_your_api_key",
environment: "production",
captureMetricKit: true,
captureUnhandledExceptions: true
)

captureMetricKit: true subscribes to MetricKit and forwards available metric and diagnostic payloads. In this beta, MetricKit forwarding is implemented for iOS and no-ops on other platforms.

MetricKit can include crash, hang, CPU, disk-write, launch, memory, and performance diagnostics depending on platform and OS availability.

captureUnhandledExceptions: true installs NSSetUncaughtExceptionHandler and emits a fatal log when an uncaught Objective-C exception reaches the handler.

This does not capture every Swift failure. Swift thrown errors, fatalError, memory access crashes, watchdog terminations, and low-level signals are not equivalent to Objective-C exceptions.

Use Auralog.run or Auralog.task at async boundaries to avoid writing manual capture calls everywhere:

.task {
try? await Auralog.run(metadata: ["screen": "home"]) {
try await viewModel.refresh()
}
}
Button("Sync") {
_ = Auralog.task(metadata: ["action": "manual_sync"]) {
try await syncNow()
}
}

When you have useful local context, direct capture is still the clearest option:

do {
try await checkout()
} catch {
Auralog.capture(error, metadata: ["screen": "checkout"])
throw error
}

The Swift SDK is not a full Crashlytics or Sentry replacement in this beta. Signal-level crash reporting, dSYM upload, symbolication, grouping, and release health dashboards are out of scope.