:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(capture): update v1 endpoint path (#60176)
Eli Reismana2a5d87c7e4a
diff --git a/rust/capture/src/v1/analytics/constants.rs b/rust/capture/src/v1/analytics/constants.rsindex bbcfe0f8d084..1d5547cbd7c1 100644--- a/rust/capture/src/v1/analytics/constants.rs+++ b/rust/capture/src/v1/analytics/constants.rs@@ -20,10 +20,10 @@ pub const SUPPORTED_ENCODINGS: &[&str] = &["gzip", "deflate", "br", "zstd"];// ---------------------------------------------------------------------------/// Primary route path for the v1 events endpoint.-pub const CAPTURE_V1_PATH: &str = "/i/v1/general/events";+pub const CAPTURE_V1_PATH: &str = "/i/v1/analytics/events";/// Trailing-slash variant registered so both URL forms resolve to the same handler.-pub(super) const CAPTURE_V1_PATH_TRAILING: &str = "/i/v1/general/events/";+pub(super) const CAPTURE_V1_PATH_TRAILING: &str = "/i/v1/analytics/events/";// ---------------------------------------------------------------------------// Metrics keysdiff --git a/rust/capture/src/v1/analytics/handler.rs b/rust/capture/src/v1/analytics/handler.rsindex 8401f5ee2911..03b7bc7dbf2d 100644--- a/rust/capture/src/v1/analytics/handler.rs+++ b/rust/capture/src/v1/analytics/handler.rs@@ -149,15 +149,13 @@ mod tests {use uuid::Uuid;use crate::router;+ use crate::v1::analytics::constants::CAPTURE_V1_PATH;use crate::v1::constants::*;use crate::v1::test_utils::{batch_payload, compressed_payload, valid_event, TestStateBuilder};fn test_app(state: router::State) -> Router {Router::new()- .route(- "/i/v1/general/events",- axum::routing::post(super::handle_request),- )+ .route(CAPTURE_V1_PATH, axum::routing::post(super::handle_request)).layer(axum::middleware::from_fn(super::super::router::v1_common_headers,))@@ -167,7 +165,7 @@ mod tests {fn valid_request() -> axum::http::request::Builder {Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Authorization", "Bearer phc_test_token").header("Content-Type", "application/json").header("X-Forwarded-For", "127.0.0.1")@@ -235,7 +233,7 @@ mod tests {let payload = batch_payload(&[valid_event()]);let req = Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Content-Type", "application/json").header("X-Forwarded-For", "127.0.0.1").header(POSTHOG_SDK_INFO, "posthog-rust/1.0.0")@@ -259,7 +257,7 @@ mod tests {// Only Authorization and Content-Type — missing SDK-Info, Attempt, etc.let req = Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Authorization", "Bearer phc_test_token").header("Content-Type", "application/json").header("X-Forwarded-For", "127.0.0.1")@@ -324,7 +322,7 @@ mod tests {let req = Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Authorization", "Bearer phc_test_token").header("Content-Type", "application/json").header("Content-Encoding", "gzip")@@ -355,7 +353,7 @@ mod tests {let req = Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Authorization", "Bearer phc_test_token").header("Content-Type", "application/json").header("Content-Encoding", "zstd")@@ -382,7 +380,7 @@ mod tests {let payload = batch_payload(&[valid_event()]);let req = Request::builder().method("POST")- .uri("/i/v1/general/events")+ .uri(CAPTURE_V1_PATH).header("Authorization", "Bearer phc_test_token").header("Content-Type", "application/json").header("Content-Encoding", "lz4")diff --git a/rust/capture/src/v1/analytics/process.rs b/rust/capture/src/v1/analytics/process.rsindex a5828b2cf9f9..a91d61b2e416 100644--- a/rust/capture/src/v1/analytics/process.rs+++ b/rust/capture/src/v1/analytics/process.rs@@ -503,6 +503,7 @@ mod tests {use crate::event_restrictions::{Pipeline, Restriction, RestrictionManager, RestrictionScope, RestrictionType,};+ use crate::v1::analytics::constants::CAPTURE_V1_PATH;use crate::v1::analytics::types::{Batch, Event, Options};use crate::v1::sinks::Destination;use crate::v1::test_utils::{@@ -867,7 +868,7 @@ mod tests {client_ip: std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST),query: crate::v1::analytics::query::Query::default(),method: axum::http::Method::POST,- path: "/i/v1/general/events",+ path: CAPTURE_V1_PATH,server_received_at,created_at: None,capture_internal: false,diff --git a/rust/capture/src/v1/test_utils.rs b/rust/capture/src/v1/test_utils.rsindex 5080836b2d3c..b682477f8dab 100644--- a/rust/capture/src/v1/test_utils.rs+++ b/rust/capture/src/v1/test_utils.rs@@ -7,6 +7,7 @@ use chrono::{DateTime, Utc};use serde_json::value::RawValue;use uuid::Uuid;+use crate::v1::analytics::constants::CAPTURE_V1_PATH;use crate::v1::analytics::query::Query;use crate::v1::analytics::types::{Event, EventResult, Options, WrappedEvent};use crate::v1::context::Context;@@ -38,7 +39,7 @@ pub fn test_context() -> Context {client_ip: IpAddr::V4(Ipv4Addr::LOCALHOST),query: Query::default(),method: Method::POST,- path: "/i/v1/general/events",+ path: CAPTURE_V1_PATH,server_received_at: Utc::now(),created_at: Some("2026-03-19T14:30:00.000Z".to_string()),capture_internal: false,diff --git a/rust/capture/tests/v1_sink_integration.rs b/rust/capture/tests/v1_sink_integration.rsindex df0ebdac28ba..2a87ee7497b3 100644--- a/rust/capture/tests/v1_sink_integration.rs+++ b/rust/capture/tests/v1_sink_integration.rs@@ -5,7 +5,7 @@//!//! Requires Docker Kafka (same rig as legacy integration tests).//!-//! TODO(v1): add HTTP-level integration tests (ServerHandle + POST /i/v1/general/events)+//! TODO(v1): add HTTP-level integration tests (ServerHandle + POST /i/v1/analytics/events)//! and process_batch orchestration tests once the v1 HTTP router is merged into the//! main application and process_batch is fully implemented (currently a stub).