Svelte: Restore analytics over started processes

This commit is contained in:
Alessandro Pignotti 2024-10-15 12:03:32 +02:00
parent 6ca6cf58a0
commit 930fc96242
3 changed files with 27 additions and 2 deletions

View file

@ -14,6 +14,7 @@
import { introMessage, errorMessage } from '$lib/messages.js' import { introMessage, errorMessage } from '$lib/messages.js'
export let configObj = null; export let configObj = null;
export let processCallback = null;
var term = new Terminal({cursorBlink:true, convertEol:true, fontFamily:"monospace", fontWeight: 400, fontWeightBold: 700}); var term = new Terminal({cursorBlink:true, convertEol:true, fontFamily:"monospace", fontWeight: 400, fontWeightBold: 700});
var cx = null; var cx = null;
@ -22,6 +23,7 @@
var linkAddon = new WebLinksAddon(); var linkAddon = new WebLinksAddon();
term.loadAddon(linkAddon); term.loadAddon(linkAddon);
var cxReadFunc = null; var cxReadFunc = null;
var processCount = 0;
function writeData(buf, vt) function writeData(buf, vt)
{ {
if(vt != 1) if(vt != 1)
@ -78,6 +80,12 @@
const display = document.getElementById("display"); const display = document.getElementById("display");
display.style.zIndex = 10; display.style.zIndex = 10;
} }
function handleProcessCreated()
{
processCount++;
if(processCallback)
processCallback(processCount);
}
async function initCheerpX() async function initCheerpX()
{ {
// TODO: Check for SAB support // TODO: Check for SAB support
@ -142,6 +150,7 @@
} }
cx.registerCallback("cpuActivity", cpuCallback); cx.registerCallback("cpuActivity", cpuCallback);
cx.registerCallback("diskActivity", hddCallback); cx.registerCallback("diskActivity", hddCallback);
cx.registerCallback("processCreated", handleProcessCreated);
term.scrollToBottom(); term.scrollToBottom();
cxReadFunc = cx.setCustomConsole(writeData, term.cols, term.rows); cxReadFunc = cx.setCustomConsole(writeData, term.cols, term.rows);
const display = document.getElementById("display"); const display = document.getElementById("display");

View file

@ -1,6 +1,14 @@
<script> <script>
import WebVM from '$lib/WebVM.svelte'; import WebVM from '$lib/WebVM.svelte';
import * as configObj from '/config_terminal' import * as configObj from '/config_terminal'
function handleProcessCreated(processCount)
{
// Log the first 5 processes, to get an idea of the level of interaction from the public
if(processCount <= 5)
{
plausible(`Process started: ${processCount}`);
}
}
</script> </script>
<WebVM configObj={configObj} /> <WebVM configObj={configObj} processCallback={handleProcessCreated} />

View file

@ -1,6 +1,14 @@
<script> <script>
import WebVM from '$lib/WebVM.svelte'; import WebVM from '$lib/WebVM.svelte';
import * as configObj from '/config_public_alpine' import * as configObj from '/config_public_alpine'
function handleProcessCreated(processCount)
{
// Log only the first process, as a proxy for successful startup
if(processCount == 1)
{
plausible("Alpine init");
}
}
</script> </script>
<WebVM configObj={configObj} /> <WebVM configObj={configObj} processCallback={handleProcessCreated} />