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/tricky-mangos-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Add user-agent to CDP connections
8 changes: 7 additions & 1 deletion packages/core/lib/v3/understudy/cdp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// lib/v3/understudy/cdp.ts
import WebSocket from "ws";
import type { Protocol } from "devtools-protocol";
import { STAGEHAND_VERSION } from "../../version";

/**
* CDP transport & session multiplexer
Expand Down Expand Up @@ -97,7 +98,12 @@ export class CdpConnection implements CDPSessionLike {
}

static async connect(wsUrl: string): Promise<CdpConnection> {
const ws = new WebSocket(wsUrl);
// Include User-Agent header for server-side observability and version tracking
const ws = new WebSocket(wsUrl, {
headers: {
"User-Agent": `Stagehand/${STAGEHAND_VERSION}`,
Comment thread
miguelg719 marked this conversation as resolved.
},
});
await new Promise<void>((resolve, reject) => {
ws.once("open", () => resolve());
ws.once("error", (e) => reject(e));
Expand Down