Android SDK reference
Package org.pulsark.analytics. Every method is safe to call from any thread, never throws and never blocks the caller (except getInstallationId, see below). Java callers can use the same API — all methods are @JvmStatic.
Pulsark
Section titled “Pulsark”| Method | Description |
|---|---|
init(context, appId, config = PulsarkConfig()) |
Call once in Application.onCreate. Ignored in secondary processes and on repeated calls. |
track(eventName, properties = emptyMap()) |
Record a custom event. See Events for naming rules and limits. |
trackAdImpression(AdImpression) |
Record a paid ad impression. See Ad revenue. |
setConsent(ConsentState) |
GRANTED, DENIED or UNKNOWN (default). Persisted across launches. |
setAccountUserId(userId: String?) |
Attach your own account ID after login; pass null on logout. The installation ID does not change. |
optOut(enabled: Boolean) |
true stops collection and clears the local queue. |
flush() |
Upload queued events now. |
getInstallationId(): String |
The installation ID, e.g. for support or deletion requests. May wait up to 1 s while the SDK initializes — do not call it repeatedly on the main thread. |
PulsarkConfig
Section titled “PulsarkConfig”| Option | Default | Description |
|---|---|---|
endpoint |
https://collect.pulsark.org |
Collection endpoint. Change only for testing. |
profile |
STANDARD |
LITE, STANDARD or GAME — see below. |
channel |
"unknown" |
Distribution channel of this build (e.g. per product flavor). Appears as build_channel. |
debug |
false |
Log to Logcat with tag Pulsark. |
batchSize |
30 |
Upload when this many events are queued. |
foregroundUploadIntervalSec |
30 |
Periodic upload while the app is in the foreground. |
sessionTimeoutSec |
30 |
Background time after which returning starts a new session. |
maxQueueEvents / maxQueueBytes |
10000 / 10 MB |
Local queue limits. When full, low-priority events are dropped first. |
maxEventAgeDays |
7 |
Events older than this are dropped instead of uploaded. |
Profiles
Section titled “Profiles”| Profile | For | Automatic events |
|---|---|---|
LITE |
Minimal utilities | first_open, session_start, app_foreground, app_background |
STANDARD |
Most apps | LITE + page_view (each Activity) |
GAME |
IAA games | Same as STANDARD; use trackAdImpression and level events |
Reliability
Section titled “Reliability”- Events are written to a local SQLite queue before upload and deleted only after the server confirms they are durably stored.
- Network errors, timeouts and 5xx responses are retried with exponential backoff; the queue survives app restarts and force-stops. Uploads also run through WorkManager when the app is in the background.
- Each event carries a unique
event_idgenerated once and reused on every retry, so the server can discard duplicates. - Event time is corrected on the server using a monotonic clock, so users changing the device clock does not distort your data.
Sessions
Section titled “Sessions”A session starts when the app comes to the foreground and ends when it has been in the background for longer than sessionTimeoutSec. Rotations, permission dialogs and short app switches do not start new sessions. If the process is killed while in the background and the user returns within the timeout, the session continues.
Multiple processes and ad SDKs
Section titled “Multiple processes and ad SDKs”Some ad SDKs start their own process, which runs Application.onCreate again. Pulsark detects this and only initializes in the main process, so you do not need to guard the call.