<commit_before>importScripts('./common.js');
importScripts('./eventsource.js');

var sse;
const connections = [];

onconnect = function(e) {
    var port = e.ports[0];
    connections.push(port);
    port.onmessage = function (event) {
        if (!sse && event.data.sseURL) {
            sse = connectSSE(event.data.sseURL, event.data.headAuthKey, event.data.headAuthValue);
            sse.onmessage = function(evt) {
                // if ack get UUID
                if (evt.data.indexOf('ACK: ') === 0) {
                    return;
                }
                let jsonEvent = JSON.parse(evt.data);

                connections.forEach(p => {
                   p.postMessage(jsonEvent);
                });
                return;
            };
        }
    };
};<commit_msg>feat(ui): add log for shared worker activity (#3004)<commit_after>importScripts('./common.js');
importScripts('./eventsource.js');

var sse;
const connections = [];
var lastEventData;
var nbEvents = 0;
onconnect = function(e) {
    var port = e.ports[0];
    connections.push(port);
    port.onmessage = function (event) {
        if (!sse && event.data.sseURL) {
            sse = connectSSE(event.data.sseURL, event.data.headAuthKey, event.data.headAuthValue);
            sse.onmessage = function(evt) {
                // if ack get UUID
                if (evt.data.indexOf('ACK: ') === 0) {
                    return;
                }
                let jsonEvent = JSON.parse(evt.data);
                nbEvents++;
                lastEventData = new Date();
                connections.forEach(p => {
                   p.postMessage(jsonEvent);
                });
                return;
            };
        }
    };
};

setInterval(() => {
    console.log('Last Event: ', lastEventData);
    console.log('Total events: ', nbEvents);
}, 10000);
{'fraction_non_alphanumeric': 0.1416982152514873, 'fraction_numerical': 0.0075716603569497025, 'mean_word_length': 1.6695526695526695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2999248', 'n_tokens_mistral': 561, 'n_tokens_neox': 532, 'n_words': 100}