diff --git a/contents/docs/session-replay/_snippets/android-installation.mdx b/contents/docs/session-replay/_snippets/android-installation.mdx index 030d8b213fd6..7aa5bf2f8e16 100644 --- a/contents/docs/session-replay/_snippets/android-installation.mdx +++ b/contents/docs/session-replay/_snippets/android-installation.mdx @@ -51,6 +51,15 @@ val config = PostHogAndroidConfig(apiKey = "").apply { // Ps: it was 500ms (0.5s) by default until version 3.8.2 // Available from version 3.10.0 (Before it was called debouncerDelayMs) sessionReplayConfig.throttleDelayMs = 1000 + + // Sample rate for session recordings. A value between 0.0 and 1.0. + // 1.0 means 100% of sessions will be recorded. 0.5 means 50%, and so on. + // Default is null (all sessions are recorded). + // + // Support for remote configuration + // in the session replay triggers (https://app.posthog.com/settings/project-replay#replay-triggers) + // requires SDK version 3.34.0 or higher. + sessionReplayConfig.sampleRate = null } ``` diff --git a/contents/docs/session-replay/_snippets/ios-installation.mdx b/contents/docs/session-replay/_snippets/ios-installation.mdx index 522cd2cc2a38..05d99f508d69 100644 --- a/contents/docs/session-replay/_snippets/ios-installation.mdx +++ b/contents/docs/session-replay/_snippets/ios-installation.mdx @@ -78,6 +78,15 @@ config.sessionReplayConfig.screenshotMode = true // A higher value reduces performance impact but decreases replay smoothness. Default is 1.0s. // Note: Previously known as `debouncerDelay` before version 3.21.0 config.sessionReplayConfig.throttleDelay = 1.0 + +// Sample rate for session recordings. A value between 0.0 and 1.0. +// 1.0 means 100% of sessions will be recorded. 0.5 means 50%, and so on. +// Default is nil (all sessions are recorded). +// +// Support for remote configuration +// in the session replay triggers (https://app.posthog.com/settings/project-replay#replay-triggers) +// requires SDK version 3.42.0 or higher. +config.sessionReplayConfig.sampleRate = 0.5 ``` ## Limitations diff --git a/contents/docs/session-replay/how-to-control-which-sessions-you-record.mdx b/contents/docs/session-replay/how-to-control-which-sessions-you-record.mdx index b0f2c97faae3..61f438ba8639 100644 --- a/contents/docs/session-replay/how-to-control-which-sessions-you-record.mdx +++ b/contents/docs/session-replay/how-to-control-which-sessions-you-record.mdx @@ -134,6 +134,44 @@ This means: > **Note:** Sampling reduces the number of sessions you record, but you cannot control which specific sessions are selected — the selection is determined by the session ID hash. +### Mobile SDK sampling + +Sampling is also available in the Android and iOS SDKs. You can set a sample rate directly in your SDK configuration: + + + + Android + iOS + + + + +```android_kotlin +val config = PostHogAndroidConfig(apiKey = "").apply { + sessionReplay = true + // Sample rate between 0.0 and 1.0. Default is null (all sessions recorded). + sessionReplayConfig.sampleRate = 0.5 // Record 50% of sessions +} +``` + +> **Note:** Requires Android SDK version 3.34.0 or higher. Remote configuration via [session replay triggers](https://app.posthog.com/settings/project-replay#replay-triggers) is also supported from this version. + + + + +```swift +let config = PostHogConfig(apiKey: "") +config.sessionReplay = true +// Sample rate between 0.0 and 1.0. Default is nil (all sessions recorded). +config.sessionReplayConfig.sampleRate = 0.5 // Record 50% of sessions +``` + +> **Note:** Requires iOS SDK version 3.42.0 or higher. Remote configuration via [session replay triggers](https://app.posthog.com/settings/project-replay#replay-triggers) is also supported from this version. + + + + + ## Combining controls Since version 1.238.0 of the web SDK you can control how multiple triggers are combined. Choosing whether recording will start when all triggers match or when any trigger matches.