watch: ingest sink (--notify ingest) posting events to a push ingest endpoint

This commit is contained in:
CRTkafa 2026-10-23 15:30:18 +08:00
parent 5b3905679b
commit 487e138f9d
9 changed files with 236 additions and 18 deletions

View file

@ -1,5 +1,5 @@
// `storebound watch`: store events for every app on this machine, for people and agents.
// storebound watch [--dir <folder>] [--every 15m] [--notify os,ntfy,telegram,webhook] [--once] [--dry] [--json]
// storebound watch [--dir <folder>] [--every 15m] [--notify os,ntfy,telegram,webhook,ingest] [--once] [--dry] [--json]
// storebound watch test [--notify ...] [--dry] sends one test event to every configured sink
// Apps: the machine's app folder list (~/.storebound/projects.json: folders and store-only apps, the same list as the
// desktop app) or --dir for one folder. Each pass reads release state (like `release status`), crash / ANR health
@ -29,7 +29,7 @@ import {
import { configuredSinks, parseNotify, sendEvent, sinkConfig, type SinkConfig } from './lib/watch-sinks';
const TAG = 'watch';
const USAGE = 'usage: storebound watch [--dir <folder>] [--every 15m] [--notify os,ntfy,telegram,webhook] [--once] [--dry] [--json] | watch test [--notify ...] [--dry]';
const USAGE = 'usage: storebound watch [--dir <folder>] [--every 15m] [--notify os,ntfy,telegram,webhook,ingest] [--once] [--dry] [--json] | watch test [--notify ...] [--dry]';
export const HEALTH_EVERY_MS = 60 * 60_000;
const MIN_EVERY_MS = 5 * 60_000;
const MAX_BACKOFF_MS = 4 * 60 * 60_000;
@ -150,7 +150,7 @@ function emit(e: WatchEvent, args: Args): void {
async function testCmd(args: Args): Promise<void> {
const c = chosenSinks(args);
const names = configuredSinks(c);
if (!names.length) { warn(TAG, 'no sink configured: set STOREBOUND_NTFY_TOPIC, STOREBOUND_TELEGRAM_TOKEN + STOREBOUND_TELEGRAM_CHAT, STOREBOUND_WEBHOOK_URL, or pass --notify os (docs/watch.md)'); process.exitCode = 1; return; }
if (!names.length) { warn(TAG, 'no sink configured: set STOREBOUND_NTFY_TOPIC, STOREBOUND_TELEGRAM_TOKEN + STOREBOUND_TELEGRAM_CHAT, STOREBOUND_WEBHOOK_URL, STOREBOUND_INGEST_URL + STOREBOUND_INGEST_TOKEN_FILE, or pass --notify os (docs/watch.md)'); process.exitCode = 1; return; }
const e = testEvent();
emit(e, args);
if (args.has('dry')) { done(TAG, `dry run: would send the test event to ${names.join(', ')}`); return; }