Skip to content

Commit 37774b9

Browse files
committed
Add event workflows and queue inspection capabilities
1 parent 3a2b77c commit 37774b9

File tree

6 files changed

+651
-69
lines changed

6 files changed

+651
-69
lines changed

docs/000-v1-plan.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
Deliver an ergonomic CLI that surfaces Plausible Analytics capabilities to humans and LLMs, while respecting rate limits, juggling multiple accounts, and enabling queued API execution.
55

66
## Current Status — 2025-10-29
7-
- ✅ Foundations in place: repo scaffolding, account store (file-backed), Plausible client (sites + stats aggregate), rate limiter scaffold, queue/worker, baseline CLI commands (`status`, `sites list`, `stats aggregate`, `events template`, `accounts` CRUD), docs/LLM artefacts, CI wiring (latest on `main` @ a38358b).
8-
- ⏳ Features to extend: events `send/import`, stats `timeseries` & `breakdown`, queue `inspect/drain`, additional Plausible endpoint coverage (sites CRUD, events POST), daily budget configurability, secure keyring fallback.
9-
- 🔬 Test gaps: integration coverage via `assert_cmd`, expanded HTTP mocks (sites CRUD, events POST), JSON snapshot assertions, rate-limit exhaustion/backpressure scenarios.
7+
- ✅ Foundations in place: repo scaffolding, account store (file-backed), Plausible client (sites + stats aggregate/timeseries/breakdown + events send), rate limiter scaffold, queue/worker with inspect/drain, CLI surface (`status`, `sites list`, `stats aggregate/timeseries/breakdown`, `events template/send/import`, `accounts` CRUD), docs/LLM artefacts, CI wiring (latest on `main` @ 3a2b77c).
8+
- ⏳ Features to extend: stats `realtime`, sites CRUD/reset/delete, queue retry/backoff controls, daily budget configurability, secure keyring fallback, telemetry export.
9+
- 🔬 Test gaps: full CLI integration coverage via `assert_cmd` + JSON snapshots, expanded HTTP mocks (sites CRUD, realtime), backpressure + large import cases, keyring mock coverage.
1010
- 🚀 Distribution polish pending: GitHub release workflow, `cargo install` docs, Homebrew tap automation, tagged release + changelog.
11-
- 🧭 Next sprint focus: close remaining CLI surface + persistence polish, then broaden tests before first public release.
11+
- 🧭 Next sprint focus: persistence polish (daily budget + keyring), extend site/event surface, then harden integration tests before release packaging.
1212

1313
## Release Scope
1414
- Sites, Stats, Events API coverage.
@@ -83,9 +83,9 @@ gantt
8383

8484
### 6. CLI Commands & Output
8585
- ✅ Sites `list`; ⏳ `create/update/reset/delete`.
86-
- ✅ Stats `aggregate`; ⏳ `timeseries/breakdown/realtime` with shared flags.
87-
- ✅ Events `template`; ⏳ `send/import`.
88-
- Queue `inspect/drain`.
86+
- ✅ Stats `aggregate/timeseries/breakdown`; ⏳ `realtime` with shared flags.
87+
- ✅ Events `template/send/import`.
88+
- Queue `inspect/drain`.
8989
- ✅ Status (reports account, limits, queue stats, API health).
9090
- ✅ Formatters: tables (human), JSON (machine).
9191
- ⏳ Snapshot tests with `insta` or `similar`.
@@ -147,19 +147,18 @@ gantt
147147
- ⏳ Post-release checklist: publish crate or instructions, Homebrew tap update.
148148

