Skip to content

Commit

Permalink
Add new constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Soltis authored and Greg Soltis committed Mar 1, 2024
1 parent e0c927c commit d549e8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions crates/turborepo-telemetry/src/config.rs
Expand Up @@ -54,8 +54,12 @@ pub struct TelemetryConfig {
}

impl TelemetryConfig {
pub fn new() -> Result<TelemetryConfig, ConfigError> {
pub fn with_default_config_path() -> Result<TelemetryConfig, ConfigError> {
let config_path = get_config_path()?;
TelemetryConfig::new(config_path)
}

pub fn new(config_path: AbsoluteSystemPathBuf) -> Result<TelemetryConfig, ConfigError> {
debug!("Telemetry config path: {}", config_path);
if !config_path.exists() {
write_new_config(&config_path)?;
Expand Down Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-telemetry/src/lib.rs
Expand Up @@ -81,7 +81,7 @@ fn init(
) -> Result<(TelemetryHandle, TelemetrySender), Box<dyn std::error::Error>> {
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();
Expand Down

0 comments on commit d549e8e

Please sign in to comment.