Module recorder

Module recorder 

Source
Expand description

Browser session recording and debugging tools.

Captures CDP events, network traffic, and performance metrics for debugging failed scraping runs, analysing anti-bot detection, and performance profiling.

§Configuration

VariableDefaultDescription
STYGIAN_RECORD_SESSIONfalseEnable recording automatically
STYGIAN_RECORD_DIR./recordingsOutput directory

§HAR export

Records all network requests in the HTTP Archive (HAR 1.2) format, which can be opened in Chrome DevTools, Fiddler, or analysed programmatically.

§Example

use stygian_browser::{BrowserPool, BrowserConfig, WaitUntil};
use stygian_browser::recorder::{SessionRecorder, RecorderConfig};
use std::time::Duration;

let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
let mut page = handle.browser().expect("valid browser").new_page().await?;

let mut recorder = SessionRecorder::start(RecorderConfig::default());
page.navigate("https://example.com", WaitUntil::Selector("body".to_string()), Duration::from_secs(30)).await?;

// Log a CDP event manually
recorder.record_event("Page.loadEventFired", serde_json::json!({"timestamp": 1234.5}));

// Export HAR
recorder.stop();
recorder.export_har("session.har")?;

Structs§

CdpEvent
A single recorded CDP event.
Har
HAR 1.2 root object.
HarCreator
HAR creator metadata.
HarEntry
A single HAR network entry (request + response).
HarHeader
A single HTTP header.
HarLog
HAR log.
HarQueryParam
Query string parameter.
HarRequest
A HAR HTTP request.
HarResponse
A HAR HTTP response.
HarTimings
HAR timing breakdown.
RecorderConfig
Configuration for a SessionRecorder.
SessionRecorder
Records CDP events and network traffic during a browser session.

Functions§

is_recording_enabled
Returns true if session recording is enabled via STYGIAN_RECORD_SESSION.