Skip to content

Browser: Playwright API metrics#316473

Draft
jruales wants to merge 10 commits into
mainfrom
jruales/2026.05-playwright-code-logs
Draft

Browser: Playwright API metrics#316473
jruales wants to merge 10 commits into
mainfrom
jruales/2026.05-playwright-code-logs

Conversation

@jruales
Copy link
Copy Markdown
Contributor

@jruales jruales commented May 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 14, 2026 18:41
@jruales jruales changed the title Playwright API metrics Browser: Playwright API metrics May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds telemetry for the Integrated Browser run_playwright_code tool to capture Playwright page API usage, success, deferral, duration, and code-size metrics.

Changes:

  • Injects telemetry into RunPlaywrightCodeTool and logs completed/failed invocations.
  • Adds pageMethodsCalled to Playwright invocation results.
  • Wraps Playwright page with a proxy to count method calls and adds a telemetry event helper.
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/electron-browser/tools/runPlaywrightCodeTool.ts Logs telemetry for Playwright code tool invocations.
src/vs/platform/browserView/node/playwrightService.ts Tracks Playwright page API calls via proxy and includes counts in invocation results.
src/vs/platform/browserView/common/playwrightService.ts Extends invoke result shape with page method call counts.
src/vs/platform/browserView/common/browserViewTelemetry.ts Defines and emits the new Playwright code telemetry event.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/platform/browserView/node/playwrightService.ts:722

  • Recursively creating a fresh proxy on every object-property read changes Playwright object identity semantics (for example, page.keyboard === page.keyboard becomes false). Code that caches, compares, or uses nested API objects as map keys can behave differently under this proxy; cache proxies per target/prefix so repeated property reads return the same wrapper.
			if (value !== null && typeof value === 'object') {
				return createPageApiProxy(value as object, methodCalls, `${prefix}${prop}.`, depth + 1);
  • Files reviewed: 4/4 changed files
  • Comments generated: 4

Comment thread src/vs/platform/browserView/node/playwrightService.ts
Comment thread src/vs/platform/browserView/node/playwrightService.ts
Comment thread src/vs/platform/browserView/node/playwrightService.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread src/vs/platform/browserView/node/playwrightService.ts
const entries = Object.entries(pageMethodsCalled);
const total = entries.reduce((sum, [, count]) => sum + count, 0);
this.telemetryService.publicLog2<RunPlaywrightCodeEvent, RunPlaywrightCodeClassification>(
'integratedBrowser.tools.runPlaywrightCode.completed',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should log this from the shared service instead -- so if a call is deferred but the agent never queries for the result, it still gets logged eventually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants