From 7bfbe0d86e76ba1c1ca66cf270c434af45fbac13 Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Sun, 30 Nov 2025 22:44:19 -0800 Subject: [PATCH] Switch to forked pop-telemetry with custom Umami endpoint support - Use forked pop-telemetry from github.com/jasonwitty/pop-cli - Implement init_with_website_id to configure custom endpoint and website ID - Add --umami-endpoint and --umami-website-id CLI parameters - Default endpoint: http://unami.wittyoneoff.com/api/send - Default website ID: caefa16f-86af-4835-8b82-c8649aea0e2a - Maintains backward compatibility with config file opt-out support This allows webterm to send analytics to our self-hosted Umami instance instead of the default pop-cli telemetry endpoint. --- Cargo.lock | 3 +-- Cargo.toml | 2 +- src/analytics.rs | 8 +++++--- src/server.rs | 21 +++++++++++++++++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f65bde..29f0c43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1660,8 +1660,7 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "pop-telemetry" version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36586f435a76531d01477ce20b10f18d79ffde9ec1bbb7ff0c91640476b11877" +source = "git+https://github.com/jasonwitty/pop-cli?branch=main#16877871008c5c1167fa8d8cb9823a8d15228169" dependencies = [ "dirs", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 9c99940..a79e302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ bytes = "1.9" log = "0.4" env_logger = "0.11" libc = "0.2" -pop-telemetry = "0.12.1" +pop-telemetry = { git = "https://github.com/jasonwitty/pop-cli", branch = "main" } dirs = "5.0" [lib] diff --git a/src/analytics.rs b/src/analytics.rs index e8587e1..2e490b9 100644 --- a/src/analytics.rs +++ b/src/analytics.rs @@ -16,12 +16,14 @@ pub struct Analytics { } impl Analytics { - /// Create a new Analytics instance + /// Create a new Analytics instance with custom Umami endpoint /// /// # Arguments + /// * `website_id` - The Umami website ID + /// * `endpoint` - The Umami instance endpoint (e.g., "http://unami.wittyoneoff.com/api/send") /// * `config_path` - Path to the telemetry config file (for opt-out checks) - pub fn new(config_path: PathBuf) -> Self { - let telemetry = Telemetry::new(&config_path); + pub fn new(website_id: String, endpoint: String, config_path: PathBuf) -> Self { + let telemetry = Telemetry::init_with_website_id(endpoint, website_id, &config_path); Self { telemetry: Arc::new(Mutex::new(Some(telemetry))), diff --git a/src/server.rs b/src/server.rs index 6282dd2..4a4ae80 100644 --- a/src/server.rs +++ b/src/server.rs @@ -25,6 +25,14 @@ struct Opt { #[arg(long, default_value = "true")] enable_analytics: bool, + /// Umami instance endpoint + #[arg(long, default_value = "http://unami.wittyoneoff.com/api/send")] + umami_endpoint: String, + + /// Umami website ID + #[arg(long, default_value = "caefa16f-86af-4835-8b82-c8649aea0e2a")] + umami_website_id: String, + /// Path to telemetry config file (for opt-out management) #[arg(long)] telemetry_config: Option, @@ -73,8 +81,17 @@ async fn main() -> std::io::Result<()> { std::fs::create_dir_all(parent).ok(); } - log::info!("Analytics enabled (config: {:?})", config_path); - Analytics::new(config_path) + log::info!( + "Analytics enabled: {} (website_id: {}, config: {:?})", + opt.umami_endpoint, + opt.umami_website_id, + config_path + ); + Analytics::new( + opt.umami_website_id.clone(), + opt.umami_endpoint.clone(), + config_path, + ) } else { log::info!("Analytics disabled"); Analytics::disabled()