: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): emit structured fields on ingestion warnings (#68972)
José Sequeirab1bdb3d96fd8
diff --git a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts b/nodejs/src/cdp/hog-transformations/hog-transformer.service.tsindex 7e8b6226f3dc..0e55e2eae6af 100644--- a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts+++ b/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts@@ -310,6 +310,7 @@ export class HogTransformerService implements HogTransformer {return {event: null,invocationResults: results,+ droppedBy: { id: hogFunction.id, name: hogFunction.name },}}diff --git a/nodejs/src/common/hog-transformations/hog-transformer.interface.ts b/nodejs/src/common/hog-transformations/hog-transformer.interface.tsindex 9d800658b844..32ca334ab85b 100644--- a/nodejs/src/common/hog-transformations/hog-transformer.interface.ts+++ b/nodejs/src/common/hog-transformations/hog-transformer.interface.ts@@ -12,6 +12,8 @@ export interface HogTransformationResult {event: PluginEvent | null// Opaque to ingestion (it only reads `.length`); cdp narrows this to its concrete result type.invocationResults: unknown[]+ // Set when `event` is null: the transformation that dropped the event.+ droppedBy?: { id: string; name: string }}export interface HogTransformer {diff --git a/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts b/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.tsindex 026ed8a469b2..74290761e43c 100644--- a/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts+++ b/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts@@ -311,9 +311,16 @@ describe('BatchWritingGroupStore', () => {expect(groupRepository.updateGroup).toHaveBeenCalledTimes(0)expect(groupRepository.inTransaction).toHaveBeenCalledTimes(0)// No transaction calls expected since optimistic update failed- expect(emitIngestionWarning).toHaveBeenCalledWith(mockOutputs, teamId, 'group_upsert_message_size_too_large', {- groupTypeIndex: 1,- groupKey: 'test',+ expect(emitIngestionWarning).toHaveBeenCalledWith(mockOutputs, teamId, {+ type: 'group_upsert_message_size_too_large',+ details: {+ groupTypeIndex: 1,+ groupKey: 'test',+ distinctId: `${teamId}:test`,+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'group-store',})})diff --git a/nodejs/src/ingestion/common/groups/batch-writing-group-store.ts b/nodejs/src/ingestion/common/groups/batch-writing-group-store.tsindex c5a7ebef53f4..e54fdb48e3fa 100644--- a/nodejs/src/ingestion/common/groups/batch-writing-group-store.ts+++ b/nodejs/src/ingestion/common/groups/batch-writing-group-store.ts@@ -373,9 +373,16 @@ export class BatchWritingGroupStore implements GroupStore {distinctId: string): Promise<void> {if (error instanceof MessageSizeTooLarge) {- await emitIngestionWarning(this.outputs, update.team_id, 'group_upsert_message_size_too_large', {- groupTypeIndex: update.group_type_index,- groupKey: update.group_key,+ await emitIngestionWarning(this.outputs, update.team_id, {+ type: 'group_upsert_message_size_too_large',+ details: {+ groupTypeIndex: update.group_type_index,+ groupKey: update.group_key,+ distinctId: distinctId,+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'group-store',})return}@@ -755,9 +762,15 @@ export class BatchWritingGroupStore implements GroupStore {batchId: number): Promise<void> {if (error instanceof MessageSizeTooLarge) {- await emitIngestionWarning(this.outputs, teamId, 'group_upsert_message_size_too_large', {- groupTypeIndex,- groupKey,+ await emitIngestionWarning(this.outputs, teamId, {+ type: 'group_upsert_message_size_too_large',+ details: {+ groupTypeIndex,+ groupKey,+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'group-store',})return}diff --git a/nodejs/src/ingestion/common/ingestion-warnings.test.ts b/nodejs/src/ingestion/common/ingestion-warnings.test.tsindex 5d799587068d..bf54748446a1 100644--- a/nodejs/src/ingestion/common/ingestion-warnings.test.ts+++ b/nodejs/src/ingestion/common/ingestion-warnings.test.ts@@ -25,7 +25,19 @@ describe('captureIngestionWarning()', () => {})it('can read own writes', async () => {- await captureIngestionWarning(kafkaProducer, 2, 'some_type', { foo: 'bar' })+ await captureIngestionWarning(kafkaProducer, 2, {+ type: 'some_type',+ // severity inside details must lose to the structured field below+ details: {+ foo: 'bar',+ distinctId: 'user-1',+ personId: '019831c9-6491-7000-8000-000000000000',+ severity: 'from-details',+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'emit-event',+ })const warnings = await clickhouse.delayUntilEventIngested(async () => await clickhouse.query('SELECT * FROM ingestion_warnings')@@ -36,10 +48,40 @@ describe('captureIngestionWarning()', () => {team_id: 2,source: 'plugin-server',type: 'some_type',- details: '{"foo":"bar"}',+ details: expect.any(String),timestamp: expect.any(String),_timestamp: expect.any(String),}),])++ // v2 derives these columns (DEFAULT expressions) from the exact JSON key names+ // emitted by serializeIngestionWarning — a renamed key silently degrades them+ // to the defaults.+ const v2Warnings = await clickhouse.delayUntilEventIngested(+ async () =>+ await clickhouse.query<{+ team_id: number+ type: string+ category: string+ severity: string+ pipeline_step: string+ distinct_id: string | null+ person_id: string | null+ }>(+ 'SELECT team_id, type, category, severity, pipeline_step, distinct_id, person_id FROM ingestion_warnings_v2'+ )+ )++ expect(v2Warnings).toEqual([+ {+ team_id: 2,+ type: 'some_type',+ category: 'size',+ severity: 'error',+ pipeline_step: 'emit-event',+ distinct_id: 'user-1',+ person_id: '019831c9-6491-7000-8000-000000000000',+ },+ ])})})diff --git a/nodejs/src/ingestion/common/ingestion-warnings.ts b/nodejs/src/ingestion/common/ingestion-warnings.tsindex 99819a4aa666..b0d21444c09c 100644--- a/nodejs/src/ingestion/common/ingestion-warnings.ts+++ b/nodejs/src/ingestion/common/ingestion-warnings.ts@@ -15,19 +15,50 @@ export const ingestionWarningCounter = new Counter({labelNames: ['type', 'emitted'],})-function serializeIngestionWarning(teamId: TeamId, type: string, details: Record<string, any>): string {+/**+ * Unified ingestion warning structure used across pipeline warnings and direct producer calls.+ */+export interface IngestionWarning {+ type: string+ details: Record<string, any>+ category?: string+ severity?: 'info' | 'warning' | 'error'+ pipelineStep?: string+ key?: string+ alwaysSend?: boolean+}++/**+ * Structured warning fields for direct producer calls.+ * Subset of IngestionWarning focusing on enrichment metadata.+ */+export interface StructuredWarningFields {+ category?: string+ severity?: 'info' | 'warning' | 'error'+ pipelineStep?: string+}++function serializeIngestionWarning(teamId: TeamId, warning: IngestionWarning): string {+ // Structured fields are spread last so a stray key in details cannot override them.+ // ClickHouse v2 materializes columns from these exact key names (see sql_v2.py).+ const fullDetails = {+ ...warning.details,+ ...(warning.category && { category: warning.category }),+ ...(warning.severity && { severity: warning.severity }),+ ...(warning.pipelineStep && { pipelineStep: warning.pipelineStep }),+ }return JSON.stringify({team_id: teamId,- type: type,+ type: warning.type,source: 'plugin-server',- details: JSON.stringify(details),+ details: JSON.stringify(fullDetails),timestamp: castTimestampOrNow(null, TimestampFormat.ClickHouse),})}-function shouldEmitWarning(teamId: TeamId, type: string, debounce?: { key?: string; alwaysSend?: boolean }): boolean {- const limiterKey = `${teamId}:${type}:${debounce?.key || ''}`- return !!debounce?.alwaysSend || IngestionWarningLimiter.consume(limiterKey, 1)+function shouldEmitWarning(teamId: TeamId, warning: IngestionWarning): boolean {+ const limiterKey = `${teamId}:${warning.type}:${warning.key || ''}`+ return !!warning.alwaysSend || IngestionWarningLimiter.consume(limiterKey, 1)}/**@@ -37,22 +68,25 @@ function shouldEmitWarning(teamId: TeamId, type: string, debounce?: { key?: striexport async function captureIngestionWarning(kafkaProducer: KafkaProducerWrapper,teamId: TeamId,- type: string,- details: Record<string, any>,- debounce?: { key?: string; alwaysSend?: boolean }+ warning: IngestionWarning): Promise<boolean> {- const emitted = shouldEmitWarning(teamId, type, debounce)- ingestionWarningCounter.inc({ type, emitted: emitted.toString() })+ const emitted = shouldEmitWarning(teamId, warning)+ ingestionWarningCounter.inc({ type: warning.type, emitted: emitted.toString() })if (emitted) {return kafkaProducer.queueMessages({topic: KAFKA_INGESTION_WARNINGS,- messages: [{ value: serializeIngestionWarning(teamId, type, details) }],+ messages: [{ value: serializeIngestionWarning(teamId, warning) }],}).then(() => true).catch((error: unknown) => {- logger.warn('⚠️', 'Failed to produce ingestion warning', { error, team_id: teamId, type, details })+ logger.warn('⚠️', 'Failed to produce ingestion warning', {+ error,+ team_id: teamId,+ type: warning.type,+ details: warning.details,+ })return false})}@@ -63,21 +97,24 @@ export async function captureIngestionWarning(export async function emitIngestionWarning(outputs: IngestionOutputs<IngestionWarningsOutput>,teamId: TeamId,- type: string,- details: Record<string, any>,- debounce?: { key?: string; alwaysSend?: boolean }+ warning: IngestionWarning): Promise<boolean> {- const emitted = shouldEmitWarning(teamId, type, debounce)- ingestionWarningCounter.inc({ type, emitted: emitted.toString() })+ const emitted = shouldEmitWarning(teamId, warning)+ ingestionWarningCounter.inc({ type: warning.type, emitted: emitted.toString() })if (emitted) {return outputs.queueMessages(INGESTION_WARNINGS_OUTPUT, [- { value: Buffer.from(serializeIngestionWarning(teamId, type, details)) },+ { value: Buffer.from(serializeIngestionWarning(teamId, warning)) },]).then(() => true).catch((error: unknown) => {- logger.warn('⚠️', 'Failed to produce ingestion warning', { error, team_id: teamId, type, details })+ logger.warn('⚠️', 'Failed to produce ingestion warning', {+ error,+ team_id: teamId,+ type: warning.type,+ details: warning.details,+ })return false})}diff --git a/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts b/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.tsindex 299e3141097a..9320a453e6c8 100644--- a/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts+++ b/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts@@ -724,15 +724,16 @@ describe('BatchWritingPersonStore', () => {await personStore.flush()expect(mockRepo.updatePersonsBatch).toHaveBeenCalled()- expect(emitIngestionWarning).toHaveBeenCalledWith(- mockIngestionWarningsOutputs,- teamId,- 'person_upsert_message_size_too_large',- {- personId: person.id,+ expect(emitIngestionWarning).toHaveBeenCalledWith(mockIngestionWarningsOutputs, teamId, {+ type: 'person_upsert_message_size_too_large',+ details: {+ personId: person.uuid,distinctId: 'test',- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })})describe('dbWriteMode functionality', () => {@@ -908,15 +909,16 @@ describe('BatchWritingPersonStore', () => {await personStore.flush()expect(mockRepo.updatePersonAssertVersion).toHaveBeenCalled()- expect(emitIngestionWarning).toHaveBeenCalledWith(- mockIngestionWarningsOutputs,- teamId,- 'person_upsert_message_size_too_large',- {- personId: person.id,+ expect(emitIngestionWarning).toHaveBeenCalledWith(mockIngestionWarningsOutputs, teamId, {+ type: 'person_upsert_message_size_too_large',+ details: {+ personId: person.uuid,distinctId: 'test',- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })expect(mockRepo.updatePerson).not.toHaveBeenCalled() // No fallback for MessageSizeTooLarge})})diff --git a/nodejs/src/ingestion/common/persons/batch-writing-person-store.ts b/nodejs/src/ingestion/common/persons/batch-writing-person-store.tsindex 6d9ac1740fcf..7a4f4cac7ab1 100644--- a/nodejs/src/ingestion/common/persons/batch-writing-person-store.ts+++ b/nodejs/src/ingestion/common/persons/batch-writing-person-store.ts@@ -788,17 +788,18 @@ export class BatchWritingPersonsStore implements PersonsStore, BatchWritingStore} else {// Handle specific error typesif (result?.error instanceof PersonPropertiesSizeViolationError) {- await emitIngestionWarning(- this.ingestionWarningsOutputs,- update.team_id,- 'person_properties_size_violation',- {- personId: update.id,+ await emitIngestionWarning(this.ingestionWarningsOutputs, update.team_id, {+ type: 'person_properties_size_violation',+ details: {+ personId: update.uuid,distinctId: update.distinct_id,teamId: update.team_id,message: 'Person properties exceeds size limit and was rejected',- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })personWriteMethodAttemptCounter.inc({db_write_mode: this.options.dbWriteMode,method: 'batch',@@ -999,15 +1000,16 @@ export class BatchWritingPersonsStore implements PersonsStore, BatchWritingStoreprivate async handleIndividualUpdateError(error: unknown, update: PersonUpdate): Promise<FlushResult[]> {// If the Kafka message is too large, we can't retry, so we need to capture a warning and stop retryingif (error instanceof MessageSizeTooLarge) {- await emitIngestionWarning(- this.ingestionWarningsOutputs,- update.team_id,- 'person_upsert_message_size_too_large',- {- personId: update.id,+ await emitIngestionWarning(this.ingestionWarningsOutputs, update.team_id, {+ type: 'person_upsert_message_size_too_large',+ details: {+ personId: update.uuid,distinctId: update.distinct_id,- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })personWriteMethodAttemptCounter.inc({db_write_mode: this.options.dbWriteMode,method: this.options.dbWriteMode,@@ -1017,17 +1019,18 @@ export class BatchWritingPersonsStore implements PersonsStore, BatchWritingStore}if (error instanceof PersonPropertiesSizeViolationError) {- await emitIngestionWarning(- this.ingestionWarningsOutputs,- update.team_id,- 'person_properties_size_violation',- {- personId: update.id,+ await emitIngestionWarning(this.ingestionWarningsOutputs, update.team_id, {+ type: 'person_properties_size_violation',+ details: {+ personId: update.uuid,distinctId: update.distinct_id,teamId: update.team_id,message: 'Person properties exceeds size limit and was rejected',- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })personWriteMethodAttemptCounter.inc({db_write_mode: this.options.dbWriteMode,method: this.options.dbWriteMode,diff --git a/nodejs/src/ingestion/common/persons/person-create-service.test.ts b/nodejs/src/ingestion/common/persons/person-create-service.test.tsindex fe79bfb70666..b0e37e9ed257 100644--- a/nodejs/src/ingestion/common/persons/person-create-service.test.ts+++ b/nodejs/src/ingestion/common/persons/person-create-service.test.ts@@ -136,18 +136,20 @@ describe('PersonCreateService', () => {)).rejects.toThrow(PersonPropertiesSizeViolationError)- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- teamId,- 'person_properties_size_violation',- {- personId: 'test-person-id',+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, teamId, {+ type: 'person_properties_size_violation',+ details: {+ // uuidFromDistinctId(teamId, 'test-distinct-id')+ personId: 'f75d0be1-213b-5c13-8aec-acd632d76425',distinctId: 'test-distinct-id',eventUuid: creatorEventUuid,teamId: teamId,message: 'Person properties exceeds size limit and was rejected',- }- )+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',+ })})it('should handle creation conflict and fetch existing person', async () => {diff --git a/nodejs/src/ingestion/common/persons/person-create-service.ts b/nodejs/src/ingestion/common/persons/person-create-service.tsindex b389814642e3..bc4230e1e70c 100644--- a/nodejs/src/ingestion/common/persons/person-create-service.ts+++ b/nodejs/src/ingestion/common/persons/person-create-service.ts@@ -86,12 +86,19 @@ export class PersonCreateService {throw new Error('Unexpected CreatePersonResult state')} catch (error) {if (error instanceof PersonPropertiesSizeViolationError) {- await emitIngestionWarning(this.context.outputs, teamId, 'person_properties_size_violation', {- personId: error.personId,- distinctId: primaryDistinctId.distinctId,- teamId: teamId,- eventUuid: creatorEventUuid,- message: 'Person properties exceeds size limit and was rejected',+ await emitIngestionWarning(this.context.outputs, teamId, {+ type: 'person_properties_size_violation',+ details: {+ // uuid of the person we tried to create; error.personId is a DB row id+ personId: uuid,+ distinctId: primaryDistinctId.distinctId,+ teamId: teamId,+ eventUuid: creatorEventUuid,+ message: 'Person properties exceeds size limit and was rejected',+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'person-store',})throw error}diff --git a/nodejs/src/ingestion/common/persons/person-merge-service.ts b/nodejs/src/ingestion/common/persons/person-merge-service.tsindex 225f55b9371c..1520fd6ccbfa 100644--- a/nodejs/src/ingestion/common/persons/person-merge-service.ts+++ b/nodejs/src/ingestion/common/persons/person-merge-service.ts@@ -173,31 +173,33 @@ export class PersonMergeService {return mergeSuccess(undefined, Promise.resolve(), true)}if (isDistinctIdIllegal(mergeIntoDistinctId)) {- await emitIngestionWarning(- this.context.outputs,- teamId,- 'cannot_merge_with_illegal_distinct_id',- {+ await emitIngestionWarning(this.context.outputs, teamId, {+ type: 'cannot_merge_with_illegal_distinct_id',+ details: {illegalDistinctId: mergeIntoDistinctId,otherDistinctId: otherPersonDistinctId,eventUuid: this.context.event.uuid,},- { alwaysSend: true }- )+ category: 'merge',+ severity: 'warning',+ pipelineStep: 'person-merge',+ alwaysSend: true,+ })return mergeSuccess(undefined, Promise.resolve(), true)}if (isDistinctIdIllegal(otherPersonDistinctId)) {- await emitIngestionWarning(- this.context.outputs,- teamId,- 'cannot_merge_with_illegal_distinct_id',- {+ await emitIngestionWarning(this.context.outputs, teamId, {+ type: 'cannot_merge_with_illegal_distinct_id',+ details: {illegalDistinctId: otherPersonDistinctId,otherDistinctId: mergeIntoDistinctId,eventUuid: this.context.event.uuid,},- { alwaysSend: true }- )+ category: 'merge',+ severity: 'warning',+ pipelineStep: 'person-merge',+ alwaysSend: true,+ })return mergeSuccess(undefined, Promise.resolve(), true)}@@ -359,17 +361,20 @@ export class PersonMergeService {// If merge isn't allowed, we will ignore it, log an ingestion warning and return success with original personif (!mergeAllowed) {- await emitIngestionWarning(- this.context.outputs,- this.context.team.id,- 'cannot_merge_already_identified',- {+ await emitIngestionWarning(this.context.outputs, this.context.team.id, {+ type: 'cannot_merge_already_identified',+ details: {sourcePersonDistinctId: otherPersonDistinctId,targetPersonDistinctId: mergeIntoDistinctId,eventUuid: this.context.event.uuid,+ personId: mergeInto.uuid,+ otherPersonId: otherPerson.uuid,},- { alwaysSend: true }- )+ category: 'merge',+ severity: 'warning',+ pipelineStep: 'person-merge',+ alwaysSend: true,+ })logger.warn('🤔', 'refused to merge an already identified user via an $identify or $create_alias call', {team_id: this.context.team.id,})@@ -417,17 +422,20 @@ export class PersonMergeService {// Handle specific error typesif (result.error instanceof PersonMergeRaceConditionError) {- await emitIngestionWarning(- this.context.outputs,- this.context.team.id,- 'merge_race_condition',- {+ await emitIngestionWarning(this.context.outputs, this.context.team.id, {+ type: 'merge_race_condition',+ details: {sourcePersonDistinctId: otherPersonDistinctId,targetPersonDistinctId: mergeIntoDistinctId,eventUuid: this.context.event.uuid,+ personId: mergeInto.uuid,+ otherPersonId: otherPerson.uuid,},- { alwaysSend: true }- )+ category: 'merge',+ severity: 'error',+ pipelineStep: 'person-merge',+ alwaysSend: true,+ })logger.warn('🤔', 'merge race condition detected, too many concurrent merges', {team_id: this.context.team.id,})diff --git a/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.tsindex f2b62131c514..86c7c06cb5b7 100644--- a/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts@@ -129,9 +129,16 @@ describe('emit-event-step', () => {// The event was not ingested, so the promise resolves with nullawait expect(result.sideEffects[0]).resolves.toBeNull()- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, 1, 'message_size_too_large', {- eventUuid: 'test-uuid',- distinctId: 'test-distinct-id',+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, 1, {+ type: 'message_size_too_large',+ details: {+ eventUuid: 'test-uuid',+ distinctId: 'test-distinct-id',+ personId: 'person-uuid',+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'emit-event',})// Metric should not be incremented when there's an errorexpect(mockEventProcessedAndIngestedCounter.inc).not.toHaveBeenCalled()diff --git a/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.tsindex 1d5b235055b2..ffaab3939ddc 100644--- a/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts@@ -90,9 +90,16 @@ export function createEmitEventStep<O extends string, T extends EmitEventStepInp// Some messages end up significantly larger than the original// after plugin processing, person & group enrichment, etc.if (error instanceof MessageSizeTooLarge) {- await emitIngestionWarning(outputs, serialized.team_id, 'message_size_too_large', {- eventUuid: serialized.uuid,- distinctId: serialized.distinct_id,+ await emitIngestionWarning(outputs, serialized.team_id, {+ type: 'message_size_too_large',+ details: {+ eventUuid: serialized.uuid,+ distinctId: serialized.distinct_id,+ personId: serialized.person_id,+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'emit-event',})// The event was not ingested, so there is no info to resolve withreturn nulldiff --git a/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.tsindex f8e15cbc7cd6..ec755f127fc4 100644--- a/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts@@ -292,10 +292,16 @@ describe('flush-batch-stores-step', () => {await result.sideEffects[0]}- expect(emitIngestionWarning).toHaveBeenCalledWith(mockOutputs, 1, 'message_size_too_large', {- eventUuid: 'uuid1',- distinctId: 'user1',- step: 'flushBatchStoresStep',+ expect(emitIngestionWarning).toHaveBeenCalledWith(mockOutputs, 1, {+ type: 'message_size_too_large',+ details: {+ personId: 'uuid1',+ distinctId: 'user1',+ step: 'flushBatchStoresStep',+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'flush',})})diff --git a/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.tsindex 4c8a0b4ea92f..364c0bc03759 100644--- a/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts@@ -149,10 +149,17 @@ function createProducePromises(personsStoreMessages: FlushResult[], outputs: PerdistinctId: record.distinctId,uuid: record.uuid,})- return emitIngestionWarning(outputs, record.teamId, 'message_size_too_large', {- eventUuid: record.uuid,- distinctId: record.distinctId,- step: 'flushBatchStoresStep',+ return emitIngestionWarning(outputs, record.teamId, {+ type: 'message_size_too_large',+ details: {+ // FlushResult.uuid is the person uuid, not the event uuid+ personId: record.uuid,+ distinctId: record.distinctId,+ step: 'flushBatchStoresStep',+ },+ category: 'size',+ severity: 'error',+ pipelineStep: 'flush',})} else {// Other errors should fail the side effectdiff --git a/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.tsindex 429adb03ff4b..3c33600a947e 100644--- a/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts@@ -41,18 +41,19 @@ export function createHandleClientIngestionWarningStep<TInput extends HandleCliepartition: message.partition,}- const ingested = emitIngestionWarning(- outputs,- team.id,- 'client_ingestion_warning',- {+ const ingested = emitIngestionWarning(outputs, team.id, {+ type: 'client_ingestion_warning',+ details: {eventUuid: event.uuid,event: event.event,distinctId: event.distinct_id,message: event.properties?.$$client_ingestion_warning_message,},- { alwaysSend: true }- ).then((emitted) => (emitted ? ingestedInfo : null))+ category: 'event',+ severity: 'info',+ pipelineStep: 'client-emit',+ alwaysSend: true,+ }).then((emitted) => (emitted ? ingestedInfo : null))return Promise.resolve(ok({ ingested: [ingested] }, [ingested]))}diff --git a/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.tsindex 01fd89c8017e..62b4b201ea95 100644--- a/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts@@ -56,10 +56,11 @@ describe('createHogTransformEventStep', () => {}})- it('drops event when transformation returns null', async () => {+ it('drops event when transformation returns null and emits a warning naming the transformation', async () => {const mockTransformer = createMockHogTransformer(() => ({event: null,invocationResults: [],+ droppedBy: { id: 'hog-fn-1', name: 'Drop internal users' },}))const hogTransformEventStep = createHogTransformEventStep(mockTransformer)const input = createTestInput()@@ -67,7 +68,25 @@ describe('createHogTransformEventStep', () => {const result = await hogTransformEventStep(input)expect(result.type).toBe(PipelineResultType.DROP)- expect(isDropResult(result) && result.reason).toBe('dropped_by_transformation')+ if (isDropResult(result)) {+ expect(result.reason).toBe('dropped_by_transformation')+ expect(result.warnings).toEqual([+ {+ type: 'event_dropped_by_transformation',+ details: {+ eventUuid: input.event.uuid,+ event: '$pageview',+ distinctId: 'user-1',+ transformationId: 'hog-fn-1',+ transformationName: 'Drop internal users',+ },+ category: 'transformation',+ severity: 'info',+ pipelineStep: 'hog-transform',+ key: 'hog-fn-1',+ },+ ])+ }})it('returns transformed event with modified properties', async () => {diff --git a/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.tsindex 579170831c9c..de05c0ff9e3a 100644--- a/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts@@ -1,4 +1,5 @@import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'import { drop, ok } from '~/ingestion/framework/results'import { ProcessingStep } from '~/ingestion/framework/steps'import { PluginEvent } from '~/plugin-scaffold'@@ -34,9 +35,25 @@ export function createHogTransformEventStep<T extends HogTransformEventInput>(const result = await hogTransformer.transformEventAndProduceMessages(event)- // If transformation dropped the event, return drop result+ // If transformation dropped the event, return drop result with a warning+ // so the user can see which transformation dropped itif (result.event === null) {- return drop('dropped_by_transformation')+ const warning: PipelineWarning = {+ type: 'event_dropped_by_transformation',+ details: {+ eventUuid: event.uuid,+ event: event.event,+ distinctId: event.distinct_id,+ transformationId: result.droppedBy?.id,+ transformationName: result.droppedBy?.name,+ },+ category: 'transformation',+ severity: 'info',+ pipelineStep: 'hog-transform',+ // Debounce per transformation so each dropping transformation surfaces+ key: result.droppedBy?.id,+ }+ return drop('dropped_by_transformation', [], [warning])}return ok({diff --git a/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.tsindex bb1423c03142..eb5f8b7ecd2a 100644--- a/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts+++ b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts@@ -156,20 +156,14 @@ describe('IngestionWarningHandlingBatchPipeline', () => {expect(results![0].context.sideEffects).toHaveLength(2)expect(mockEmitIngestionWarning).toHaveBeenCalledTimes(2)- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- team.id,- 'test_warning',- { field: 'value' },- { key: undefined, alwaysSend: undefined }- )- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- team.id,- 'another_warning',- { error: 'something' },- { key: undefined, alwaysSend: undefined }- )+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, team.id, {+ type: 'test_warning',+ details: { field: 'value' },+ })+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, team.id, {+ type: 'another_warning',+ details: { error: 'something' },+ })})it('should handle warning with alwaysSend flag', async () => {@@ -193,13 +187,11 @@ describe('IngestionWarningHandlingBatchPipeline', () => {pipeline.feed(batch)const results = await pipeline.next()- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- team.id,- 'critical_warning',- { urgent: true },- { key: undefined, alwaysSend: true }- )+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, team.id, {+ type: 'critical_warning',+ details: { urgent: true },+ alwaysSend: true,+ })expect(results![0].context.warnings).toEqual([])})@@ -322,20 +314,14 @@ describe('IngestionWarningHandlingBatchPipeline', () => {pipeline.feed(batch)await pipeline.next()- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- team1.id,- 'warning_team1',- { team: 1 },- { key: undefined, alwaysSend: undefined }- )- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- team2.id,- 'warning_team2',- { team: 2 },- { key: undefined, alwaysSend: undefined }- )+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, team1.id, {+ type: 'warning_team1',+ details: { team: 1 },+ })+ expect(mockEmitIngestionWarning).toHaveBeenCalledWith(mockOutputs, team2.id, {+ type: 'warning_team2',+ details: { team: 2 },+ })})})diff --git a/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.tsindex f11a53104bd6..1a2ebcd5ee84 100644--- a/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts+++ b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts@@ -31,13 +31,7 @@ export class IngestionWarningHandlingBatchPipeline<return results.map((resultWithContext) => {if (resultWithContext.context.warnings && resultWithContext.context.warnings.length > 0) {const warningPromises = resultWithContext.context.warnings.map((warning) =>- emitIngestionWarning(- this.outputs,- resultWithContext.context.team.id,- warning.type,- warning.details,- { key: warning.key, alwaysSend: warning.alwaysSend }- )+ emitIngestionWarning(this.outputs, resultWithContext.context.team.id, warning))return {diff --git a/nodejs/src/ingestion/framework/pipeline.interface.ts b/nodejs/src/ingestion/framework/pipeline.interface.tsindex e736a40e0fc3..8dc9032674a5 100644--- a/nodejs/src/ingestion/framework/pipeline.interface.ts+++ b/nodejs/src/ingestion/framework/pipeline.interface.ts@@ -1,13 +1,10 @@import { Message } from 'node-rdkafka'+import { IngestionWarning } from '~/ingestion/common/ingestion-warnings'+import { PipelineResult, PipelineResultOk } from './results'-export interface PipelineWarning {- type: string- details: Record<string, any>- key?: string- alwaysSend?: boolean-}+export type PipelineWarning = IngestionWarning/*** Processing context that carries message through pipeline transformationsdiff --git a/nodejs/src/ingestion/framework/result-handling-helpers.test.ts b/nodejs/src/ingestion/framework/result-handling-helpers.test.tsindex e6b928e6ac6b..47d3145b041b 100644--- a/nodejs/src/ingestion/framework/result-handling-helpers.test.ts+++ b/nodejs/src/ingestion/framework/result-handling-helpers.test.ts@@ -5,7 +5,6 @@ import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'import { logger } from '~/common/utils/logger'import { captureException } from '~/common/utils/posthog'import { PromiseScheduler } from '~/common/utils/promise-scheduler'-import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'import {logDroppedMessage,produceMessageToDLQ,@@ -17,17 +16,8 @@ import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outpujest.mock('~/common/utils/logger')jest.mock('~/common/utils/posthog')-jest.mock('~/ingestion/common/ingestion-warnings', () => {- const actual = jest.requireActual('~/ingestion/common/ingestion-warnings')- return {- ...actual,- emitIngestionWarning: jest.fn(),- }-})-const mockLogger = logger as jest.Mocked<typeof logger>const mockCaptureException = captureException as jest.MockedFunction<typeof captureException>-const mockEmitIngestionWarning = emitIngestionWarning as jest.MockedFunction<typeof emitIngestionWarning>describe('produceMessageToDLQ', () => {let mockOutputs: jest.Mocked<IngestionOutputs<'dlq' | 'ingestion_warnings'>>@@ -52,8 +42,6 @@ describe('produceMessageToDLQ', () => {{ uuid: 'test-uuid-123' },],} as Message-- mockEmitIngestionWarning.mockResolvedValue(true)})it('should send message to DLQ with proper headers and logging', async () => {@@ -71,20 +59,6 @@ describe('produceMessageToDLQ', () => {error: 'Test error',})- expect(mockEmitIngestionWarning).toHaveBeenCalledWith(- mockOutputs,- 42,- 'pipeline_step_dlq',- {- distinctId: 'test-user',- eventUuid: 'test-uuid-123',- error: 'Test error',- event: 'pageview',- step: stepName,- },- { alwaysSend: true }- )-expect(mockOutputs.produce).toHaveBeenCalledWith(DLQ_OUTPUT, {value: mockMessage.value,key: mockMessage.key,@@ -116,8 +90,6 @@ describe('produceMessageToDLQ', () => {event: undefined,error: 'Test error',})-- expect(mockEmitIngestionWarning).not.toHaveBeenCalled()})it('should handle different header value types', async () => {diff --git a/nodejs/src/ingestion/framework/result-handling-helpers.ts b/nodejs/src/ingestion/framework/result-handling-helpers.tsindex a8bbe58e95c7..7750d49280db 100644--- a/nodejs/src/ingestion/framework/result-handling-helpers.ts+++ b/nodejs/src/ingestion/framework/result-handling-helpers.ts@@ -1,11 +1,10 @@import { Message } from 'node-rdkafka'-import { DLQ_OUTPUT, DlqOutput, IngestionWarningsOutput } from '~/common/outputs'+import { DLQ_OUTPUT, DlqOutput } from '~/common/outputs'import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'import { logger } from '~/common/utils/logger'import { captureException } from '~/common/utils/posthog'import { PromiseScheduler } from '~/common/utils/promise-scheduler'-import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'/*** Helper function to copy and extend headers from a Kafka message@@ -73,7 +72,7 @@ function getEventMetadata(message: Message): { teamId?: string; distinctId?: str* Send a Kafka message to the dead letter queue with proper logging and metrics.*/export async function produceMessageToDLQ(- outputs: IngestionOutputs<DlqOutput | IngestionWarningsOutput>,+ outputs: IngestionOutputs<DlqOutput>,originalMessage: Message,error: unknown,stepName: string@@ -91,22 +90,6 @@ export async function produceMessageToDLQ(})try {- if (messageInfo.teamId) {- await emitIngestionWarning(- outputs,- parseInt(messageInfo.teamId, 10),- 'pipeline_step_dlq',- {- distinctId: messageInfo.distinctId || 'unknown',- eventUuid: messageInfo.uuid || 'unknown',- error: error instanceof Error ? error.message : String(error),- event: messageInfo.event || 'unknown',- step,- },- { alwaysSend: true }- )- }-await outputs.produce(DLQ_OUTPUT, {value: originalMessage.value,key: originalMessage.key ?? null,diff --git a/nodejs/tests/helpers/clickhouse.ts b/nodejs/tests/helpers/clickhouse.tsindex 88d1347c875d..14ddcc21e108 100644--- a/nodejs/tests/helpers/clickhouse.ts+++ b/nodejs/tests/helpers/clickhouse.ts@@ -121,7 +121,11 @@ export class Clickhouse {this.truncate('ingestion_warnings'),])- await Promise.allSettled([this.truncate('sharded_ingestion_warnings'), this.truncate('sharded_app_metrics')])+ await Promise.allSettled([+ this.truncate('sharded_ingestion_warnings'),+ this.truncate('sharded_app_metrics'),+ this.truncate('ingestion_warnings_v2'),+ ])}// Topics that this database's Kafka engine tables consume from. Tests pre-create every