There are some configurations that can be used to adjust how recordings are captured.
Attribute | Description |
---|---|
maskAllInputs Type: Boolean Default: true | When true , all data from user input fields will be replaced by '*'s. |
maskInputOptions Type: Object Default: {} | Only takes effect if maskAllInputs is false . It determines which specific input field types should be masked. An example value might be { password: true } . Options are: password , textarea , select , color , date , email , month , number , range , search , tel , text , time , url , week , and datetime-local . |
inlineStylesheet Type: Boolean Default: true | If false , stylesheets will not be included with the recording data. Rather, a URL pointing to the stylesheet will be included. Setting this to false will decrease the storage space used for recordings and improve playback buffering time, but it can also cause some flickering in the playback experience. |
recordCanvas Type: Boolean Default: false | If true , canvas elements will be recorded by rrweb. |
To configure these options, pass them to your posthog.init
call along with your other posthog-js
configurations. They go inside of the session_recording
attribute, like so:
posthog.init('<ph_project_api_key>', {api_host: '<ph_instance_address>',session_recording: {inlineStylesheet: false,},// ... other options})
Console logs recording (beta)
PostHog can also capture console logs from your application. This is useful for debugging, providing extra context on what is happening in your users browser environment. As console logs can contain sensitive information we do not capture these logs automatically. You can enable this feature globally from your PostHog project settings page or client-side by setting enable_recording_console_log
in our JavaScript library config to true
.
Console logs will be recorded if either the project setting or the client-side config is set to true
. If recordings overall are disabled then console logs will also not be recorded.
posthog.init('<ph_project_api_key>', {api_host: '<ph_instance_address>',// REMINDER: This is only needed if you aren't using the project settings configenable_recording_console_log: true,// ... other options})
Further controls
If you want more granular controls, you can choose to enable session recording using feature flags. This enables you to control session recordings based on users with certain previous events/actions or properties (or just to capture a percentage of all sessions).
To do this set disable_session_recording
in our JavaScript library config to true
.
Then conditionally call the method posthog.startSessionRecording
to enable it using the feature flag.
For example:
posthog.init('<ph_project_api_key>', {api_host: '<ph_instance_address>',disable_session_recording: true,// ... other options})window.posthog.onFeatureFlags(function () {if (window.posthog.isFeatureEnabled('your-feature-flag')) {window.posthog.startSessionRecording()}})
Equally you can stop the recording at any point via:
posthog.stopSessionRecording()