Documentation
¶
Index ¶
- func RenderTraceHTML(entries []TraceEntry, sourcePath string) string
- func WriteHAR(h *HAR, path string) error
- type HAR
- type HARContent
- type HARCreator
- type HAREntry
- type HARLog
- type HARPage
- type HARRequest
- type HARResponse
- type HARTimings
- type Recorder
- type RecorderOp
- type RecorderOpts
- type TraceEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderTraceHTML ¶
func RenderTraceHTML(entries []TraceEntry, sourcePath string) string
RenderTraceHTML produces a self-contained HTML viewer of a trace. No external deps; opens directly in a browser.
Types ¶
type HAR ¶
type HAR struct {
Log HARLog `json:"log"`
}
HAR follows the HAR 1.2 specification (W3C Web Performance Working Group). It's intentionally minimal: we only populate what NetworkEntry knows about, leaving the optional fields (headers, cookies, content text) empty so parsers treat them as "not captured" rather than "empty".
type HARContent ¶
HARContent carries the payload summary (size, MIME).
type HARCreator ¶
HARCreator identifies the tool that recorded the trace.
type HAREntry ¶
type HAREntry struct {
PageRef string `json:"pageref,omitempty"`
StartedDateTime string `json:"startedDateTime"`
Time int64 `json:"time"`
Request HARRequest `json:"request"`
Response HARResponse `json:"response"`
Cache struct{} `json:"cache"`
Timings HARTimings `json:"timings"`
}
HAREntry is one network request + response.
type HARLog ¶
type HARLog struct {
Version string `json:"version"`
Creator HARCreator `json:"creator"`
Pages []HARPage `json:"pages"`
Entries []HAREntry `json:"entries"`
}
HARLog is the top-level container.
type HARPage ¶
type HARPage struct {
StartedDateTime string `json:"startedDateTime"`
ID string `json:"id"`
Title string `json:"title"`
}
HARPage groups entries by the top-level navigation that produced them.
type HARRequest ¶
type HARRequest struct {
Method string `json:"method"`
URL string `json:"url"`
HTTPVersion string `json:"httpVersion"`
Headers []string `json:"headers"`
QueryString []string `json:"queryString"`
HeadersSize int `json:"headersSize"`
BodySize int `json:"bodySize"`
}
HARRequest describes the outgoing request.
type HARResponse ¶
type HARResponse struct {
Status int `json:"status"`
StatusText string `json:"statusText"`
HTTPVersion string `json:"httpVersion"`
Headers []string `json:"headers"`
Cookies []string `json:"cookies"`
Content HARContent `json:"content"`
RedirectURL string `json:"redirectURL"`
HeadersSize int `json:"headersSize"`
BodySize int `json:"bodySize"`
}
HARResponse describes the incoming response.
type HARTimings ¶
type HARTimings struct {
Send int `json:"send"`
Wait int64 `json:"wait"`
Receive int `json:"receive"`
}
HARTimings models per-phase durations. We only know the total so we put it on "wait".
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder injects a JS listener into the page, coalesces typing, and emits JSONL ops to w. It uses Runtime.addBinding so the JS → Go channel is clean (no console-log pollution).
Call Start() once then either Wait() (blocks until done) or Stop().
func NewRecorder ¶
NewRecorder creates a recorder but does not start it.
func (*Recorder) Done ¶
func (r *Recorder) Done() <-chan struct{}
Done returns a channel closed when the recorder stops.
type RecorderOp ¶
RecorderOp is a single user-action op, ready to be written as JSONL. The schema matches the agentRequest format consumed by `ghostchrome agent`.
type RecorderOpts ¶
RecorderOpts configures a Recorder session.
type TraceEntry ¶
type TraceEntry struct {
TS int64 `json:"ts"`
Op string `json:"op"`
Args map[string]any `json:"args,omitempty"`
OK bool `json:"ok"`
Outcome string `json:"outcome,omitempty"`
DurationMs int64 `json:"duration_ms"`
Summary string `json:"summary,omitempty"`
Error string `json:"error,omitempty"`
Shot string `json:"shot,omitempty"`
}
TraceEntry is one line of a ghostchrome MCP session trace (JSONL).