Android SDK
High-fidelity analytics and session replay for native Android applications.
sdks/sankofa_sdk_androidAndroid SDK 🚀
The Sankofa Android SDK provides a complete solution for product analytics and session replay in native Android applications. It is designed to be lightweight, offline-ready, and privacy-first.
✨ Key Features
- Event Tracking: Send custom events with arbitrary properties and automatic device metadata.
- Identity Management: Link anonymous users to permanent customer profiles.
- Session Replay:
- Screenshot Mode: Pixel-perfect visual capture for complex UI debugging.
- Auto-masking: Sensitive data protection via Kotlin extensions and automatic
EditTextdetection.
- Offline Reliability: Robust local queueing with background auto-flushing via WorkManager.
- Privacy First: Granular controls over what to track and what to mask.
🚀 Quick Start
1. Install
Add the dependency to your module's build.gradle.kts (or build.gradle):
dependencies {
implementation("dev.sankofa.sdk:sankofa-android:1.0.0")
}2. Initialize
Initialize the SDK in your Application class. It auto-registers to all Activities – no per-screen boilerplate required.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Sankofa.init(
context = this,
apiKey = "YOUR_PROJECT_API_KEY",
config = SankofaConfig(
recordSessions = true,
maskAllInputs = true, // Auto-mask all EditTexts
)
)
}
}
🛠 Configuration Options
The SankofaConfig class allows you to fine-tune the SDK's behavior.
| Option | Default | Description |
|---|---|---|
endpoint | https://api.sankofa.dev | Base URL of your Sankofa server |
recordSessions | true | Enable or disable high-fidelity session replay |
maskAllInputs | true | Auto-mask all EditText views in session recordings |
debug | false | Enable verbose Logcat output for debugging |
trackLifecycleEvents | true | Auto-track $app_opened/foregrounded/backgrounded |
flushIntervalSeconds | 30 | Interval for flushing queued events while foregrounded |
batchSize | 50 | Maximum number of events to queue before flushing |
Example with Custom Configuration
Sankofa.init(
context = this,
apiKey = "YOUR_PROJECT_API_KEY",
config = SankofaConfig(
endpoint = "https://analytics.yourdomain.com",
recordSessions = true,
maskAllInputs = true,
debug = true
)
)
📈 Tracking Events
Track any user action with a simple method call. Events are automatically enriched with device metadata and batched for efficient uploading.
1. Simple Event Tracking
Sankofa.track("started_trial")
2. Tracking with Properties
Sankofa.track("completed_purchase", mapOf(
"item_id" to "cam_001",
"item_name" to "Vintage Camera",
"price" to 120.50,
"currency" to "USD"
))
3. Automatic Metadata
Sankofa automatically captures the following device properties with every event:
- Device: $brand, $model, $os_version
- Screen: $screen_width, $screen_height
- App: $app_version, $app_release
👤 Identity & People
Sankofa allows you to resolve anonymous user identities and manage rich customer profiles.
1. Identifying Users
When a user logs in, use Sankofa.identify() to link their anonymous history to their unique user ID.
Sankofa.identify("user_99")
2. Resetting Identity
When a user logs out, use Sankofa.reset() to clear their current identity and start a fresh anonymous session.
Sankofa.reset()
3. Setting Person Properties
Sankofa.setPerson(
name = "Jane Doe",
email = "[email protected]",
properties = mapOf(
"membership" to "Gold",
"signup_source" to "referral"
)
)
🎥 Session Replay & Privacy
Sankofa's session replay engine captures pixel-perfect recordings of user interactions.
Privacy & Masking 🛡
Privacy is a top priority. Sankofa provides multiple ways to mask sensitive content from session recordings.
Automatic Masking
When maskAllInputs is enabled (default), the SDK automatically blacks out all EditText views.
Manual Masking
Option 1: Kotlin Extension (Recommended)
import dev.sankofa.sdk.util.sankofaMask
mySensitiveView.sankofaMask = true
Option 2: View Tag
mySensitiveView.tag = "sankofa_mask"
📑 API Reference
Sankofa (Singleton)
| Method | Signature | Description |
|---|---|---|
init | init(context: Context, apiKey: String, config: SankofaConfig) | Initializes the SDK. |
track | track(eventName: String, properties: Map<String, Any?>?) | Tracks a custom event. |
identify | identify(userId: String) | Links anonymous data to a known user ID. |
reset | reset() | Clears identity and starts a new anonymous session. |
setPerson | setPerson(name: String?, email: String?, properties: Map<String, Any?>?) | Sets common profile attributes. |
flush | flush() | Force-uploads all queued events immediately. |
shutdown | shutdown() | Tears down the SDK and persists state. |
SankofaConfig
| Property | Type | Default | Description |
|---|---|---|---|
endpoint | String | https://api.sankofa.dev | Server URL. |
recordSessions | Boolean | true | Enable/disable recordings. |
maskAllInputs | Boolean | true | Auto-mask all EditText views. |
debug | Boolean | false | Enable verbose logging. |
trackLifecycleEvents | Boolean | true | Auto-track app open/close. |
flushIntervalSeconds | Int | 30 | Event flush interval. |
batchSize | Int | 50 | Event queue limit. |