Add user agent to quickinstall stats report

This commit is contained in:
Félix Saparelli 2022-02-16 11:20:27 +13:00
parent 6faa9f8129
commit d3f8802514
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474

View file

@ -8,6 +8,7 @@ use crate::{download, remote_exists, PkgFmt};
const BASE_URL: &str = "https://github.com/alsuren/cargo-quickinstall/releases/download"; const BASE_URL: &str = "https://github.com/alsuren/cargo-quickinstall/releases/download";
const STATS_URL: &str = "https://warehouse-clerk-tmp.vercel.app/api/crate"; const STATS_URL: &str = "https://warehouse-clerk-tmp.vercel.app/api/crate";
const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
pub struct QuickInstall { pub struct QuickInstall {
package: String, package: String,
@ -61,7 +62,12 @@ impl QuickInstall {
pub async fn report(&self) -> Result<(), anyhow::Error> { pub async fn report(&self) -> Result<(), anyhow::Error> {
info!("Sending installation report to quickinstall (anonymous)"); info!("Sending installation report to quickinstall (anonymous)");
remote_exists(&self.stats_url(), Method::HEAD).await?; reqwest::Client::builder()
.user_agent(USER_AGENT)
.build()?
.request(Method::HEAD, &self.stats_url())
.send()
.await?;
Ok(()) Ok(())
} }
} }