crash: try to attach dimensions to the crash report

This commit is contained in:
Mitchell Hashimoto
2024-09-01 10:29:53 -07:00
parent 37577630ac
commit f0916d58e8
3 changed files with 112 additions and 0 deletions

View File

@@ -14,6 +14,14 @@ pub fn captureEvent(value: Value) ?UUID {
return uuid;
}
pub fn setContext(key: []const u8, value: Value) void {
c.sentry_set_context_n(key.ptr, key.len, value.value);
}
pub fn removeContext(key: []const u8) void {
c.sentry_remove_context_n(key.ptr, key.len);
}
pub fn setTag(key: []const u8, value: []const u8) void {
c.sentry_set_tag_n(key.ptr, key.len, value.ptr, value.len);
}

View File

@@ -24,6 +24,22 @@ pub const Value = struct {
) };
}
pub fn initObject() Value {
return .{ .value = c.sentry_value_new_object() };
}
pub fn initString(value: []const u8) Value {
return .{ .value = c.sentry_value_new_string_n(value.ptr, value.len) };
}
pub fn initBool(value: bool) Value {
return .{ .value = c.sentry_value_new_bool(@intFromBool(value)) };
}
pub fn initInt32(value: i32) Value {
return .{ .value = c.sentry_value_new_int32(value) };
}
pub fn decref(self: Value) void {
c.sentry_value_decref(self.value);
}
@@ -35,4 +51,14 @@ pub const Value = struct {
pub fn isNull(self: Value) bool {
return c.sentry_value_is_null(self.value) != 0;
}
/// sentry_value_set_by_key_n
pub fn setByKey(self: Value, key: []const u8, value: Value) void {
_ = c.sentry_value_set_by_key_n(
self.value,
key.ptr,
key.len,
value.value,
);
}
};