Skip to content

Add screenshot capture with configurable always/on_error/never modes#1

Open
bigtiger wants to merge 1 commit into
mainfrom
feature-screenshots
Open

Add screenshot capture with configurable always/on_error/never modes#1
bigtiger wants to merge 1 commit into
mainfrom
feature-screenshots

Conversation

@bigtiger
Copy link
Copy Markdown
Contributor

Summary

  • Adds a screenshots: option to Perchfall::Client#run, accepting :always, :on_error (default), or :never
  • Captures a PNG via Playwright and embeds it as base64 in the report under report.screenshots
  • Excludes screenshot data from to_h/to_json by default; opt-in via include_screenshots: true to prevent accidental leakage of sensitive page content into logs and serialised payloads

Details

The Node script accepts a --screenshot flag and returns the captured PNG as base64 in the JSON output under the screenshots key. On the on_error path, capture runs inside a .catch(() => null) guard so a screenshot failure never obscures the underlying page error.

The safe-by-default serialisation decision mirrors the existing SSRF protections: screenshot data from authenticated pages can contain session tokens, PII, or internal tooling state. Callers must explicitly pass include_screenshots: true to include it in output.

See ADR 0016 for full rationale, transport overhead considerations, and the screenshot_path: file-based transport flagged as future work.

Test plan

  • bundle exec rspec passes (194 examples, 0 failures, 100% line coverage)
  • screenshots: :always — verify report.screenshots is a non-nil base64 string on a successful check
  • screenshots: :on_error — verify report.screenshots is nil on a clean check and non-nil when the page fails
  • screenshots: :never — verify report.screenshots is always nil
  • report.to_h excludes screenshots key by default
  • report.to_h(include_screenshots: true) includes the key
  • report.to_json(include_screenshots: true) round-trips correctly through JSON.parse
  • Invalid screenshots: value raises ArgumentError with a clear message

@bigtiger bigtiger requested a review from jonsgreen March 18, 2026 14:42
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.

1 participant