Extendd UserAgent with system information collected at runtime
This commit is contained in:
@@ -10,6 +10,7 @@ use nym_bin_common::build_information::{BinaryBuildInformation, BinaryBuildInfor
|
||||
pub struct UserAgent {
|
||||
pub application: String,
|
||||
pub version: String,
|
||||
pub system: Option<String>,
|
||||
pub platform: String,
|
||||
pub git_commit: String,
|
||||
}
|
||||
@@ -17,10 +18,11 @@ pub struct UserAgent {
|
||||
impl fmt::Display for UserAgent {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let abbreviated_commit = self.git_commit.chars().take(7).collect::<String>();
|
||||
let system_information = self.system.clone().unwrap_or_else(|| "unknown".to_string());
|
||||
write!(
|
||||
f,
|
||||
"{}/{}/{}/{}",
|
||||
self.application, self.version, self.platform, abbreviated_commit
|
||||
"{}/{}/{}/{}/{}",
|
||||
self.application, self.version, system, self.platform, abbreviated_commit
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -38,6 +40,7 @@ impl From<BinaryBuildInformation> for UserAgent {
|
||||
UserAgent {
|
||||
application: build_info.binary_name.to_string(),
|
||||
version: build_info.build_version.to_string(),
|
||||
system: None,
|
||||
platform: build_info.cargo_triple.to_string(),
|
||||
git_commit: build_info.commit_sha.to_string(),
|
||||
}
|
||||
@@ -49,6 +52,7 @@ impl From<BinaryBuildInformationOwned> for UserAgent {
|
||||
UserAgent {
|
||||
application: build_info.binary_name,
|
||||
version: build_info.build_version,
|
||||
system: None,
|
||||
platform: build_info.cargo_triple,
|
||||
git_commit: build_info.commit_sha,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user