// Start the record var options = { maskAllInputs: true, emit: function (event) { var json_event = JSON.stringify(event); try { // Fixing srcset issue with relative URLs // Browse all occurences of srcset starting with relative URLs while (json_event.indexOf('"srcset":"/') !== -1) { var srcset_index = json_event.indexOf('"srcset":"/'); var srcset = json_event.substring(srcset_index + 10, json_event.indexOf('"', srcset_index + 10)); var srcset_splitted = srcset.split(','); var srcset_splitted_fixed = []; for (var i = 0; i < srcset_splitted.length; i++) { var srcset_item = srcset_splitted[i].replace(/(\\n)/g, ' ').trim(); if (srcset_item.indexOf("/") == 0) { srcset_item = location.protocol + '//' + location.host + srcset_item; } srcset_splitted_fixed.push(srcset_item); } var srcset_fixed = srcset_splitted_fixed.join(', '); // Clean previous srcset and replace it with the fixed one json_event = json_event.substring(0, srcset_index + 10) + srcset_fixed + json_event.substring(json_event.indexOf('"', srcset_index + 10)); } } catch (exc) { // Reset json event json_event = JSON.stringify(event); } events_list.push(JSON.parse(json_event)); } };