Application subclass.
Requirements
- Android SDK 23+ (Android 6.0 Marshmallow and later)
- Java 17 toolchain
- Kotlin (Java consumers work, but the API uses Kotlin’s
suspendand default arguments)
Install
In your project’ssettings.gradle, add the JitPack repo to dependencyResolutionManagement:
build.gradle, add the dependency:
Initialise
SubclassApplication and call Spotzee.initialize from onCreate. Use a publishable key (pk_…); read Manage API keys for how to mint one.
AndroidManifest.xml:
initialize returns the Spotzee instance. Stash it as a companion object (or inject through your DI framework) so other layers can call analytics.track(…), analytics.identify(…), and so on.
To wire in-app notifications and deeplinks, also pass an InAppDelegate:
What every request carries
The SDK adds these headers to every API call. You don’t set them yourself.
The SDK’s Gson serialiser converts Kotlin camelCase property names to snake_case before sending, so
Identity(externalId = …) lands as external_id on the wire.
Identity persistence
The SDK persists three values inSharedPreferences:
anonymousId: minted on first call, kept across app launches.externalId: cached on the singleton afteridentifysucceeds.deviceId: a per-install UUID, used when registering for push.
analytics.reset() on sign-out to clear externalId and the persisted anonymous ID.
Errors
Failed requests returnResult.failure(IOException(...)) with a one-line summary that includes the HTTP status, the API error code (when present), the message, and the request_id. The legacy { error: string } shape and the new RFC 7807 envelope are both parsed; quote request_id to support.
track and register are fire-and-forget and don’t return failures to your code; check Logcat under the Spotzee tag for transient issues. identify, alias, getNotifications, and consume are suspend and surface results explicitly.
Debugging
PassisDebug = true (or isDebug = BuildConfig.DEBUG) to Spotzee.initialize to flip the SDK’s HTTP logging to body level. Every request and response prints to Logcat under tag OkHttp so you can inspect payloads. Leave isDebug = false (the default) for production builds.
Next steps
Identify users
Link anonymous activity to a known user.
Track events
Send custom events with properties.
Push notifications
Register for FCM and route incoming pushes through the SDK.
In-app notifications and deeplinks
Render in-app dialogs and unwrap App Links.