Skip to content

Commit e980ff6

Browse files
send analytics flag to analytics server
1 parent 4240fb5 commit e980ff6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/utils/update.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ use std::time::Duration;
2020

2121
use anyhow::anyhow;
2222
use chrono::{DateTime, Utc};
23+
use http::header;
2324

24-
use crate::about;
25+
use crate::{about, parseable::PARSEABLE};
2526

2627
use super::uid;
2728

@@ -32,11 +33,19 @@ pub struct LatestRelease {
3233
}
3334

3435
pub async fn get_latest(deployment_id: &uid::Uid) -> Result<LatestRelease, anyhow::Error> {
36+
let send_analytics = PARSEABLE.options.send_analytics.to_string();
37+
let mut headers = header::HeaderMap::new();
38+
headers.insert(
39+
"P_SEND_ANONYMOUS_USAGE_DATA",
40+
header::HeaderValue::from_str(send_analytics.as_str()).expect("valid header value"),
41+
);
3542
let agent = reqwest::ClientBuilder::new()
3643
.user_agent(about::user_agent(deployment_id))
44+
.default_headers(headers)
3745
.timeout(Duration::from_secs(8))
3846
.build()
3947
.expect("client can be built on this system");
48+
4049
let json: serde_json::Value = agent
4150
.get("https://download.parseable.io/latest-version")
4251
.send()

0 commit comments

Comments
 (0)