> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Kotlin Multiplatform Session Replay installation 1. 1 ## Install the dependency Required Add the PostHog KMP SDK to your shared module's `commonMain` source set: shared/build.gradle.kts ```kotlin kotlin { sourceSets { commonMain.dependencies { implementation("com.posthog:posthog-kmp:0.+") } } } ``` `0.+` resolves to the latest `0.x` release. The SDK is a pre-release, so the API can change between minor versions – pin an exact version from [Maven Central](https://central.sonatype.com/artifact/com.posthog/posthog-kmp) if you would rather upgrade deliberately. **Supported targets** Session replay is captured on Android, iOS and the web. It is ignored on the JVM (desktop) target. 2. 2 ## Enable session recordings in project settings Required Go to your PostHog [Project Settings](https://us.posthog.com/settings/project-replay) and enable **Record user sessions**. Session recordings will not work without this setting enabled. 3. 3 ## Configure PostHog with session replay Required Pass a `SessionRecordingConfig` to `PostHogConfig` from shared code. Here are all the available options: Kotlin ```kotlin import com.posthog.kmp.PostHog import com.posthog.kmp.PostHogConfig import com.posthog.kmp.PostHogContext import com.posthog.kmp.SessionRecordingConfig val config = PostHogConfig( apiKey = "", host = "https://us.i.posthog.com", // Enable session recording. Requires enabling in your project settings as well. sessionRecording = SessionRecordingConfig( enabled = true, // Whether text input values are masked. Default is true. maskAllTextInputs = true, // Whether images are masked. Default is true. maskAllImages = true, // Whether network requests are included in the recording. Default is true. captureNetworkTelemetry = true, // Capture console and system logs (iOS and web). Default is false. captureLogs = false, // Whether replays are created using high quality screenshots instead of // wireframes (experimental, Android and iOS). Default is false. // Screenshots may contain sensitive information, so use with caution. screenshot = false, // Capture Android logcat output (Android only). Default is true. captureLogcat = true, // Touch event debounce delay in milliseconds (Android only). Default is 1000. debouncerDelayMs = 1000L, ), ) ``` Pass that config to `PostHog.setup()`. Android needs the `Application` instance, so it takes `PostHogContext(application)` – every other target takes the no-argument `PostHogContext()`. ## Tab MyApplication.kt ```kotlin import android.app.Application class MyApplication : Application() { override fun onCreate() { super.onCreate() PostHog.setup(config = config, context = PostHogContext(this)) } } ``` ## Tab Kotlin ```kotlin PostHog.setup(config = config, context = PostHogContext()) ``` For more configuration options, see the [Kotlin Multiplatform session replay docs](/docs/libraries/kmp.md#session-replay). 4. 4 ## Watch session recordings Recommended Visit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions. [Watch your first recording →](https://app.posthog.com/replay/home) 5. 5 ## Next steps Recommended Now that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform. | Resource | Description | | --- | --- | | [Watching recordings](/docs/session-replay/how-to-watch-recordings.md) | How to find and watch session recordings | | [Privacy controls](/docs/session-replay/privacy.md) | How to mask sensitive data in recordings | | [Network recording](/docs/session-replay/network-recording.md) | How to capture network requests in recordings | | [Console log recording](/docs/session-replay/console-log-recording.md) | How to capture console logs in recordings | | [More tutorials](/docs/session-replay/tutorials.md) | Other real-world examples and use cases | ### Still have questions? Ask PostHog AI ### Was this page useful? HelpfulCould be better