Skip to content

sonusony19/openpanel-android

 
 

Repository files navigation

OpenPanel Kotlin SDK

Native Kotlin and Android SDK for OpenPanel, the open-source product analytics platform and Mixpanel alternative.

Installation

Add JitPack to your repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

Add the SDK dependency:

dependencies {
    implementation("com.github.sonusony19.openpanel-android:openpanel-android:0.0.1")
}

JitPack builds from GitHub tags, so replace 0.0.1 with the release tag you publish.

For local verification before a public release:

./gradlew :OpenPanelSDK:publishReleasePublicationToMavenLocal

Minimum supported Android API level: 23.

Usage

Initialize the SDK from your Application class or another app-level startup point:

import dev.openpanel.OpenPanel

val op = OpenPanel.create(
    context = applicationContext,
    options = OpenPanel.Options(
        clientId = "YOUR_CLIENT_ID",
        clientSecret = "YOUR_CLIENT_SECRET"
    )
)

Options

  • clientId: Required OpenPanel client ID.
  • clientSecret: Optional client secret. Native Android integrations usually need this for authenticated event ingestion.
  • apiUrl: Optional API URL for OpenPanel Cloud or a self-hosted instance. Defaults to https://api.openpanel.dev.
  • waitForProfile: Delays event sending until a profile is identified.
  • filter: Invoked before sending a payload. Return false to drop the payload.
  • disabled: Disables sending while keeping SDK calls safe.
  • automaticTracking: Tracks app_opened and app_closed from Android activity lifecycle callbacks.
  • verbose: Enables debug logging.

Track Events

op.track("button_clicked", mapOf("button_id" to "submit_form"))

Identify Users

op.identify(
    "user123",
    mapOf(
        "firstName" to "John",
        "lastName" to "Doe",
        "email" to "john@example.com",
        "customAttribute" to "value"
    )
)

Global Properties

op.setGlobalProperties(
    mapOf(
        "app_version" to "1.0.2",
        "environment" to "production"
    )
)

Profile Utilities

op.alias("user123", "john_doe")
op.increment("user123", "login_count", 1)
op.decrement("user123", "credits", 5)
op.clear()

Publishing

JitPack is the primary release path for now. Create and push a GitHub release tag, then look up sonusony19/openpanel-android on JitPack to trigger the build.

The SDK module publishes a release AAR, sources JAR, javadocs JAR, and Maven POM. JitPack uses jitpack.yml to run the release publication to Maven local with Java 17.

Useful tasks:

./gradlew :OpenPanelSDK:assembleRelease
./gradlew :OpenPanelSDK:publishReleasePublicationToMavenLocal
./gradlew :OpenPanelSDK:publishReleasePublicationToLocalBuildRepository

Maven Central metadata is kept in gradle.properties for a later Central release. The future Maven Central coordinate is:

dependencies {
    implementation("io.github.sonusony19:openpanel-android:0.0.1")
}

Maven Central publishing task:

./gradlew :OpenPanelSDK:publishReleasePublicationToSonatypeRepository

Maven Central publishing expects credentials from Gradle properties or environment variables:

  • mavenCentralUsername or MAVEN_CENTRAL_USERNAME
  • mavenCentralPassword or MAVEN_CENTRAL_PASSWORD
  • signingInMemoryKey or SIGNING_KEY
  • signingInMemoryKeyPassword or SIGNING_KEY_PASSWORD

License

This SDK follows the repository license in LICENSE.md.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Kotlin 100.0%