feat: add local sampleRate config for session recording#3169
Merged
marandaneto merged 5 commits intomainfrom Mar 2, 2026
Merged
feat: add local sampleRate config for session recording#3169marandaneto merged 5 commits intomainfrom
marandaneto merged 5 commits intomainfrom
Conversation
Add sampleRate option to SessionRecordingOptions that allows setting the session recording sample rate locally. When set, it takes precedence over the remote config. Validates that the value is between 0 and 1, logging a warning and falling back to remote config for invalid values. Also adds documentation comments to enable_recording_console_log and capture_performance.network_timing clarifying their relationship to session recording/replay features.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Extract _validateSampleRate method that validates the value is between 0 and 1, returning null for invalid/missing values with a warning log. Applied to both local config and remote config sampleRate values.
Contributor
Contributor
|
Size Change: +3.4 kB (+0.05%) Total Size: 6.69 MB
ℹ️ View Unchanged
|
dustinbyrne
approved these changes
Feb 27, 2026
TueHaulund
approved these changes
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users need the ability to configure the session recording sample rate locally in their SDK init config, rather than relying solely on remote configuration. This enables faster iteration and local testing without needing to update remote settings.
Changes
sampleRateoption toSessionRecordingOptionsin@posthog/types— a number between 0 and 1 (e.g., 0.5 = 50% of sessions recorded)_persistRemoteConfiginsession-recording.tsto check for localsampleRatefirst, falling back to remote config when not setenable_recording_console_logandcapture_performanceclarifying their relationship to session recording/replayRelease info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file