: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(ingestion): unify ingestion lag metrics across pipelines (#63064)
Paweł Ledwoń0a769df71419
diff --git a/nodejs/src/common/metrics.ts b/nodejs/src/common/metrics.tsindex 917233c2ed81..5b78eeeea73a 100644--- a/nodejs/src/common/metrics.ts+++ b/nodejs/src/common/metrics.ts@@ -16,12 +16,12 @@ export const cookielessRedisErrorCounter = new Counter({export const ingestionLagGauge = new Gauge({name: 'ingestion_lag_ms',help: 'Time difference in ms between event capture time (now header) and ingestion time',- labelNames: ['topic', 'partition', 'groupId'],+ labelNames: ['topic', 'partition'],})export const ingestionLagHistogram = new Histogram({name: 'ingestion_lag_ms_histogram',help: 'Distribution of ingestion lag per event in ms',- labelNames: ['groupId', 'partition'],+ labelNames: ['partition'],buckets: [1000, 2000, 5000, 10000, 30000, 60000, 120000, 300000, 600000, 900000],})diff --git a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts b/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.tsindex cd20d0db89b9..11ccb37435b0 100644--- a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts+++ b/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts@@ -105,7 +105,6 @@ function buildPipeline(configOverrides: Partial<AiEventSubpipelineConfig> = {})enabledPercentage: 0,stripHeavyTeams: [],},- groupId: 'test-group',topHog: (step) => step,...configOverrides,}diff --git a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts b/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.tsindex 25b1ec72ef58..9e47600084c4 100644--- a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts+++ b/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts@@ -12,8 +12,9 @@ import { PersonsStoreForBatch } from '../../../worker/ingestion/persons/persons-import { AiEventOutput, AsyncOutput, EVENTS_OUTPUT, EventOutput } from '../../analytics/outputs'import { PersonDistinctIdsOutput, PersonsOutput } from '../../analytics/outputs'import { IngestionWarningsOutput } from '../../common/outputs'+import { createRecordIngestionLagStep } from '../../common/steps/record-ingestion-lag'import { createCreateEventStep } from '../../event-processing/create-event-step'-import { createEmitEventStep } from '../../event-processing/emit-event-step'+import { EmitEventStepOutput, createEmitEventStep } from '../../event-processing/emit-event-step'import { EventPipelineRunnerOptions } from '../../event-processing/event-pipeline-options'import { createHogTransformEventStep } from '../../event-processing/hog-transform-event-step'import { createNormalizeEventStep } from '../../event-processing/normalize-event-step'@@ -46,16 +47,14 @@ export interface AiEventSubpipelineConfig {groupTypeManager: GroupTypeManagerhogTransformer: HogTransformerServicesplitAiEventsConfig: SplitAiEventsStepConfig- groupId: stringtopHog: TopHogWrapper}export function createAiEventSubpipeline<TInput extends AiEventSubpipelineInput, TContext>(builder: StartPipelineBuilder<TInput, TContext>,config: AiEventSubpipelineConfig-): PipelineBuilder<TInput, void, TContext, AsyncOutput> {- const { options, outputs, teamManager, groupTypeManager, hogTransformer, splitAiEventsConfig, groupId, topHog } =- config+): PipelineBuilder<TInput, EmitEventStepOutput, TContext, AsyncOutput> {+ const { options, outputs, teamManager, groupTypeManager, hogTransformer, splitAiEventsConfig, topHog } = configreturn builder.pipe(createNormalizeProcessPersonFlagStep())@@ -108,7 +107,6 @@ export function createAiEventSubpipeline<TInput extends AiEventSubpipelineInput,topHog(createEmitEventStep({outputs,- groupId,}),[sum(@@ -136,4 +134,5 @@ export function createAiEventSubpipeline<TInput extends AiEventSubpipelineInput,]))+ .pipe(createRecordIngestionLagStep())}diff --git a/nodejs/src/ingestion/analytics/event-subpipeline.ts b/nodejs/src/ingestion/analytics/event-subpipeline.tsindex 43705724989f..b1a6ca6c6dd8 100644--- a/nodejs/src/ingestion/analytics/event-subpipeline.ts+++ b/nodejs/src/ingestion/analytics/event-subpipeline.ts@@ -9,8 +9,9 @@ import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'import { GroupStoreForBatch } from '../../worker/ingestion/groups/group-store-for-batch'import { PersonsStoreForBatch } from '../../worker/ingestion/persons/persons-store-for-batch'import { IngestionWarningsOutput } from '../common/outputs'+import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'import { createCreateEventStep } from '../event-processing/create-event-step'-import { createEmitEventStep } from '../event-processing/emit-event-step'+import { EmitEventStepOutput, createEmitEventStep } from '../event-processing/emit-event-step'import { EventPipelineRunnerOptions } from '../event-processing/event-pipeline-options'import { createHogTransformEventStep } from '../event-processing/hog-transform-event-step'import { createNormalizeEventStep } from '../event-processing/normalize-event-step'@@ -40,15 +41,14 @@ export interface EventSubpipelineConfig {teamManager: TeamManagergroupTypeManager: GroupTypeManagerhogTransformer: HogTransformerService- groupId: stringtopHog: TopHogWrapper}export function createEventSubpipeline<TInput extends EventSubpipelineInput, TContext>(builder: StartPipelineBuilder<TInput, TContext>,config: EventSubpipelineConfig-): PipelineBuilder<TInput, void, TContext, AsyncOutput> {- const { options, outputs, teamManager, groupTypeManager, hogTransformer, groupId, topHog } = config+): PipelineBuilder<TInput, EmitEventStepOutput, TContext, AsyncOutput> {+ const { options, outputs, teamManager, groupTypeManager, hogTransformer, topHog } = configreturn builder.pipe(createNormalizeProcessPersonFlagStep())@@ -99,7 +99,6 @@ export function createEventSubpipeline<TInput extends EventSubpipelineInput, TCotopHog(createEmitEventStep({outputs,- groupId,}),[sum(@@ -127,4 +126,5 @@ export function createEventSubpipeline<TInput extends EventSubpipelineInput, TCo]))+ .pipe(createRecordIngestionLagStep())}diff --git a/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts b/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.tsindex b6303fe6cc81..80a72eb4caca 100644--- a/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts+++ b/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts@@ -30,6 +30,7 @@ import {createValidateAiEventTokensStep,createValidateHistoricalMigrationStep,} from '../event-preprocessing'+import { EmitEventStepOutput } from '../event-processing/emit-event-step'import { EventPipelineRunnerOptions } from '../event-processing/event-pipeline-options'import { createFlushBatchStoresStep } from '../event-processing/flush-batch-stores-step'import { SplitAiEventsStepConfig } from '../event-processing/split-ai-events-step'@@ -56,7 +57,6 @@ export interface JoinedIngestionPipelineConfig {preservePartitionLocality: booleanpersonsPrefetchEnabled: booleancdpHogWatcherSampleRate: number- groupId: stringoutputs: IngestionOutputs<| EventOutput| AiEventOutput@@ -135,7 +135,6 @@ export function createJoinedIngestionPipeline<preservePartitionLocality,personsPrefetchEnabled,cdpHogWatcherSampleRate,- groupId,outputs,splitAiEventsConfig,perDistinctIdOptions,@@ -186,11 +185,17 @@ export function createJoinedIngestionPipeline<teamManager,groupTypeManager,hogTransformer,- groupId,topHog: topHogWrapper,}- return newBatchingPipeline<TInput, void, TContext, IngestionBatchContext, TContext, OverflowOutput | AsyncOutput>(+ return newBatchingPipeline<+ TInput,+ EmitEventStepOutput,+ TContext,+ IngestionBatchContext,+ TContext,+ OverflowOutput | AsyncOutput+ >((beforeBatch) =>beforeBatch.pipe(createEventFiltersBatchAppMetricsBeforeBatchStep(outputs))diff --git a/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts b/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.tsindex 7a9e5e4a13af..418128710f71 100644--- a/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts+++ b/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts@@ -7,6 +7,7 @@ import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'import { AI_EVENT_TYPES } from '../ai'import { AiEventSubpipelineInput, createAiEventSubpipeline } from '../ai/pipelines/ai-event-subpipeline'import { IngestionWarningsOutput } from '../common/outputs'+import { EmitEventStepOutput } from '../event-processing/emit-event-step'import { EventPipelineRunnerOptions } from '../event-processing/event-pipeline-options'import { SplitAiEventsStepConfig } from '../event-processing/split-ai-events-step'import { IngestionOutputs } from '../outputs/ingestion-outputs'@@ -26,7 +27,6 @@ export interface PerDistinctIdPipelineConfig {teamManager: TeamManagergroupTypeManager: GroupTypeManagerhogTransformer: HogTransformerService- groupId: stringtopHog: TopHogWrapper}@@ -48,9 +48,8 @@ function classifyEvent(input: PerDistinctIdPipelineInput): EventBranch {export function createPerDistinctIdPipeline<TInput extends PerDistinctIdPipelineInput, TContext>(builder: StartPipelineBuilder<TInput, TContext>,config: PerDistinctIdPipelineConfig-): PipelineBuilder<TInput, void, TContext, AsyncOutput> {- const { options, outputs, splitAiEventsConfig, teamManager, groupTypeManager, hogTransformer, groupId, topHog } =- config+): PipelineBuilder<TInput, EmitEventStepOutput, TContext, AsyncOutput> {+ const { options, outputs, splitAiEventsConfig, teamManager, groupTypeManager, hogTransformer, topHog } = configreturn builder.retry((e) =>@@ -64,7 +63,6 @@ export function createPerDistinctIdPipeline<TInput extends PerDistinctIdPipelinegroupTypeManager,hogTransformer,splitAiEventsConfig,- groupId,topHog,}))@@ -75,7 +73,6 @@ export function createPerDistinctIdPipeline<TInput extends PerDistinctIdPipelineteamManager,groupTypeManager,hogTransformer,- groupId,topHog,}))diff --git a/nodejs/src/ingestion/clientwarnings/pipeline.ts b/nodejs/src/ingestion/clientwarnings/pipeline.tsindex b5592e69e2ff..b1ae42356c7c 100644--- a/nodejs/src/ingestion/clientwarnings/pipeline.ts+++ b/nodejs/src/ingestion/clientwarnings/pipeline.ts@@ -12,6 +12,7 @@ import {createEventFiltersBatchAppMetricsBeforeBatchStep,createFlushEventFiltersBatchAppMetricsStep,} from '../common/steps/event-filters-steps'+import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'import { addTeamToContext } from '../common/subpipelines/helpers'import {createParseHeadersStep,@@ -23,6 +24,7 @@ import {} from '../event-preprocessing'import { createApplyBasicEventRestrictionsStep } from '../event-preprocessing/apply-event-restrictions'import { createDropOldEventsStep } from '../event-processing/drop-old-events-step'+import { EmitEventStepOutput } from '../event-processing/emit-event-step'import { createHandleClientIngestionWarningStep } from '../event-processing/handle-client-ingestion-warning-step'import { IngestionOutputs } from '../outputs/ingestion-outputs'import { newBatchingPipeline } from '../pipelines/builders'@@ -58,7 +60,7 @@ export function createClientWarningsPipeline<promiseScheduler,}- return newBatchingPipeline<TInput, void, TContext, EventFiltersBatchContext, TContext>(+ return newBatchingPipeline<TInput, EmitEventStepOutput, TContext, EventFiltersBatchContext, TContext>((beforeBatch) => beforeBatch.pipe(createEventFiltersBatchAppMetricsBeforeBatchStep(outputs)),(batch) =>batch@@ -82,7 +84,8 @@ export function createClientWarningsPipeline<.pipe(createValidateEventPropertiesStep()).pipe(createApplyEventFiltersStep(eventFilterManager)).pipe(createDropOldEventsStep())- .pipe(createHandleClientIngestionWarningStep())+ .pipe(createHandleClientIngestionWarningStep(outputs))+ .pipe(createRecordIngestionLagStep()))).handleIngestionWarnings(outputs)diff --git a/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts b/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.tsnew file mode 100644index 000000000000..c1e34f61b774--- /dev/null+++ b/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts@@ -0,0 +1,170 @@+import { ingestionLagGauge, ingestionLagHistogram } from '../../../common/metrics'+import { IngestedEventInfo } from '../../event-processing/emit-event-step'+import { isOkResult } from '../../pipelines/results'+import { RecordIngestionLagInput, createRecordIngestionLagStep } from './record-ingestion-lag'++const FAKE_NOW_MS = 1702654321987 // 2023-12-15T14:32:01.987Z++/**+ * The step records metrics in fire-and-forget `.then` reactions on the ingested+ * promises (it doesn't await them, so it can sit mid-pipeline). It registers those+ * reactions before the test awaits the same promises, so awaiting them here+ * guarantees the recording has run — no microtask-queue guessing.+ */+async function recorded(ingested: Promise<unknown>[]): Promise<void> {+ await Promise.allSettled(ingested)+}++async function getGaugeValue(topic: string, partition: string): Promise<number | undefined> {+ const metric = await ingestionLagGauge.get()+ return metric.values.find((v) => v.labels.topic === topic && v.labels.partition === partition)?.value+}++async function getHistogramCountAndSum(partition: string): Promise<{ count: number; sum: number } | null> {+ const metric = await ingestionLagHistogram.get()+ const find = (suffix: string): number | undefined =>+ metric.values.find(+ (v) => v.metricName === `ingestion_lag_ms_histogram${suffix}` && v.labels.partition === partition+ )?.value+ const count = find('_count')+ const sum = find('_sum')+ return count === undefined || sum === undefined ? null : { count, sum }+}++async function expectNoSamples(partition: string): Promise<void> {+ expect(await getGaugeValue('test-topic', partition)).toBeUndefined()+ expect(await getHistogramCountAndSum(partition)).toBeNull()+}++describe('record-ingestion-lag', () => {+ beforeEach(() => {+ jest.useFakeTimers()+ jest.setSystemTime(FAKE_NOW_MS)+ ingestionLagGauge.reset()+ ingestionLagHistogram.reset()+ })++ afterEach(() => {+ jest.useRealTimers()+ })++ function ingestedInfo(lagMs: number, partition: number = 5): IngestedEventInfo {+ return {+ capturedAt: new Date(FAKE_NOW_MS - lagMs),+ topic: 'test-topic',+ partition,+ }+ }++ it('records gauge and histogram lag once the ingested promise resolves', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')+ const input: RecordIngestionLagInput = { ingested: [Promise.resolve(ingestedInfo(5432))] }++ const result = await step(input)++ expect(isOkResult(result)).toBe(true)+ if (isOkResult(result)) {+ expect(result.value).toBe(input)+ }+ await recorded(input.ingested)+ expect(await getGaugeValue('test-topic', '5')).toBe(5432)+ expect(await getHistogramCountAndSum('5')).toEqual({ count: 1, sum: 5432 })+ })++ it('measures lag at ack time, not at processing time', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')+ let ack!: (info: IngestedEventInfo) => void+ const pending = new Promise<IngestedEventInfo>((resolve) => {+ ack = resolve+ })++ await step({ ingested: [pending] })+ // Nothing recorded until the ack resolves+ expect(await getHistogramCountAndSum('5')).toBeNull()++ // The ack arrives one second after processing+ jest.setSystemTime(FAKE_NOW_MS + 1000)+ ack(ingestedInfo(2000))+ await recorded([pending])++ expect(await getGaugeValue('test-topic', '5')).toBe(3000)+ expect(await getHistogramCountAndSum('5')).toEqual({ count: 1, sum: 3000 })+ })++ it('records each ingested event separately, gauge keeps the last value per partition', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')+ await expectNoSamples('7')+ const input: RecordIngestionLagInput = {+ ingested: [+ Promise.resolve(ingestedInfo(5000)),+ Promise.resolve(ingestedInfo(2000)),+ Promise.resolve(ingestedInfo(3000, 7)),+ ],+ }++ await step(input)+ await recorded(input.ingested)++ expect(await getGaugeValue('test-topic', '5')).toBe(2000)+ expect(await getGaugeValue('test-topic', '7')).toBe(3000)+ expect(await getHistogramCountAndSum('5')).toEqual({ count: 2, sum: 7000 })+ expect(await getHistogramCountAndSum('7')).toEqual({ count: 1, sum: 3000 })+ })++ it('records partition 0 correctly in both gauge and histogram', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('0')+ const input: RecordIngestionLagInput = { ingested: [Promise.resolve(ingestedInfo(2500, 0))] }++ await step(input)+ await recorded(input.ingested)++ expect(await getGaugeValue('test-topic', '0')).toBe(2500)+ expect(await getHistogramCountAndSum('0')).toEqual({ count: 1, sum: 2500 })+ })++ it.each([+ ['the emission failed', (): Promise<IngestedEventInfo | null> => Promise.reject(new Error('produce failed'))],+ ['the event was not ingested', (): Promise<IngestedEventInfo | null> => Promise.resolve(null)],+ [+ 'the capture time is missing',+ (): Promise<IngestedEventInfo | null> => Promise.resolve({ topic: 'test-topic', partition: 5 }),+ ],+ ])('records no sample when %s', async (_name, makePromise) => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')+ const ingested = [makePromise()]++ await step({ ingested })+ await recorded(ingested)++ await expectNoSamples('5')+ })++ it('records no sample when nothing was emitted', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')++ await step({ ingested: [] })+ await recorded([])++ await expectNoSamples('5')+ })++ // A rejecting ingested promise must not surface as an unhandled rejection: the step+ // attaches an onRejected handler when it observes each promise. jest fails any test+ // that leaks an unhandled rejection, so exercising the reject path here is the guard.+ it('handles a rejecting ingested promise without recording a sample', async () => {+ const step = createRecordIngestionLagStep()+ await expectNoSamples('5')+ const ingested = [Promise.reject(new Error('produce failed'))]++ await step({ ingested })+ await recorded(ingested)++ await expectNoSamples('5')+ })+})diff --git a/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts b/nodejs/src/ingestion/common/steps/record-ingestion-lag.tsnew file mode 100644index 000000000000..79c0a109d21b--- /dev/null+++ b/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts@@ -0,0 +1,44 @@+import { ingestionLagGauge, ingestionLagHistogram } from '../../../common/metrics'+import { IngestedEventInfo } from '../../event-processing/emit-event-step'+import { PipelineResult, ok } from '../../pipelines/results'+import { ProcessingStep } from '../../pipelines/steps'++export interface RecordIngestionLagInput {+ ingested: Promise<IngestedEventInfo | null>[]+}++/**+ * Records ingestion lag for each ingested event, computed from the capture+ * time (`now` header) once the emission has been acked by Kafka. No sample+ * is recorded for events that were not ingested (failed emission, null info)+ * or that have no capture time.+ *+ * The step does not await the promises — it observes them and passes the+ * input through unchanged, so it can be placed anywhere downstream of the+ * emitting step.+ *+ * Pipeline and lane identity come from the registry-wide default labels+ * (`ingestion_pipeline`, `ingestion_lane`), so the metrics only carry+ * topic/partition labels.+ */+export function createRecordIngestionLagStep<T extends RecordIngestionLagInput>(): ProcessingStep<T, T> {+ return function recordIngestionLagStep(input: T): Promise<PipelineResult<T>> {+ for (const promise of input.ingested) {+ void promise.then(recordIngestionLag, () => {+ // The emission failed — the event was not ingested, so no lag sample+ })+ }+ return Promise.resolve(ok(input))+ }+}++function recordIngestionLag(info: IngestedEventInfo | null): void {+ if (info === null || info.capturedAt === undefined) {+ return+ }++ const lag = Date.now() - info.capturedAt.getTime()+ const partition = String(info.partition)+ ingestionLagGauge.labels({ topic: info.topic, partition }).set(lag)+ ingestionLagHistogram.labels({ partition }).observe(lag)+}diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.tsindex c01576306eb4..659ff67252c8 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts@@ -281,7 +281,6 @@ export class ErrorTrackingConsumer {this.pipeline = createErrorTrackingPipeline({outputs: this.deps.outputs,- groupId: this.config.groupId,promiseScheduler: this.promiseScheduler,teamManager: this.deps.teamManager,personRepository: this.deps.personRepository,diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.tsindex ccdf20ed715d..ec5814dc0a7f 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts@@ -312,7 +312,6 @@ describe('ErrorTrackingPipeline', () => {'test'),}),- groupId: 'error-tracking-test',promiseScheduler,teamManager: mockTeamManager,personRepository: mockPersonRepository,diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.tsindex dec16f454905..c97670ce90dc 100644--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts+++ b/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts@@ -17,6 +17,7 @@ import {OverflowOutput,TophogOutput,} from '../common/outputs'+import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'import { CookielessManager } from '../cookieless/cookieless-manager'import {createApplyCookielessProcessingStep,@@ -29,7 +30,7 @@ import {createSkipCookielessRateLimitToOverflowStep,} from '../event-preprocessing'import { createCreateEventStep } from '../event-processing/create-event-step'-import { createEmitEventStep } from '../event-processing/emit-event-step'+import { EmitEventStepOutput, createEmitEventStep } from '../event-processing/emit-event-step'import { createHogTransformEventStep } from '../event-processing/hog-transform-event-step'import { createReadOnlyProcessGroupsStep } from '../event-processing/readonly-process-groups-step'import { IngestionOutputs } from '../outputs/ingestion-outputs'@@ -54,11 +55,11 @@ export interface ErrorTrackingPipelineInput {}/**- * The pipeline output is void because the final step emits to Kafka.- * Successful events are produced to the output topic, while failures- * are handled by the result handling pipeline (DLQ, drop, redirect).+ * The final step emits to Kafka and outputs handles to the in-flight+ * emissions. Successful events are produced to the output topic, while+ * failures are handled by the result handling pipeline (DLQ, drop, redirect).*/-export type ErrorTrackingPipelineOutput = void+export type ErrorTrackingPipelineOutput = EmitEventStepOutputexport type ErrorTrackingOutputs = IngestionOutputs<EventOutput | IngestionWarningsOutput | DlqOutput | OverflowOutput | TophogOutput | AppMetricsOutput@@ -66,7 +67,6 @@ export type ErrorTrackingOutputs = IngestionOutputs<export interface ErrorTrackingPipelineConfig {outputs: ErrorTrackingOutputs- groupId: stringpromiseScheduler: PromiseSchedulerteamManager: TeamManagerpersonRepository: PersonReadRepository@@ -162,7 +162,6 @@ export function createErrorTrackingPipeline(> {const {outputs,- groupId,promiseScheduler,teamManager,personRepository,@@ -289,7 +288,6 @@ export function createErrorTrackingPipeline(topHogWrapper(createEmitEventStep({outputs,- groupId,}),[count('emitted_events', (input) => ({@@ -303,6 +301,7 @@ export function createErrorTrackingPipeline(]))+ .pipe(createRecordIngestionLagStep())))})diff --git a/nodejs/src/ingestion/event-processing/emit-event-step.test.ts b/nodejs/src/ingestion/event-processing/emit-event-step.test.tsindex 76b1b332c4c9..04bc2415e0ff 100644--- a/nodejs/src/ingestion/event-processing/emit-event-step.test.ts+++ b/nodejs/src/ingestion/event-processing/emit-event-step.test.ts@@ -4,7 +4,6 @@ import { Message } from 'node-rdkafka'import { createTestEventHeaders } from '../../../tests/helpers/event-headers'import { createTestMessage } from '../../../tests/helpers/kafka-message'import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'-import { ingestionLagGauge, ingestionLagHistogram } from '../../common/metrics'import { EventHeaders, ISOTimestamp, ProcessedEvent, ProjectId } from '../../types'import { MessageSizeTooLarge } from '../../utils/db/error'import { eventProcessedAndIngestedCounter } from '../../worker/ingestion/event-pipeline/metrics'@@ -32,24 +31,8 @@ jest.mock('../../worker/ingestion/event-pipeline/metrics', () => ({},}))-// Mock the ingestion lag metrics-jest.mock('~/common/metrics', () => ({- ingestionLagGauge: {- labels: jest.fn().mockReturnValue({- set: jest.fn(),- }),- },- ingestionLagHistogram: {- labels: jest.fn().mockReturnValue({- observe: jest.fn(),- }),- },-}))-const mockEmitIngestionWarning = jest.mocked(emitIngestionWarning)const mockEventProcessedAndIngestedCounter = jest.mocked(eventProcessedAndIngestedCounter)-const mockIngestionLagGauge = jest.mocked(ingestionLagGauge)-const mockIngestionLagHistogram = jest.mocked(ingestionLagHistogram)describe('emit-event-step', () => {let mockOutputs: jest.Mocked<IngestionOutputs<EventOutput | IngestionWarningsOutput>>@@ -67,7 +50,6 @@ describe('emit-event-step', () => {config = {outputs: mockOutputs,- groupId: 'test-group-id',}mockProcessedEvent = {@@ -108,7 +90,8 @@ describe('emit-event-step', () => {expect(isOkResult(result)).toBe(true)if (isOkResult(result)) {- expect(result.value).toBeUndefined()+ expect(result.value.ingested).toHaveLength(1)+ expect(result.value.ingested).toEqual(result.sideEffects)}expect(result.sideEffects).toHaveLength(1)expect(mockOutputs.produce).toHaveBeenCalledWith(EVENTS_OUTPUT, {@@ -118,8 +101,12 @@ describe('emit-event-step', () => {teamId: mockProcessedEvent.team_id,})- // Execute the side effect to test metric increment- await result.sideEffects[0]+ // The ingested promise resolves with the event info once acked+ await expect(result.sideEffects[0]).resolves.toEqual({+ capturedAt: mockHeaders.now,+ topic: mockMessage.topic,+ partition: mockMessage.partition,+ })expect(mockEventProcessedAndIngestedCounter.inc).toHaveBeenCalledTimes(1)} finally {jest.useRealTimers()@@ -136,13 +123,10 @@ describe('emit-event-step', () => {const result = await step(input)expect(isOkResult(result)).toBe(true)- if (isOkResult(result)) {- expect(result.value).toBeUndefined()- }expect(result.sideEffects).toHaveLength(1)- // Execute the side effect to test error handling- await result.sideEffects[0]+ // The event was not ingested, so the promise resolves with null+ await expect(result.sideEffects[0]).resolves.toBeNull()expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, 1, 'message_size_too_large', {eventUuid: 'test-uuid',@@ -315,226 +299,4 @@ describe('emit-event-step', () => {expect(productTrackHeader(customEvent)).toBe('general')})})-- describe('ingestion lag metric', () => {- const FAKE_NOW_MS = 1702654321987 // 2023-12-15T14:32:01.987Z- let mockSetFn: jest.Mock- let mockObserveFn: jest.Mock-- const createMessage = (overrides: Partial<Message> = {}): Message => ({- value: Buffer.from('test-value'),- key: Buffer.from('test-key'),- offset: 100,- partition: 5,- topic: 'test-topic',- size: 10,- ...overrides,- })-- beforeEach(() => {- jest.useFakeTimers()- jest.setSystemTime(FAKE_NOW_MS)-- mockSetFn = jest.fn()- mockObserveFn = jest.fn()- mockIngestionLagGauge.labels.mockReturnValue({ set: mockSetFn } as any)- mockIngestionLagHistogram.labels.mockReturnValue({ observe: mockObserveFn } as any)- })-- afterEach(() => {- jest.useRealTimers()- })-- it('should record ingestion lag when headers.now and message are present', async () => {- const captureTime = new Date(FAKE_NOW_MS - 5432) // 5.432 seconds before fake now- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: captureTime }),- message: createMessage(),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).toHaveBeenCalledWith({- topic: 'test-topic',- partition: '5',- groupId: 'test-group-id',- })- expect(mockSetFn).toHaveBeenCalledTimes(1)- expect(mockSetFn).toHaveBeenCalledWith(5432)- })-- it('should not record ingestion lag when headers.now is missing', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders(),- message: createMessage(),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).not.toHaveBeenCalled()- expect(mockSetFn).not.toHaveBeenCalled()- })-- it('should not record ingestion lag when message.topic is undefined', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage({ topic: undefined as unknown as string }),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).not.toHaveBeenCalled()- expect(mockSetFn).not.toHaveBeenCalled()- })-- it('should not record ingestion lag when message.partition is undefined', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage({ partition: undefined as unknown as number }),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).not.toHaveBeenCalled()- expect(mockSetFn).not.toHaveBeenCalled()- })-- it('should use groupId from config in metric labels', async () => {- const customConfig = { ...config, groupId: 'custom-consumer-group' }- const step = createEmitEventStep(customConfig)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage(),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).toHaveBeenCalledWith({- topic: 'test-topic',- partition: '5',- groupId: 'custom-consumer-group',- })- })-- it('should handle partition 0 correctly', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage({ partition: 0 }),- }-- await step(input)-- expect(mockIngestionLagGauge.labels).toHaveBeenCalledWith({- topic: 'test-topic',- partition: '0',- groupId: 'test-group-id',- })- })-- describe('histogram', () => {- it('should observe lag in histogram with correct labels', async () => {- const captureTime = new Date(FAKE_NOW_MS - 5432)- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: captureTime }),- message: createMessage(),- }-- await step(input)-- expect(mockIngestionLagHistogram.labels).toHaveBeenCalledWith({- groupId: 'test-group-id',- partition: '5',- })- expect(mockObserveFn).toHaveBeenCalledTimes(1)- expect(mockObserveFn).toHaveBeenCalledWith(5432)- })-- it('should use custom groupId in histogram labels', async () => {- const customConfig = { ...config, groupId: 'custom-consumer-group' }- const step = createEmitEventStep(customConfig)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage({ partition: 3 }),- }-- await step(input)-- expect(mockIngestionLagHistogram.labels).toHaveBeenCalledWith({- groupId: 'custom-consumer-group',- partition: '3',- })- expect(mockObserveFn).toHaveBeenCalledWith(1000)- })-- it('should not observe histogram when headers.now is missing', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders(),- message: createMessage(),- }-- await step(input)-- expect(mockIngestionLagHistogram.labels).not.toHaveBeenCalled()- expect(mockObserveFn).not.toHaveBeenCalled()- })-- it('should not observe histogram when message.partition is undefined', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 1000) }),- message: createMessage({ partition: undefined as unknown as number }),- }-- await step(input)-- expect(mockIngestionLagHistogram.labels).not.toHaveBeenCalled()- expect(mockObserveFn).not.toHaveBeenCalled()- })-- it('should handle partition 0 correctly in histogram', async () => {- const step = createEmitEventStep(config)- const input: EmitEventStepInput<EventOutput> = {- eventsToEmit: [{ event: mockProcessedEvent, output: EVENTS_OUTPUT }],- teamId: 1,- headers: createTestEventHeaders({ now: new Date(FAKE_NOW_MS - 2500) }),- message: createMessage({ partition: 0 }),- }-- await step(input)-- expect(mockIngestionLagHistogram.labels).toHaveBeenCalledWith({- groupId: 'test-group-id',- partition: '0',- })- expect(mockObserveFn).toHaveBeenCalledWith(2500)- })- })- })})diff --git a/nodejs/src/ingestion/event-processing/emit-event-step.ts b/nodejs/src/ingestion/event-processing/emit-event-step.tsindex 2dc4771b0b76..11cfc455af2d 100644--- a/nodejs/src/ingestion/event-processing/emit-event-step.ts+++ b/nodejs/src/ingestion/event-processing/emit-event-step.ts@@ -1,7 +1,6 @@import { DateTime } from 'luxon'import { Message } from 'node-rdkafka'-import { ingestionLagGauge, ingestionLagHistogram } from '../../common/metrics'import { EventHeaders, ProcessedEvent, RawKafkaEvent, TimestampFormat } from '../../types'import { MessageSizeTooLarge } from '../../utils/db/error'import { safeClickhouseString } from '../../utils/db/utils'@@ -20,7 +19,6 @@ export interface EventToEmit<O extends string> {export interface EmitEventStepConfig<O extends string> {outputs: IngestionOutputs<O | IngestionWarningsOutput>- groupId: string}export interface EmitEventStepInput<O extends string> {@@ -30,21 +28,44 @@ export interface EmitEventStepInput<O extends string> {message: Message}+/**+ * Info about an ingested event, resolved by `ingested` promises once the+ * event has been acked by Kafka.+ */+export interface IngestedEventInfo {+ /** Capture time from the `now` header; undefined when the header is missing. */+ capturedAt?: Date+ /** Topic and partition the event was consumed from. */+ topic: string+ partition: number+}++export interface EmitEventStepOutput {+ /**+ * One promise per emitted event, resolving with the event info once the+ * emission has been acked by Kafka, or with null when the event was not+ * ingested (e.g. rejected as too large). The same promises also flow+ * through side effects for scheduling; this field lets downstream steps+ * (e.g. ingestion lag recording) observe when the events have actually+ * been ingested. Empty when nothing was emitted.+ */+ ingested: Promise<IngestedEventInfo | null>[]+}+export function createEmitEventStep<O extends string, T extends EmitEventStepInput<O>>(config: EmitEventStepConfig<O>-): ProcessingStep<T, void> {+): ProcessingStep<T, EmitEventStepOutput> {return function emitEventStep(input) {const { eventsToEmit, headers, message } = input- const { outputs, groupId } = config+ const { outputs } = config- // Record ingestion lag metric if we have the required data- if (headers?.now && message?.topic !== undefined && message?.partition !== undefined) {- const lag = Date.now() - headers.now.getTime()- ingestionLagGauge.labels({ topic: message.topic, partition: String(message.partition), groupId }).set(lag)- ingestionLagHistogram.labels({ groupId, partition: String(message.partition) }).observe(lag)+ const ingestedInfo: IngestedEventInfo = {+ capturedAt: headers.now,+ topic: message.topic,+ partition: message.partition,}- const sideEffects: Promise<void>[] = []+ const ingested: Promise<IngestedEventInfo | null>[] = []for (const { event, output } of eventsToEmit) {const serialized = serializeEvent(event)@@ -59,9 +80,9 @@ export function createEmitEventStep<O extends string, T extends EmitEventStepInpheaders: { productTrack: productTrackHeader(event) },teamId: serialized.team_id,})- .then((result) => {+ .then(() => {eventProcessedAndIngestedCounter.inc()- return result+ return ingestedInfo}).catch(async (error) => {// TODO: For now we have to live with the ingestion warning happening here@@ -73,15 +94,17 @@ export function createEmitEventStep<O extends string, T extends EmitEventStepInpeventUuid: serialized.uuid,distinctId: serialized.distinct_id,})+ // The event was not ingested, so there is no info to resolve with+ return null} else {throw error}})- sideEffects.push(emitPromise)+ ingested.push(emitPromise)}- return Promise.resolve(ok(undefined, sideEffects))+ return Promise.resolve(ok({ ingested }, ingested))}}diff --git a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts b/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.tsindex e5a7872130df..5d515e7add9a 100644--- a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts+++ b/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts@@ -1,6 +1,12 @@import { v4 } from 'uuid'+import { createTestEventHeaders } from '../../../tests/helpers/event-headers'+import { createTestMessage } from '../../../tests/helpers/kafka-message'+import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'import { createTestPluginEvent } from '../../../tests/helpers/plugin-event'+import { parseJSON } from '../../utils/json-parse'+import { INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput } from '../common/outputs'+import { IngestionOutputs } from '../outputs/ingestion-outputs'import { PipelineResultType } from '../pipelines/results'import {HandleClientIngestionWarningStepInput,@@ -9,6 +15,7 @@ import {describe('handleClientIngestionWarningStep', () => {const eventUuid = v4()+ const capturedAt = new Date('2023-12-15T14:32:01.987Z')const baseEvent = createTestPluginEvent({distinct_id: 'my_id',@@ -20,14 +27,34 @@ describe('handleClientIngestionWarningStep', () => {uuid: eventUuid,})- const baseInput: HandleClientIngestionWarningStepInput = {- event: baseEvent,- }+ let mockOutputs: jest.Mocked<IngestionOutputs<IngestionWarningsOutput>>+ let baseInput: HandleClientIngestionWarningStepInput++ beforeEach(() => {+ mockOutputs = createMockIngestionOutputs<IngestionWarningsOutput>()+ baseInput = {+ event: baseEvent,+ team: { id: 1 },+ headers: createTestEventHeaders({ now: capturedAt }),+ message: createTestMessage(),+ }+ })- const handleStep = createHandleClientIngestionWarningStep()+ function producedWarning(): { team_id: number; type: string; details: Record<string, any> } {+ expect(mockOutputs.queueMessages).toHaveBeenCalledWith(INGESTION_WARNINGS_OUTPUT, [+ { value: expect.any(Buffer) },+ ])+ const value = mockOutputs.queueMessages.mock.calls[0][1][0].value+ if (value === null) {+ throw new Error('expected warning message to have a value')+ }+ const parsed = parseJSON(value.toString())+ return { ...parsed, details: parseJSON(parsed.details) }+ }describe('$$client_ingestion_warning events', () => {- it('processes $$client_ingestion_warning event and adds warning', async () => {+ it('emits the warning and resolves ingested with the event info', async () => {+ const step = createHandleClientIngestionWarningStep(mockOutputs)const input: HandleClientIngestionWarningStepInput = {...baseInput,event: {@@ -37,45 +64,50 @@ describe('handleClientIngestionWarningStep', () => {},}- const result = await handleStep(input)+ const result = await step(input)expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value).toBeUndefined()+ expect(result.value.ingested).toHaveLength(1)+ expect(result.value.ingested).toEqual(result.sideEffects)+ await expect(result.value.ingested[0]).resolves.toEqual({+ capturedAt,+ topic: 'test-topic',+ partition: 5,+ })}- expect(result.warnings).toHaveLength(1)- expect(result.warnings[0]).toMatchObject({- type: 'client_ingestion_warning',- details: {- eventUuid: eventUuid,- event: '$$client_ingestion_warning',- distinctId: 'my_id',- message: 'Test warning message',- },- alwaysSend: true,++ const warning = producedWarning()+ expect(warning.team_id).toBe(1)+ expect(warning.type).toBe('client_ingestion_warning')+ expect(warning.details).toMatchObject({+ eventUuid: eventUuid,+ event: '$$client_ingestion_warning',+ distinctId: 'my_id',+ message: 'Test warning message',})})- it('includes message property in warning details', async () => {+ it('handles missing warning message property', async () => {+ const step = createHandleClientIngestionWarningStep(mockOutputs)const input: HandleClientIngestionWarningStepInput = {...baseInput,event: {...baseEvent,event: '$$client_ingestion_warning',- properties: { $$client_ingestion_warning_message: 'Custom error message!' },+ properties: {},},}- const result = await handleStep(input)+ const result = await step(input)expect(result.type).toBe(PipelineResultType.OK)- if (result.type === PipelineResultType.OK) {- expect(result.value).toBeUndefined()- }- expect(result.warnings[0].details.message).toBe('Custom error message!')+ expect(producedWarning().details.message).toBeUndefined()})- it('handles missing warning message property', async () => {+ it('resolves ingested with null when the warning could not be produced', async () => {+ mockOutputs.queueMessages.mockRejectedValue(new Error('produce failed'))+ const step = createHandleClientIngestionWarningStep(mockOutputs)const input: HandleClientIngestionWarningStepInput = {...baseInput,event: {@@ -85,72 +117,35 @@ describe('handleClientIngestionWarningStep', () => {},}- const result = await handleStep(input)+ const result = await step(input)expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value).toBeUndefined()+ await expect(result.value.ingested[0]).resolves.toBeNull()}- expect(result.warnings[0].details.message).toBeUndefined()})})describe('non-client ingestion warning events', () => {- it('DLQs regular events', async () => {- const input: HandleClientIngestionWarningStepInput = {- ...baseInput,- event: {- ...baseEvent,- event: '$pageview',- },- }-- const result = await handleStep(input)-- expect(result.type).toBe(PipelineResultType.DLQ)- if (result.type === PipelineResultType.DLQ) {- expect(result.reason).toBe('unexpected_event_type')- expect(result.error).toBeInstanceOf(Error)- expect((result.error as Error).message).toBe('Expected $$client_ingestion_warning, got $pageview')- }- })-- it('DLQs $identify events', async () => {- const input: HandleClientIngestionWarningStepInput = {- ...baseInput,- event: {- ...baseEvent,- event: '$identify',- },- }-- const result = await handleStep(input)-- expect(result.type).toBe(PipelineResultType.DLQ)- if (result.type === PipelineResultType.DLQ) {- expect(result.reason).toBe('unexpected_event_type')- expect(result.error).toBeInstanceOf(Error)- expect((result.error as Error).message).toBe('Expected $$client_ingestion_warning, got $identify')- }- })-- it('DLQs custom events', async () => {+ it.each([['$pageview'], ['$identify'], ['custom_event']])('DLQs %s events', async (eventName) => {+ const step = createHandleClientIngestionWarningStep(mockOutputs)const input: HandleClientIngestionWarningStepInput = {...baseInput,event: {...baseEvent,- event: 'custom_event',+ event: eventName,},}- const result = await handleStep(input)+ const result = await step(input)expect(result.type).toBe(PipelineResultType.DLQ)if (result.type === PipelineResultType.DLQ) {expect(result.reason).toBe('unexpected_event_type')expect(result.error).toBeInstanceOf(Error)- expect((result.error as Error).message).toBe('Expected $$client_ingestion_warning, got custom_event')+ expect((result.error as Error).message).toBe(`Expected $$client_ingestion_warning, got ${eventName}`)}+ expect(mockOutputs.queueMessages).not.toHaveBeenCalled()})})})diff --git a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts b/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.tsindex d28bdefc28d2..9e67557eefe5 100644--- a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts+++ b/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts@@ -1,17 +1,33 @@+import { Message } from 'node-rdkafka'+import { PluginEvent } from '~/plugin-scaffold'+import { EventHeaders } from '../../types'+import { emitIngestionWarning } from '../common/ingestion-warnings'+import { IngestionWarningsOutput } from '../common/outputs'+import { IngestionOutputs } from '../outputs/ingestion-outputs'import { PipelineResult, dlq, ok } from '../pipelines/results'import { ProcessingStep } from '../pipelines/steps'+import { EmitEventStepOutput, IngestedEventInfo } from './emit-event-step'export interface HandleClientIngestionWarningStepInput {event: PluginEvent+ team: { id: number }+ headers: EventHeaders+ message: Message}-export function createHandleClientIngestionWarningStep<- TInput extends HandleClientIngestionWarningStepInput,->(): ProcessingStep<TInput, void> {- return async function handleClientIngestionWarningStep(input: TInput): Promise<PipelineResult<void>> {- const event = input.event+/**+ * Emits a `client_ingestion_warning` ingestion warning for the event. Mirrors+ * the emit event step's output: the warning produce promise resolves with the+ * ingested event info (or null when the warning could not be produced) so+ * downstream steps can observe when the event has been ingested.+ */+export function createHandleClientIngestionWarningStep<TInput extends HandleClientIngestionWarningStepInput>(+ outputs: IngestionOutputs<IngestionWarningsOutput>+): ProcessingStep<TInput, EmitEventStepOutput> {+ return function handleClientIngestionWarningStep(input: TInput): Promise<PipelineResult<EmitEventStepOutput>> {+ const { event, team, headers, message } = inputif (event.event !== '$$client_ingestion_warning') {return Promise.resolve(@@ -19,21 +35,25 @@ export function createHandleClientIngestionWarningStep<)}- return ok(- undefined,- [],- [- {- type: 'client_ingestion_warning',- details: {- eventUuid: event.uuid,- event: event.event,- distinctId: event.distinct_id,- message: event.properties?.$$client_ingestion_warning_message,- },- alwaysSend: true,- },- ]- )+ const ingestedInfo: IngestedEventInfo = {+ capturedAt: headers.now,+ topic: message.topic,+ partition: message.partition,+ }++ const ingested = emitIngestionWarning(+ outputs,+ team.id,+ 'client_ingestion_warning',+ {+ eventUuid: event.uuid,+ event: event.event,+ distinctId: event.distinct_id,+ message: event.properties?.$$client_ingestion_warning_message,+ },+ { alwaysSend: true }+ ).then((emitted) => (emitted ? ingestedInfo : null))++ return Promise.resolve(ok({ ingested: [ingested] }, [ingested]))}}diff --git a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts b/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.tsindex ebbf33e31923..19946f0adbae 100644--- a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts+++ b/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts@@ -1,6 +1,9 @@+import { Message } from 'node-rdkafka'+import { createTestEventHeaders } from '../../../tests/helpers/event-headers'+import { createTestMessage } from '../../../tests/helpers/kafka-message'import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'-import { ISOTimestamp, PreIngestionEvent, ProjectId } from '../../types'+import { EventHeaders, ISOTimestamp, PreIngestionEvent, ProjectId } from '../../types'import { parseJSON } from '../../utils/json-parse'import { cloneObject } from '../../utils/utils'import { IngestionOutputs } from '../outputs/ingestion-outputs'@@ -53,16 +56,23 @@ describe('createExtractHeatmapDataStep', () => {step = createExtractHeatmapDataStep(mockOutputs)})+ // The pipeline always provides headers and message at this step; fill defaults so each+ // test only specifies what it cares about.+ const runStep = (input: {+ preparedEvent: PreIngestionEvent+ headers?: EventHeaders+ message?: Message+ }): ReturnType<typeof step> => step({ headers: createTestEventHeaders(), message: createTestMessage(), ...input })+describe('no heatmap or scroll depth data', () => {it('returns OK with no side effects when no $heatmap_data or scroll depth data is present', async () => {const event = createTestEvent()delete event.properties.$heatmap_data- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value.preparedEvent).toEqual(event)expect(result.sideEffects).toEqual([])expect(result.warnings).toEqual([])}@@ -73,7 +83,7 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()event.properties.$heatmap_data = null- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).not.toHaveBeenCalled()@@ -83,7 +93,7 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()event.properties.$heatmap_data = undefined- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).not.toHaveBeenCalled()@@ -94,20 +104,13 @@ describe('createExtractHeatmapDataStep', () => {it('extracts and queues heatmap data', async () => {const event = createTestEvent()- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {// Original event should not be mutatedexpect(event.properties.$heatmap_data).toBeDefined()- // Result should have heatmap data removed- expect(result.value.preparedEvent.properties.$heatmap_data).toBeUndefined()-- // Should preserve other properties- expect(result.value.preparedEvent.properties.$current_url).toBe('http://localhost:3000/')- expect(result.value.preparedEvent.properties.$session_id).toBe('018eebf3-79cd-70da-895f-b6cf352bd688')-expect(result.sideEffects).toHaveLength(1)expect(result.warnings).toEqual([])}@@ -149,7 +152,7 @@ describe('createExtractHeatmapDataStep', () => {'http://localhost:3000/about': [{ x: 300, y: 400, target_fixed: true, type: 'mousemove' }],}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -170,7 +173,7 @@ describe('createExtractHeatmapDataStep', () => {$prev_pageview_max_scroll: 225,}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -206,7 +209,7 @@ describe('createExtractHeatmapDataStep', () => {$prev_pageview_max_scroll: 500,}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -231,11 +234,10 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()event.properties.$heatmap_data = {}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value.preparedEvent.properties.$heatmap_data).toBeUndefined()expect(result.sideEffects).toEqual([])}expect(mockOutputs.queueMessages).not.toHaveBeenCalled()@@ -244,7 +246,7 @@ describe('createExtractHeatmapDataStep', () => {it('drops event with invalid distinct_id', async () => {const event = createTestEvent({ distinctId: '' })- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.DROP)if (result.type === PipelineResultType.DROP) {@@ -256,7 +258,7 @@ describe('createExtractHeatmapDataStep', () => {it('drops event with illegal distinct_id', async () => {const event = createTestEvent({ distinctId: 'distinct_id' })- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.DROP)if (result.type === PipelineResultType.DROP) {@@ -270,7 +272,7 @@ describe('createExtractHeatmapDataStep', () => {event.properties.$viewport_height = NaNevent.properties.$viewport_width = 1071- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.DROP)if (result.type === PipelineResultType.DROP) {@@ -283,7 +285,7 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()delete event.properties.$viewport_height- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.DROP)if (result.type === PipelineResultType.DROP) {@@ -297,7 +299,7 @@ describe('createExtractHeatmapDataStep', () => {' ': [{ x: 100, y: 200, target_fixed: false, type: 'click' }],}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {@@ -320,7 +322,7 @@ describe('createExtractHeatmapDataStep', () => {'http://localhost:3000/': 'not an array' as any,}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {@@ -350,7 +352,7 @@ describe('createExtractHeatmapDataStep', () => {],}- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -365,13 +367,13 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()const originalEvent = cloneObject(event)- await step({ preparedEvent: event })+ await runStep({ preparedEvent: event })expect(event).toEqual(originalEvent)expect(event.properties.$heatmap_data).toBeDefined()})- it('preserves input properties in the result', async () => {+ it('returns only the ingested handles', async () => {const event = createTestEvent()const input = {preparedEvent: event,@@ -379,14 +381,12 @@ describe('createExtractHeatmapDataStep', () => {anotherField: 123,}- const result = await step(input as any)+ const result = await runStep(input as any)expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value).toMatchObject({- customField: 'test-value',- anotherField: 123,- })+ // The event is not emitted onwards — the step returns only the lag handles.+ expect(Object.keys(result.value)).toEqual(['ingested'])}})})@@ -400,7 +400,7 @@ describe('createExtractHeatmapDataStep', () => {}event.distinctId = null as any // This should cause an error- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })// The error should be caught and converted to a warningexpect(result.type).toBe(PipelineResultType.DROP)@@ -416,7 +416,7 @@ describe('createExtractHeatmapDataStep', () => {event.properties.$viewport_height = 1600event.properties.$viewport_width = 1280- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -437,11 +437,11 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()const headers = createTestEventHeaders({ skip_heatmap_processing: true })- const result = await step({ preparedEvent: event, headers })+ const result = await runStep({ preparedEvent: event, headers })expect(result.type).toBe(PipelineResultType.OK)if (result.type === PipelineResultType.OK) {- expect(result.value.preparedEvent).toBe(event)+ expect(result.value.ingested).toEqual([])expect(result.sideEffects).toEqual([])expect(result.warnings).toEqual([])}@@ -452,7 +452,7 @@ describe('createExtractHeatmapDataStep', () => {const event = createTestEvent()const headers = createTestEventHeaders({ skip_heatmap_processing: false })- const result = await step({ preparedEvent: event, headers })+ const result = await runStep({ preparedEvent: event, headers })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)@@ -461,10 +461,66 @@ describe('createExtractHeatmapDataStep', () => {it('extracts normally when headers are not provided', async () => {const event = createTestEvent()- const result = await step({ preparedEvent: event })+ const result = await runStep({ preparedEvent: event })expect(result.type).toBe(PipelineResultType.OK)expect(mockOutputs.queueMessages).toHaveBeenCalledTimes(1)})})++ describe('ingestion lag tracking', () => {+ const capturedAt = new Date('2023-12-15T14:32:01.987Z')++ it('resolves ingested with source event info once the produce is acked', async () => {+ const event = createTestEvent()+ const headers = createTestEventHeaders({ now: capturedAt })+ const message = createTestMessage({ topic: 'heatmaps_topic', partition: 3 })++ const result = await runStep({ preparedEvent: event, headers, message })++ expect(result.type).toBe(PipelineResultType.OK)+ if (result.type === PipelineResultType.OK) {+ expect(result.value.ingested).toHaveLength(1)+ await expect(result.value.ingested[0]).resolves.toEqual({+ capturedAt,+ topic: 'heatmaps_topic',+ partition: 3,+ })+ }+ })++ it('records no ingested handle when there is no heatmap data', async () => {+ const event = createTestEvent()+ delete event.properties.$heatmap_data+ const message = createTestMessage()++ const result = await runStep({ preparedEvent: event, message })++ expect(result.type).toBe(PipelineResultType.OK)+ if (result.type === PipelineResultType.OK) {+ expect(result.value.ingested).toEqual([])+ }+ })++ // A failed produce must resolve the lag promise to null rather than reject it, so it+ // can never surface as an unhandled rejection (the step's then() handles both branches).+ // jest fails any test that leaks an unhandled rejection, so this also guards that.+ it('resolves ingested to null when the produce fails, without rejecting', async () => {+ mockOutputs.queueMessages.mockRejectedValue(new Error('produce failed'))+ const event = createTestEvent()+ const message = createTestMessage()++ const result = await runStep({+ preparedEvent: event,+ headers: createTestEventHeaders({ now: capturedAt }),+ message,+ })++ expect(result.type).toBe(PipelineResultType.OK)+ if (result.type === PipelineResultType.OK) {+ expect(result.value.ingested).toHaveLength(1)+ await expect(result.value.ingested[0]).resolves.toBeNull()+ }+ })+ })})diff --git a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts b/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.tsindex 39afea16cf71..4a67e402f606 100644--- a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts+++ b/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts@@ -1,9 +1,11 @@+import { Message } from 'node-rdkafka'import { URL } from 'url'import { EventHeaders, PreIngestionEvent, RawClickhouseHeatmapEvent, TimestampFormat } from '../../types'import { logger } from '../../utils/logger'import { castTimestampOrNow } from '../../utils/utils'import { isDistinctIdIllegal } from '../../worker/ingestion/persons/person-merge-service'+import { EmitEventStepOutput, IngestedEventInfo } from '../event-processing/emit-event-step'import { IngestionOutputs } from '../outputs/ingestion-outputs'import { PipelineWarning } from '../pipelines/pipeline.interface'import { PipelineResult, drop, isOkResult, ok } from '../pipelines/results'@@ -12,31 +14,38 @@ import { HEATMAPS_OUTPUT, HeatmapsOutput } from './outputs'export interface ExtractHeatmapDataStepInput {preparedEvent: PreIngestionEvent- headers?: EventHeaders-}--export type ExtractHeatmapDataStepResult<TInput> = TInput & {- preparedEvent: PreIngestionEvent+ headers: EventHeaders+ message: Message}+/**+ * Terminal step of the heatmaps pipeline: extracts heatmap data and produces it to+ * Kafka. The event itself is not emitted onwards, so only the `ingested` handles+ * (for the lag step) are returned — see EmitEventStepOutput.+ */export function createExtractHeatmapDataStep<TInput extends ExtractHeatmapDataStepInput>(outputs: IngestionOutputs<HeatmapsOutput>-): ProcessingStep<TInput, ExtractHeatmapDataStepResult<TInput>> {- return async function extractHeatmapDataStep(- input: TInput- ): Promise<PipelineResult<ExtractHeatmapDataStepResult<TInput>>> {- const { preparedEvent, headers } = input+): ProcessingStep<TInput, EmitEventStepOutput> {+ return async function extractHeatmapDataStep(input: TInput): Promise<PipelineResult<EmitEventStepOutput>> {+ const { preparedEvent, headers, message } = inputconst { eventUuid } = preparedEvent// When capture has already redirected heatmap data to the heatmaps topic,// skip extraction here — capture strips $heatmap_data before publishing.- if (headers?.skip_heatmap_processing) {- return Promise.resolve(ok(input))+ if (headers.skip_heatmap_processing) {+ return Promise.resolve(ok({ ingested: [] }))}const acks: Promise<void>[] = []+ const ingested: Promise<IngestedEventInfo | null>[] = []const warnings: PipelineWarning[] = []+ const ingestedInfo: IngestedEventInfo = {+ capturedAt: headers.now,+ topic: message.topic,+ partition: message.partition,+ }+try {const extractResult = extractScrollDepthHeatmapData(preparedEvent)@@ -48,14 +57,22 @@ export function createExtractHeatmapDataStep<TInput extends ExtractHeatmapDataStwarnings.push(...extractWarnings)if (heatmapEvents.length > 0) {- acks.push(- outputs.queueMessages(- HEATMAPS_OUTPUT,- heatmapEvents.map((rawEvent) => ({- key: eventUuid,- value: Buffer.from(JSON.stringify(rawEvent)),- teamId: preparedEvent.teamId,- }))+ const ack = outputs.queueMessages(+ HEATMAPS_OUTPUT,+ heatmapEvents.map((rawEvent) => ({+ key: eventUuid,+ value: Buffer.from(JSON.stringify(rawEvent)),+ teamId: preparedEvent.teamId,+ }))+ )+ acks.push(ack)+ // Self-handle the lag-tracking branch so a produce failure can never surface+ // as an unhandled rejection: a failed produce resolves to null (no lag sample).+ // The raw `ack` in side effects still carries the error for normal handling.+ ingested.push(+ ack.then(+ () => ingestedInfo,+ () => null))}@@ -68,14 +85,7 @@ export function createExtractHeatmapDataStep<TInput extends ExtractHeatmapDataSt})}- // Create a copy without the $heatmap_data property (we don't want to ingest this to the events table)- const { $heatmap_data, ...propertiesWithoutHeatmapData } = preparedEvent.properties- const preparedEventWithoutHeatmapData: PreIngestionEvent = {- ...preparedEvent,- properties: propertiesWithoutHeatmapData,- }-- return Promise.resolve(ok({ ...input, preparedEvent: preparedEventWithoutHeatmapData }, acks, warnings))+ return Promise.resolve(ok({ ingested }, acks, warnings))}}diff --git a/nodejs/src/ingestion/heatmaps/pipeline.ts b/nodejs/src/ingestion/heatmaps/pipeline.tsindex 1bea3a256848..cf598a28dbc6 100644--- a/nodejs/src/ingestion/heatmaps/pipeline.ts+++ b/nodejs/src/ingestion/heatmaps/pipeline.ts@@ -12,6 +12,7 @@ import {createEventFiltersBatchAppMetricsBeforeBatchStep,createFlushEventFiltersBatchAppMetricsStep,} from '../common/steps/event-filters-steps'+import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'import { addTeamToContext } from '../common/subpipelines/helpers'import { CookielessManager } from '../cookieless/cookieless-manager'import {@@ -25,6 +26,7 @@ import {} from '../event-preprocessing'import { createApplyBasicEventRestrictionsStep } from '../event-preprocessing/apply-event-restrictions'import { createDropOldEventsStep } from '../event-processing/drop-old-events-step'+import { EmitEventStepOutput } from '../event-processing/emit-event-step'import { createNormalizeEventStep } from '../event-processing/normalize-event-step'import { createPrepareEventStep } from '../event-processing/prepare-event-step'import { IngestionOutputs } from '../outputs/ingestion-outputs'@@ -34,7 +36,6 @@ import { createCheckHeatmapOptInStep } from './check-heatmap-opt-in-step'import { createDisablePersonProcessingStep } from './disable-person-processing-step'import { createExtractHeatmapDataStep } from './extract-heatmap-data-step'import { HeatmapsOutput } from './outputs'-import { createSkipEmitEventStep } from './skip-emit-event-step'export interface HeatmapsPipelineConfig {outputs: IngestionOutputs<HeatmapsOutput | IngestionWarningsOutput | DlqOutput | AppMetricsOutput>@@ -73,7 +74,7 @@ export function createHeatmapsPipeline<TInput extends HeatmapsPipelineInput, TCopromiseScheduler,}- return newBatchingPipeline<TInput, void, TContext, EventFiltersBatchContext, TContext>(+ return newBatchingPipeline<TInput, EmitEventStepOutput, TContext, EventFiltersBatchContext, TContext>((beforeBatch) => beforeBatch.pipe(createEventFiltersBatchAppMetricsBeforeBatchStep(outputs)),(batch) =>batch@@ -111,7 +112,7 @@ export function createHeatmapsPipeline<TInput extends HeatmapsPipelineInput, TCo.pipe(createNormalizeEventStep()).pipe(createPrepareEventStep()).pipe(createExtractHeatmapDataStep(outputs))- .pipe(createSkipEmitEventStep())+ .pipe(createRecordIngestionLagStep()))).handleIngestionWarnings(outputs)diff --git a/nodejs/src/ingestion/heatmaps/skip-emit-event-step.ts b/nodejs/src/ingestion/heatmaps/skip-emit-event-step.tsdeleted file mode 100644index b018e30898b7..000000000000--- a/nodejs/src/ingestion/heatmaps/skip-emit-event-step.ts+++ /dev/null@@ -1,8 +0,0 @@-import { PipelineResult, ok } from '../pipelines/results'-import { ProcessingStep } from '../pipelines/steps'--export function createSkipEmitEventStep<TInput>(): ProcessingStep<TInput, void> {- return function skipEmitEventStep(_input: TInput): Promise<PipelineResult<void>> {- return Promise.resolve(ok(undefined))- }-}diff --git a/nodejs/src/ingestion/ingestion-consumer.ts b/nodejs/src/ingestion/ingestion-consumer.tsindex 803552aea647..51bd185fde6b 100644--- a/nodejs/src/ingestion/ingestion-consumer.ts+++ b/nodejs/src/ingestion/ingestion-consumer.ts@@ -261,7 +261,6 @@ export class IngestionConsumer {preservePartitionLocality: this.config.INGESTION_OVERFLOW_PRESERVE_PARTITION_LOCALITY,personsPrefetchEnabled: this.config.PERSONS_PREFETCH_ENABLED,cdpHogWatcherSampleRate: this.config.CDP_HOG_WATCHER_SAMPLE_RATE,- groupId: this.groupId,outputs,splitAiEventsConfig: parseSplitAiEventsConfig(this.config.INGESTION_AI_EVENT_SPLITTING_ENABLED,diff --git a/nodejs/src/servers/ingestion-api-server.ts b/nodejs/src/servers/ingestion-api-server.tsindex a1085b405158..590b61ef188f 100644--- a/nodejs/src/servers/ingestion-api-server.ts+++ b/nodejs/src/servers/ingestion-api-server.ts@@ -338,15 +338,12 @@ export class IngestionApiServer implements NodeServer {this.topHog.start()// 7. Create the ingestion pipeline- const groupId = this.config.INGESTION_CONSUMER_GROUP_ID-const joinedPipelineConfig: JoinedIngestionPipelineConfig = {eventSchemaEnforcementEnabled: this.config.EVENT_SCHEMA_ENFORCEMENT_ENABLED,overflowEnabled: this.overflowEnabled(),preservePartitionLocality: this.config.INGESTION_OVERFLOW_PRESERVE_PARTITION_LOCALITY,personsPrefetchEnabled: this.config.PERSONS_PREFETCH_ENABLED,cdpHogWatcherSampleRate: this.config.CDP_HOG_WATCHER_SAMPLE_RATE,- groupId,outputs: ingestionOutputs,splitAiEventsConfig: parseSplitAiEventsConfig(this.config.INGESTION_AI_EVENT_SPLITTING_ENABLED,