149149
## Next Implementation Priorities (TDD-First)
150-
1. **Stats timeseries/breakdown**
151-
- Red tests: extend `client` module mocks to capture new endpoints, add CLI integration snapshots (human + JSON).
152-
- Green: implement API calls, queue intents, CLI wiring, output rendering, ensure rate-limit weights captured.
153-
2. **Events send/import workflows**
154-
- Red tests: event payload validation unit tests, CLI integration for `send` (stdin + flags) and `import` (NDJSON reader with `--dry-run`), worker interactions verifying queue submission.
155-
- Green: implement request builders, streaming uploads, background processing, success/failure telemetry.
156-
- Refactor: share schema templates between docs and runtime.
157-
3. **Queue management commands**
158-
- Red tests: queue inspection snapshots demonstrating ordering, drain command ensuring telemetry updates.
159-
- Green: introspection APIs on queue, CLI commands, optional `--json`.
160-
4. **Rate limit daily budget & keyring integration**
150+
1. **Sites CRUD & stats realtime**
151+
- Red tests: HTTP mocks for site create/update/reset/delete and realtime visitors; CLI integration snapshots (table + JSON).
152+
- Green: extend client endpoints, queue intents, confirmation prompts, output renderers.
153+
2. **Rate limit daily budget & keyring integration**
161154
- Red tests: ledger persistence with configurable daily caps, platform keyring mock verifying fallback logic.
162155
- Green: configuration plumbing, CLI flags/environment overrides, migration script for existing users.
156+
3. **CLI integration & snapshot test harness**
157+
- Red tests: `assert_cmd` coverage for happy-path commands, JSON/table snapshot assertions, rate-limit exhaustion scenarios.
158+
- Green: add fixture helpers, wire into CI, document how to refresh snapshots.
159+
4. **Queue resilience & telemetry**
160+
- Red tests: retry/backoff semantics, failure reporting, queue status metrics export.
161+
- Green: implement retry policy, expose metrics in `status` and `queue inspect` output.
163162
5. **Distribution pipeline**
164163
- Red tests: check GitHub workflow via `cargo xtask` smoke (or script).
165164
- Green: publish workflow, Homebrew tap formula generation, README install section refinements.

docs/architeture.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
- Expose machine-readable JSON outputs and human-readable table narratives.
88

99
## Status Snapshot — 2025-10-29
10-
- ✅ Implemented: account store (file-backed) with CRUD, Plausible client (sites list, stats aggregate), rate limiter with hourly ledger, queue + telemetry, baseline CLI commands (`status`, `sites list`, `stats aggregate`, `events template`, `accounts` subcommands), documentation set, CI pipeline.
11-
- ⏳ In progress: extend Plausible client (stats `timeseries/breakdown`, sites CRUD, events POST), enrich queue commands, implement events workflows, add integration tests & snapshot coverage, support daily budget overrides and secure keyring/OS credential fallback.
10+
- ✅ Implemented: account store (file-backed) with CRUD, Plausible client (sites list, stats aggregate/timeseries/breakdown, events send), rate limiter with hourly ledger, queue + telemetry + inspect/drain snapshotting, CLI commands (`status`, `sites list`, `stats aggregate/timeseries/breakdown`, `events template/send/import`, `accounts` subcommands), documentation set, CI pipeline.
11+
- ⏳ In progress: extend Plausible client (sites CRUD/reset/delete, stats realtime, advanced events batching), integration tests & CLI snapshots, daily budget overrides, secure keyring/OS credential fallback, queue retry/backoff controls.
1212
- 🚀 Pending release tasks: distribution automation (GitHub releases, Homebrew tap), versioning, `plausible doctor`, TDD expansion before v1 tag.
1313

1414
## API Surface Summary
@@ -53,19 +53,19 @@
5353

5454
### `plausible stats`
5555
-`aggregate` – returns KPI metrics; supports `--metric` repeatable flags.
56-
- `timeseries` – emits chronologically sorted rows; optional `--json` or `--csv`.
57-
- `breakdown` – slices by dimensions with pagination; handles `--dimension` values.
56+
- `timeseries` – emits chronologically sorted rows; optional `--json` or `--csv`.
57+
- `breakdown` – slices by dimensions with pagination; handles `--dimension` values.
5858
-`realtime` – fetch visitors currently on site.
5959
- Shared flags: `--site`, `--period|--date`, `--filters`, `--props`, `--format`.
6060

6161
### `plausible events`
62-
- `send` – post events from CLI or piped JSON.
63-
- `import` – batch read newline-delimited events with optional `--dry-run`.
62+
- `send` – post events from CLI (`--data/--file/--stdin`) with optional domain override.
63+
- `import` – batch read newline-delimited events with optional `--dry-run`.
6464
-`template` – prints example payload for copy/paste or LLM usage.
6565

6666
### `plausible queue`
67-
- `drain`force worker to process queued jobs.
68-
- `inspect` – display pending requests, retry counts, and ETA per job.
67+
- `drain`wait until the background worker finishes all pending jobs.
68+
- `inspect` – display pending/in-flight jobs with timestamps (JSON/table).
6969

7070
### `plausible status`
7171
- Display current account, API health, queued job counts, remaining hourly/daily budget, last reset timestamp.

0 commit comments

Comments
 (0)