1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
5#[serde(rename_all = "camelCase")]
6pub struct Session {
7 pub id: String,
8 pub session_name: Option<String>,
9 pub service_name: String,
10 pub service_version: Option<String>,
11 pub app_identifier: Option<String>,
12 pub pid: Option<i64>,
13 pub started_at: String,
14 pub ended_at: Option<String>,
15 pub schema_version: i64,
16 pub auditaur_version: Option<String>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
20#[serde(rename_all = "camelCase")]
21pub struct LogRecord {
22 pub session_id: String,
23 pub timestamp_unix_nanos: i64,
24 pub observed_timestamp_unix_nanos: Option<i64>,
25 pub severity_text: Option<String>,
26 pub severity_number: Option<i64>,
27 pub body: Option<String>,
28 pub body_json: Option<Value>,
29 pub trace_id: Option<String>,
30 pub span_id: Option<String>,
31 pub scope_name: Option<String>,
32 pub scope_version: Option<String>,
33 pub attributes: Value,
34 pub source: TelemetrySource,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
38#[serde(rename_all = "camelCase")]
39pub struct SpanRecord {
40 pub session_id: String,
41 pub trace_id: String,
42 pub span_id: String,
43 pub parent_span_id: Option<String>,
44 pub name: String,
45 pub kind: Option<String>,
46 pub start_time_unix_nanos: i64,
47 pub end_time_unix_nanos: Option<i64>,
48 pub status_code: Option<String>,
49 pub status_message: Option<String>,
50 pub scope_name: Option<String>,
51 pub scope_version: Option<String>,
52 pub attributes: Value,
53 pub source: TelemetrySource,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
57#[serde(rename_all = "camelCase")]
58pub struct FrontendError {
59 pub session_id: String,
60 pub timestamp_unix_nanos: i64,
61 pub message: String,
62 pub stack: Option<String>,
63 pub filename: Option<String>,
64 pub line_number: Option<i64>,
65 pub column_number: Option<i64>,
66 pub error_type: Option<String>,
67 pub trace_id: Option<String>,
68 pub span_id: Option<String>,
69 pub window_label: Option<String>,
70 pub attributes: Value,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
74#[serde(rename_all = "camelCase")]
75pub struct TauriIpcCall {
76 pub session_id: String,
77 pub timestamp_unix_nanos: i64,
78 pub duration_ms: Option<f64>,
79 pub command: String,
80 pub status: String,
81 pub error_message: Option<String>,
82 pub trace_id: Option<String>,
83 pub span_id: Option<String>,
84 pub window_label: Option<String>,
85 pub args_json: Option<Value>,
86 pub args_redacted: bool,
87 pub result_summary: Option<String>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
91#[serde(rename_all = "camelCase")]
92pub struct TauriEventRecord {
93 pub session_id: String,
94 pub timestamp_unix_nanos: i64,
95 pub event_name: String,
96 pub direction: String,
97 pub target: Option<String>,
98 pub trace_id: Option<String>,
99 pub span_id: Option<String>,
100 pub window_label: Option<String>,
101 pub payload_summary: Option<String>,
102 pub payload_json: Option<Value>,
103 pub payload_redacted: bool,
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
107#[serde(rename_all = "camelCase")]
108pub struct TauriWindowState {
109 pub session_id: String,
110 pub timestamp_unix_nanos: i64,
111 pub window_label: String,
112 pub webview_label: Option<String>,
113 pub url: Option<String>,
114 pub title: Option<String>,
115 pub focused: Option<bool>,
116 pub visible: Option<bool>,
117 pub width: Option<f64>,
118 pub height: Option<f64>,
119 pub scale_factor: Option<f64>,
120 pub attributes: Value,
121}
122
123#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
124#[serde(rename_all = "snake_case")]
125pub enum TelemetrySource {
126 Frontend,
127 Backend,
128 Plugin,
129 ThirdPartyOtel,
130}
131
132impl TelemetrySource {
133 pub fn as_str(self) -> &'static str {
134 match self {
135 Self::Frontend => "frontend",
136 Self::Backend => "backend",
137 Self::Plugin => "plugin",
138 Self::ThirdPartyOtel => "third_party_otel",
139 }
140 }
141
142 pub fn from_storage(value: &str) -> Self {
143 match value {
144 "frontend" => Self::Frontend,
145 "backend" => Self::Backend,
146 "plugin" => Self::Plugin,
147 "third_party_otel" => Self::ThirdPartyOtel,
148 _ => Self::ThirdPartyOtel,
149 }
150 }
151}