All documentation

Instrument / guide 04

Playwright agent observability

Add the @tracify/playwright reporter to trace browser-agent test runs, actions, assertions and trace.zip artifacts in Tracify, without replacing Playwright.

Copy or share.

Playwright agent observability

Use the @tracify/playwright reporter when an agent acts through a browser and you need the test outcome beside the agent's model, tool, and API spans. Playwright remains the runner and the owner of trace.zip; Tracify receives the execution evidence and links back to the artifact.

Install from the workspace

The adapter is currently maintained in this repository and is not presented as a public registry package until its first release. From the repository root:

bash
npm install ./packages/playwright @playwright/test

Set TRACIFY_API_KEY in the CI environment, then register the reporter:

ts
import { defineConfig } from "@playwright/test";
import TracifyReporter from "@tracify/playwright";

export default defineConfig({
  reporter: [[TracifyReporter, {
    environment: "ci",
    release: process.env.GITHUB_SHA,
    traceArtifactUrl: process.env.PLAYWRIGHT_TRACE_URL,
  }]],
});

Event contract

The reporter maps Playwright lifecycle data into the existing Tracify span shape. The first contract covers:

  • run and ci_metadata for the test run and CI context.
  • test_step for test cases and Playwright steps.
  • assertion for expectation steps.
  • browser_action, network_request, and console_error for fixture or helper instrumentation.
  • screenshot and trace_artifact for references to captured artifacts.

Use the reporter's record* helpers when a fixture observes an event that the Playwright reporter API does not expose directly:

ts
reporter.recordBrowserAction("submit order", { selector: "button[type=submit]" });
reporter.recordNetworkRequest("POST /api/orders", { statusCode: 201 });
reporter.recordConsoleError("Unhandled page error", { page: "/checkout" });

Each event preserves its status, timing, parent relationship, metadata, and error details. traceArtifactUrl links the original Playwright artifact; Tracify does not reimplement the Playwright Trace Viewer.

Data boundaries

The adapter sends event metadata and artifact references by default. It does not upload screenshot bytes, request bodies, or arbitrary test attachments. Review the existing project redaction and retention settings before adding sensitive values to event metadata.