Nixtrail AndroidClient documentation
Maven repository

Android SDK 0.10.5

iOS, Android core, and Android Compose share version 0.10.5. Behavior is unchanged from Android 0.2.1. Shared release notes.

Integrate Nixtrail for Kotlin

Installation, sessions, navigation, engagement, handled errors, and useful session replay for Android Views and Jetpack Compose.

Platform
Android 11+
Language
Kotlin
Endpoint
https://api.nixtrail.com
Artifacts
telemetry + optional telemetry-compose

Step 1

Add the Maven packages

settings.gradle.kts
dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    maven("https://sdk.nixtrail.com/maven")
  }
}
app/build.gradle.kts
dependencies {
  implementation("com.nixtrail:telemetry:0.10.5")
  implementation("com.nixtrail:telemetry-compose:0.10.5") // Compose only
}

The core package has no Compose dependency and works with normal Android Views.

Step 2

Start once from Application

MyApplication.kt
class MyApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    Nixtrail.start(
      this,
      NixtrailConfiguration(appId = "<APP_UUID>")
    )
  }
}
AndroidManifest.xml
<application android:name=".MyApplication" ... />

Internet and network-state permissions merge from the SDK. No Activity lifecycle forwarding is required.

Routing

Use the right environment automatically

InstallEnvironment
Debuggable Android Studio buildDevelopment
Non-debuggable install outside PlayStaging
Google Play installProduction

Android production currently requires a client enrollment key from the production environment. The key is sent only during enrollment; the issued installation token is encrypted behind Android Keystore.

Automatic telemetry

A bounded baseline, without UI noise

Nixtrail records install and first open, cold open, foreground/background, update, best-effort close, session start/timeout/end, meaningful connectivity changes, configuration changes, memory pressure, fatal crashes, and SDK startup.

Foreground duration stops while the app is backgrounded or the device is locked. Android process death is not treated as a guaranteed close, and a later cold session supersedes an abandoned active session.

Navigation

Track screens and summarize scrolling

Compose
NixtrailScreen("checkout") {
  CheckoutScreen()
}

val state = rememberScrollState()
TrackNixtrailScroll("checkout", state)
Android Views
override fun onResume() {
  super.onResume()
  Nixtrail.screenView("checkout")
}

override fun onPause() {
  Nixtrail.endScreenView("checkout")
  super.onPause()
}

Scrolling updates one in-memory summary. The completed screen.view carries duration, previous screen, maximum depth, and whether the end was reached.

Product semantics

Add meaningful custom events

Kotlin
Nixtrail.track(
  "document.signed",
  mapOf("format" to "pades", "duration_ms" to 842)
)

Nixtrail.capture(error, source = "document_signing")

Use completed actions and outcomes. Do not send names, email addresses, typed text, secrets, tokens, or raw network content.

Opt-in capture

Useful replay with targeted privacy

Configuration
NixtrailConfiguration(
  appId = appId,
  sessionReplay = SessionReplayConfiguration(enabled = true)
)

The environment policy must also enable replay. Frames are downscaled to a 540-pixel maximum, JPEG quality 28, duplicate-suppressed, and raw-DEFLATE compressed. Normal labels and imagery stay visible.

Privacy masks
NixtrailReplay.setMasked(paymentView)
AccountSummary(Modifier.nixtrailReplayMasked())

Text inputs, web content, and surface-backed content are masked automatically. Replay captures normalized touch markers but never typed input.

Failure isolation

Telemetry stays invisible to users

Invalid configuration disables the SDK and appears in Nixtrail.status(). Fire-and-forget public calls contain telemetry errors, and the SDK never presents alerts, dialogs, or toasts.

Replay keeps only one frame in flight, performs filtering and JPEG encoding on its own worker, cleans bitmaps in all failure paths, and disables itself after a capture failure or memory warning. Fatal exits and ANRs are detected from ApplicationExitInfo on the next launch, with no telemetry storage or network work on the crashing thread.

Delivery

Offline by default, policy controlled

Events enter a bounded SQLite queue before network delivery. Batches are idempotent and retry when connectivity returns. Remote policy controls collection, sampling, priority, blocked event names, batch sizing, cadence, and replay limits.

Properties are bounded and common PII or credential keys are dropped. The SDK does not auto-capture request bodies, response bodies, headers, typed text, precise location, or business outcomes.

Android 0.1.2 and later preserve explicitly supplied latitude, longitude, and location properties, including nested coordinate objects. The server accepts these fields. The SDK does not request location permission or collect GPS coordinates automatically. Update older SDK versions before sending coordinates.

Testing app instrumentation

val recorder = TelemetryTestRecorder()
Nixtrail.withTestRecorder(recorder) {
  store.adopt(selectedItem) // Calls the app's real analytics wrapper.
}
check(recorder.events.map { it.name } == listOf("item.adopted"))

