Removes telemetry dependence on notifications

This commit is contained in:
Nikolay Govorov
2026-02-03 16:43:25 +00:00
parent d318fe24b8
commit dbf18b90a7
5 changed files with 23 additions and 56 deletions

View File

@@ -5,7 +5,6 @@ const Allocator = std.mem.Allocator;
const log = @import("../log.zig");
const App = @import("../App.zig");
const Notification = @import("../Notification.zig");
const uuidv4 = @import("../id.zig").uuidv4;
const IID_FILE = "iid";
@@ -63,32 +62,6 @@ fn TelemetryT(comptime P: type) type {
log.warn(.telemetry, "record error", .{ .err = err, .type = @tagName(std.meta.activeTag(event)) });
};
}
// Called outside of `init` because we need a stable pointer for self.
// We care page_navigate events, but those happen on a Browser's
// notification. This doesn't exist yet, and there isn't only going to
// be 1, browsers come and go.
// What we can do is register for the `notification_created` event.
// In the callback for that, `onNotificationCreated`, we can then register
// for the browser-events that we care about.
pub fn register(self: *Self, notification: *Notification) !void {
if (self.disabled) {
return;
}
try notification.register(.notification_created, self, onNotificationCreated);
}
fn onNotificationCreated(ctx: *anyopaque, new: *Notification) !void {
return new.register(.page_navigate, ctx, onPageNavigate);
}
fn onPageNavigate(ctx: *anyopaque, data: *const Notification.PageNavigate) !void {
const self: *Self = @ptrCast(@alignCast(ctx));
self.record(.{ .navigate = .{
.proxy = false,
.tls = std.ascii.startsWithIgnoreCase(data.url, "https://"),
} });
}
};
}