identify, track, page and screen events from your app, keeps them on disk until they are delivered, and, with its optional push module, registers the phone for mobile push.
It needs Android 6.0 (API 23) or later.
Installation
The SDK has two modules:The Android SDK artifacts are not on Maven yet. Contact us at support@tranthor.com for the build to add to your project.
Usage
suspend functions, so call them from a coroutine. Create one instance, for example in your Application, and keep it for the life of the app. Each call returns once the event is saved on the phone. It does not wait for the network, so events survive the app being closed.
From Java
Java code usesTranthorClient, which takes callbacks and keeps calls in the order you make them:
Methods
anonymousId, userId and isOptedOut read the current state.
Every event method also takes optional userId, anonymousId, messageId, timestamp and context arguments. Numbers are sent as doubles, so send identifiers larger than 2^53 as strings. A payload nested more than about 60 levels deep is refused.
Identity
Beforeidentify, events carry an anonymous id that the SDK creates and stores on the phone. After identify, events carry the user id.
- The
identifycall sends both the user id and the anonymous id, which lets Tranthor attach the customer’s earlier anonymous activity to them. - If a different customer identifies on the same phone, the SDK first replaces the anonymous id with a new one. The second customer never inherits the first customer’s anonymous activity.
- An empty
userIdis treated as no user id. reset()clears the user id and starts a new anonymous id.
Consent
optOut() discards everything queued and ignores later calls until optIn(). While opted out, flush() returns without sending anything. If the phone is registered for push, opting out also tells Tranthor to stop sending push to it.
That last message is the one thing the SDK sends while opted out. If it cannot be delivered, the SDK tries again when the app next starts or returns to the foreground, and on the next optIn() or optOut(). Until it is delivered, events queued after an optIn() wait behind it, and flush() throws instead of sending.
Configuration
Configuration takes these options. Java code sets them on Configuration.Builder.
Delivery
- Events are sent in batches. Network errors and HTTP 408, 425, 429 and 5xx responses are retried, and a
Retry-Afterheader is honoured up to 30 seconds. Other statuses, such as an invalid write key (401), are dropped after one attempt and reported throughonError. - Queued events are stored in the app’s private storage, kept out of Auto Backup, and sent after a restart.
- The SDK sends what is queued when the app goes to the background. Android can stop a background app at any moment, so anything not yet delivered is sent the next time the app opens.
- The events passed to
onErrorare the real events. For a phone registered for push, a droppedInstallation Registeredincludes its push token, so do not log them or send them to a crash reporter. A rejected opt-out removal is reported with the token replaced by<redacted>. - With the default settings a batch is dropped after about 15 seconds of failed attempts. An app that stays offline longer than that can lose events.
Push
To send push to the app, addtranthor-push and follow Install the SDK and bind push. The push module uses the same instance, write key and queue, so identify, reset, optOut and optIn keep the phone’s registration in step with no extra calls. A phone is registered only while a customer is signed in: identify registers it and reset() removes it (Who a phone belongs to).
If you do not want the POST_NOTIFICATIONS permission merged into your app, remove it in your manifest:

