mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Generate non-persisted iid if app_path is null
This commit is contained in:
@@ -60,7 +60,11 @@ fn TelemetryT(comptime P: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn getOrCreateId(app_dir_path_: ?[]const u8) ?[36]u8 {
|
fn getOrCreateId(app_dir_path_: ?[]const u8) ?[36]u8 {
|
||||||
const app_dir_path = app_dir_path_ orelse return null;
|
const app_dir_path = app_dir_path_ orelse {
|
||||||
|
var id: [36]u8 = undefined;
|
||||||
|
uuidv4(&id);
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
var buf: [37]u8 = undefined;
|
var buf: [37]u8 = undefined;
|
||||||
var dir = std.fs.openDirAbsolute(app_dir_path, .{}) catch |err| {
|
var dir = std.fs.openDirAbsolute(app_dir_path, .{}) catch |err| {
|
||||||
@@ -146,6 +150,10 @@ test "telemetry: getOrCreateId" {
|
|||||||
std.fs.cwd().deleteFile("/tmp/" ++ IID_FILE) catch {};
|
std.fs.cwd().deleteFile("/tmp/" ++ IID_FILE) catch {};
|
||||||
const id3 = getOrCreateId("/tmp/").?;
|
const id3 = getOrCreateId("/tmp/").?;
|
||||||
try testing.expectEqual(false, std.mem.eql(u8, &id1, &id3));
|
try testing.expectEqual(false, std.mem.eql(u8, &id1, &id3));
|
||||||
|
|
||||||
|
const id4 = getOrCreateId(null).?;
|
||||||
|
try testing.expectEqual(false, std.mem.eql(u8, &id1, &id4));
|
||||||
|
try testing.expectEqual(false, std.mem.eql(u8, &id3, &id4));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "telemetry: sends event to provider" {
|
test "telemetry: sends event to provider" {
|
||||||
|
|||||||
Reference in New Issue
Block a user