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

wrap window.WebSocket to enhance network capture #25721

Open
8 tasks
pauldambra opened this issue Oct 22, 2024 · 1 comment
Open
8 tasks

wrap window.WebSocket to enhance network capture #25721

pauldambra opened this issue Oct 22, 2024 · 1 comment
Labels
enhancement New feature or request feature/replay Features for Team Replay

Comments

@pauldambra
Copy link
Member

pauldambra commented Oct 22, 2024

Feature request

websocket implementations rely on window.WebSocket not window.fetch so our network capture doesn't see or report on websocket requests

if we also patched websockets then we could capture info about them too

to-do

  • resurrect the ability to load different recorder.js versions
  • add mechanism for letting decide roll those out by team id
  • split xhr/fetch capture out of recorder.js
  • add a web socket example in the playground
  • add web socket wrapper
  • make new recorder-v3.js that includes xhr/fetch/web socket capture
  • figure out some UI for showing it in the network capture panel
  • roll that out for some testers

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
@mattc
Copy link

mattc commented Oct 22, 2024

The individual messages inside the Websocket are conceptually equivalent to fetch calls, so that's what really needs to be captured.

The browser API for Websockets is very small. The minimal wrapping for capturing messages would involve patching the window.Websocket constructor, the send method (outgoing messages), and the message flavor of addEventListener (incoming messages).

Also consider tracking connection state/errors by monitoring the close method and the close/error/open addEventListeners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature/replay Features for Team Replay
Development

No branches or pull requests

2 participants