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

Multiple Session Recording warnings when disable_session_recording = true #1378

Closed
vonBrax opened this issue Aug 22, 2024 · 5 comments · Fixed by #1379
Closed

Multiple Session Recording warnings when disable_session_recording = true #1378

vonBrax opened this issue Aug 22, 2024 · 5 comments · Fixed by #1379

Comments

@vonBrax
Copy link

vonBrax commented Aug 22, 2024

Bug description

When initializing posthog with disable_session_recording: true, after a few interactions with the app, at some point some warnings start showing in the console:

image

Even though no api calls are made, which seems to be respecting the disable_session_recording property, the presence of this logs may induce the customer to think that their session is being recorded and that our application is violating their privacy settings.

The problem seems to be happening because the SessionRecorder constructor is called and immediatelly starts listening to some browsers events:

window?.addEventListener('beforeunload', () => {
this._flushBuffer()
})
window?.addEventListener('offline', () => {
this._tryAddCustomEvent('browser offline', {})
})
window?.addEventListener('online', () => {
this._tryAddCustomEvent('browser online', {})
})
window?.addEventListener('visibilitychange', () => {
if (document?.visibilityState) {
const label = 'window ' + document.visibilityState
this._tryAddCustomEvent(label, {})
}
})

I'm assuming that then the events are added to a queue, which also seems to have a limit of 5 entries, and if the entries can't be processed - probably because session recording should be disabled -, then the warnings start showing up.

Additional info

We are using the bundled version of posthog as described in the docs, which means that the session-recorder module is not lazy-loaded by posthog, and seems to be instantiated regardless of the posthog init config.

Steps to reproduce

  1. Bundle posthog and it's dependencies
  2. Start the app and initialize posthog with disable_session_recording: true
  3. Trigger the visibilitychange event 5 times (for example switching to a different tab or ALT+TAB to a different running application)
  4. After that, any subsequent visibilitychange event will cause a SessionRecording warning to be displayed in the browser console
@pauldambra
Copy link
Member

hey @vonBrax

just updating you that there's some CI fixing happening in our end-to-end tests and I'm out of the office till tuesday so I think it will be tuesday before the fix is merged

sorry, we're normally faster than that)

@vonBrax
Copy link
Author

vonBrax commented Aug 23, 2024

Hey @pauldambra, no worries. Thank you for the update and for the quick fix here!

@pauldambra
Copy link
Member

This should be resolved in 1.158.1

Do let us know if not!

@vonBrax
Copy link
Author

vonBrax commented Aug 27, 2024

I can confirm that the issue is fixed in 1.158.1.

Thank you @pauldambra !

@pauldambra
Copy link
Member

Great news, thanks for the detailed report @vonBrax 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants