About five minutes, on the free plan, without a credit card.
1
Add the dependency
The SDK is OpenPanel's own package, distributed under the dev.openpanel group id. Privytics is independent and not affiliated with OpenPanel. Note that upstream still marks this artifact as not yet published, so you will need to build it from the kotlin-sdk repository until it lands on Maven Central.
dependencies {
implementation 'dev.openpanel:openpanel:0.0.1'
}
2
Initialise with your Privytics API URL
apiUrl is the option for pointing the SDK at a non-default instance, and it is required for Privytics. If you omit it your events go to OpenPanel's own host instead. clientSecret is documented as being needed only for server-side events, so leave it out of the app binary.
import dev.openpanel.OpenPanel
val op = OpenPanel.create(
context,
OpenPanel.Options(
clientId = "YOUR_CLIENT_ID",
apiUrl = "https://api.privytics.com"
)
)
3
Track events and identify users
track takes an event name and a property map. identify attaches your own user id so sessions link into one profile. That is opt-in and needs your own lawful basis.
op.track("button_clicked", mapOf("button_id" to "submit_form"))
op.identify("user123", mapOf(
"firstName" to "John",
"lastName" to "Doe",
"email" to "john@example.com"
))
// Call on sign out to remove the current user
op.clear()
4
Turn on automatic lifecycle tracking
With automaticTracking enabled the SDK records app_opened and app_closed. setGlobalProperties adds fields to every event that follows, which is useful for build channel or environment.
val op = OpenPanel.create(
context,
OpenPanel.Options(
clientId = "YOUR_CLIENT_ID",
apiUrl = "https://api.privytics.com",
automaticTracking = true
)
)
op.setGlobalProperties(mapOf(
"app_version" to "1.0.2",
"environment" to "production"
))