diff --git a/crates/server/src/routes/config.rs b/crates/server/src/routes/config.rs index 4504cb52..4fb33aad 100644 --- a/crates/server/src/routes/config.rs +++ b/crates/server/src/routes/config.rs @@ -88,12 +88,25 @@ async fn update_config( ) -> ResponseJson> { let config_path = config_path(); + // Get the current analytics_enabled state before updating + let old_analytics_enabled = { + let config = deployment.config().read().await; + config.analytics_enabled + }; + match save_config_to_file(&new_config, &config_path).await { Ok(_) => { let mut config = deployment.config().write().await; *config = new_config.clone(); drop(config); + // If analytics was just enabled (changed from None/false to true), track session_start + if new_config.analytics_enabled == Some(true) && old_analytics_enabled != Some(true) { + deployment + .track_if_analytics_allowed("session_start", serde_json::json!({})) + .await; + } + ResponseJson(ApiResponse::success(new_config)) } Err(e) => ResponseJson(ApiResponse::error(&format!("Failed to save config: {}", e))),