Configuration

Complete reference for configuring the TestRelic Playwright analytics reporter — output path, stack traces, network stats, redaction, and CI metadata.

Appium / WDIO configuration

This page covers @testrelic/playwright-analytics options. For Appium mobile testing with WebdriverIO, see Appium Configuration.

Tune what the reporter captures — stack traces, snippets, network, streaming, metadata — through the options object passed to the reporter in playwright.config.ts.

Common configuration patterns

AI Prompt — CI configuration
Update my playwright.config.ts to use @testrelic/playwright-analytics with a CI
configuration that reads build metadata from environment variables:

['@testrelic/playwright-analytics', {
  outputPath: './ci-reports/analytics.json',
  includeStackTrace: false,
  includeNetworkStats: true,
  testRunId: process.env.CI_BUILD_ID || null,
  metadata: {
    branch: process.env.CI_BRANCH,
    commit: process.env.CI_COMMIT_SHA,
    buildUrl: process.env.CI_BUILD_URL,
  }
}]

Show me the updated file.
AI Prompt — Redact sensitive data
Update my @testrelic/playwright-analytics reporter configuration to redact sensitive
data patterns from reports. Add these redact patterns:

redactPatterns: [
  /api_key=[^&\s]+/gi,
  /password=[^&\s]+/gi,
  /token=[^&\s]+/gi,
]

Show me the updated reporter configuration.

Options reference

OptionTypeDefaultDescription
outputPathstring'./test-results/analytics-timeline.json'Where to write the JSON report (embedded mode); its directory also holds the streaming report and artifacts
htmlReportPathstringoutputPath with .htmlWhere to write the HTML report
openReportbooleantrueOpen the HTML report after the run (skipped in CI)
quietbooleanfalseSuppress the console summary box
includeStackTracebooleanfalseInclude full stack traces in failure diagnostics
includeCodeSnippetsbooleantrueInclude source code snippets around the failure line
codeContextLinesnumber3Lines of context above/below the failure line
includeNetworkStatsbooleantrueTrack network requests and bytes per navigation
trackApiCallsbooleantrueTrack request (APIRequestContext) calls in the fixtures
captureRequestHeadersbooleantrueInclude request headers for tracked API calls
captureResponseHeadersbooleantrueInclude response headers for tracked API calls
captureRequestBodybooleantrueInclude the request body for tracked API calls
captureResponseBodybooleantrueInclude the response body for tracked API calls
redactHeadersstring[]['authorization', 'cookie', 'set-cookie', 'x-api-key']API header names (case-insensitive) whose values become [REDACTED]; setting it replaces the default list
redactBodyFieldsstring[]['password', 'secret', 'token', 'apiKey', 'api_key']API body fields redacted at any depth; setting it replaces the default list
apiIncludeUrls(string | RegExp)[][] (track all)Only track API calls matching these URL patterns
apiExcludeUrls(string | RegExp)[][]Skip API calls matching these patterns; takes precedence over include
includeActionStepsbooleantrueCapture Playwright test steps/actions plus assertions, video-synced
captureConsoleLogsbooleantrueCapture browser console logs (E2E) and terminal output (API) per test
captureAssertionsbooleantrueCapture expect() assertion results
includeArtifactsbooleantrueCapture screenshots, video, and trace artifacts
captureNavigationbooleantrueCapture the Test Navigation timeline; set false to drop it before upload
captureChangedFilesbooleantrueSend the paths (never contents) of files changed by the run's commit with the cloud upload
navigationTypesNavigationType[] | nullnull (all)Filter the timeline to specific navigation types, e.g. goto, navigation, link_click, form_submit, back, forward, refresh, redirect, popstate, spa_route, spa_replace, hash_change, page_load, manual_record
redactPatterns(string | RegExp)[][] (additional only)Extra patterns appended to the built-in redaction set (AWS keys, Bearer tokens, PEM private keys, credentials in URLs)
testRunIdstring | nullnull (auto UUID)Override the test run ID — useful for correlating with external CI systems
metadataRecord<string, unknown> | nullnullAttach custom metadata to the report
reportMode'streaming' | 'embedded' | 'auto''streaming'streaming writes per-test files to .testrelic-report/ (view with npx testrelic serve); embedded writes one JSON file plus a self-contained HTML file; auto picks by suite size
streamingThresholdnumber0With reportMode: 'auto', suites with at least this many tests use streaming
cloudobject—Cloud upload options — see Cloud upload

Large runs always upload

You never lose a run to an upload size limit. When a run is large, the reporter automatically sheds optional detail in tiers — console and network logs first, then API-call detail, then remaining per-test detail, and as a last resort only the run summary — so the run still uploads. Each step prints a [testrelic] WARNING line. No configuration is required.

Cloud upload

Cloud upload turns on when an API key is found. Settings are merged from, highest priority first: environment variables, the reporter's cloud options, .testrelic/testrelic-config.json (discovered by walking up from the working directory), then built-in defaults.

playwright.config.ts
['@testrelic/playwright-analytics', {
  cloud: {
    apiKey: process.env.TESTRELIC_API_KEY,
    upload: 'both',
  },
}]
cloud optionTypeDefaultDescription
apiKeystring—TestRelic API key. A '$VAR' string is read from that environment variable
endpointstring'https://platform.testrelic.ai/api/v1'Cloud API endpoint
upload'batch' | 'realtime' | 'both''batch'batch sends one payload at the end; realtime streams results as tests finish; both does both
timeoutnumber30000Per-request timeout (ms)
uploadBudgetMsnumber120000Total time budget for the upload phase (ms), so a slow network cannot hold the run open
projectNamestring—Project name, used to identify the repository when there is no git remote
uploadArtifactsbooleantrueUpload screenshots, videos, traces and visual images
artifactMaxSizeMbnumber50Per-file size limit for artifact uploads (MB)
queueMaxAgestring'7d'How long failed uploads stay queued for retry (s, m, h, d units)
queueDirectorystring'.testrelic/queue'Where failed uploads are queued

The repository is identified automatically from your git remote — no repository ID is needed. The same settings can live in .testrelic/testrelic-config.json (created by the package's postinstall outside CI); commit that file and ignore .testrelic/queue/ and .testrelic/cache/:

.testrelic/testrelic-config.json
{
  "cloud": { "apiKey": "$TESTRELIC_API_KEY", "upload": "both" },
  "testrelic-repo": { "name": "my-project" },
  "queue": { "maxAge": "7d", "directory": ".testrelic/queue" }
}

Environment variables

VariableEffect
TESTRELIC_API_KEYAPI key (overrides every other source)
TESTRELIC_CLOUD_ENDPOINTOverride the API endpoint
TESTRELIC_UPLOAD_STRATEGYbatch, realtime or both
TESTRELIC_CLOUD_TIMEOUTPer-request timeout in ms (1000–120000)
TESTRELIC_RUN_TYPETag the run as smoke, regression, nightly or ci so it lands in the matching monitoring dashboard
TESTRELIC_CLOUD_PLATFORMbrowserstack or lambdatest — link the run to a remote browser-farm session. TESTRELIC_CLOUD_BUILD_ID and TESTRELIC_CLOUD_SESSION_ID add the vendor build/session; BrowserStack and LambdaTest env vars are detected automatically

Troubleshooting

SymptomWhat to try
Very large JSON in CITurn off includeStackTrace / includeCodeSnippets, narrow navigationTypes, or disable includeNetworkStats for a CI-only profile.
Missing code around failuresSet includeCodeSnippets to true and increase codeContextLines.

Next steps

Was this page helpful?

On this page