Capture WebSockets
OpenReplay can record chosen WebSocket channels and display them in the session replay. This is useful when troubleshooting certain situations by providing additional context.
Enable WebSockets Recording
Section titled Enable WebSockets RecordingTo enable WebSockets recording, you will need to create a hook that will listen to messages:
const wsHook = tracker.trackWs('my_ws_channel')
myWsChannel.on('important_message', (data) => {
wsHook('important_message', data, 'down')
/** your code */
})
myWsChannel.onAnyOutgoing((event, data) => {
wsHook(event, data, 'up')
})
Example built with socket-io docs
Note: This is just a basic example, make sure to read how to listen to message events and plan what you actually need to capture accordingly. Big/heavy traffic will lead to bigger replay sizes.
Data Sanitization
Section titled Data SanitizationYou can sanitize data before it is sent via hook.
Have questions?
Section titled Have questions?If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.