Events & Activity

View as Markdown

Every run records a structured timeline. Events are the low-level record of what happened; activity is the higher-level view over the same run. Both can be listed page by page or streamed live.

List events

1const events = await bctrl.runs.events.list(runId);
2
3for await (const event of bctrl.runs.events.iter(runId)) {
4 console.log(event.time, event.type, event.status);
5}

Filter by type, status, pageId, or contextId:

1await bctrl.runs.events.list(runId, { type: "navigation" });

Valid type values: runtime.lifecycle, navigation, network.request, network.response, network.failed, console.message.

Stream events

For a live feed, use streamUrl to get a server-sent events endpoint and consume it with your SSE client of choice:

1const url = bctrl.runs.events.streamUrl(runId, { type: "console.message" });
2
3const source = new EventSource(url);
4source.onmessage = (message) => {
5 const event = JSON.parse(message.data);
6 console.log(event.type, event.name);
7};

See Streaming for the SSE consumption pattern.

Activity

1const activity = await bctrl.runs.activity.list(runId);
2
3for await (const item of bctrl.runs.activity.iter(runId)) {
4 console.log(item);
5}
6
7const liveUrl = bctrl.runs.activity.streamUrl(runId);

Next