Skip to content

Kotlin LogSnag client to easily track events in your Kotlin Multiplatform projects

License

Notifications You must be signed in to change notification settings

vinceglb/logsnag-kotlin

Repository files navigation

LogSnag

LogSnag Kotlin

Get notifications and track your project events in your Kotlin project.

LogSnag Kotlin Discord Documentation
Badge Android Badge iOS Badge JVM


📦 Setup

  1. Add the following to your build.gradle.kts file:
repositories {
    mavenCentral()
}

dependencies {
    implementation("io.github.vinceglb:logsnag-kotlin:1.0.0")
}
  1. Choose and add to your dependencies one of Ktor's engines. In case of Kotlin Multiplatform project, add an engine to each target.

🧑‍💻 Usage

⚡️ Initialize Client

Create an instance of LogSnag client:

val logSnag = LogSnag(
    token = "your-token",
    project = "your-project",
)

📝 Track Event

Send a track event to LogSnag:

logSnag.track(
    channel = "waitlist",
    event = "User Joined",
    description = "A user joined the waitlist",
    icon = "🎉",
    userId = "user_123",
    tags = mapOf("source" to "google"),
    notify = true,
)

👤 User Properties

Identify a user and set their properties:

logSnag.identify(
    userId = "user_123",
    properties = mapOf(
        "name" to "John Doe",
        "email" to "john@doe.com",
        "plan" to "premium",
    ),
)

✨ Track Insight

Send a insight track to LogSnag:

logSnag.insightTrack(
    title = "User Count",
    value = "100",
    icon = "👨",
)

➕ Increment Insight

Increment an insight track to LogSnag:

logSnag.insightIncrement(
    title = "User Count",
    value = 1,
    icon = "👨",
)

🤩 Contributing

To be able to work on the project locally, you need to update the local.properties file with your LogSnag token and project ID:

LOGSNAG_TOKEN=your-token
LOGSNAG_PROJECT=your-project