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.
This commit is contained in:
parent
4204773492
commit
7bfbe0d86e
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -1660,8 +1660,7 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "pop-telemetry"
|
name = "pop-telemetry"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/jasonwitty/pop-cli?branch=main#16877871008c5c1167fa8d8cb9823a8d15228169"
|
||||||
checksum = "36586f435a76531d01477ce20b10f18d79ffde9ec1bbb7ff0c91640476b11877"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
|||||||
@ -29,7 +29,7 @@ bytes = "1.9"
|
|||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
pop-telemetry = "0.12.1"
|
pop-telemetry = { git = "https://github.com/jasonwitty/pop-cli", branch = "main" }
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|||||||
@ -16,12 +16,14 @@ pub struct Analytics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Analytics {
|
impl Analytics {
|
||||||
/// Create a new Analytics instance
|
/// Create a new Analytics instance with custom Umami endpoint
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # 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)
|
/// * `config_path` - Path to the telemetry config file (for opt-out checks)
|
||||||
pub fn new(config_path: PathBuf) -> Self {
|
pub fn new(website_id: String, endpoint: String, config_path: PathBuf) -> Self {
|
||||||
let telemetry = Telemetry::new(&config_path);
|
let telemetry = Telemetry::init_with_website_id(endpoint, website_id, &config_path);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
telemetry: Arc::new(Mutex::new(Some(telemetry))),
|
telemetry: Arc::new(Mutex::new(Some(telemetry))),
|
||||||
|
|||||||
@ -25,6 +25,14 @@ struct Opt {
|
|||||||
#[arg(long, default_value = "true")]
|
#[arg(long, default_value = "true")]
|
||||||
enable_analytics: bool,
|
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)
|
/// Path to telemetry config file (for opt-out management)
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
telemetry_config: Option<PathBuf>,
|
telemetry_config: Option<PathBuf>,
|
||||||
@ -73,8 +81,17 @@ async fn main() -> std::io::Result<()> {
|
|||||||
std::fs::create_dir_all(parent).ok();
|
std::fs::create_dir_all(parent).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("Analytics enabled (config: {:?})", config_path);
|
log::info!(
|
||||||
Analytics::new(config_path)
|
"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 {
|
} else {
|
||||||
log::info!("Analytics disabled");
|
log::info!("Analytics disabled");
|
||||||
Analytics::disabled()
|
Analytics::disabled()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user