Skip to content

server: document category const on Browser*Event schemas#260

Merged
archandatta merged 1 commit into
mainfrom
hypeship/browser-event-category
May 29, 2026
Merged

server: document category const on Browser*Event schemas#260
archandatta merged 1 commit into
mainfrom
hypeship/browser-event-category

Conversation

@archandatta
Copy link
Copy Markdown
Contributor

@archandatta archandatta commented May 29, 2026

Summary

  • Adds a category const to 27 of 30 Browser*Event documentation schemas in server/openapi.yaml.
  • Field maps 1:1 to the Category Go field on events.Event that the VM already sets on every emitted event (server/lib/events/event.go:38), so consumers can read it directly off the per-variant schema instead of falling back to the base TelemetryEvent.
  • Regenerates server/lib/oapi/oapi.go so the Go types pick up the new constants.

Source-of-truth for the const values:

Schema Category Source
Browser{Console,Network,Page,Interaction,Monitor}*Event (22) derived by prefix (console/network/page/interaction/system) matches cdpmonitor/*.go, screenshot.go, devtoolsproxy/proxy.go, monitor.go
BrowserApiCallEvent api cmd/api/api/middleware.go:67
BrowserCdpConnectEvent / BrowserCdpDisconnectEvent system lib/devtoolsproxy/proxy.go:474,491
BrowserSystemOomKillEvent system lib/sysmon/sysmon.go:180
BrowserServiceCrashedEvent system cmd/supervisord-shim/main.go:234

Skipped (left as-is, no category declared on the per-variant schema):

  • BrowserLiveViewConnectEvent / BrowserLiveViewDisconnectEvent — emitted by Neko (external)
  • BrowserCaptchaSolveResultEvent — emitted by external captcha solver

Their producers live outside this repo, so I didn't want to lock down a const without confirmation. Worth a follow-up to either declare them here (likely system for live_view; captcha is less obvious) or document them as freeform on those schemas. Wire emission for these still flows through the base TelemetryEvent schema, which already declares category with the full enum.

Companion to https://github.com/kernel/kernel/pull/2252 (kernel/kernel openapi) — same field, mirrored on the doc-only schemas here.

Test plan

  • cd server && make oapi-generate regenerates cleanly
  • cd server && go vet ./... clean
  • cd server && go build ./... clean
  • cd server && go test -race $(go list ./... | grep -v /e2e$) — all packages pass

🤖 Generated with Claude Code


Note

Low Risk
OpenAPI and generated Go type changes only; runtime category assignment is unchanged and three external-producer events are intentionally left undocumented.

Overview
Documents category on 27 per-variant Browser*Event schemas in server/openapi.yaml, each as a fixed const (console, network, page, interaction, api, or system) aligned with what the VM already puts on events.Event. server/lib/oapi/oapi.go is regenerated so typed events expose Category, enum constants, and Valid() helpers.

BrowserLiveView* and BrowserCaptchaSolveResultEvent are unchanged (no locked const) because those producers sit outside this repo.

Reviewed by Cursor Bugbot for commit a04ed01. Bugbot is set up for automated code reviews on this repo. Configure here.

Each Browser*Event schema now declares the category field that the
event already carries on the wire (set by Event.Category in
lib/events/event.go). Schemas use a const so generated clients can
narrow the category by event variant.

Coverage: 27 of 30 Browser*Event schemas. Skips live_view_connect,
live_view_disconnect, and captcha_solve_result — those are emitted by
external producers (Neko, captcha solvers), and their category values
should be confirmed with the producers before locking them down.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@archandatta archandatta marked this pull request as ready for review May 29, 2026 13:32
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 and found 1 potential issue.

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 a04ed01. Configure here.

Comment thread server/lib/oapi/oapi.go
@@ -614,6 +1004,21 @@ func (e BrowserServiceCrashedEventDataPhase) Valid() bool {
}
}

// Defines values for BrowserSystemOomKillEventCategory.
const (
System BrowserSystemOomKillEventCategory = "system"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Generated constant System breaks naming pattern, risks collision

Low Severity

The generated constant for BrowserSystemOomKillEventCategory is named just System instead of BrowserSystemOomKillEventCategorySystem, which is the pattern followed by all 26 other category constants (e.g., BrowserServiceCrashedEventCategorySystem, BrowserCdpConnectEventCategorySystem). This happens because oapi-codegen's name deduplication strips the suffix when the type name already ends with the CamelCase'd enum value. The bare System export in the oapi package is a latent collision risk and inconsistent with the rest of the generated API surface. A workaround in the OpenAPI spec (e.g., adjusting the schema name) or an output-options override in the codegen config could produce a more specific name.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a04ed01. Configure here.

@firetiger-agent
Copy link
Copy Markdown

Monitoring Plan: Add category Required Field to Browser Event Schemas

What this PR does: Formalizes browser telemetry event categorization by documenting the category constant for each event type in the OpenAPI schema — grouping events into api, console, network, page, and system buckets. This is a schema codegen update with no behavioral logic changes.

Intended effect:

  • API error rate: baseline ~48,000–49,000 errors/hr (active hours); confirmed if rate stays within ±6% post-deploy — no new error patterns should appear
  • Telemetry stream events: no change in volume or format expected; confirmed if StreamTelemetryEvents endpoint continues serving without validation errors

Risks:

  • Schema validation rejects existing events — if validation enforces the new required: category field and any producer isn't sending it, events could be rejected; alert if API errors spike >10% above baseline (~54,000/hr) in first 2 hours post-deploy
  • Go struct serialization panicCategory field added to event structs; if any code path creates structs without populating it, could cause 5xx panics; alert on any new FATAL logs or unexpected 500 responses in the telemetry streaming path
  • Client deserialization breakage — strict consumers receiving the new field may fail; alert if any consumer-side "unknown field" or "invalid response" error pattern appears in API logs

Status updates will be posted automatically on this PR as monitoring progresses.

View monitor

@archandatta archandatta requested review from Sayan- and rgarcia May 29, 2026 13:39
@archandatta archandatta merged commit 59d3d4e into main May 29, 2026
18 of 22 checks passed
@archandatta archandatta deleted the hypeship/browser-event-category branch May 29, 2026 15:29
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