Switch to forked pop-telemetry with custom Umami endpoint support
All checks were successful
Build and Deploy to K3s / test (push) Successful in 2m13s
Build and Deploy to K3s / lint (push) Successful in 1m37s
Build and Deploy to K3s / build-and-push (push) Successful in 5m22s
Build and Deploy to K3s / deploy (push) Successful in 9s

- 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.
This commit is contained in:
jasonwitty 2025-11-30 22:44:19 -08:00
parent 4204773492
commit 7bfbe0d86e
4 changed files with 26 additions and 8 deletions

3
Cargo.lock generated
View File

@ -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",

View File

@ -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]

View File

@ -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))),

View File

@ -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<PathBuf>,
@ -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()