From 47cffb8819931c7b363489223a959d47318bccb8 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 26 Jun 2026 11:46:09 +0800 Subject: [PATCH 1/6] telemetry: Optimize the payload size, add navigation type First, this adds 1 small piece of data to the navigate event: whether the navigate was a page, frame or popup. It also adds a session id, but as far as I'm concerned, this isn't "new" information, or any new tracking/insight into users. Between the iid and the "run" event, a "session" was always trackable. By giving it an explicit value, we can shrink the size of all other messes. This change reduces the telemetry payload by ~70% (despite the extra nav field). I'm hoping this might remove a reason some people would consider turning it off. It hits a /v2/ endpoint. The changes: 1 - A header is the first message in a session and contains all of the static data, as well as a session id 2 - Every event is encoded as an array, [$SID, "event-type, params...] ``` {"sid":"92e98210a141f497","iid":"$UUID","mode":"fetch","os":"macos","arch":"aarch64","version":"$VERSION","proxy":false} ["92e98210a141f497","run"] ["92e98210a141f497","nav",false,"page"] ``` (the driver=cdp field was removed from nav, because it was always cdp). Some notes for the server: 1 - The server can tell a header from an event based on the first character. 2 - The SID is 8 bytes, enough to be unique, but not globally unique. The iid + sid + time window is how a events for the same SID can be grouped. 3 - A valid event is always an array of 2+ items, index 0 = SID, index 1 = type Although positional data isn't expressive, it's still extendable. The 4 events: run, no parameters (mostly just used to flush the header now) ["sid", "run"] // nav, tls, page/popup/iframe ["sid","nav",true,"page"] // bof, # of lost telemetry events ["sid","bof",42] // llm, provider, model (nullable) ["sid","llm","anthropic","claude"] --- src/browser/Frame.zig | 25 +++--- src/telemetry/lightpanda.zig | 154 +++++++++++++++++++++++++++++------ src/telemetry/telemetry.zig | 5 +- 3 files changed, 146 insertions(+), 38 deletions(-) diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig index 4f0207366..2d5526506 100644 --- a/src/browser/Frame.zig +++ b/src/browser/Frame.zig @@ -652,13 +652,7 @@ pub fn navigate(self: *Frame, request_url: [:0]const u8, opts: NavigateOpts) !vo .timestamp = timestamp(.monotonic), }); - // Record telemetry for navigation - session.browser.app.telemetry.record(.{ - .navigate = .{ - .tls = false, // about:blank and blob: are not TLS - .proxy = session.browser.app.config.httpProxy() != null, - }, - }); + self.recordNavigateTelemetry(false); session.notification.dispatch(.frame_navigated, &.{ .req_id = req_id, @@ -738,10 +732,7 @@ pub fn navigate(self: *Frame, request_url: [:0]const u8, opts: NavigateOpts) !vo }); // Record telemetry for navigation - session.browser.app.telemetry.record(.{ .navigate = .{ - .tls = std.ascii.startsWithIgnoreCase(self.url, "https://"), - .proxy = session.browser.app.config.httpProxy() != null, - } }); + self.recordNavigateTelemetry(std.ascii.startsWithIgnoreCase(self.url, "https://")); session.navigation._current_navigation_kind = opts.kind; @@ -767,6 +758,18 @@ pub fn navigate(self: *Frame, request_url: [:0]const u8, opts: NavigateOpts) !vo }; } +fn recordNavigateTelemetry(self: *Frame, tls: bool) void { + self._session.browser.app.telemetry.record(.{ .navigate = .{ + .tls = tls, + .context = if (self.parent != null) + .iframe + else if (self.window._opener != null) + .popup + else + .page, + } }); +} + // Navigation can happen in many places, such as executing a