Documentation
SDKappsprint-android

Android (Kotlin)

Installation, configuration, event tracking, and full API reference for the Android (Kotlin) SDK.

Requirements

  • Android minSdk 24
  • compileSdk 35
  • Java 17+

1. Install

Local Gradle module

// settings.gradle.kts
include(":sdk")
project(":sdk").projectDir = File(rootDir, "../appsprint-android/sdk")
// app/build.gradle.kts
dependencies {
implementation(project(":sdk"))
}

Sync Gradle after adding the module.

2. Configure

import com.appsprint.sdk.AppSprint
import com.appsprint.sdk.AppSprintConfig
// Call in Application.onCreate() or first Activity
val appSprint = AppSprint.shared(applicationContext)
appSprint.configure(
AppSprintConfig(apiKey = "as_live_xxxxx")
)

Thread-safe (@Synchronized). Automatically tracks the install, registers a lifecycle observer for background flushes, and retries any queued events.

Configuration options

OptionTypeDefaultDescription
apiKeyStringYour live API key (starts with as_live_).
apiUrlStringhttps://api.appsprint.appOverride the API base URL.
isDebugBooleanfalseEnable debug logging (sets logLevel to DEBUG).
logLevelInt2 (WARN)0 = DEBUG, 1 = INFO, 2 = WARN, 3 = ERROR.
customerUserIdString?nullSet a customer user ID at initialization time.

3. Track events

// Standard event
appSprint.sendEvent(AppSprintEventType.LOGIN)
// Revenue event
appSprint.sendEvent(
AppSprintEventType.PURCHASE,
params = mapOf("revenue" to 9.99, "currency" to "USD")
)
// Custom event with parameters
appSprint.sendEvent(
AppSprintEventType.CUSTOM,
name = "level_complete",
params = mapOf("level" to 5, "score" to 1200)
)

Supported event types

loginsign_upregisterpurchasesubscribestart_trialadd_to_cartadd_to_wishlistinitiate_checkoutview_contentview_itemsearchsharetutorial_completelevel_startlevel_completecustom

Use custom with a name parameter for any event not in this list.

4. Read attribution

After configure() completes, the SDK caches the attribution result from the install response. Access it synchronously:

val attr = appSprint.getAttribution()
println(attr?.source) // "fingerprint" or "organic"
println(attr?.confidence) // 0.0–1.0
println(attr?.campaignName) // UTM campaign name if available
FieldDescription
source"apple_ads", "fingerprint", or "organic"
confidenceMatch confidence from 0.0 to 1.0
campaignNameCampaign name (if attributed to an ad)
utmSourceUTM source from the tracking link
utmMediumUTM medium from the tracking link
utmCampaignUTM campaign from the tracking link

API reference

configure(config)

Initialize the SDK. Auto-tracks install and registers lifecycle observer.

appSprint.configure(AppSprintConfig(apiKey = "…"))

sendEvent(type, name?, params?)

Send an event. Queued automatically if offline.

appSprint.sendEvent(AppSprintEventType.PURCHASE, params = mapOf("revenue" to 9.99))

flush()

Retry all queued events immediately.

appSprint.flush()

clearData()

Clear all cached state, queue, and disabled flag.

appSprint.clearData()

getAppSprintId()

String?

Returns the install ID, or null before install completes.

val id = appSprint.getAppSprintId()

getAttribution()

AttributionResult?

Returns cached attribution data from install.

val attr = appSprint.getAttribution()

isInitialized()

Boolean

True once configure() has completed.

appSprint.isInitialized()

isSdkDisabled()

Boolean

True if the API key was rejected (401/403).

appSprint.isSdkDisabled()

sendTestEvent()

TestEventResult

Send a diagnostic event. Returns success/message.

val result = appSprint.sendTestEvent()

setCustomerUserId(id)

Attach your own user ID. Sent immediately or queued.

appSprint.setCustomerUserId("user-123")

Offline behavior

  • Events that fail to send are automatically queued in native storage (up to 100 events).
  • The queue persists across app restarts.
  • Queued events are retried automatically when configure() completes, when the app moves to the background, or when you call flush().
  • If a queued event receives a 401/403, the SDK disables itself and clears the queue.

Platform notes

  • Apple Search Ads attribution is not available on Android. The enableAppleAdsAttribution config option is ignored.
  • IDFA/IDFV are iOS-only. Android device fingerprinting uses Build.MODEL, screen metrics, locale, timezone, and OS version.
  • The SDK registers a DefaultLifecycleObserver on ProcessLifecycleOwner to flush events when the app moves to the background.
  • configure() is @Synchronized — safe to call from any thread.

Integrations

Once the SDK is configured, connect revenue and ad-network integrations:

Troubleshooting

getAppSprintId() returns null

configure() fires the install request asynchronously. If you need the ID immediately, check isInitialized() or retry after a short delay.

Events not appearing in dashboard

Check that you are using a live API key (as_live_*). Call sendTestEvent() and inspect the result.

SDK disabled after 401/403

The SDK disables itself when the API key is rejected. Call clearData() and re-configure with a valid key.

Events lost on app kill

Events are persisted to SharedPreferences. They will be retried on next app launch after configure().

Connectivity test

val result = appSprint.sendTestEvent()
println("${result.success}${result.message}")

Verification checklist

  1. Create a blank Android app and include the SDK module.
  2. Call configure() in Application.onCreate() or first Activity.
  3. Verify getAppSprintId() returns a value after first launch.
  4. Send login, purchase, and custom events — confirm in dashboard.
  5. Send an event offline, kill the app, relaunch with connectivity — verify the event appears.
  6. Call sendTestEvent() and confirm { success: true }.