Android (Kotlin / Java) In development

The nabd-android library for native apps from minSdk 24.

Not available yet. These examples show the planned API; package and function names may change before the first release.

Install

build.gradle.kts
dependencies {
    implementation("com.mokinan.nabd:nabd-android:<version>")
    implementation("com.mokinan.nabd:nabd-compose:<version>") // if you use Compose
    implementation("com.mokinan.nabd:nabd-okhttp:<version>")  // to measure OkHttp requests
}

Once published.

Setup

App.kt
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Nabd.init(
            this,
            NabdConfig(
                orgToken = BuildConfig.NABD_KEY,
                appName = "My App",
                environment = NabdEnvironment.PRODUCTION,
                consentRequired = true,
            ),
        )
    }
}
Java
Nabd.init(this, new NabdConfig.Builder(BuildConfig.NABD_KEY, "My App").build());

Remember to register App in android:name inside AndroidManifest.xml.

kotlin
Nabd.setConsent(true)

Screen names

Activities and Fragments are captured automatically by class name. With R8, Fragment names change, so name them explicitly:

Views
class InvoiceFragment : Fragment(), NabdScreenName {
    override val nabdScreen = "invoice_create"
}
Compose + Navigation
val navController = rememberNavController()
NabdTrackNavigation(navController) // uses the route pattern

// or for one specific screen
NabdScreen("invoice_create") { InvoiceCreateContent() }

Manual events

kotlin
Nabd.trackEvent(NabdEvent.TaskCompleted, screen = "invoice_create")
Nabd.startLoading("invoice_create")
Nabd.stopLoading("invoice_create")
Nabd.setUserRef(userRefFromServer)

// an error you caught: type and fingerprint only
Nabd.captureError(error)

Network

OkHttp
val client = OkHttpClient.Builder()
    .addInterceptor(NabdOkHttpInterceptor()) // status and duration only
    .build()

Captured automatically

With every error or unexpected exit, the last 10 steps. Turn it off with errorTrail = false.

Detection limits: disabled buttons inside Compose are not detected, Compose taps appear in the trail as “another element”, and taps inside dialogs (Dialog and BottomSheet) are not observed.

Support chat

With messages, your team can message a specific user from a ticket in the dashboard, and the user replies inside the app. Off by default; the floating button appears only when there is a message for them, after consent. You need setUserRef to open a ticket for them.

kotlin
Nabd.init(this, NabdConfig(orgToken = BuildConfig.NABD_KEY, appName = "My App", messages = true))

// Java
new NabdConfig.Builder(BuildConfig.NABD_KEY, "My App").messages(true).build();
With your own UI
// with messagesUi = false in NabdConfig
val listener = NabdMessagesListener { conversations -> render(conversations) }
Nabd.addMessagesListener(listener) // remove it with removeMessagesListener
Nabd.watchMessages(true)           // while the conversation is open
Nabd.replyToMessage(conversationId, text) { sent -> }
Nabd.markMessagesRead(conversationId)

Message text is stored in Nabd for the retention period. Tell your users in your privacy policy, and add “Customer Support” to your App Store and Google Play disclosures.

Privacy

kotlin
Nabd.ignore(view)                 // excluded from rage taps
Modifier.nabdIgnore()             // the same in Compose
Nabd.requestDataDeletion()
Nabd.setConsent(false)

Update the Data safety section in Google Play. The library does not use the advertising ID.