vakaGitHub

iOS SDK (Swift)

Package: sdks/ios (Swift Package Vaka, iOS 15+, macOS 12+, tvOS 15+). Apps depend on it by repository URL (https://github.com/ErikHellman/vaka, product Vaka) through the root Package.swift. Install steps: install/ios.md.

API

// App init / application(_:didFinishLaunchingWithOptions:)
Vaka.start(Vaka.Options(
    key: "vk_...",
    endpoint: URL(string: "https://vaka.example.com")!,
    release: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,   // default
    environment: "production"                                                          // default
))

Vaka.screen("Checkout")                      // screen_view
Vaka.track("purchase", ["plan": "pro"])      // custom event
Vaka.capture(error)                          // handled Error, with stack trace
Vaka.capture(message: "Cache rebuilt", level: .warning)
Vaka.addBreadcrumb(category: "cart", message: "Added item 42")
Vaka.identify("user-123")                    // opt-in; Vaka.identify(nil) clears
Vaka.setTag("flavor", "free")                // added to later errors
Vaka.flush()                                 // send now

Vaka.Options also takes crashReporting, sessionTracking, sessionTimeout (30 s), flushInterval (10 s), maxBatchSize (50), debug (console logging), enabled (false = no-op), tags and storageDirectory. All calls are thread-safe and do nothing before start.

Behaviour

Development

The package builds and its tests run on Linux too (the crash handler uses ELF build ids there), which is how CI and agents without a Mac test it:

cd sdks/ios && swift test
# end-to-end against a local server:
VAKA_TEST_ENDPOINT=http://localhost:8080 VAKA_TEST_KEY=vk_... swift test --filter IntegrationTests

See ingest.md for the wire format, especially "Native crashes".