Expand description
Privacy-aware portable traces (issue #87).
A trace is one versioned directory holding a manifest, an ordered timeline, per-checkpoint DOM snapshots and the mutation batches between them.
Rust records traces natively (issue #108): start_trace writes the same
bundle JavaScript writes, record for record, write_trace_viewer adds the
same offline viewer, and TraceOptions::links streams the same Links
Notation export. record_scenario keeps a bundle only when the work it
wraps fails, as retain-on-failure does in the JavaScript test runner.
Every in-page function comes from the shared assets.json,
so the page runs the very code JavaScript runs. Rust reads traces too. See
docs/feature-parity.md for the current state of each language.
§Example
use std::sync::Arc;
use browser_commander::core::EngineAdapter;
use browser_commander::traces::{
read_trace, start_trace, write_trace_viewer, AdapterTracePage, TraceLinksOptions,
TraceOptions,
};
let mut options = TraceOptions::new("./traces/run");
options.mode = "continuous".into();
options.links = Some(TraceLinksOptions {
output: "./traces/run.lino".into(),
include: None,
});
let recorder = start_trace(Arc::new(AdapterTracePage::new(page)), options).await?;
recorder.checkpoint("after-login").await?;
let result = recorder.stop().await?;
write_trace_viewer(&result.path)?;
let trace = read_trace(&result.path)?;
for checkpoint in &trace.checkpoints {
println!("{:?}", checkpoint.name);
}Re-exports§
pub use reader::diff_control_state;pub use reader::parse_ndjson;pub use reader::read_trace;pub use reader::ControlChange;pub use reader::ControlChangeKind;pub use reader::ParsedNdjson;pub use reader::Trace;pub use reader::TraceCheckpoint;pub use reader::TraceError;pub use schema::assert_readable_manifest;pub use schema::sequence_name;pub use schema::TraceCheckpointReason;pub use schema::TraceCounts;pub use schema::TraceDropReason;pub use schema::TraceEvent;pub use schema::TraceFiles;pub use schema::TraceLiveState;pub use schema::TraceManifest;pub use schema::TraceMode;pub use schema::TraceMutationKind;pub use schema::TraceOutcome;pub use schema::TraceReplaySupport;pub use schema::TRACE_EVENT_SOURCES;pub use schema::TRACE_FORMAT;pub use schema::TRACE_SCHEMA_VERSION;pub use bundle::iso_timestamp;pub use bundle::TraceClock;pub use bundle::TraceLimits;pub use bundle::TraceProblem;pub use bundle::TraceRecordError;pub use jsonfmt::Json;pub use jsonfmt::JsonObject;pub use links::trace_links;pub use links::write_trace_links;pub use links::TraceExportError;pub use links::TraceLinksOptions;pub use page::AdapterTracePage;pub use page::TracePage;pub use recorder::start_trace;pub use recorder::TraceCheckpointOptions;pub use recorder::TraceDomOptions;pub use recorder::TraceFailure;pub use recorder::TraceInitialCheckpoint;pub use recorder::TraceOptions;pub use recorder::TraceRecorder;pub use recorder::TraceResult;pub use recorder::TraceScreenshots;pub use recorder::TraceStopOptions;pub use recorder::DEFAULT_CAPTURE_TIMEOUT_MS;pub use redaction::normalize_privacy_options;pub use redaction::redact_url;pub use redaction::redact_value;pub use redaction::NormalizedPrivacy;pub use redaction::RedactCallback;pub use redaction::RedactContext;pub use redaction::TracePrivacyOptions;pub use redaction::REDACTED;pub use retention::finish_scenario_trace;pub use retention::record_scenario;pub use retention::resolve_trace_setting;pub use retention::scenario_trace_options;pub use retention::start_scenario_trace;pub use retention::trace_output_path;pub use retention::ScenarioRun;pub use retention::ScenarioTrace;pub use retention::TraceSetting;pub use retention::TEST_TRACE_MODES;pub use retention::TRACE_BUNDLE_SUFFIX;pub use viewer::render_trace_viewer;pub use viewer::write_trace_viewer;pub use viewer::DEFAULT_MAX_INLINE_BYTES;
Modules§
- assets
- The in-page code and viewer shared with JavaScript (issue #108).
- bundle
- Writing a trace bundle to disk (issue #108).
- identity
- Who a trace record belongs to (issue #93).
- jsonfmt
- JSON that keeps the key order JavaScript would keep.
- links
- A Links Notation view of a trace bundle (issue #94).
- mutation_
stream - The continuous half of a trace (issue #93), in Rust (issue #108).
- page
- What a trace recorder needs from the page it records (issue #108).
- reader
- Reading a trace bundle (issue #87).
- recorder
- The trace recorder (issue #87), native in Rust (issue #108).
- redaction
- Privacy rules for recorded traces (issue #87).
- retention
- Keep a run’s trace only when the run failed (issue #108).
- schema
- The portable browser trace format, as Rust knows it (issue #87).
- viewer
- The offline trace viewer (issue #87), written by Rust.