Skip to content

Commit f09b184

Browse files
miguelg719chromiebotChromie Botclaude
authored
Add user-agent (#1646)
# why For observability into stagehand sessions # what changed - Added a custom `Stagehand/<version>` user agent header to CDP connections. # test plan <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Set a custom User-Agent on CDP WebSocket connections: Stagehand/<version> using STAGEHAND_VERSION. This helps servers identify the client for logging and compatibility. <sup>Written for commit 4a0c58d. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1646">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: Chromie <miguel@browserbase.com> Co-authored-by: Chromie Bot <chromie@browserbase.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 653268b commit f09b184

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/tricky-mangos-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
Add user-agent to CDP connections

packages/core/lib/v3/understudy/cdp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// lib/v3/understudy/cdp.ts
22
import WebSocket from "ws";
33
import type { Protocol } from "devtools-protocol";
4+
import { STAGEHAND_VERSION } from "../../version";
45

56
/**
67
* CDP transport & session multiplexer
@@ -97,7 +98,12 @@ export class CdpConnection implements CDPSessionLike {
9798
}
9899

99100
static async connect(wsUrl: string): Promise<CdpConnection> {
100-
const ws = new WebSocket(wsUrl);
101+
// Include User-Agent header for server-side observability and version tracking
102+
const ws = new WebSocket(wsUrl, {
103+
headers: {
104+
"User-Agent": `Stagehand/${STAGEHAND_VERSION}`,
105+
},
106+
});
101107
await new Promise<void>((resolve, reject) => {
102108
ws.once("open", () => resolve());
103109
ws.once("error", (e) => reject(e));

0 commit comments

Comments
 (0)