diff --git a/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/down.sql b/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/down.sql new file mode 100644 index 000000000..031117ea9 --- /dev/null +++ b/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/down.sql @@ -0,0 +1,4 @@ +ALTER TABLE reported_errors + DROP COLUMN timestamp; +ALTER TABLE reported_errors + DROP COLUMN version; diff --git a/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/up.sql b/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/up.sql new file mode 100644 index 000000000..257c4ebe3 --- /dev/null +++ b/coordinator/migrations/2024-05-09-051816_add_timestamp_and_version_to_error_logs/up.sql @@ -0,0 +1,5 @@ +-- Your SQL goes here +ALTER TABLE reported_errors + ADD COLUMN timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE reported_errors + ADD COLUMN version TEXT NOT NULL DEFAULT '<2.3.1'; diff --git a/coordinator/src/db/reported_errors.rs b/coordinator/src/db/reported_errors.rs index 8533cc123..4ecac3c48 100644 --- a/coordinator/src/db/reported_errors.rs +++ b/coordinator/src/db/reported_errors.rs @@ -7,6 +7,7 @@ use xxi_node::commons::ReportedError; struct NewReportedError { trader_pubkey: String, error: String, + version: String, } pub(crate) fn insert(conn: &mut PgConnection, error: ReportedError) -> QueryResult<()> { @@ -22,6 +23,7 @@ impl From for NewReportedError { Self { trader_pubkey: value.trader_pk.to_string(), error: value.msg, + version: value.version.unwrap_or("<2.3.1".to_owned()), } } } diff --git a/coordinator/src/schema.rs b/coordinator/src/schema.rs index acd032a54..4453c9803 100644 --- a/coordinator/src/schema.rs +++ b/coordinator/src/schema.rs @@ -389,6 +389,8 @@ diesel::table! { id -> Int4, trader_pubkey -> Text, error -> Text, + timestamp -> Timestamptz, + version -> Text, } } diff --git a/crates/xxi-node/src/commons/reported_error.rs b/crates/xxi-node/src/commons/reported_error.rs index b32ed571d..72de6f0f5 100644 --- a/crates/xxi-node/src/commons/reported_error.rs +++ b/crates/xxi-node/src/commons/reported_error.rs @@ -6,4 +6,5 @@ use serde::Serialize; pub struct ReportedError { pub trader_pk: PublicKey, pub msg: String, + pub version: Option, } diff --git a/mobile/native/src/report_error.rs b/mobile/native/src/report_error.rs index 0a243f898..d6a1792ee 100644 --- a/mobile/native/src/report_error.rs +++ b/mobile/native/src/report_error.rs @@ -5,6 +5,8 @@ use crate::state::get_or_create_tokio_runtime; use reqwest::Url; pub fn report_error_to_coordinator(error: &E) { + let version = env!("CARGO_PKG_VERSION").to_string(); + let client = reqwest_client(); let pk = get_node().inner.info.pubkey; @@ -23,6 +25,7 @@ pub fn report_error_to_coordinator(error: &E) { .json(&xxi_node::commons::ReportedError { trader_pk: pk, msg: error_string, + version: Some(version), }) .send() .await