Skip to content

Kotlin Android SDK and Kotlin JVM for RudderStack - the Customer Data Platform for Developers.

License

Notifications You must be signed in to change notification settings

rudderlabs/rudder-sdk-kotlin

Repository files navigation

RudderStack
The Customer Data Platform for Developers

Website · Documentation · Community Slack


RudderStack Kotlin SDK - alpha version

The Kotlin SDK enables you to track customer event data from your Android or Kotlin JVM applications and send it to your configured destinations via RudderStack.

Be aware that this SDK supports only a limited set of Rudderstack's features.


Table of Contents


Installing the Kotlin Android SDK

Add the SDK to your Android project using Gradle:

dependencies {
    implementation("com.rudderstack.sdk.kotlin:android:<latest_version>")
}

Replace <latest_version> with the version number you want to use. You can find the latest release here.

Installing the Kotlin JVM SDK

Add the SDK to your Kotlin JVM project using Gradle:

dependencies {
    implementation("com.rudderstack.sdk.kotlin:core:<latest_version>")
}

Replace <latest_version> with the version number you want to use. You can find the latest release here.


Initializing the SDK

To initialize the Android RudderStack SDK, add the Analytics initialisation snippet to your application’s entry point (e.g., in onCreate method):

import android.app.Application
import com.rudderstack.sdk.kotlin.android.Analytics
import com.rudderstack.sdk.kotlin.android.Configuration

class MyApplication : Application() {

    lateinit var analytics: Analytics

    override fun onCreate() {
        super.onCreate()
        initializeAnalytics(this)
    }

    private fun initializeAnalytics(application: Application) {
        analytics = Analytics(
            configuration = Configuration(
                writeKey = "<WRITE_KEY>",
                application = application,
                dataPlaneUrl = "<DATA_PLANE_URL>",
            )
        )
    }
}

Replace:

  • <WRITE_KEY>: Your project’s write key.
  • <DATA_PLANE_URL>: The URL of your RudderStack data plane.

Identifying users

The identify API lets you recognize a user and associate them with their traits:

analytics.identify(
	userId = "1hKOmRA4el9Zt1WSfVJIVo4GRlm",
	traits = buildJsonObject {
		put("name", "Alex Keener")
		put("email", "[email protected]")
	}
)

Tracking user actions

The track API lets you capture user events:

analytics.track(
    event = "Order Completed",
    properties = buildJsonObject {
	put("revenue", 30)
        put("currency", "USD")
    }
)

Contact us

For more information:


Follow Us


About

Kotlin Android SDK and Kotlin JVM for RudderStack - the Customer Data Platform for Developers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •