mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 18:26:13 +03:00
Session class
This commit is contained in:
@ -349,6 +349,100 @@ pub const EncodedItem = struct {
|
|||||||
payload: []const u8,
|
payload: []const u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
pub const SessionStatus = enum {
|
||||||
|
// Session is healthy, will never happend crash reporting
|
||||||
|
ok,
|
||||||
|
// Session terminated normally, will never happend crash reporting
|
||||||
|
exited,
|
||||||
|
// Session crashed
|
||||||
|
crashed,
|
||||||
|
// Session exited in an abnormal state that is not crash
|
||||||
|
abnormal,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const SessionAttrs = struct {
|
||||||
|
// Sentry release ID (release)
|
||||||
|
release: []const u8,
|
||||||
|
|
||||||
|
// Sentry environment
|
||||||
|
// Feel like it should be an enum, but possible values not provided
|
||||||
|
environment: []const u8,
|
||||||
|
// Sentry docs does say it's required, but also that is not persisted
|
||||||
|
ip_address: ?[]const u8,
|
||||||
|
// Sentry docs does say it's required, but also that is not persisted
|
||||||
|
user_agent: ?[]const u8,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// A sentry session
|
||||||
|
///
|
||||||
|
/// https://develop.sentry.dev/sdk/data-model/envelope-items/#session
|
||||||
|
pub const Session = struct {
|
||||||
|
|
||||||
|
// Session start datetime string, ISO format
|
||||||
|
started: []const u8,
|
||||||
|
|
||||||
|
// Unique session id generated by the client, it can be
|
||||||
|
// empty for sessions in exited state
|
||||||
|
sid: ?[]const u8,
|
||||||
|
|
||||||
|
// Distinct id, should identify a machine or a user. It is an hash
|
||||||
|
did: ?[]const u8,
|
||||||
|
|
||||||
|
// Sequential number, logical clock, defaults to current unix
|
||||||
|
// timestamp in milliseconds
|
||||||
|
seq: ?u64,
|
||||||
|
|
||||||
|
// Timestamp of session change event, not sure of its meaning for crash handling
|
||||||
|
// Datetime string, ISO format
|
||||||
|
timestamp: ?[]const u8,
|
||||||
|
|
||||||
|
// Denotes that an event is the first recorded one for a specific session
|
||||||
|
init: ?bool = false,
|
||||||
|
|
||||||
|
// Represents the length of a session in seconds
|
||||||
|
duration: ?f64,
|
||||||
|
|
||||||
|
// The current status of the session, tracks reason of
|
||||||
|
// termination, should not be different from "crashed"
|
||||||
|
status: ?SessionStatus,
|
||||||
|
|
||||||
|
// Number of errors encountered during the session. The crash is
|
||||||
|
// always counted as an error
|
||||||
|
errors: u16,
|
||||||
|
|
||||||
|
// From the docs "The mechanism that caused the session to finish
|
||||||
|
// with an abnormal status...". If useless can be removed
|
||||||
|
abnormal_mechanism: ?[] const u8,
|
||||||
|
|
||||||
|
attrs: SessionAttrs,
|
||||||
|
|
||||||
|
pub fn decode(
|
||||||
|
alloc: Allocator,
|
||||||
|
encoded: EncodedItem,
|
||||||
|
) Item.DecodeError!Session {
|
||||||
|
_ = alloc;
|
||||||
|
_ = encoded;
|
||||||
|
|
||||||
|
std.debug.print("Decode requested correctly", .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn encode(
|
||||||
|
self: *Session,
|
||||||
|
alloc: Allocator,
|
||||||
|
) !EncodedItem {
|
||||||
|
_ = alloc;
|
||||||
|
_ = self;
|
||||||
|
|
||||||
|
std.debug.print("Encode requested correctly", .{});
|
||||||
|
|
||||||
|
return .{};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// An arbitrary file attachment.
|
/// An arbitrary file attachment.
|
||||||
///
|
///
|
||||||
/// https://develop.sentry.dev/sdk/envelopes/#attachment
|
/// https://develop.sentry.dev/sdk/envelopes/#attachment
|
||||||
|
Reference in New Issue
Block a user