mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
add additition navigate fields
This commit is contained in:
@@ -339,7 +339,6 @@ pub const Page = struct {
|
|||||||
// see Inspector.contextCreated
|
// see Inspector.contextCreated
|
||||||
pub fn navigate(self: *Page, uri: []const u8, aux_data: ?[]const u8) !void {
|
pub fn navigate(self: *Page, uri: []const u8, aux_data: ?[]const u8) !void {
|
||||||
const arena = self.arena;
|
const arena = self.arena;
|
||||||
self.session.app.telemetry.record(.{ .navigate = {} });
|
|
||||||
|
|
||||||
log.debug("starting GET {s}", .{uri});
|
log.debug("starting GET {s}", .{uri});
|
||||||
|
|
||||||
@@ -366,6 +365,11 @@ pub const Page = struct {
|
|||||||
|
|
||||||
// TODO handle fragment in url.
|
// TODO handle fragment in url.
|
||||||
|
|
||||||
|
self.session.app.telemetry.record(.{ .navigate = .{
|
||||||
|
.proxy = false,
|
||||||
|
.tls = std.ascii.eqlIgnoreCase(self.uri.scheme, "https"),
|
||||||
|
} });
|
||||||
|
|
||||||
// load the data
|
// load the data
|
||||||
var resp = try self.session.loader.get(arena, self.uri);
|
var resp = try self.session.loader.get(arena, self.uri);
|
||||||
defer resp.deinit();
|
defer resp.deinit();
|
||||||
|
|||||||
@@ -50,12 +50,8 @@ pub const LightPanda = struct {
|
|||||||
pub fn send(self: *LightPanda, iid: ?[]const u8, run_mode: RunMode, raw_event: telemetry.Event) !void {
|
pub fn send(self: *LightPanda, iid: ?[]const u8, run_mode: RunMode, raw_event: telemetry.Event) !void {
|
||||||
const event = LightPandaEvent{
|
const event = LightPandaEvent{
|
||||||
.iid = iid,
|
.iid = iid,
|
||||||
.driver = if (std.meta.activeTag(raw_event) == .navigate) "cdp" else null,
|
|
||||||
.mode = run_mode,
|
.mode = run_mode,
|
||||||
.os = builtin.os.tag,
|
.event = raw_event,
|
||||||
.arch = builtin.cpu.arch,
|
|
||||||
.version = build_info.git_commit,
|
|
||||||
.event = @tagName(std.meta.activeTag(raw_event)),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
@@ -119,9 +115,42 @@ pub const LightPanda = struct {
|
|||||||
const LightPandaEvent = struct {
|
const LightPandaEvent = struct {
|
||||||
iid: ?[]const u8,
|
iid: ?[]const u8,
|
||||||
mode: RunMode,
|
mode: RunMode,
|
||||||
driver: ?[]const u8,
|
event: telemetry.Event,
|
||||||
os: std.Target.Os.Tag,
|
|
||||||
arch: std.Target.Cpu.Arch,
|
pub fn jsonStringify(self: *const LightPandaEvent, writer: anytype) !void {
|
||||||
version: []const u8,
|
try writer.beginObject();
|
||||||
event: []const u8,
|
|
||||||
|
try writer.objectField("iid");
|
||||||
|
try writer.write(self.iid);
|
||||||
|
|
||||||
|
try writer.objectField("mode");
|
||||||
|
try writer.write(self.mode);
|
||||||
|
|
||||||
|
try writer.objectField("os");
|
||||||
|
try writer.write(builtin.os.tag);
|
||||||
|
|
||||||
|
try writer.objectField("arch");
|
||||||
|
try writer.write(builtin.cpu.arch);
|
||||||
|
|
||||||
|
try writer.objectField("version");
|
||||||
|
try writer.write(build_info.git_commit);
|
||||||
|
|
||||||
|
try writer.objectField("event");
|
||||||
|
try writer.write(@tagName(std.meta.activeTag(self.event)));
|
||||||
|
|
||||||
|
inline for (@typeInfo(telemetry.Event).Union.fields) |union_field| {
|
||||||
|
if (self.event == @field(telemetry.Event, union_field.name)) {
|
||||||
|
const inner = @field(self.event, union_field.name);
|
||||||
|
const TI = @typeInfo(@TypeOf(inner));
|
||||||
|
if (TI == .Struct) {
|
||||||
|
inline for (TI.Struct.fields) |field| {
|
||||||
|
try writer.objectField(field.name);
|
||||||
|
try writer.write(@field(inner, field.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try writer.endObject();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -93,8 +93,13 @@ fn getOrCreateId(app_dir_path_: ?[]const u8) ?[36]u8 {
|
|||||||
|
|
||||||
pub const Event = union(enum) {
|
pub const Event = union(enum) {
|
||||||
run: void,
|
run: void,
|
||||||
navigate: void,
|
navigate: Navigate,
|
||||||
flag: []const u8, // used for testing
|
flag: []const u8, // used for testing
|
||||||
|
|
||||||
|
const Navigate = struct {
|
||||||
|
tls: bool,
|
||||||
|
proxy: bool,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const NoopProvider = struct {
|
const NoopProvider = struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user