diff --git a/clients/cli/src/analytics.rs b/clients/cli/src/analytics.rs index 2bde0fe..a1e04c8 100644 --- a/clients/cli/src/analytics.rs +++ b/clients/cli/src/analytics.rs @@ -1,4 +1,4 @@ -use crate::config::{analytics_token, analytics_api_secret}; +use crate::config::{analytics_id, analytics_api_key}; use chrono::Datelike; use chrono::Timelike; use reqwest::header::{ACCEPT, CONTENT_TYPE}; @@ -16,8 +16,8 @@ pub fn track( ) { println!("{}", description); - let firebase_app_id = analytics_token(ws_addr_string); - let firebase_api_secret = analytics_api_secret(ws_addr_string); + let firebase_app_id = analytics_id(ws_addr_string); + let firebase_api_key = analytics_api_key(ws_addr_string); if firebase_app_id.is_empty() { return; } @@ -26,7 +26,7 @@ pub fn track( // For tracking events, we use the Firebase Measurement Protocol // Firebase is mostly designed for mobile and web apps, but for our use case of a CLI, // we can use the Measurement Protocol to track events by POST to a URL. - // The only thing that may be unexpected is that the URL we use includes a firebase secret (something we dont typically add to client code) + // The only thing that may be unexpected is that the URL we use includes a firebase key // Firebase format for properties for Mesurement protocol: // https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=firebase#payload @@ -67,7 +67,7 @@ pub fn track( .post(format!( "https://www.google-analytics.com/mp/collect?firebase_app_id={}&api_secret={}", firebase_app_id, - firebase_api_secret + firebase_api_key )) .body(format!("[{}]", body.to_string())) .header(ACCEPT, "text/plain") diff --git a/clients/cli/src/config.rs b/clients/cli/src/config.rs index 998366d..ee18bd3 100644 --- a/clients/cli/src/config.rs +++ b/clients/cli/src/config.rs @@ -1,6 +1,13 @@ -// This version is ONLY compiled when running in debug mode +// Debug version of analytics_id #[cfg(debug_assertions)] -pub fn analytics_token(_ws_addr_string: &str) -> String { +pub fn analytics_id(_ws_addr_string: &str) -> String { + // Use one of the tokens in the release version if debugging analytics + return "".into(); +} + +// Debug version of analytics_api_key +#[cfg(debug_assertions)] +pub fn analytics_api_key(_ws_addr_string: &str) -> String { // Use one of the tokens in the release version if debugging analytics return "".into(); } @@ -30,15 +37,15 @@ mod firebase { pub const STAGING_APP_ID: &str = "1:222794630996:web:1758d64a85eba687eaaac1"; pub const BETA_APP_ID: &str = "1:279395003658:web:04ee2c524474d683d75ef3"; - // DUMMY VALUES FOR DEBUGGING, NOT REAL API SECRETS + // Analytics Secrets for the different environments pub const DEV_API_SECRET: &str = "85858585858585858585858585858585"; pub const STAGING_API_SECRET: &str = "85858585858585858585858585858585"; - pub const BETA_API_SECRET: &str = "85858585858585858585858585858585"; + pub const BETA_API_SECRET: &str = "gxxzKAQLSl-uYI0eKbIi_Q"; } -// // This version is ONLY compiled when running in release mode +// Release versions (existing code) #[cfg(not(debug_assertions))] -pub fn analytics_token(ws_addr_string: &str) -> String { +pub fn analytics_id(ws_addr_string: &str) -> String { // Determine the environment from the web socket string (ws_addr_string) let env = match ws_addr_string { @@ -58,7 +65,7 @@ pub fn analytics_token(ws_addr_string: &str) -> String { } #[cfg(not(debug_assertions))] -pub fn analytics_api_secret(ws_addr_string: &str) -> String { +pub fn analytics_api_key(ws_addr_string: &str) -> String { match ws_addr_string { web_socket_urls::DEV => firebase::DEV_API_SECRET.to_string(), web_socket_urls::STAGING => firebase::STAGING_API_SECRET.to_string(),