:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(workflows): let the matcher read internal events from their own cluster (#100965)
Harley Alexander0dfe05e1fe87
diff --git a/nodejs/src/cdp/config.ts b/nodejs/src/cdp/config.tsindex 59bf1d2a0eef..62feb3dc9a0f 100644--- a/nodejs/src/cdp/config.ts+++ b/nodejs/src/cdp/config.ts@@ -61,6 +61,8 @@ export type CdpConfig = ClickhouseConfig & {CDP_CYCLOTRON_COMPRESS_KAFKA_DATA: boolean// Off until Django emits `$workflow_step_resume`, or parked steps never wake.CDP_HOGFLOW_AWAITED_STEPS_ENABLED: boolean+ // Django produces cdp_internal_events to the cyclotron cluster; empty inherits the consumer default.+ CDP_INTERNAL_EVENTS_CONSUMER_METADATA_BROKER_LIST: stringCDP_REDIS_HOST: stringCDP_REDIS_PORT: numberCDP_REDIS_PASSWORD: string@@ -262,6 +264,7 @@ export function getDefaultCdpConfig(): CdpConfig {CDP_CYCLOTRON_USE_BULK_COPY_JOB: isProdEnv() ? false : true,CDP_CYCLOTRON_COMPRESS_KAFKA_DATA: true,CDP_HOGFLOW_AWAITED_STEPS_ENABLED: isProdEnv() ? false : true,+ CDP_INTERNAL_EVENTS_CONSUMER_METADATA_BROKER_LIST: '',CDP_REDIS_HOST: '127.0.0.1',CDP_REDIS_PORT: 6379,CDP_REDIS_PASSWORD: '',diff --git a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.tsindex b1c759359ceb..b92b50186a82 100644--- a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts+++ b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts@@ -1,6 +1,8 @@import '../../../tests/helpers/mocks/consumer.mock'import { HogFlow } from '~/cdp/schema/hogflow'+import { KAFKA_CDP_INTERNAL_EVENTS, KAFKA_EVENTS_JSON } from '~/common/config/kafka-topics'+import { createKafkaConsumer } from '~/common/kafka/consumer'import { parseJSON } from '~/common/utils/json-parse'import { logger } from '~/common/utils/logger'import * as posthogUtils from '~/common/utils/posthog'@@ -240,6 +242,25 @@ describe('CdpHogflowSubscriptionMatcherConsumer', () => {matcher.clearWatcherTimers()})+ describe('consumer wiring', () => {+ it('reads internal events from the cluster the wakes are produced to, not the events cluster', () => {+ const createConsumer = jest.mocked(createKafkaConsumer)+ createConsumer.mockClear()+ new CdpHogflowSubscriptionMatcherConsumer(+ {+ CYCLOTRON_NODE_DATABASE_URL: 'postgres://test',+ CDP_INTERNAL_EVENTS_CONSUMER_METADATA_BROKER_LIST: 'cyclotron:9092',+ } as any,+ {} as any+ )+ const byTopic = Object.fromEntries(+ createConsumer.mock.calls.map(([config, rdKafka]) => [config.topic, rdKafka])+ )+ expect(byTopic[KAFKA_CDP_INTERNAL_EVENTS]).toMatchObject({ 'metadata.broker.list': 'cyclotron:9092' })+ expect(byTopic[KAFKA_EVENTS_JSON]?.['metadata.broker.list']).toBeUndefined()+ })+ })+describe('wakeMatchingWorkflows', () => {it('is a no-op when no events have person_id', async () => {await matcher.runWake([diff --git a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.tsindex 8f4cdf85fcd3..89bbc5117718 100644--- a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts+++ b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts@@ -244,7 +244,12 @@ export class CdpHogflowSubscriptionMatcherConsumer<groupId: 'cdp-hogflow-subscription-matcher-internal-events-consumer',topic: KAFKA_CDP_INTERNAL_EVENTS,},- startAtLatest+ {+ ...startAtLatest,+ ...(config.CDP_INTERNAL_EVENTS_CONSUMER_METADATA_BROKER_LIST+ ? { 'metadata.broker.list': config.CDP_INTERNAL_EVENTS_CONSUMER_METADATA_BROKER_LIST }+ : {}),+ })this.personDistinctIdKafkaConsumer = createKafkaConsumer({