Skip to content

Android

Add the dependency to your module, then initialize once from Application.onCreate(). The generated snippet carries the current version:

// build.gradle.kts
implementation("com.kloudmate.rum:rum-core:<version>")

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

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

appId defaults to the package name, so you don’t need to pass it.

Screen views, app start, slow and frozen frames, device vitals, ANRs, crashes, and tap spans are captured from this call on.

Screen names come from Activity and Fragment lifecycle callbacks. Compose navigation happens inside a single Activity, so those callbacks never fire for it. Report the screen yourself:

navController.addOnDestinationChangedListener { _, destination, _ ->
    KloudMateRum.setCurrentScreen(destination.route ?: "unknown")
}

HTTP capture needs one extra step. OkHttp cannot be patched globally, so add the interceptor to every OkHttpClient you build:

val client = OkHttpClient.Builder()
    .addInterceptor(KloudMateRum.okHttpInterceptor()!!)
    .build()

Without the interceptor, the app reports no HTTP spans at all.

Set the user after sign-in:

KloudMateRum.setUser(id = "u123", email = "alice@example.com")

Call 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. Without the call, a sign-out followed by a different sign-in keeps one session ID across both people.

fun onLogout() {
    KloudMateRum.endSession()
    // ... clear your own auth state
}

Everything setUser() set is cleared, values set with setGlobalAttributes() are kept, and the next session starts at the next instrumented event.