diff --git a/crates/turborepo-lib/src/commands/telemetry.rs b/crates/turborepo-lib/src/commands/telemetry.rs index 583697fabd7d9..fa9a961bb6e76 100644 --- a/crates/turborepo-lib/src/commands/telemetry.rs +++ b/crates/turborepo-lib/src/commands/telemetry.rs @@ -38,7 +38,7 @@ pub fn configure( base: &mut CommandBase, telemetry: CommandEventBuilder, ) { - let config = TelemetryConfig::new(); + let config = TelemetryConfig::with_default_config_path(); let mut config = match config { Ok(config) => config, Err(e) => { diff --git a/crates/turborepo-telemetry/src/config.rs b/crates/turborepo-telemetry/src/config.rs index 9c04cd1349ce2..a7f09f1d041ab 100644 --- a/crates/turborepo-telemetry/src/config.rs +++ b/crates/turborepo-telemetry/src/config.rs @@ -54,8 +54,12 @@ pub struct TelemetryConfig { } impl TelemetryConfig { - pub fn new() -> Result { + pub fn with_default_config_path() -> Result { let config_path = get_config_path()?; + TelemetryConfig::new(config_path) + } + + pub fn new(config_path: AbsoluteSystemPathBuf) -> Result { debug!("Telemetry config path: {}", config_path); if !config_path.exists() { write_new_config(&config_path)?; @@ -100,7 +104,7 @@ impl TelemetryConfig { } pub fn one_way_hash(input: &str) -> String { - match TelemetryConfig::new() { + match TelemetryConfig::with_default_config_path() { Ok(config) => config.one_way_hash_with_config_salt(input), Err(_) => TelemetryConfig::one_way_hash_with_tmp_salt(input), } @@ -252,7 +256,7 @@ fn write_new_config(file_path: &AbsoluteSystemPath) -> Result<(), ConfigError> { // Create the directory if it doesn't exist file_path .ensure_dir() - .map_err(|_| ConfigError::Message("Failed to create director".to_string()))?; + .map_err(|_| ConfigError::Message("Failed to create directory".to_string()))?; // Write the file file_path diff --git a/crates/turborepo-telemetry/src/lib.rs b/crates/turborepo-telemetry/src/lib.rs index 0c1c1c7d55a15..b5ac50e78bcf2 100644 --- a/crates/turborepo-telemetry/src/lib.rs +++ b/crates/turborepo-telemetry/src/lib.rs @@ -81,7 +81,7 @@ fn init( ) -> Result<(TelemetryHandle, TelemetrySender), Box> { let (tx, rx) = mpsc::unbounded_channel(); let (cancel_tx, cancel_rx) = oneshot::channel(); - let mut config = TelemetryConfig::new()?; + let mut config = TelemetryConfig::with_default_config_path()?; config.show_alert(ui); let session_id = Uuid::new_v4();