For suspending code, use Nixtrail.withTestRecorderAsync(recorder) { ... }. The recorder follows structured child coroutines across dispatcher changes and isolates parallel tests. Synchronous scopes are thread-local; executor callbacks, new threads, and independent coroutine scopes require explicit scopes. Nested scopes restore the prior recorder even when a block throws. Records include sanitized properties, name, priority, and occurrence time; snapshots are copied. Capacity defaults to 256 and is bounded to 1–1,000; overflow increments droppedEventCount. reset() clears records and overflow.

This sink intercepts custom track submissions only, without configuring an Android runtime, writing storage, or uploading. It tests instrumentation intent, not consent, remote-policy admission, automatic events, persistence, or delivery. Other SDK APIs retain their normal behavior. Use only in tests.

trackAndWait and screenViewAndWait suspend until the bounded persistence attempt completes and return a Boolean. They do not wait for upload. They return false when disabled, rejected, overloaded, storage fails, or startup is still unresolved; regular fire-and-forget calls can use the startup buffer. In a test scope, trackAndWait returns whether the recorder accepted the submission.

Original context and delayed diagnostics

Every queued event now carries its original app/build, OS/device, locale, and SDK context, including across upgrades. screen.entered persists an instrumented screen immediately, while screen.view still reports the completed span. Custom and handled-error events include the allowed current screen. For crash-sensitive operations, await screenViewAndWait/trackAndWait and inspect the result before continuing; disk failure can still lose telemetry.

A worker-written atomic history retains at most 16 session contexts, 32 breadcrumbs per context, and seven days of activity. Historical ApplicationExitInfo reports have an empty receiving session_id, a stable installation-scoped exit identity, and time_basis=process_exit_timestamp. Up to three possible prior contexts, eight breadcrumbs each, fit a 5,000-byte evidence budget. PID/time matching is unconfirmed evidence, not proof of a session match. Missing original context uses an unknown app release rather than the current release. Disablement clears history; current policy also filters embedded evidence before upload.

Java ANR traces and API 31+ native tombstone protobufs provide up to 24 stack frames / 8,000 encoded bytes from a maximum 2 MiB trace. Native frames retain binary name/build ID, relative PC, and instruction address; Java frames retain symbol/file/line. Raw trace text, abort messages, thread names, logs, and memory are not uploaded. stack_status and stack_truncated expose availability and limits. Keep native symbols and R8 mapping files for your releases. Android may not retain a trace; a Java fatal exit commonly has none. No crashing-thread exception/signal handler is installed. A trace read that never returns can occupy the single diagnostic worker; it cannot accumulate workers or block event uploads.

Android's process-exit timestamp is not MetricKit's diagnostic-window timestamp. ANR traces can predate a later process death and do not establish exact incident session attribution. See ApplicationExitInfo and the native tombstone schema.

Reliability limits and platform parity

0.2.1 corrected Compose publication metadata: the Compose BOM is exported, so consumer apps do not need to provide one just to resolve Nixtrail.

  • Public/worker event budgets allow a burst of 256 and refill at 50 per second. The worker retains at most 256 ordinary commands; control work is coalesced. Status exposes dropped command/event counts. Payloads are snapshotted before retention: 128 map entries, 100 list entries, eight levels, 2,048 nodes, 32,768 total string characters, and 16,000 encoded property bytes. Unsupported objects become null rather than invoking application-defined conversions.
  • SQLite retains at most 10,000 events / 32 MiB of payloads, each at most 64 KiB. Filesystem/database overhead is additional. Eviction/deletion failures stop progress and appear in status; a failed batch deletion is not retried in a loop.
  • One event transport operation runs at a time, separately from capture/storage. Upload passes process at most ten batches, and re-read policy before sending. Failed transport or upload bookkeeping backs off from five seconds to five minutes. Responses are limited to 256 KiB / 32 JSON levels, with 10-second connection, 20-second read, and 20-second scheduled disconnect deadlines. An OS call which ignores disconnect can occupy that one transport worker; no duplicate workers are created. Redirects are not followed with installation credentials.
  • Deferred setup retains at most 100 ordered in-memory operations. Transient environment lookup failure remains unresolved and retries; it does not guess staging. Original event/lifecycle timestamps survive replay. Buffer overflow and pending counts appear in status. Process exit loses this memory buffer.
  • Replay remains opt-in. Its installation-scoped disk spool has at most 512 chunks/markers, at most 1 MiB each, inside the configured storage budget. Capture handoff retains at most eight observations. Each pass uploads at most eight chunks. Storage failure/exhaustion stops capture. Main-thread mask traversal is iterative, limited to 1,024 views / 64 levels / an 8 ms preflight budget. A capture taking more than 16 ms stops future capture. This circuit breaker cannot interrupt host drawing code that never returns. Secure windows are skipped and memory pressure disables replay.

The Android 0.10.5 line incorporates the portable improvements through iOS 0.10.4. StoreKit/App Attest, MetricKit JSON nesting, UIKit hooks, and Apple symbol formats remain platform-specific. Android uses install-source routing, encrypted client credentials, ApplicationExitInfo, native tombstones, and Android window hooks. This release does not add Play Integrity, infer product screen names, guarantee all crash traces, or make replay automatic. Google Play test-track routing and production enrollment requirements are unchanged.