# Quickstart

> Add the Pulsark Android SDK to your app and see your first events.

Source: https://pulsark.org/docs/quickstart/

You need an `app_id` (public, goes into your APK) and, to read data, a platform key (`dak_…`, secret, never put it in an app). Both come with your [early-access account](/#access). You can also create more apps with the [REST API](/docs/api/#apps).

## 1. Add the repository and dependency

```kotlin title="settings.gradle.kts"
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven("https://pulsark.org/maven/")
    }
}
```

```kotlin title="app/build.gradle.kts"
dependencies {
    implementation("org.pulsark:analytics:0.1.0")
}
```

Requirements: `minSdk` 21+. The SDK adds the `INTERNET` and `ACCESS_NETWORK_STATE` permissions. Dependencies: OkHttp, AndroidX WorkManager and Lifecycle.

## 2. Initialize in `Application.onCreate`

```kotlin title="MyApp.kt"
import org.pulsark.analytics.Profile
import org.pulsark.analytics.Pulsark
import org.pulsark.analytics.PulsarkConfig

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Pulsark.init(this, appId = "app_xxxxxxxxxxxx", config = PulsarkConfig(profile = Profile.GAME))
    }
}
```

```java title="MyApp.java"
Pulsark.init(this, "app_xxxxxxxxxxxx", new PulsarkConfig());
```

`init` takes < 5 ms and does all I/O on a background thread. Calls from secondary processes (for example an ad SDK's process) are ignored automatically.

## 3. Record consent

Until you call `setConsent`, only essential events are collected (`first_open`, `session_start`, `app_foreground`/`app_background`, `ad_impression`). After the user agrees:

```kotlin
Pulsark.setConsent(ConsentState.GRANTED)
```

See [Privacy & data](/docs/privacy/) for what each state means.

## 4. Track something

```kotlin
Pulsark.track("level_end", mapOf("level_id" to "3", "result" to "win", "duration_ms" to 41250))
```

Sessions, foreground time and screens (`page_view`) are tracked for you. For ad revenue, see [Ad revenue](/docs/ad-revenue/).

## 5. Check it works

- Set `PulsarkConfig(debug = true)` and watch Logcat with the tag `Pulsark`.
- Call `Pulsark.flush()` to upload immediately instead of waiting for the next batch.
- Metrics are aggregated hourly. Query today's DAU:

```bash
curl -H "Authorization: Bearer $PULSARK_KEY" \
  "https://api.pulsark.org/api/v1/metrics/dau?app_id=app_xxxxxxxxxxxx"
```

Or just ask your AI assistant after [connecting MCP](/docs/mcp/).

## Next

- [SDK reference](/docs/android/) — every method and option.
- [Events](/docs/events/) — naming rules and limits.
- [Integrate with AI](/docs/ai-integration/) — a ready-made prompt that does steps 1–4 for you.
