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
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
class App : Application() {
override fun onCreate() {
super.onCreate()
Nabd.init(
this,
NabdConfig(
orgToken = BuildConfig.NABD_KEY,
appName = "My App",
environment = NabdEnvironment.PRODUCTION,
consentRequired = true,
),
)
}
}Nabd.init(this, new NabdConfig.Builder(BuildConfig.NABD_KEY, "My App").build());Remember to register App in android:name inside AndroidManifest.xml.
Consent
Nabd.setConsent(true)Screen names
Activities and Fragments are captured automatically by class name. With R8, Fragment names change, so name them explicitly:
class InvoiceFragment : Fragment(), NabdScreenName {
override val nabdScreen = "invoice_create"
}val navController = rememberNavController()
NabdTrackNavigation(navController) // uses the route pattern
// or for one specific screen
NabdScreen("invoice_create") { InvoiceCreateContent() }Manual events
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
val client = OkHttpClient.Builder()
.addInterceptor(NabdOkHttpInterceptor()) // status and duration only
.build()Captured automatically
- Rage taps, and taps on a disabled View.
- Unhandled crashes: type and fingerprint, sent on the next launch. If the app dies in the foreground without a recorded crash, it counts as an unexpected exit (estimated).
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.
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 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)- The app checks for messages when it opens or returns to the foreground, every two minutes, and every 15 seconds while the conversation is open. There is no notification while the app is closed.
- The interface is Arabic if the device or app language is Arabic, and English otherwise.
- The conversation and its taps are not counted as usage signals.
- The conversation is tied to this installation by a random secret stored on the device; another device of the same user does not see it, and a data deletion request changes the secret.
- Compute
user_refwith HMAC on your server, so a user cannot pretend to be someone else. - A very quick return from the background may not trigger a new check; the message shows at the next periodic check.
- The floating button may cover part of your UI at the bottom.
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
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.