Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cdp-lifecycle-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/browse-cli": patch
---

`browse cdp` now also calls `Page.setLifecycleEventsEnabled` whenever the Page domain is enabled, so consumers receive `Page.lifecycleEvent` notifications (`init`, `commit`, `DOMContentLoaded`, `load`, `firstPaint`, `firstContentfulPaint`, `networkAlmostIdle`, `networkIdle`, etc.) in addition to `Page.frameNavigated`. `--pretty` mode formats lifecycle events with the milestone name. No effect on consumers that pass `--domain` without `Page`.
17 changes: 17 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,18 @@ program
} else {
sendCDP(ws, `${domain}.enable`, {}, sessionId);
}

// Page.enable does not emit Page.lifecycleEvent on its own; it requires
// a separate opt-in. Enable it so consumers see DOMContentLoaded, load,
// firstPaint, networkIdle, etc.
if (domain === "Page") {
sendCDP(
ws,
"Page.setLifecycleEventsEnabled",
{ enabled: true },
sessionId,
);
}
}
}

Expand Down Expand Up @@ -2822,6 +2834,11 @@ program
if (url) line += ` ${url}`;
break;
}
case "Page.lifecycleEvent": {
const name = (params?.name as string) ?? "";
if (name) line += ` ${name}`;
break;
}
case "Target.attachedToTarget": {
const info = params?.targetInfo as
| { type?: string; url?: string }
Expand Down
Loading