From ab7e5fbf955c45ffe6f867c089b58cc395c5801b Mon Sep 17 00:00:00 2001 From: Alex Chi Z Date: Wed, 7 May 2025 14:34:21 +0800 Subject: [PATCH] feat(pageserver): add PostHog config section Signed-off-by: Alex Chi Z --- libs/pageserver_api/src/config.rs | 18 ++++++++++++++++++ pageserver/src/config.rs | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libs/pageserver_api/src/config.rs b/libs/pageserver_api/src/config.rs index b64c42a808..f1201f0689 100644 --- a/libs/pageserver_api/src/config.rs +++ b/libs/pageserver_api/src/config.rs @@ -43,6 +43,21 @@ pub struct NodeMetadata { pub other: HashMap, } +/// PostHog integration config +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct PostHogConfig { + /// PostHog project ID + project_id: String, + /// Server-side (private) API key + server_api_key: String, + /// Client-side (public) API key + client_api_key: String, + /// Private API URL + private_api_url: String, + /// Public API URL + public_api_url: String, +} + /// `pageserver.toml` /// /// We use serde derive with `#[serde(default)]` to generate a deserializer @@ -182,6 +197,8 @@ pub struct ConfigToml { pub tracing: Option, pub enable_tls_page_service_api: bool, pub dev_mode: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub posthog_config: Option, } #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] @@ -659,6 +676,7 @@ impl Default for ConfigToml { tracing: None, enable_tls_page_service_api: false, dev_mode: false, + posthog_config: None, } } } diff --git a/pageserver/src/config.rs b/pageserver/src/config.rs index ded2805602..5b9009be90 100644 --- a/pageserver/src/config.rs +++ b/pageserver/src/config.rs @@ -14,7 +14,7 @@ use std::time::Duration; use anyhow::{Context, bail, ensure}; use camino::{Utf8Path, Utf8PathBuf}; use once_cell::sync::OnceCell; -use pageserver_api::config::{DiskUsageEvictionTaskConfig, MaxVectoredReadBytes}; +use pageserver_api::config::{DiskUsageEvictionTaskConfig, MaxVectoredReadBytes, PostHogConfig}; use pageserver_api::models::ImageCompressionAlgorithm; use pageserver_api::shard::TenantShardId; use pem::Pem; @@ -230,6 +230,9 @@ pub struct PageServerConf { /// such as authentication requirements for HTTP and PostgreSQL APIs. /// This is insecure and should only be used in development environments. pub dev_mode: bool, + + /// PostHog integration config + pub posthog_config: Option, } /// Token for authentication to safekeepers @@ -404,6 +407,7 @@ impl PageServerConf { tracing, enable_tls_page_service_api, dev_mode, + posthog_config, } = config_toml; let mut conf = PageServerConf { @@ -513,6 +517,7 @@ impl PageServerConf { } None => Vec::new(), }, + posthog_config, }; // ------------------------------------------------------------