Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ pub fn get_latest_release() -> &'static Option<LatestRelease> {
}

// User Agent for Download API call
// Format: Parseable/<UID>/<version>/<commit_hash> (<OS>; <Platform>)
pub fn user_agent(uid: &Ulid) -> String {
// Format: Parseable/<UID>/<version>/<commit_hash>/<send_analytics> (<OS>; <Platform>)
pub fn user_agent(uid: &Ulid, send_analytics: bool) -> String {
analytics::refresh_sys_info();
format!(
"Parseable/{}/{}/{} ({:?}; {})",
"Parseable/{}/{}/{}/{} ({:?}; {})",
uid,
current().released_version,
current().commit_hash,
send_analytics,
System::name().unwrap_or_default(),
platform()
)
Expand Down
6 changes: 4 additions & 2 deletions src/utils/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::time::Duration;
use anyhow::anyhow;
use chrono::{DateTime, Utc};

use crate::about;
use crate::{about, parseable::PARSEABLE};

use super::uid;

Expand All @@ -32,11 +32,13 @@ pub struct LatestRelease {
}

pub async fn get_latest(deployment_id: &uid::Uid) -> Result<LatestRelease, anyhow::Error> {
let send_analytics = PARSEABLE.options.send_analytics;
let agent = reqwest::ClientBuilder::new()
.user_agent(about::user_agent(deployment_id))
.user_agent(about::user_agent(deployment_id, send_analytics))
.timeout(Duration::from_secs(8))
.build()
.expect("client can be built on this system");

let json: serde_json::Value = agent
.get("https://download.parseable.io/latest-version")
.send()
Expand Down
Loading