Add Millimetry to an Android app
The Android SDK is a Kotlin library with coroutines as its only dependency. It runs on Android 7.0 (API 24) or later, and every call is safe from any thread.
1. Create the app
Section titled “1. Create the app”In the dashboard, choose Add an app or site, name the app, and copy its key (ak_…). The key identifies your app; it is not a secret, so it is fine in your APK.
2. Add the library
Section titled “2. Add the library”dependencies { implementation("app.millimetry:millimetry:0.1.0")}The library adds the INTERNET permission to your manifest and nothing else.
3. Configure at launch
Section titled “3. Configure at launch”Call configure once, in your Application’s onCreate, so it runs before any activity.
import app.millimetry.Millimetry
class SlicksApplication : Application() { override fun onCreate() { super.onCreate() Millimetry.configure(this, appKey = "ak_…", host = "https://e.millimetry.app") }}By default the SDK sends app_open at launch and whenever the app returns to the foreground. Nothing else is tracked automatically. Turn it off with options = Options(trackAppOpen = false).
From a builder’s chat
Section titled “From a builder’s chat”Building with an AI app builder or a coding agent’s chat? Paste this, with your key in place of ak_…:
Add Millimetry analytics to this Android app. Add implementation("app.millimetry:millimetry:0.1.0") andin Application.onCreate call Millimetry.configure(this, appKey = "ak_…", host = "https://e.millimetry.app").Track the screens that matter with Millimetry.screen("name") and the actions that matter withMillimetry.track("event_name"), names in snake_case, never a name, email or id in them.No identifier, no consent prompt: Millimetry stores none. Then tell me which events you added.4. Track events
Section titled “4. Track events”Millimetry.track("screen_view", mapOf("screen" to "settings"))Millimetry.track("purchase", mapOf("plan" to "pro", "price" to 4.99, "trial" to false))- Names are 1 to 64 characters. Names starting with
$are reserved. - Up to 25 properties per event. Values are strings, whole numbers, decimals or Booleans; anything else is dropped before it leaves the device.
- Strings longer than 256 characters are cut.
From Java, every member is static: Millimetry.track("purchase", Map.of("plan", "pro")).
See naming events for names that stay useful. Never put personal data in properties: no names, email addresses, phone numbers or account IDs. The server drops properties that look like those, but that is a safety net, not a guarantee.
When events are sent
Section titled “When events are sent”Events wait in a small queue on disk and go out in batches:
- every 30 seconds while the app is in the foreground (every 2 seconds in debuggable builds);
- as soon as 50 events are waiting;
- when the app moves to the background, while the process is still alive;
- when you call
Millimetry.flush()(asuspendfunction; from Java,Millimetry.flush(Runnable)).
Offline, or when the server is busy, a batch stays queued and is retried with a growing delay, up to 5 minutes. A batch keeps its ID across retries and relaunches, so it is stored once however many times it arrives. The queue keeps at most 1,000 events and drops events older than 7 days.
Debug builds
Section titled “Debug builds”Debuggable builds (the debug build type) mark their events as debug data. The dashboard keeps that data apart and deletes it after 30 days. Override with Options(isDebug = …).
Letting people opt out
Section titled “Letting people opt out”Millimetry.setEnabled(false) stops tracking and deletes everything queued. The SDK does not remember the choice, because remembering it would mean storing something on the device. Keep your own setting and apply it on every launch, before configuring:
Millimetry.setEnabled(settings.analyticsAllowed)Millimetry.configure(this, appKey = "ak_…", host = "https://e.millimetry.app")