: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
fix(capture): reroute v1 historical events before restrictions (#116952)
Paweł Ledwoń24b7c1a326ea
diff --git a/rust/capture/src/events/analytics.rs b/rust/capture/src/events/analytics.rsindex 8e0d5955a29f..0dbb79821cba 100644--- a/rust/capture/src/events/analytics.rs+++ b/rust/capture/src/events/analytics.rs@@ -489,23 +489,7 @@ async fn process_events_inner(drop_ai_byte_limited(&mut events, ai_byte_rate_limiter.as_ref()).await;// Per-(token, distinct_id) global rate limiting: skip person processing for- // hot distinct_ids and reroute AnalyticsMain events to overflow. Import mode- // opts out entirely — historical backfills must never be throttled — so the- // limiter is skipped even if one were wired.- //- // DIVERGENCE from v1 (`v1::analytics::process`), intentional and out of scope- // to reconcile here — a future routing refactor must not assume parity:- // 1. Ordering: legacy runs this GRL step BEFORE burst overflow stamping- // (`stamp_overflow_reason` below); v1 runs the GRL AFTER its overflow- // stamping. Both set overflow_reason on AnalyticsMain only, so the- // end state matches, but the pass order differs.- // 2. Lane assignment is a single `DataType::from_event_name` match in- // legacy versus assign-then-reroute in v1.- // Both paths charge the same shared limiter for every non-dropped event,- // including events whose person processing is already off, so per-key counts- // are identical regardless of which pipeline serves the key.- // Import is unaffected by both: the GRL never runs (guard below) and no- // overflowable lane is reachable, so behavior is identical across paths.+ // hot distinct_ids and reroute AnalyticsMain events to overflow.if context.capture_mode.applies_global_rate_limit() {if let Some(ref limiter) = global_rate_limiter {let mut limited_distinct_ids: HashSet<&str> = HashSet::new();diff --git a/rust/capture/src/v1/analytics/process.rs b/rust/capture/src/v1/analytics/process.rsindex 4131341a4d1b..14a8f3cb6dae 100644--- a/rust/capture/src/v1/analytics/process.rs+++ b/rust/capture/src/v1/analytics/process.rs@@ -17,7 +17,7 @@ use super::constants::{DETAIL_PERSON_PROCESSING_DISABLED, FUTURE_EVENT_HOURS_CUTOFF_MS, ILLEGAL_DISTINCT_IDS,};use super::response::BatchResponse;-use super::types::{Batch, Event, EventResult, OptionKeys, Options, WrappedEvent};+use super::types::{Batch, Event, EventResult, OptionKeys, Options, ValidatedEvent, WrappedEvent};use crate::event_restrictions::{EventContext, EventRestrictionService};use crate::events::ai_byte_limit::charge_ai_bytes;use crate::global_rate_limiter::{GlobalRateLimitKey, GlobalRateLimiter};@@ -92,13 +92,14 @@ async fn run_pipeline(}context.set_batch_metadata(&batch);- let mut events = match validate_events(context, batch) {+ let events = match validate_events(context, batch) {Ok(events) => events,Err(err) => {emit_batch_abort_warning(state, context, &err, batch_len);return Err(err);}};+ let mut events = assign_destinations(&state.historical_cfg, context, events);// Import mode ingests only historical backfills: drop any batch not flagged// `historical_migration` (a batch-level flag) by marking every event Drop and@@ -156,8 +157,6 @@ async fn run_pipeline(apply_ai_byte_limits(limiter, &context.api_token, &mut events).await;}- apply_historical_rerouting(&state.historical_cfg, context, &mut events);-// Overflow and global rate limit are independent checks on different axes:// overflow reroutes bursting keys; global rate limit disables person processing.if state.overflow_limiter.is_some() || state.ai_events_overflow_limiter.is_some() {@@ -169,25 +168,6 @@ async fn run_pipeline();}- // Import mode opts out of the global rate limiter entirely — historical- // backfills must never be throttled — so it's skipped even if one were wired.- //- // DIVERGENCE from legacy (`events::analytics`), intentional and out of scope- // to reconcile here — a future routing refactor must not assume parity:- // 1. Ordering: v1 runs this GRL step AFTER burst overflow stamping (above);- // legacy runs its GRL BEFORE overflow stamping. The pass order differs,- // but the observable outcome does not: both reroute only- // AnalyticsMain/Destination::AnalyticsOverflow, and both drop the partition key- // once person processing is off, so a key the GRL wanted spread stays- // spread on either path even when the burst limiter preserves locality.- // `crate::overflow_parity` pins that across the whole matrix.- // 2. Lane assignment is assign-then-reroute in v1 versus a single- // `DataType::from_event_name` match in legacy.- // Both paths charge the same shared limiter for every non-dropped event,- // including events whose person processing is already off, so per-key counts- // are identical regardless of which pipeline serves the key.- // Import is unaffected by both: the GRL never runs (guard below) and no- // overflowable lane is reachable, so behavior is identical across paths.if state.capture_mode.applies_global_rate_limit() {if let Some(ref limiter) = state.global_rate_limiter_token_distinctid {let _ = apply_token_distinct_id_limits(@@ -497,9 +477,9 @@ fn validate_batch(batch: &Batch) -> Result<(), Error> {Ok(())}-fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<WrappedEvent>, Error> {+fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<ValidatedEvent>, Error> {let batch_len = batch.batch.len();- let mut events: Vec<WrappedEvent> = Vec::with_capacity(batch_len);+ let mut events: Vec<ValidatedEvent> = Vec::with_capacity(batch_len);let mut seen: HashSet<Uuid> = HashSet::with_capacity(batch_len);let mut illegal_distinct_id_count: u64 = 0;@@ -517,25 +497,20 @@ fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<Wrapped));}- let destination = destination_for_event_name(&event.event);-match validate_event(&event) {Ok(raw_ts) => {// `observe_malformed_events` counts and logs this drop.let options = match event.options.validate() {Ok(opts) => opts,Err(err) => {- events.push(WrappedEvent {+ events.push(ValidatedEvent {event,uuid,options: Options::default(),adjusted_timestamp: None,result: EventResult::Drop,details: Some(err.detail()),- destination,force_disable_person_processing: false,- spread_partitions: false,- is_gateway_verified: false,});continue;}@@ -551,7 +526,7 @@ fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<Wrappedif illegal {illegal_distinct_id_count += 1;}- events.push(WrappedEvent {+ events.push(ValidatedEvent {event,uuid,options,@@ -562,24 +537,18 @@ fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<Wrapped} else {None},- destination,force_disable_person_processing: illegal,- spread_partitions: false,- is_gateway_verified: false,});}Err(err) => {- events.push(WrappedEvent {+ events.push(ValidatedEvent {event,uuid,options: Options::default(),adjusted_timestamp: None,result: EventResult::Drop,details: Some(err.tag()),- destination,force_disable_person_processing: false,- spread_partitions: false,- is_gateway_verified: false,});}}@@ -603,7 +572,7 @@ fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<WrappedOk(events)}-fn observe_malformed_events(context: &RequestContext, events: &[WrappedEvent]) {+fn observe_malformed_events(context: &RequestContext, events: &[ValidatedEvent]) {let mut malformed: HashMap<&'static str, u64> = HashMap::new();for event in events.iter() {@@ -742,36 +711,46 @@ fn normalize_timestamp(adjusted}-fn apply_historical_rerouting(- cfg: &router::HistoricalConfig,+fn assign_destinations(+ historical_cfg: &router::HistoricalConfig,context: &RequestContext,- events: &mut [WrappedEvent],-) {- for event in events.iter_mut() {- if event.result != EventResult::Ok || event.destination != Destination::AnalyticsMain {- continue;- }-- // Batch-level flag: all events in a historical migration batch are historical- if context.historical_migration {- event.destination = Destination::AnalyticsHistorical;- metrics::counter!(CAPTURE_V1_EVENTS_REROUTED_HISTORICAL, "reason" => "batch_flag")- .increment(1);- continue;- }-- // Timestamp-based: reroute old events when the feature is enabled- if let Some(ts) = event.adjusted_timestamp {- if cfg.should_reroute(crate::v0_request::DataType::AnalyticsMain, ts) {- event.destination = Destination::AnalyticsHistorical;- metrics::counter!(- CAPTURE_V1_EVENTS_REROUTED_HISTORICAL,- "reason" => "timestamp"- )- .increment(1);+ events: Vec<ValidatedEvent>,+) -> Vec<WrappedEvent> {+ events+ .into_iter()+ .map(|validated| {+ let mut destination = destination_for_event_name(&validated.event.event);+ if let Some(ts) = validated.adjusted_timestamp {+ destination = route_historical(historical_cfg, context, destination, ts);}- }+ validated.into_wrapped(destination)+ })+ .collect()+}++fn route_historical(+ cfg: &router::HistoricalConfig,+ context: &RequestContext,+ destination: Destination,+ adjusted_timestamp: DateTime<Utc>,+) -> Destination {+ if destination != Destination::AnalyticsMain {+ return destination;+ }+ if context.historical_migration {+ metrics::counter!(CAPTURE_V1_EVENTS_REROUTED_HISTORICAL, "reason" => "batch_flag")+ .increment(1);+ return Destination::AnalyticsHistorical;}+ if cfg.should_reroute(+ crate::v0_request::DataType::AnalyticsMain,+ adjusted_timestamp,+ ) {+ metrics::counter!(CAPTURE_V1_EVENTS_REROUTED_HISTORICAL, "reason" => "timestamp")+ .increment(1);+ return Destination::AnalyticsHistorical;+ }+ destination}fn apply_overflow_stamping(@@ -872,12 +851,6 @@ async fn apply_restrictions(}// Priority: overflow < custom topic < DLQ (DLQ wins, applied last)- // Overflow only applies to the overflowing lanes: AnalyticsMain, and- // AiMain once the AI overflow valve is armed (each rerouting to its- // own overflow destination). AnalyticsHistorical must never overflow- // (v0's `pipeline::resolve` rule). Today this stage runs before historical- // rerouting so an analytics event is always AnalyticsMain here; the- // explicit guard makes the invariant ordering-independent.let force_overflow_destination = match event.destination {Destination::AnalyticsMain => Some(Destination::AnalyticsOverflow),Destination::AiMain if ai_events_overflow_enabled => Some(Destination::AiOverflow),@@ -1122,9 +1095,7 @@ async fn apply_token_distinct_id_limits(event.force_disable_person_processing = true;event.details = Some(DETAIL_PERSON_PROCESSING_DISABLED);// Reroute to overflow to spread a hot token:distinct_id across- // partitions. Gated to AnalyticsMain only: this stage runs after- // historical rerouting, and AnalyticsHistorical must never overflow- // (matches v0's `pipeline::resolve`). Other lanes (exceptions,+ // partitions. Gated to AnalyticsMain only. Other lanes (exceptions,// heatmaps, etc.) keep their own destination.if event.destination == Destination::AnalyticsMain {event.destination = Destination::AnalyticsOverflow;@@ -1223,7 +1194,6 @@ mod tests {use crate::v1::prepare::DEFAULT_SCATTER_GATHER_MIN_BATCH;use crate::v1::test_utils::{self, find_by_did, malformed_wrapped_event, raw_obj, valid_event, wrapped_event,- wrapped_event_at,};use crate::v1::types::Destination;use crate::v1::Error;@@ -1602,7 +1572,7 @@ mod tests {let batch = valid_batch(vec![illegal_event]);let events = validate_events(&ctx, batch).unwrap();assert_eq!(events.len(), 1, "id={id:?}");- assert!(events[0].should_publish(), "id={id:?}");+ assert_eq!(events[0].result, EventResult::Ok, "id={id:?}");}}@@ -3144,153 +3114,52 @@ mod tests {assert_eq!(ev.details, Some(DETAIL_PERSON_PROCESSING_DISABLED));}- // --- apply_historical_rerouting ---+ // --- route_historical ---- #[test]- fn historical_batch_flag_reroutes_all_events() {- let cfg = router::HistoricalConfig::new(false, 1);- let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- let mut events = vec![- wrapped_event("$pageview", "user-1"),- wrapped_event("$identify", "user-2"),- ];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- for ev in &events {- assert_eq!(ev.destination, Destination::AnalyticsHistorical);- }+ struct RouteInput {+ destination: Destination,+ historical_migration: bool,+ rerouting_enabled: bool,+ event_age: Duration,}- #[test]- fn historical_timestamp_reroutes_old_event() {- let cfg = router::HistoricalConfig::new(true, 30);- let ctx = test_utils::test_context();- let old_ts = Utc::now() - Duration::days(60);- let mut events = vec![wrapped_event_at(old_ts)];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- let ev = &events[0];- assert_eq!(ev.destination, Destination::AnalyticsHistorical);- }-- #[test]- fn historical_timestamp_keeps_recent_event() {- let cfg = router::HistoricalConfig::new(true, 30);- let ctx = test_utils::test_context();- let recent_ts = Utc::now() - Duration::hours(1);- let mut events = vec![wrapped_event_at(recent_ts)];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- let ev = &events[0];- assert_eq!(ev.destination, Destination::AnalyticsMain);- }-- #[test]- fn historical_rerouting_disabled_no_change() {- let cfg = router::HistoricalConfig::new(false, 30);- let ctx = test_utils::test_context();- let old_ts = Utc::now() - Duration::days(60);- let mut events = vec![wrapped_event_at(old_ts)];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- let ev = &events[0];- assert_eq!(ev.destination, Destination::AnalyticsMain);- }-- #[test]- fn historical_skips_non_analytics_main() {- let cfg = router::HistoricalConfig::new(true, 30);- let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- let ev = wrapped_event("$pageview", "user-1");- let ev_uuid = ev.uuid;- let mut events = vec![ev];- events- .iter_mut()- .find(|e| e.uuid == ev_uuid)- .unwrap()- .destination = Destination::AnalyticsOverflow;-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- assert_eq!(- events- .iter()- .find(|e| e.uuid == ev_uuid)- .unwrap()- .destination,- Destination::AnalyticsOverflow- );- }-- #[test]- fn historical_skips_dropped_events() {- let cfg = router::HistoricalConfig::new(true, 30);- let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- let ev = wrapped_event("$pageview", "user-1");- let ev_uuid = ev.uuid;- let mut events = vec![ev];- let e = events.iter_mut().find(|e| e.uuid == ev_uuid).unwrap();- e.result = EventResult::Drop;-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- assert_eq!(- events- .iter()- .find(|e| e.uuid == ev_uuid)- .unwrap()- .destination,- Destination::AnalyticsMain- );- }-- #[test]- fn historical_skips_malformed_events() {- let cfg = router::HistoricalConfig::new(true, 30);- let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- let mut events = vec![malformed_wrapped_event()];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- let ev = &events[0];- assert_eq!(ev.destination, Destination::AnalyticsMain);- }-- #[test]- fn historical_mixed_batch_flag_and_already_redirected() {- let cfg = router::HistoricalConfig::new(false, 1);+ #[rstest::rstest]+ #[case::batch_flag(+ RouteInput { destination: Destination::AnalyticsMain, historical_migration: true, rerouting_enabled: false, event_age: Duration::hours(1) },+ Destination::AnalyticsHistorical,+ )]+ #[case::old_timestamp(+ RouteInput { destination: Destination::AnalyticsMain, historical_migration: false, rerouting_enabled: true, event_age: Duration::days(60) },+ Destination::AnalyticsHistorical,+ )]+ #[case::recent_timestamp(+ RouteInput { destination: Destination::AnalyticsMain, historical_migration: false, rerouting_enabled: true, event_age: Duration::hours(1) },+ Destination::AnalyticsMain,+ )]+ #[case::rerouting_disabled(+ RouteInput { destination: Destination::AnalyticsMain, historical_migration: false, rerouting_enabled: false, event_age: Duration::days(60) },+ Destination::AnalyticsMain,+ )]+ #[case::ai_lane_ignores_batch_flag(+ RouteInput { destination: Destination::AiMain, historical_migration: true, rerouting_enabled: true, event_age: Duration::days(60) },+ Destination::AiMain,+ )]+ #[case::exceptions_ignore_batch_flag(+ RouteInput { destination: Destination::ErrorTrackingMain, historical_migration: true, rerouting_enabled: true, event_age: Duration::days(60) },+ Destination::ErrorTrackingMain,+ )]+ fn route_historical_moves_only_analytics_main(+ #[case] input: RouteInput,+ #[case] expected: Destination,+ ) {+ let cfg = router::HistoricalConfig::new(input.rerouting_enabled, 30);let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- let dlq_ev = wrapped_event("$identify", "user-2");- let dlq_uuid = dlq_ev.uuid;- let mut events = vec![wrapped_event("$pageview", "user-1"), dlq_ev];- events- .iter_mut()- .find(|e| e.uuid == dlq_uuid)- .unwrap()- .destination = Destination::Dlq;+ ctx.historical_migration = input.historical_migration;- apply_historical_rerouting(&cfg, &ctx, &mut events);+ let destination =+ route_historical(&cfg, &ctx, input.destination, Utc::now() - input.event_age);- let main_ev = find_by_did(&events, "user-1");- assert_eq!(main_ev.destination, Destination::AnalyticsHistorical);- // DLQ event untouched- assert_eq!(- events- .iter()- .find(|e| e.uuid == dlq_uuid)- .unwrap()- .destination,- Destination::Dlq- );+ assert_eq!(destination, expected);}// --- ordering preservation regressions ---@@ -3329,8 +3198,12 @@ mod tests {let events = validate_events(&ctx, batch).unwrap();+ let distinct_ids: Vec<&str> = events+ .iter()+ .map(|e| e.event.distinct_id.as_str())+ .collect();assert_eq!(- distinct_id_sequence(&events),+ distinct_ids,vec!["user-pos-0", "user-pos-1", "user-pos-2", "user-pos-3"],);}@@ -3345,34 +3218,6 @@ mod tests {assert!(matches!(err, Error::DuplicateEventUuid(_)));}- #[tokio::test]- async fn apply_historical_rerouting_preserves_order() {- // Interleave old + recent so the timestamp branch flips some events.- let cfg = router::HistoricalConfig::new(true, 30);- let ctx = test_utils::test_context();- let now = Utc::now();- let mut e0 = wrapped_event_at(now - Duration::days(60));- e0.event.distinct_id = "user-pos-0".to_string();- let mut e1 = wrapped_event_at(now - Duration::hours(1));- e1.event.distinct_id = "user-pos-1".to_string();- let mut e2 = wrapped_event_at(now - Duration::days(90));- e2.event.distinct_id = "user-pos-2".to_string();- let mut e3 = wrapped_event_at(now - Duration::minutes(5));- e3.event.distinct_id = "user-pos-3".to_string();- let mut events = vec![e0, e1, e2, e3];-- apply_historical_rerouting(&cfg, &ctx, &mut events);-- assert_eq!(- distinct_id_sequence(&events),- vec!["user-pos-0", "user-pos-1", "user-pos-2", "user-pos-3"],- );- assert_eq!(events[0].destination, Destination::AnalyticsHistorical);- assert_eq!(events[1].destination, Destination::AnalyticsMain);- assert_eq!(events[2].destination, Destination::AnalyticsHistorical);- assert_eq!(events[3].destination, Destination::AnalyticsMain);- }-#[tokio::test]async fn apply_restrictions_preserves_order() {let service = restriction_service(@@ -3459,18 +3304,7 @@ mod tests {"user-pos-5",];- // Stage 1: historical rerouting (batch flag on).- let cfg = router::HistoricalConfig::new(false, 1);- let mut ctx = test_utils::test_context();- ctx.historical_migration = true;- apply_historical_rerouting(&cfg, &ctx, &mut events);- assert_eq!(- distinct_id_sequence(&events),- expected,- "order changed after apply_historical_rerouting",- );-- // Stage 2: restrictions (no rules → passthrough, still iterates).+ // Stage 1: restrictions (no rules → passthrough, still iterates).let service =EventRestrictionService::new(vec![Pipeline::Analytics], StdDuration::from_secs(300));service.update(RestrictionManager::new()).await;@@ -3482,7 +3316,7 @@ mod tests {"order changed after apply_restrictions",);- // Stage 3: token+distinct_id limits — limit one Ok mid-batch.+ // Stage 2: token+distinct_id limits — limit one Ok mid-batch.let mut tdctx = test_utils::test_context();tdctx.api_token = "phc_tok".to_string();let limiter = mock_limiter(vec!["phc_tok:user-pos-2"]);@@ -4421,18 +4255,24 @@ mod tests {#[tokio::test]async fn import_mode_historical_batch_never_overflows() {- // Import's no-overflow guarantee on the v1 path. Non-AI events in a- // historical batch reroute to AnalyticsHistorical before overflow- // stamping (which only touches AnalyticsMain), and AI events divert- // to the AI lane, which cannot stamp overflow while the AI overflow- // valve is unset — the capture-import config. Even with the burst- // overflow limiter armed at burst=1 and all three events sharing one- // token:distinct_id — which would overflow the 2nd and 3rd in Events- // mode — nothing lands on events_overflow or the AI overflow lane.+ let restrictions = restriction_service(+ "phc_test_token",+ vec![Restriction {+ restriction_type: RestrictionType::ForceOverflow,+ scope: RestrictionScope::AllEvents,+ args: None,+ }],+ )+ .await;let ts = TestStateBuilder::new().with_capture_mode(crate::config::CaptureMode::Import).with_overflow_limiter(1, 1)+ .with_restriction_service(restrictions).build();+ assert!(+ !ts.state.ai_events_overflow_enabled,+ "capture-import leaves the AI valve unarmed"+ );let mut ctx = test_utils::test_analytics_context();let batch = historical_batch(vec![Event {diff --git a/rust/capture/src/v1/analytics/types.rs b/rust/capture/src/v1/analytics/types.rsindex 8b77b6b2126a..65d751bd1e91 100644--- a/rust/capture/src/v1/analytics/types.rs+++ b/rust/capture/src/v1/analytics/types.rs@@ -347,18 +347,52 @@ pub struct WrappedEvent {}impl WrappedEvent {- /// Option keys that dropped this event; recomputed since only drops need it.pub fn failed_option_keys(&self) -> OptionKeys {- match self.details {- Some(DETAIL_INVALID_OPTIONS) => self- .event- .options- .validate()- .err()- .map_or_else(OptionKeys::default, OptionsError::failed_keys),- _ => OptionKeys::default(),+ failed_option_keys(&self.event, self.details)+ }+}++#[derive(Debug)]+pub struct ValidatedEvent {+ pub event: Event,+ pub uuid: Uuid,+ pub options: Options,+ pub adjusted_timestamp: Option<DateTime<Utc>>,+ pub result: EventResult,+ pub details: Option<&'static str>,+ pub force_disable_person_processing: bool,+}++impl ValidatedEvent {+ pub fn into_wrapped(self, destination: Destination) -> WrappedEvent {+ WrappedEvent {+ event: self.event,+ uuid: self.uuid,+ options: self.options,+ adjusted_timestamp: self.adjusted_timestamp,+ result: self.result,+ details: self.details,+ destination,+ force_disable_person_processing: self.force_disable_person_processing,+ spread_partitions: false,+ is_gateway_verified: false,}}++ pub fn failed_option_keys(&self) -> OptionKeys {+ failed_option_keys(&self.event, self.details)+ }+}++fn failed_option_keys(event: &Event, details: Option<&'static str>) -> OptionKeys {+ match details {+ Some(DETAIL_INVALID_OPTIONS) => event+ .options+ .validate()+ .err()+ .map_or_else(OptionKeys::default, OptionsError::failed_keys),+ _ => OptionKeys::default(),+ }}impl Publishable for WrappedEvent {@@ -446,12 +480,6 @@ impl Publishable for WrappedEvent {buf}- /// Computed here rather than stamped during processing because it depends- /// on the final destination: `apply_restrictions` can disable person- /// processing while an event is still `AnalyticsMain`, and- /// `apply_historical_rerouting` may afterwards move it to- /// `AnalyticsHistorical`, whose consumers need the key. Deciding late- /// keeps the rule correct no matter how the stages are ordered.fn ordering(&self) -> OrderingGuarantee {if !self.destination.absorbs_hot_keys() {return OrderingGuarantee::PerDistinctId;diff --git a/rust/capture/src/v1/test_utils.rs b/rust/capture/src/v1/test_utils.rsindex d3aa15febbd4..d9e875da3b5c 100644--- a/rust/capture/src/v1/test_utils.rs+++ b/rust/capture/src/v1/test_utils.rs@@ -113,31 +113,6 @@ pub fn wrapped_event(event_name: &str, distinct_id: &str) -> WrappedEvent {}}-pub fn wrapped_event_at(timestamp: DateTime<Utc>) -> WrappedEvent {- let uuid = Uuid::new_v4();- WrappedEvent {- event: Event {- event: "$pageview".to_string(),- uuid: uuid.to_string(),- distinct_id: "user-1".to_string(),- timestamp: timestamp.to_rfc3339(),- session_id: None,- window_id: None,- options: RawOptions::default(),- properties: raw_obj("{}"),- },- uuid,- options: Options::default(),- adjusted_timestamp: Some(timestamp),- result: EventResult::Ok,- details: None,- destination: Destination::default(),- force_disable_person_processing: false,- spread_partitions: false,- is_gateway_verified: false,- }-}-pub fn malformed_wrapped_event() -> WrappedEvent {let uuid = Uuid::new_v4();WrappedEvent {