Android session replay

Last updated:

|Edit this page

🚧 NOTE: Android is considered beta and is free while in beta. We are keen to gather as much feedback as possible so if you try this out please let us know. You can send feedback via the in-app support panel or one of our other support options.

Installation

Install and configure PostHog as you normally would. Ensure you've enabled session recordings in your project settings and then add sessionReplay = true to your PostHog configuration alongside any of your other configuration options.

Session replay requires PostHog Android SDK version >= 3.4.0, and it's recommended to always use the latest version.

Android
val config = PostHogAndroidConfig(apiKey = "<ph_project_api_key>").apply {
// Enable session recording. Requires enabling in your project settings as well.
// Default is false.
sessionReplay = true
// Whether text inputs are masked. Default is true.
// This isn't supported for Jetpack Compose views.
// Password inputs are always masked regardless
sessionReplayConfig.maskAllTextInputs = true
// Whether images are masked. Default is true.
// This isn't supported for Jetpack Compose views.
sessionReplayConfig.maskAllImages = true
// Capture logs automatically. Default is true.
sessionReplayConfig.captureLogcat = true
// Whether replays are created using high quality screenshots. Default is false.
// If disabled, replays are created using wireframes instead.
// The screenshot may contain sensitive information, so use with caution
sessionReplayConfig.screenshot = false
// Deboucer delay used to reduce the number of snapshots captured and reduce performance impact. Default is 500ms
sessionReplayConfig.debouncerDelayMs = 500
}

Additional options

Capture network telemetry

To capture network requests in your recordings, add PostHogOkHttpInterceptor to your OkHttp Interceptor.

Android
import com.posthog.PostHogOkHttpInterceptor
import okhttp3.OkHttpClient
private val client = OkHttpClient.Builder()
.addInterceptor(PostHogOkHttpInterceptor(captureNetworkTelemetry = true))
.build()

Note: Only metric-like data like speed, size, and response code are captured. No data is captured from the request or response body.

Masking and redacting

🚧 NOTE: Currently, this isn't supported if using Jetpack Compose views. We're investigating this issue.

Your replays may contain sensitive information. For example, if you're building a banking app you may not want to capture how much money a user has in their account.

To replace any type of View with a redacted version in the recording, set the tag to ph-no-capture.

XML
<ImageView
android:id="@+id/imvProfilePhoto"
android:layout_width="200dp"
android:layout_height="200dp"
android:tag="ph-no-capture"
/>

Limitations

  • Requires Android API >= 26.
  • Jetpack Compose is only supported if screenshotMode is enabled.
    • Masking and redacting in Jetpack Compose isn't supported yet. We're investigating this issue.
  • Custom views are partly supported, and only fully supported if screenshotMode is enabled.
  • WebView is not supported. A placeholder will be shown.
  • Keyboard is not supported. A placeholder will be shown.
  • Flutter for Android isn't supported.

Questions?

Was this page useful?

Next article

iOS session replay

🚧 NOTE: iOS session replay is considered beta and is free while in beta. We are keen to gather as much feedback as possible so if you try this out please let us know. You can send feedback via the in-app support panel or one of our other support options . Installation Install and configure PostHog as you normally would. Ensure you've enabled session recordings in your project settings and then add config.sessionReplay = true to your PostHog configuration alongside any of your other…

Read next article