: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
use serde::{Deserialize, Serialize};
/// One re-keyed event as published to `cohort_stream_events`. Field names mirror the shuffler
/// envelope exactly.
///
/// `properties` / `person_properties` are raw JSON strings parsed lazily in globals construction.
/// `source_partition` / `source_offset` are the upstream coordinates for replay-safe counter
/// increments.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CohortStreamEvent {
pub team_id: i32,
pub person_id: String,
pub distinct_id: String,
pub uuid: String,
pub event: String,
/// ClickHouse wire format `"YYYY-MM-DD HH:MM:SS.ffffff"`; normalized to ISO 8601 in globals.
pub timestamp: String,
pub properties: Option<String>,
pub person_properties: Option<String>,
pub elements_chain: Option<String>,
pub source_offset: i64,
/// Not always a Kafka partition. Each shuffler input topic writes its partitions into its own
/// range (`SourcePartitionRange` in the shuffler), so a reader must treat the value as an opaque
/// `i32` key and must not bound or narrow it.
pub source_partition: i32,
/// The merge origin person, set when a post-merge straggler is redirected to the merged-into
/// person. `None` for a normal event. Stage 1 routes replay-dedup through
/// `redirect_dedup[origin]` when set, preventing double-fold.
#[serde(default)]
pub redirected_from: Option<String>,
/// Cross-partition re-produce hops this straggler has taken through the tombstone redirect.
/// `0` for a normal event; incremented on each re-key produce. At the cap
/// (`MAX_CROSS_PARTITION_REDIRECT_HOPS`) the worker degrades to an inline fold to break cycles.
#[serde(default)]
pub redirect_hops: u8,
}