🚧 NOTE: Mobile recording is currently only available on Android and is considered
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.
Overview
Mobile Session Recording allows you to record user sessions on mobile devices. This includes screen recordings, network requests, logs and touches. This data can then be used to understand how users are interacting with your app and to identify bugs and issues.
How it works
We have taken our time to make sure we provide a useful and detailed recording experience whilst keeping the performance and security of your app as a top priority. By default, the configuration is restrictive with automatic masking.
Screen recording
Mobile recording is primarily done using native APIs to grab the view hierarchy state when the screen is drawn. This is done carefully so as not to affect performance in any way a user may notice.
The view hierarchy is transformed to a JSON data structure and later rendered as a HTML wireframe. Since it is a wireframe, the UI won't have the original look and feel but it should be close enough to understand the user's behaviour.
Network recording
Network requests are recorded using the PostHogOkHttpInterceptor
interceptor (OkHttp only). Only metric-like data is currently gathered to give a picture of speed, size and response code. No data is captured from the request or response body.
Installation
Add the dependency.
implementation("com.posthog:posthog-android:$latestVersion")
Initialize the SDK in the Application
class.
import android.app.Applicationimport com.posthog.android.PostHogAndroidimport com.posthog.android.PostHogAndroidConfigclass SampleApp : Application() {companion object {const val POSTHOG_API_KEY = "<ph_project_api_key>"// usually 'https://app.posthog.com' or 'https://eu.posthog.com'const val POSTHOG_HOST = "<ph_instance_address>"}override fun onCreate() {super.onCreate()val config = PostHogAndroidConfig(apiKey = POSTHOG_API_KEY,host = POSTHOG_HOST)config.sessionReplay = truePostHogAndroid.setup(this, config)}}
Add the OkHttp Interceptor.
import com.posthog.PostHogOkHttpInterceptorimport okhttp3.OkHttpClientprivate val client = OkHttpClient.Builder().addInterceptor(PostHogOkHttpInterceptor(captureNetworkTelemetry = true)).build()
Limitations
- Requires the PostHog Android SDK version >= 3.1.0 - use the latest version.
- Requires Android API >= 26, otherwise it's a NoOp.
- Not compatible with Jetpack Compose.
- Custom views are not fully supported.
- WebView is not supported, a placeholder will be shown.
- Keyboard is not supported, a placeholder will be shown.
- React Native and Flutter for Android aren't supported.
- Let us know when you're ready to view the recordings. While replay is in beta there's still some setup on our side before you can playback the sessions. You can send feedback via the in-app support panel or one of our other support options
Recording specific configuration
SDK configurations during the SDK initialization.
val config = PostHogAndroidConfig(apiKey = POSTHOG_API_KEY).apply {// enable session recording, requires enabling on the project configuration as well.sessionReplay = true// all texts are masked (default is enabled)sessionReplayConfig.maskAllTextInputs = false// all images are placeholders (default is enabled)sessionReplayConfig.maskAllImages = false// capture logs automatically (default is enabled)sessionReplayConfig.captureLogcat = true}
View configuration, if setting the View#tag to ph-no-capture
, the image will be a placeholder.
<ImageViewandroid:id="@+id/imvProfilePhoto"android:layout_width="200dp"android:layout_height="200dp"android:tag="ph-no-capture"/>