feat: gate telemetry behind Cargo feature flags (#8119)
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com> Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -3,12 +3,15 @@ use clap::{Args, CommandFactory, Parser, Subcommand};
|
||||
use clap_complete::{generate, Shell as ClapShell};
|
||||
use goose::builtin_extension::register_builtin_extensions;
|
||||
use goose::config::{Config, GooseMode};
|
||||
#[cfg(feature = "telemetry")]
|
||||
use goose::posthog::get_telemetry_choice;
|
||||
use goose::recipe::Recipe;
|
||||
use goose_mcp::mcp_server_runner::{serve, McpCommand};
|
||||
use goose_mcp::{AutoVisualiserRouter, ComputerControllerServer, MemoryServer, TutorialServer};
|
||||
|
||||
use crate::commands::configure::{configure_telemetry_consent_dialog, handle_configure};
|
||||
#[cfg(feature = "telemetry")]
|
||||
use crate::commands::configure::configure_telemetry_consent_dialog;
|
||||
use crate::commands::configure::handle_configure;
|
||||
use crate::commands::info::handle_info;
|
||||
use crate::commands::project::{handle_project_default, handle_projects_interactive};
|
||||
use crate::commands::recipe::{handle_deeplink, handle_list, handle_open, handle_validate};
|
||||
@@ -1108,6 +1111,7 @@ async fn handle_interactive_session(
|
||||
session_opts: SessionOptions,
|
||||
extension_opts: ExtensionOptions,
|
||||
) -> Result<()> {
|
||||
#[cfg(feature = "telemetry")]
|
||||
if get_telemetry_choice().is_none() {
|
||||
configure_telemetry_consent_dialog()?;
|
||||
}
|
||||
@@ -1332,6 +1336,7 @@ async fn handle_run_command(
|
||||
output_opts: OutputOptions,
|
||||
model_opts: ModelOptions,
|
||||
) -> Result<()> {
|
||||
#[cfg(feature = "telemetry")]
|
||||
if run_behavior.interactive && get_telemetry_choice().is_none() {
|
||||
configure_telemetry_consent_dialog()?;
|
||||
}
|
||||
@@ -1643,6 +1648,7 @@ async fn handle_default_session() -> Result<()> {
|
||||
return handle_configure().await;
|
||||
}
|
||||
|
||||
#[cfg(feature = "telemetry")]
|
||||
if get_telemetry_choice().is_none() {
|
||||
configure_telemetry_consent_dialog()?;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use goose::config::{
|
||||
PermissionManager,
|
||||
};
|
||||
use goose::model::ModelConfig;
|
||||
#[cfg(feature = "telemetry")]
|
||||
use goose::posthog::{get_telemetry_choice, TELEMETRY_ENABLED_KEY};
|
||||
use goose::providers::base::ConfigKey;
|
||||
use goose::providers::chatgpt_codex::reasoning_levels_for_model;
|
||||
@@ -44,6 +45,7 @@ pub async fn handle_configure() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "telemetry")]
|
||||
pub fn configure_telemetry_consent_dialog() -> anyhow::Result<bool> {
|
||||
let config = Config::global();
|
||||
|
||||
@@ -114,6 +116,7 @@ async fn handle_first_time_setup(config: &Config) -> anyhow::Result<()> {
|
||||
);
|
||||
println!();
|
||||
|
||||
#[cfg(feature = "telemetry")]
|
||||
configure_telemetry_consent_dialog()?;
|
||||
|
||||
println!();
|
||||
@@ -1264,13 +1267,21 @@ pub fn remove_extension_dialog() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
pub async fn configure_settings_dialog() -> anyhow::Result<()> {
|
||||
let setting_type = cliclack::select("What setting would you like to configure?")
|
||||
.item("goose_mode", "goose mode", "Configure goose mode")
|
||||
.item(
|
||||
#[allow(unused_mut)]
|
||||
let mut setting_select = cliclack::select("What setting would you like to configure?").item(
|
||||
"goose_mode",
|
||||
"goose mode",
|
||||
"Configure goose mode",
|
||||
);
|
||||
#[cfg(feature = "telemetry")]
|
||||
{
|
||||
setting_select = setting_select.item(
|
||||
"telemetry",
|
||||
"Telemetry",
|
||||
"Enable or disable anonymous usage data collection",
|
||||
)
|
||||
);
|
||||
}
|
||||
let setting_type = setting_select
|
||||
.item(
|
||||
"tool_permission",
|
||||
"Tool Permission",
|
||||
@@ -1309,6 +1320,7 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
|
||||
"goose_mode" => {
|
||||
configure_goose_mode_dialog()?;
|
||||
}
|
||||
#[cfg(feature = "telemetry")]
|
||||
"telemetry" => {
|
||||
configure_telemetry_dialog()?;
|
||||
}
|
||||
@@ -1383,6 +1395,7 @@ pub fn configure_goose_mode_dialog() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "telemetry")]
|
||||
pub fn configure_telemetry_dialog() -> anyhow::Result<()> {
|
||||
let config = Config::global();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use tracing_subscriber::{
|
||||
Registry,
|
||||
};
|
||||
|
||||
#[cfg(feature = "otel")]
|
||||
use goose::otel::otlp;
|
||||
use goose::tracing::langfuse_layer;
|
||||
|
||||
@@ -67,6 +68,7 @@ fn setup_logging_internal(name: Option<&str>, force: bool) -> Result<()> {
|
||||
// Console logging disabled for CLI - all logs go to files only
|
||||
];
|
||||
|
||||
#[cfg(feature = "otel")]
|
||||
if !force {
|
||||
layers.extend(otlp::init_otlp_layers(goose::config::Config::global()));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ async fn main() -> Result<()> {
|
||||
|
||||
let result = cli().await;
|
||||
|
||||
#[cfg(feature = "otel")]
|
||||
if goose::otel::otlp::is_otlp_initialized() {
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
|
||||
goose::otel::otlp::shutdown_otlp();
|
||||
|
||||
@@ -579,6 +579,7 @@ async fn configure_session_prompts(
|
||||
}
|
||||
|
||||
pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
|
||||
#[cfg(feature = "telemetry")]
|
||||
goose::posthog::set_session_context("cli", session_config.resume);
|
||||
|
||||
let config = Config::global();
|
||||
|
||||
Reference in New Issue
Block a user