diff --git a/.changeset/brown-ghosts-teach.md b/.changeset/brown-ghosts-teach.md new file mode 100644 index 0000000000..b67fff36a0 --- /dev/null +++ b/.changeset/brown-ghosts-teach.md @@ -0,0 +1,5 @@ +--- +'hive-apollo-router-plugin': patch +--- + +Use the correct plugin version in the User-Agent header used for Console requests diff --git a/packages/libraries/router/src/agent.rs b/packages/libraries/router/src/agent.rs index 477d245ce8..e662ff941f 100644 --- a/packages/libraries/router/src/agent.rs +++ b/packages/libraries/router/src/agent.rs @@ -1,3 +1,5 @@ +use crate::consts::PLUGIN_VERSION; + use super::graphql::OperationProcessor; use graphql_parser::schema::{parse_schema, Document}; use reqwest::Client; @@ -10,8 +12,6 @@ use std::{ use thiserror::Error; use tokio::sync::Mutex as AsyncMutex; -static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA"); - #[derive(Serialize, Debug)] pub struct Report { size: usize, @@ -299,7 +299,7 @@ impl UsageAgent { ) .header( reqwest::header::USER_AGENT, - format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")), + format!("hive-apollo-router/{}", PLUGIN_VERSION), ) .json(&report) .send() diff --git a/packages/libraries/router/src/consts.rs b/packages/libraries/router/src/consts.rs new file mode 100644 index 0000000000..9de035966b --- /dev/null +++ b/packages/libraries/router/src/consts.rs @@ -0,0 +1 @@ +pub const PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/packages/libraries/router/src/lib.rs b/packages/libraries/router/src/lib.rs index 89395180c9..c90d87cf65 100644 --- a/packages/libraries/router/src/lib.rs +++ b/packages/libraries/router/src/lib.rs @@ -1,4 +1,5 @@ mod agent; +pub mod consts; mod graphql; pub mod persisted_documents; pub mod registry; diff --git a/packages/libraries/router/src/main.rs b/packages/libraries/router/src/main.rs index a0543cd19b..c2f1f1ee70 100644 --- a/packages/libraries/router/src/main.rs +++ b/packages/libraries/router/src/main.rs @@ -1,5 +1,6 @@ // Specify the modules our binary should include -- https://twitter.com/YassinEldeeb7/status/1468680104243077128 mod agent; +mod consts; mod graphql; mod persisted_documents; mod registry; diff --git a/packages/libraries/router/src/registry.rs b/packages/libraries/router/src/registry.rs index 195c43e391..c0ab13b300 100644 --- a/packages/libraries/router/src/registry.rs +++ b/packages/libraries/router/src/registry.rs @@ -1,3 +1,4 @@ +use crate::consts::PLUGIN_VERSION; use crate::registry_logger::Logger; use anyhow::{anyhow, Result}; use sha2::Digest; @@ -24,8 +25,6 @@ pub struct HiveRegistryConfig { schema_file_path: Option, } -static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA"); - impl HiveRegistry { #[allow(clippy::new_ret_no_self)] pub fn new(user_config: Option) -> Result<()> { @@ -171,7 +170,7 @@ impl HiveRegistry { headers.insert( reqwest::header::USER_AGENT, reqwest::header::HeaderValue::from_str( - format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")).as_str(), + format!("hive-apollo-router/{}", PLUGIN_VERSION).as_str(), ) .unwrap(), );