mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
chore: add session-loss diagnostics
This commit is contained in:
1 parent
f06a514bd2
commit
b449be1544
19 files changed
+907
-32
No files matched your search
@@ -58,6 +58,10 @@ pub enum EventKind {
|
||||
BrowserDisconnected,
|
||||
#[serde(rename = "browser.connected")]
|
||||
BrowserConnected,
|
||||
/// Structured diagnostics emitted by locally instrumented extension
|
||||
/// builds. Production peers may ignore this event safely.
|
||||
#[serde(rename = "browser.diagnostic")]
|
||||
BrowserDiagnostic,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -256,6 +260,27 @@ mod tests {
|
||||
assert_eq!(frame.event, EventKind::SystemHeartbeat);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_diagnostic_event_frame_round_trips_from_extension_shape() {
|
||||
let wire = serde_json::json!({
|
||||
"event": "browser.diagnostic",
|
||||
"payload": {
|
||||
"schema_version": 1,
|
||||
"worker_boot_id": "worker-1",
|
||||
"entries": [{ "event": "extension.worker.started" }]
|
||||
}
|
||||
});
|
||||
let frame: EventFrame = serde_json::from_value(wire).unwrap();
|
||||
assert_eq!(frame.event, EventKind::BrowserDiagnostic);
|
||||
assert_eq!(
|
||||
frame
|
||||
.payload
|
||||
.get("worker_boot_id")
|
||||
.and_then(|value| value.as_str()),
|
||||
Some("worker-1")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn session_user_interrupt_serialises_as_snake_case() {
|
||||
let v = serde_json::to_value(EventKind::SessionUserInterrupt).unwrap();
|
||||
|
||||
Reference in new issue
Block a user