Skip to content

iOS

Add the package in Xcode under File > Add Package Dependencies, using https://github.com/kloudmate/rum-mobile-swift and the Up to Next Major rule. Then initialize once from your AppDelegate or your App init:

import KloudMateRum

let config = KloudMateRumConfig(
    endpoint: "https://otel.kloudmate.com:4318",
    rumAccessToken: "YOUR_PUBLIC_API_KEY",
    applicationName: "MyApp"
)
config.deploymentEnvironment = "production"
config.version = "1.0.0"
config.sampleRate = 1.0
config.sessionReplayEnabled = true
config.replaySampleRate = 0.25

KloudMateRum.shared.doInit(config: config)

Get your key and the rest of the values from Add application. See Add an application.

KloudMateRumConfig accepts either those three arguments or the full set, with nothing in between, so pass the first three and assign the rest as properties. appId defaults to the bundle ID.

Screen views, app start, crashes, app hangs, and tap spans are captured from this call on. For a screen the SDK can’t detect, such as a purely programmatic transition, name it yourself with KloudMateRum.shared.setCurrentScreen(name: "Checkout").

URLSession.shared is instrumented automatically. A session your app builds from its own configuration is not, because it only consults the protocolClasses on that configuration. Opt each one in:

let configuration = URLSessionConfiguration.default
KloudMateRum.shared.instrument(configuration: configuration)
let session = URLSession(configuration: configuration)

Most apps build their own session, so skipping this usually means no HTTP spans at all.

Set the user after sign-in:

KloudMateRum.shared.setUser(id: "u123", email: "alice@example.com", extra: [:])

Call KloudMateRum.shared.endSession() on sign-out. Nothing else detects a sign-out, and a mobile session runs for up to four hours, never times out while the app is in the foreground, and survives the process being killed.