Add experiment logs to the monitoring page #48

Merged
0950726 merged 122 commits from feat/experiment-logs into dev 2026-01-28 10:16:00 +00:00
Showing only changes of commit 96242fa6b0 - Show all commits

View File

@@ -1,5 +1,6 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
const API_BASE = "http://localhost:8000/button_pressed"; // Change depending on Pims interup agent/ correct endpoint const API_BASE_BP = "http://localhost:8000/button_pressed"; // Change depending on Pims interup agent/ correct endpoint
const API_BASE = "http://localhost:8000";
/** /**
@@ -8,7 +9,7 @@ const API_BASE = "http://localhost:8000/button_pressed"; // Change depending on
*/ */
const sendAPICall = async (type: string, context: string, endpoint?: string) => { const sendAPICall = async (type: string, context: string, endpoint?: string) => {
try { try {
const response = await fetch(`${API_BASE}${endpoint ?? ""}`, { const response = await fetch(`${API_BASE_BP}${endpoint ?? ""}`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ type, context }), body: JSON.stringify({ type, context }),
@@ -71,7 +72,7 @@ export async function playExperiment(): Promise<void> {
*/ */
export function useExperimentLogger(onUpdate?: (data: any) => void) { export function useExperimentLogger(onUpdate?: (data: any) => void) {
useEffect(() => { useEffect(() => {
const eventSource = new EventSource(`${API_BASE}`); const eventSource = new EventSource(`${API_BASE}/experiment_stream`);
eventSource.onmessage = (event) => { eventSource.onmessage = (event) => {
try { try {