Skip to main content

Quick Start

Call start() once at app startup, on the main thread — Application.onCreate is the conventional place:

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
B2MetricSDK.getInstance(this).start(
B2MetricAnalyticsConfig(
apiKey = "YOUR_API_KEY",
appIdentifier = "my_app"
)
)
}
}

// Track events anywhere in your app
B2MetricSDK.getInstance(context).logEvent(
name = "button_clicked",
properties = mapOf("screen" to "home")
)
Note

appIdentifier must match ^[a-z][a-z0-9]*(_[a-z0-9]+)*$ — starts with a letter, only a-z, 0-9 and single _ separators. Every other method called before start() logs an error and returns without doing anything.