Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: usage and some comments #206

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 5 additions & 72 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,79 +197,12 @@ PostHog.close()

## Android Session Recording

Enable `Record user sessions` on the [PostHog project settings](https://us.posthog.com/settings/project-replay#replay).

Requires the Android SDK version >= [3.4.0](https://github.com/PostHog/posthog-android/releases/).

Enable the SDK to capture Session Recording.

```kotlin
val config = PostHogAndroidConfig(apiKey).apply {
// sessionReplay is disabled by default
sessionReplay = true
// sessionReplayConfig is optional, they are enabled by default
// this isn't supported if using Jetpack Compose views, use with caution
sessionReplayConfig.maskAllTextInputs = true
// this isn't supported if using Jetpack Compose views, use with caution
sessionReplayConfig.maskAllImages = true
sessionReplayConfig.captureLogcat = true
// screenshot is disabled by default
// The screenshot may contain sensitive information, use with caution
sessionReplayConfig.screenshot = false
// debouncerDelayMs is 500ms by default
sessionReplayConfig.debouncerDelayMs = 1000
}
```

If you don't want to mask everything, you can disable the mask config above and mask specific views using the `ph-no-capture` value in the [android:tag](https://developer.android.com/reference/android/view/View#attr_android:tag) or [android:contentDescription](https://developer.android.com/reference/android/view/View#attr_android:contentDescription)..

```xml
<ImageView
android:id="@+id/imvAndroid"
android:layout_width="230dp"
android:layout_height="391dp"
android:src="@drawable/android_logo"
android:tag="ph-no-capture"
/>
```

Currently masking and redacting isn't supported if using Jetpack Compose views, We're investigating this issue.
Read the Mobile session replay [documentation](https://posthog.com/docs/session-replay/mobile).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove some dupe


Add the `PostHogOkHttpInterceptor` to your `OkHttpClient` to capture network requests.

```kotlin
import com.posthog.PostHogOkHttpInterceptor
import okhttp3.OkHttpClient

private val client = OkHttpClient.Builder()
.addInterceptor(PostHogOkHttpInterceptor(captureNetworkTelemetry = true))
.build()
```

If there are missing images (Drawables) in the session recording, most likely is because the Drawable could not be transformed to a Bitmap. You can transform the Drawable to a Bitmap programmatically using the `drawableConverter`.

```kotlin
import com.posthog.android.replay.PostHogDrawableConverter
Enable `Record user sessions` on the [PostHog project settings](https://us.posthog.com/settings/project-replay#replay).

val config = PostHogAndroidConfig(apiKey).apply {
sessionReplayConfig.drawableConverter = PostHogDrawableConverter { drawable ->
// your custom Drawables
if (drawable is IconicsDrawable) {
drawable.toBitmap()
} else {
null
}
}
}
```
[Install the SDK](https://posthog.com/docs/session-replay/installation?tab=Android) to capture Session recording.

### Limitations
Install and learn more about [Network performance recording](https://posthog.com/docs/session-replay/network-recording?tab=Android).

- Requires Android API >= 26, otherwise it's a NoOp.
- [Jetpack Compose](https://developer.android.com/jetpack/compose) is only supported if the `screenshot` option is enabled.
- Masking and Redaction aren't supported yet, We're investigating this issue.
- It's a representation of the user's screen, not a video recording.
- Custom views are not fully supported.
- If the option `screenshot` is enabled, the SDK will take a screenshot of the screen instead of making a representation of the user's screen.
- WebView is not supported, a placeholder will be shown.
- React Native and Flutter for Android aren't supported.
Learn more about [Privacy controls](https://posthog.com/docs/session-replay/privacy?tab=Android).
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PostHogSessionReplayConfig
@JvmOverloads
constructor(
/**
* Enable masking of all text input fields
* Enable masking of all text and text input fields
* Defaults to true
*/
@PostHogExperimental
Expand Down
Loading