Atatus Real User Monitoring (RUM) for Android helps you monitor the real user experience of your native Android apps. The SDK collects views, user interactions, network requests, errors, and crashes, and sends the data to your Atatus dashboard.
Prerequisites
- Android 6.0 (API level 23) or higher.
- A RUM application in Atatus with a license key.
Setup
1. Declare the SDK as a dependency
Add the Atatus Android RUM SDK to your application module's build.gradle file.
dependencies {
implementation("com.atatus:atatus-android-rum:1.+")
}
2. Specify application details in Atatus
In your Atatus dashboard, open the RUM application you created and note the following values:
- License Key, which authenticates the SDK with Atatus.
- Environment, which is the name you choose for the deployment, such as production or staging.
3. Initialize the Atatus SDK
Initialize the Atatus SDK in your Application class so it starts as early as possible in the application lifecycle.
import android.app.Application
import com.atatus.android.Atatus
import com.atatus.android.core.configuration.AtatusSite
import com.atatus.android.core.configuration.Configuration
import com.atatus.android.privacy.TrackingConsent
class SampleApplication : Application() {
override fun onCreate() {
super.onCreate()
val configuration = Configuration.Builder(
licenseKey = "<LICENSE_KEY>",
env = "<ENV_NAME>",
appName = "<APP_VARIANT_NAME>"
).build()
Atatus.initialize(this, configuration, TrackingConsent.GRANTED)
}
}
Replace the placeholders with your license key, environment, and application variant name. The variant should match BuildConfig.FLAVOR if your application uses product flavors. Otherwise, use an empty string ("").
4. Enable Real User Monitoring (RUM)
Enable RUM to automatically track views, user interactions, and long-running tasks.
import com.atatus.android.rum.Rum
import com.atatus.android.rum.RumConfiguration
import com.atatus.android.rum.tracking.ActivityViewTrackingStrategy
val rumConfiguration = RumConfiguration.Builder()
.trackUserInteractions()
.trackLongTasks(durationThreshold = 100L)
.useViewTrackingStrategy(ActivityViewTrackingStrategy(trackExtras = true))
.build()
Rum.enable(rumConfiguration)
This configuration enables automatic view tracking, user interaction tracking, and long task tracking.
5. Track network requests
To automatically track network requests made with OkHttp, add the Atatus OkHttp dependency to your application module's build.gradle file.
dependencies {
implementation("com.atatus:atatus-android-okhttp:1.+")
}
Add the Atatus interceptor to your OkHttpClient:
import com.atatus.android.okhttp.AtatusInterceptor
import okhttp3.OkHttpClient
val tracedHosts = listOf("example.com", "example.eu")
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(
AtatusInterceptor.Builder(tracedHosts).build()
)
.build()
The interceptor automatically reports supported OkHttp requests as RUM resources, including details such as the URL, HTTP method, response status, and request duration.
6. Track background events
By default, Atatus does not collect events that occur while no view is active, such as when the app runs in the background. To collect these events, enable background event tracking.
val rumConfiguration = RumConfiguration.Builder()
.trackBackgroundEvents(true)
.build()
Enabling background event tracking may create additional RUM sessions, which can impact your billing. Enable this option only if you need visibility into background activity.
7. Start monitoring
Build and run your application. Within a few minutes, views, user actions, network requests, and errors appear in your Atatus dashboard. To verify the setup quickly, you can report a test error from anywhere in your code:
import com.atatus.android.rum.GlobalRumMonitor
import com.atatus.android.rum.RumErrorSource
GlobalRumMonitor.get().addError(
message = "Test Atatus setup",
source = RumErrorSource.SOURCE,
throwable = null,
attributes = emptyMap()
)
Next steps
- Connect your mobile requests to your backend with Application Monitoring.
- Set up alerts to get notified about errors and performance regressions.
+1-415-800-4104