mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
sentry init uses proper cache dir, sets tags
This commit is contained in:
@ -14,6 +14,10 @@ pub fn captureEvent(value: Value) ?UUID {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
pub fn setTag(key: []const u8, value: []const u8) void {
|
||||
c.sentry_set_tag_n(key.ptr, key.len, value.ptr, value.len);
|
||||
}
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ pub const GlobalState = struct {
|
||||
internal_os.fixMaxFiles();
|
||||
|
||||
// Initialize our crash reporting.
|
||||
try sentry.init();
|
||||
try sentry.init(self.alloc);
|
||||
|
||||
// const sentrylib = @import("sentry");
|
||||
// if (sentrylib.captureEvent(sentrylib.Value.initMessageEvent(
|
||||
|
@ -1,7 +1,9 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const build_config = @import("build_config.zig");
|
||||
const sentry = @import("sentry");
|
||||
const internal_os = @import("os/main.zig");
|
||||
|
||||
const log = std.log.scoped(.sentry);
|
||||
|
||||
@ -12,7 +14,11 @@ const log = std.log.scoped(.sentry);
|
||||
/// crash reports and logs, but we only store them locally (see Transport).
|
||||
/// It is up to the user to grab the logs and manually send them to us
|
||||
/// (or they own Sentry instance) if they want to.
|
||||
pub fn init() !void {
|
||||
pub fn init(gpa: Allocator) !void {
|
||||
var arena = std.heap.ArenaAllocator.init(gpa);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
const transport = sentry.Transport.init(&Transport.send);
|
||||
errdefer transport.deinit();
|
||||
|
||||
@ -20,17 +26,32 @@ pub fn init() !void {
|
||||
errdefer sentry.c.sentry_options_free(opts);
|
||||
sentry.c.sentry_options_set_release_n(
|
||||
opts,
|
||||
build_config.version_string,
|
||||
build_config.version_string.ptr,
|
||||
build_config.version_string.len,
|
||||
);
|
||||
sentry.c.sentry_options_set_transport(opts, @ptrCast(transport));
|
||||
|
||||
// Determine the Sentry cache directory.
|
||||
const cache_dir = try internal_os.xdg.cache(alloc, .{ .subdir = "ghostty/sentry" });
|
||||
sentry.c.sentry_options_set_database_path_n(
|
||||
opts,
|
||||
cache_dir.ptr,
|
||||
cache_dir.len,
|
||||
);
|
||||
|
||||
// Debug logging for Sentry
|
||||
sentry.c.sentry_options_set_debug(opts, @intFromBool(true));
|
||||
|
||||
if (sentry.c.sentry_init(opts) != 0) {
|
||||
log.warn("failed to initialize sentry", .{});
|
||||
}
|
||||
// Setup some basic tags that we always want present
|
||||
sentry.setTag("app-runtime", @tagName(build_config.app_runtime));
|
||||
sentry.setTag("font-backend", @tagName(build_config.font_backend));
|
||||
sentry.setTag("renderer", @tagName(build_config.renderer));
|
||||
|
||||
// Initialize
|
||||
if (sentry.c.sentry_init(opts) != 0) return error.SentryInitFailed;
|
||||
|
||||
// Log some information about sentry
|
||||
log.debug("sentry initialized database={s}", .{cache_dir});
|
||||
}
|
||||
|
||||
/// Process-wide deinitialization of our Sentry client. This ensures all
|
||||
|
Reference in New Issue
Block a user