rrweb example
Example 1: rrweb example
let events = [];
rrweb.record({
emit(event) {
// push event into the events array
events.push(event);
},
});
// this function will send events to the backend and reset the events array
function save() {
const body = JSON.stringify({ events });
events = [];
fetch('http://YOUR_BACKEND_API', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body,
});
}
// save events every 10 seconds
setInterval(save, 10 * 1000);
Example 2: rrweb example
rrweb.record({
emit(event) {
// store the event in any way you like
},
});