mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
don't send empty envelopes
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const c = @import("c.zig").c;
|
const c = @import("c.zig").c;
|
||||||
|
const Value = @import("value.zig").Value;
|
||||||
|
|
||||||
/// sentry_envelope_t
|
/// sentry_envelope_t
|
||||||
pub const Envelope = opaque {
|
pub const Envelope = opaque {
|
||||||
@ -15,4 +16,10 @@ pub const Envelope = opaque {
|
|||||||
path.len,
|
path.len,
|
||||||
) != 0) return error.WriteFailed;
|
) != 0) return error.WriteFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn event(self: *Envelope) ?Value {
|
||||||
|
const val: Value = .{ .value = c.sentry_envelope_get_event(@ptrCast(self)) };
|
||||||
|
if (val.isNull()) return null;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,4 +31,8 @@ pub const Value = struct {
|
|||||||
pub fn incref(self: Value) Value {
|
pub fn incref(self: Value) Value {
|
||||||
c.sentry_value_incref(self.value);
|
c.sentry_value_incref(self.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn isNull(self: Value) bool {
|
||||||
|
return c.sentry_value_is_null(self.value) != 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -75,6 +75,9 @@ pub const Transport = struct {
|
|||||||
|
|
||||||
/// Implementation of send but we can use Zig errors.
|
/// Implementation of send but we can use Zig errors.
|
||||||
fn sendInternal(envelope: *sentry.Envelope) !void {
|
fn sendInternal(envelope: *sentry.Envelope) !void {
|
||||||
|
// If our envelope doesn't have an event then we don't do anything.
|
||||||
|
if (envelope.event() == null) return;
|
||||||
|
|
||||||
var arena = std.heap.ArenaAllocator.init(state.alloc);
|
var arena = std.heap.ArenaAllocator.init(state.alloc);
|
||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
|
Reference in New Issue
Block a user