diff --git a/package.json b/package.json index 45976d25..af5bd559 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "start": "npm run build && npx serve", "serve": "npx serve", "build": "node scripts/build-dist.mjs", - "build:css": "npx tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify", + "build:css": "tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify", "build:beacon:bundle": "node scripts/build-beacon.mjs", "build:beacon": "npm run build:beacon:bundle && npm run lint:inline-styles", "ci:beacon": "npm run build:beacon", diff --git a/scripts/agent/telemetry-aggregator.mjs b/scripts/agent/telemetry-aggregator.mjs index 615799b2..33541709 100644 --- a/scripts/agent/telemetry-aggregator.mjs +++ b/scripts/agent/telemetry-aggregator.mjs @@ -147,19 +147,26 @@ function collectGenericLogs(filepath, sourceName) { for (const line of lines) { // Simple heuristic for generic logs: look for "Error:" or "Exception:" // and capture following lines that look like stack traces (start with 'at ' or are indented) + // Also support bracketed log levels like [ERROR], [FAIL], [CRITICAL], [WARN] - const isErrorStart = /Error:|Exception:|FAIL|CRITICAL/.test(line); + const errorMatch = line.match(/(?:\[\s*(?:ERROR|FAIL|CRITICAL|EXCEPTION|WARN|WARNING)\s*\])|(?:\b(?:Error|Exception|Warning):)|(?:\b(?:FAIL|CRITICAL)\b)/i); + const isErrorStart = !!errorMatch; const isStackLine = /^\s+at /.test(line) || /^\s+/.test(line); // Indented lines often follow errors if (isErrorStart) { if (currentError) { errors.push(currentError); } + + let severity = 'High'; + if (line.match(/CRITICAL/i)) severity = 'Critical'; + else if (line.match(/WARN|WARNING/i)) severity = 'Medium'; + currentError = { source: sourceName, title: sanitize(line.trim()), details: [sanitize(line.trim())], - severity: 'High' + severity: severity }; } else if (currentError && isStackLine) { currentError.details.push(sanitize(line.trim())); diff --git a/tests/app-batch-fetch-profiles.test.mjs b/tests/app-batch-fetch-profiles.test.mjs index 243b861f..95463f71 100644 --- a/tests/app-batch-fetch-profiles.test.mjs +++ b/tests/app-batch-fetch-profiles.test.mjs @@ -55,11 +55,9 @@ test("batchFetchProfiles handles fast and failing relays", async () => { const originalWriteRelays = Array.isArray(nostrClient.writeRelays) ? [...nostrClient.writeRelays] : nostrClient.writeRelays; - // Make sure to backup readRelays too const originalReadRelays = Array.isArray(nostrClient.readRelays) ? [...nostrClient.readRelays] : nostrClient.readRelays; - const originalPool = nostrClient.pool; const poolListCalls = []; @@ -67,9 +65,7 @@ test("batchFetchProfiles handles fast and failing relays", async () => { nostrClient.relays = [FAST_RELAY, FAIL_RELAY]; nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY]; nostrClient.writeRelays = [FAST_RELAY, FAIL_RELAY]; - // Mock readRelays to match relays, avoiding duplicate/extra queries if the implementation prioritizes them nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY]; - nostrClient.pool = { list: (relays, filters) => { poolListCalls.push({ relays, filters });