Skip to content

feat: add browsers telemetry events read command (kernel-go-sdk v0.70.0)#190

Open
archandatta wants to merge 3 commits into
mainfrom
archand/kernel-1338/cli-telemetry-events
Open

feat: add browsers telemetry events read command (kernel-go-sdk v0.70.0)#190
archandatta wants to merge 3 commits into
mainfrom
archand/kernel-1338/cli-telemetry-events

Conversation

@archandatta

@archandatta archandatta commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds kernel browsers telemetry events <id> — reads the paginated telemetry archive for a browser session, alongside the existing live telemetry stream.

Flags:

  • --limit (1–100, default 20) — page size
  • --all — fetch every page (walks the cursor via the SDK auto-pager); without it you get the first page
  • --since / --until (RFC-3339 timestamp or a duration like 5m)
  • --categories (repeatable; server-side filter, validated against the event category set incl. monitor)
  • -o json (newline-delimited JSON envelopes, matching telemetry stream)

Resolves the identifier (name-or-id) to a session ID via browsers.Get, same as stream. Text output is time \t seq \t [category] \t type.

SDK bump (bundled)

This bumps kernel-go-sdk v0.66.0 → v0.70.0 to pick up the telemetry Events/EventsAutoPaging surface (added when the API endpoint shipped). Bundled into this PR per the repo convention (e.g. 2c06a2c, where a feature carries the SDK bump it needs).

The bump also changed APIKeyService.Get to take a params arg, so cmd/api_keys.go (and its test fake) now pass kernel.APIKeyGetParams{} — an empty value that preserves prior behavior. Unrelated to telemetry, but required for the bump to compile.

Test coverage

Unit tests cover the single-page path: validation (nil telemetry, bad -o, unknown category), browsers.Get error surfacing, param mapping (limit/since/until/categories), multi-event emit, and JSON output.

The --all auto-paging path is not unit-tested: the SDK's OffsetPaginationAutoPager advances via GetNextPage, which requires a live request config, so a hand-built pager can't be driven in a unit test (this is the first CLI consumer of an SDK auto-pager). The loop is a thin for pager.Next() wrapper; the cursor/termination math lives in and is tested by the SDK, and end-to-end paging is exercised by the API-side staging smoke.

Test plan

  • go build ./... / go vet ./... / gofmt clean
  • go test ./... passing locally (incl. telemetry events + api_keys)
  • make lint (golangci-lint) in CI
  • Manual: events <id> happy path + headers, --categories, --since/--until, --limit, --all, -o json, unknown id → 404

archandatta and others added 2 commits June 23, 2026 19:07
Add `kernel browsers telemetry events <id>` to read the paginated
telemetry archive, alongside the existing live `telemetry stream`.
Supports --limit/--offset cursor paging, --since/--until window bounds,
repeatable --category server-side filtering, --all to walk every page,
and -o json for newline-delimited envelopes.

Requires a kernel-go-sdk release exposing the telemetry Events method;
the dependency bump lands separately after the API deploys.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address review: remove the --offset flag (it advertised an X-Next-Offset
cursor the command never emits; --all owns multi-page paging). Rename
--category to --categories to match the telemetry stream sibling, and
drop the now-inaccurate "ignored with --all"/"ignored when --offset"
help clauses. Expand the param-mapping test to cover since/until and
multi-event emit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@archandatta archandatta marked this pull request as ready for review June 24, 2026 14:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d18dca1. Configure here.

Comment thread cmd/browsers.go
telemetryEvents.Flags().String("until", "", "Window end (exclusive): RFC-3339 timestamp or duration like 5m")
telemetryEvents.Flags().StringSlice("categories", []string{}, "Filter by event category (console,network,page,interaction,control,connection,system,screenshot,captcha,monitor)")
telemetryEvents.Flags().Bool("all", false, "Fetch every page instead of just the first")
telemetryEvents.Flags().StringP("output", "o", "", "Output format: json for newline-delimited JSON envelopes")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline JSON output flag

Low Severity

The new telemetry events command registers -o/--output with a hand-rolled StringP and custom help instead of addJSONOutputFlag, which centralizes the flag and Output format: json for raw API response wording across CLI commands.

Fix in Cursor Fix in Web

Triggered by learned rule: Use shared JSON output helpers in CLI commands

Reviewed by Cursor Bugbot for commit d18dca1. Configure here.

Comment thread cmd/browsers_telemetry_test.go Outdated
The telemetry events command needs the Events/EventsAutoPaging surface
added in v0.70.0. Adapt the command's category param to the generated
[]string type and fix the stale validation-error assertion. The bump
also changes APIKeyService.Get to take a params arg, so update the
api_keys command and its fake to pass APIKeyGetParams (empty preserves
prior behavior).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@archandatta archandatta changed the title feat: add browsers telemetry events read command feat: add browsers telemetry events read command (kernel-go-sdk v0.70.0) Jun 25, 2026
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​kernel/​kernel-go-sdk@​v0.66.0 ⏵ v0.70.072 +1100100100100

View full report

@archandatta archandatta requested review from Sayan- and rgarcia June 25, 2026 13:15

@rgarcia rgarcia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed from correctness/qa and CLI surface consistency. make build and make test passed, but I think these need changes before merge.

QA / correctness

  • cmd/browsers_telemetry.go:273 — multi-category filtering does not work in real QA. With a telemetry archive containing console, network, and page events, --categories console and --categories network each returned rows, but both --categories console,network and repeated --categories console --categories network returned zero rows. This needs a live/SDK-level fix and a test that covers more than one category.

  • cmd/browsers_telemetry.go:263--limit accepts invalid values even though the help says 1-100. In QA, --limit -1 exited 0 and returned the default page, and --limit 101 also exited 0. Please validate the range client-side or loosen the help text.

  • cmd/browsers_telemetry.go:267--since 1s returned Internal_error: failed to read telemetry events with exit 1 on an otherwise valid session, while an empty --until 1h window returned zero rows cleanly. This may be API-side duration handling, but the CLI exposes it directly, so the command should either validate supported duration forms or the endpoint needs to stop returning a 500 for an empty/recent window.

CLI surface consistency

  • cmd/browsers.go:2757telemetry events omits the --types filter that exists on sibling telemetry stream. Since both commands expose telemetry event envelopes, users will expect the same category/type filtering shape unless there is a clear reason documented in help/docs.

  • cmd/browsers.go:2754 — the command uses list-like paging language (--limit, “per page”, “first page”) but exposes no --offset/cursor, and the NDJSON output only prints event items. That makes the default mode non-pageable, unlike the rest of the CLI list surfaces that expose --limit + --offset. Consider exposing a continuation mechanism or framing this as “latest N events” with --all for archive dumps.

  • README.md:316 — the README telemetry section documents telemetry stream but not the new recorded telemetry events command. Since this adds a user-facing CLI surface, please document the command, flags, output mode, and how it differs from live streaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants