Appearance
Android (Kotlin)
Install
In your app module's build.gradle.kts:
kotlin
dependencies {
implementation("com.xkdlabs:simpledatalogs:0.1.0")
}It needs minSdk 21 and adds the INTERNET permission for you. Until the library is on Maven Central, build it locally as shown in the Android SDK page.
Add it
kotlin
import com.xkdlabs.simpledatalogs.Autocapture
import com.xkdlabs.simpledatalogs.SimpleDataLogs
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
SimpleDataLogs.configure(this, ingestKey = "sdl_pub_…", autocapture = Autocapture.ALL)
}
}
// Anywhere, from any thread:
SimpleDataLogs.track("signup", mapOf("plan" to "pro"))Register MyApplication with android:name on the <application> tag, and ship a public sdl_pub_ key.
Send everything, or only what you choose
- Everything:
Autocapture.ALLsends launches, sessions, crashes and screen views. - Pick:
Autocapture.SESSIONS + Autocapture.CRASHES. - Only your own events: leave
autocaptureout.
Compose destinations and fragments are not activities, so send their screen views yourself:
kotlin
SimpleDataLogs.trackScreen("Settings")In the first minute
session_startandapp_launched(withis_first_launch) as soon as the first activity starts.- A
screen_vieweach time an activity resumes. - After an uncaught exception,
app_crashedon the next launch. - Your events within 10 seconds (5 while the app is debuggable), and at once when the app goes to the background.
Autocapture defaults
| Option | With Autocapture.ALL |
|---|---|
APP_LAUNCHES | on |
SESSIONS (30 minutes in the background ends one) | on |
CRASHES (uncaught JVM exceptions) | on |
SCREEN_VIEWS (activity resumed, screen = class name) | on |
Native (NDK) crashes and ANRs are not captured. Everything else, including the opt-out and WorkManager, is in the Android SDK reference.