Skip to main content

SpendOwl

The main entry point for the SpendOwl SDK. All methods are static—you don’t need to create an instance.
import SpendOwl

Configuration Methods

configure(apiKey:)

Configures the SDK with your API key.
public static func configure(apiKey: String)
apiKey
String
required
Your SpendOwl API key from the dashboard.
Example:
SpendOwl.configure(apiKey: "spendowl_live_xxx")
Call this once during app launch. Subsequent calls are ignored.

configure(_:)

Configures the SDK with custom options.
public static func configure(_ configuration: SpendOwlConfiguration)
configuration
SpendOwlConfiguration
required
Configuration options including API key, timeout, and retry settings.
Example:
let config = SpendOwlConfiguration(
    apiKey: "spendowl_live_xxx",
    timeoutInterval: 30,
    maxRetries: 5
)
SpendOwl.configure(config)

Attribution Methods

attribution() async throws

Fetches attribution data asynchronously.
public static func attribution() async throws -> AttributionResult
Returns: AttributionResult containing campaign, ad group, and keyword data. Throws: SpendOwlError if attribution fails. Example:
Task {
    do {
        let attribution = try await SpendOwl.attribution()
        print("Campaign: \(attribution.campaignName ?? "organic")")
    } catch {
        print("Error: \(error)")
    }
}

attribution(completion:)

Fetches attribution data using a completion handler.
public static func attribution(
    completion: ((Result<AttributionResult, SpendOwlError>) -> Void)? = nil
)
completion
Closure
default:"nil"
Called with the attribution result. May be called on any queue.
Example:
SpendOwl.attribution { result in
    switch result {
    case .success(let attribution):
        print("Status: \(attribution.status)")
    case .failure(let error):
        print("Error: \(error)")
    }
}

User Identity Methods

setUserId(_:)

Sets the user ID for attribution and purchase tracking.
public static func setUserId(_ userId: String)
userId
String
required
Your internal user identifier (e.g., database ID, UUID).
Example:
SpendOwl.setUserId("user-123")
The user ID is included with all subsequent attribution and purchase events.

clearUserId()

Clears the current user ID.
public static func clearUserId()
Example:
SpendOwl.clearUserId()

Properties

enableLogging

Enables or disables debug logging.
public static var enableLogging: Bool { get set }
Default: false Example:
SpendOwl.enableLogging = true
Disable logging in production. Logs may contain sensitive information.

logLevel

The current log level for granular control.
public static var logLevel: Logger.Level { get set }
Values:
LevelDescription
.noneNo logging (default)
.errorOnly errors
.infoErrors and important events
.debugAll messages including debug info
Example:
SpendOwl.logLevel = .debug

isConfigured

Returns true if the SDK is configured and ready.
public static var isConfigured: Bool { get }
Example:
if SpendOwl.isConfigured {
    let attribution = try await SpendOwl.attribution()
}

sdkVersion

The current SDK version string.
public static var sdkVersion: String { get }
Example:
print(SpendOwl.sdkVersion) // "1.0.0"

Platform Availability

@available(iOS 15.0, macOS 12.0, *)
public final class SpendOwl

Thread Safety

The SpendOwl class is thread-safe (Sendable). All methods can be called from any thread.