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:
+5
-3
@@ -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))),
|
||||
|
||||
+19
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user