: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): prefetch teams and hog functions in non-analytics lanes (#106530)
Paweł Ledwoń5961f58f35b4
diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/createPrefetchStep.test.ts b/nodejs/src/ingestion/common/steps/create-prefetch-step.test.tssimilarity index 96%rename from nodejs/src/ingestion/pipelines/analytics/steps/createPrefetchStep.test.tsrename to nodejs/src/ingestion/common/steps/create-prefetch-step.test.tsindex 955ba6f1bbc6..7d4b83c39bda 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/createPrefetchStep.test.ts+++ b/nodejs/src/ingestion/common/steps/create-prefetch-step.test.ts@@ -1,6 +1,6 @@import { logger } from '~/common/utils/logger'+import { createPrefetchStep } from '~/ingestion/common/steps/create-prefetch-step'import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'-import { createPrefetchStep } from '~/ingestion/pipelines/analytics/steps/createPrefetchStep'type TestInput = { key: string | null }diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/createPrefetchStep.ts b/nodejs/src/ingestion/common/steps/create-prefetch-step.tssimilarity index 100%rename from nodejs/src/ingestion/pipelines/analytics/steps/createPrefetchStep.tsrename to nodejs/src/ingestion/common/steps/create-prefetch-step.tsdiff --git a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.test.ts b/nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.test.tssimilarity index 87%rename from nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.test.tsrename to nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.test.tsindex fb6fb889dd14..7c91f50edb94 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.test.ts+++ b/nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.test.ts@@ -1,5 +1,5 @@+import { prefetchHogFunctionsStep } from '~/ingestion/common/steps/prefetch-hog-functions-step'import { PipelineResultType } from '~/ingestion/framework/results'-import { prefetchHogFunctionsStep } from '~/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep'type TestInput = { team: { id: number } }diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.ts b/nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.tssimilarity index 88%rename from nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.tsrename to nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.tsindex c57a1d1cd7eb..77ff690c21e2 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep.ts+++ b/nodejs/src/ingestion/common/steps/prefetch-hog-functions-step.ts@@ -1,5 +1,5 @@import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'-import { createPrefetchStep } from '~/ingestion/pipelines/analytics/steps/createPrefetchStep'+import { createPrefetchStep } from '~/ingestion/common/steps/create-prefetch-step'import { Team } from '~/types'type PrefetchHogFunctionsStepInput = { team: Pick<Team, 'id'> }diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.test.ts b/nodejs/src/ingestion/common/steps/prefetch-teams-step.test.tssimilarity index 89%rename from nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.test.tsrename to nodejs/src/ingestion/common/steps/prefetch-teams-step.test.tsindex b88923de3b2c..038462e494c3 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.test.ts+++ b/nodejs/src/ingestion/common/steps/prefetch-teams-step.test.ts@@ -1,5 +1,5 @@+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import { PipelineResultType } from '~/ingestion/framework/results'-import { prefetchTeamsStep } from '~/ingestion/pipelines/analytics/steps/prefetchTeamsStep'type TestInput = { headers: { token?: string } }diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.ts b/nodejs/src/ingestion/common/steps/prefetch-teams-step.tssimilarity index 87%rename from nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.tsrename to nodejs/src/ingestion/common/steps/prefetch-teams-step.tsindex 5b3c567c79e7..44cd819d8338 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchTeamsStep.ts+++ b/nodejs/src/ingestion/common/steps/prefetch-teams-step.ts@@ -1,5 +1,5 @@import { TeamManager } from '~/common/utils/team-manager'-import { createPrefetchStep } from '~/ingestion/pipelines/analytics/steps/createPrefetchStep'+import { createPrefetchStep } from '~/ingestion/common/steps/create-prefetch-step'import { EventHeaders } from '~/types'type PrefetchTeamsStepInput = { headers: Pick<EventHeaders, 'token'> }diff --git a/nodejs/src/ingestion/pipelines/ai/consumer.test.ts b/nodejs/src/ingestion/pipelines/ai/consumer.test.tsindex 72b34ace1546..5f58b614057e 100644--- a/nodejs/src/ingestion/pipelines/ai/consumer.test.ts+++ b/nodejs/src/ingestion/pipelines/ai/consumer.test.ts@@ -27,6 +27,8 @@ describe('createAiConsumer', () => {INGESTION_OVERFLOW_PRESERVE_PARTITION_LOCALITY: false,INGESTION_WORKER_CONCURRENT_BATCHES: 1,DROP_EVENTS_BY_TOKEN_DISTINCT_ID: '',+ TEAMS_PREFETCH_ENABLED: false,+ HOG_FUNCTIONS_PREFETCH_ENABLED: false,SKIP_PERSONS_PROCESSING_BY_TOKEN_DISTINCT_ID: '',INGESTION_FORCE_OVERFLOW_BY_TOKEN_DISTINCT_ID: '',EVENT_SCHEMA_ENFORCEMENT_ENABLED: false,diff --git a/nodejs/src/ingestion/pipelines/ai/consumer.ts b/nodejs/src/ingestion/pipelines/ai/consumer.tsindex 6655b20de4a0..32b04d73656c 100644--- a/nodejs/src/ingestion/pipelines/ai/consumer.ts+++ b/nodejs/src/ingestion/pipelines/ai/consumer.ts@@ -57,6 +57,8 @@ export type AiConsumerConfig = CommonIngestionConsumerConfig &| 'SKIP_PERSONS_PROCESSING_BY_TOKEN_DISTINCT_ID'| 'INGESTION_FORCE_OVERFLOW_BY_TOKEN_DISTINCT_ID'| 'EVENT_SCHEMA_ENFORCEMENT_ENABLED'+ | 'TEAMS_PREFETCH_ENABLED'+ | 'HOG_FUNCTIONS_PREFETCH_ENABLED'| 'AI_BLOB_S3_BUCKET'| 'AI_BLOB_S3_PREFIX'| 'AI_BLOB_S3_ENDPOINT'@@ -199,6 +201,8 @@ export function createAiConsumer(config: AiConsumerConfig, sharedScope: AiSharedoverflowLaneTTLRefreshService: container.overflowLaneTTLRefreshService,concurrentBatches: config.INGESTION_WORKER_CONCURRENT_BATCHES,eventSchemaEnforcementEnabled: config.EVENT_SCHEMA_ENFORCEMENT_ENABLED,+ teamsPrefetchEnabled: config.TEAMS_PREFETCH_ENABLED,+ hogFunctionsPrefetchEnabled: config.HOG_FUNCTIONS_PREFETCH_ENABLED,// Schema loads run detached in the LazyLoader buffer, so an un-retried transient// failure can surface as an unhandled rejection and restart the worker.eventSchemaEnforcementManager: new EventSchemaEnforcementManager(container.postgres, {diff --git a/nodejs/src/ingestion/pipelines/ai/pipeline.test.ts b/nodejs/src/ingestion/pipelines/ai/pipeline.test.tsindex 9f583615849b..128d757c0309 100644--- a/nodejs/src/ingestion/pipelines/ai/pipeline.test.ts+++ b/nodejs/src/ingestion/pipelines/ai/pipeline.test.ts@@ -40,7 +40,10 @@ describe('AiIngestionPipeline', () => {let mockEventFilterManager: { getFilter: jest.Mock }let mockCookielessManager: jest.Mocked<CookielessManager>let mockHogTransformer: jest.Mocked<- Pick<HogTransformer, 'transformEventAndProduceMessages' | 'processInvocationResults'>+ Pick<+ HogTransformer,+ 'transformEventAndProduceMessages' | 'processInvocationResults' | 'prefetchHogFunctionsForTeams'+ >>let mockPersonRepository: jest.Mocked<PersonReadRepository>let mockGroupTypeManager: jest.Mocked<ReadOnlyGroupTypeManager>@@ -105,6 +108,7 @@ describe('AiIngestionPipeline', () => {mockTeamManager = {getTeamByToken: jest.fn().mockResolvedValue(team),+ getTeamsByTokens: jest.fn().mockResolvedValue({}),getTeam: jest.fn().mockResolvedValue(team),} as unknown as jest.Mocked<TeamManager>@@ -124,8 +128,12 @@ describe('AiIngestionPipeline', () => {.fn().mockImplementation((event) => Promise.resolve({ event, invocationResults: [] })),processInvocationResults: jest.fn().mockResolvedValue(undefined),+ prefetchHogFunctionsForTeams: jest.fn().mockResolvedValue(undefined),} as unknown as jest.Mocked<- Pick<HogTransformer, 'transformEventAndProduceMessages' | 'processInvocationResults'>+ Pick<+ HogTransformer,+ 'transformEventAndProduceMessages' | 'processInvocationResults' | 'prefetchHogFunctionsForTeams'+ >>mockPersonRepository = {@@ -163,6 +171,8 @@ describe('AiIngestionPipeline', () => {[APP_METRICS_OUTPUT]: single(APP_METRICS_OUTPUT, 'clickhouse_app_metrics2_test'),}),teamManager: mockTeamManager,+ teamsPrefetchEnabled: true,+ hogFunctionsPrefetchEnabled: true,eventIngestionRestrictionManager: mockEventIngestionRestrictionManager,eventFilterManager: mockEventFilterManager as any,cookielessManager: mockCookielessManager,diff --git a/nodejs/src/ingestion/pipelines/ai/pipeline.ts b/nodejs/src/ingestion/pipelines/ai/pipeline.tsindex 87fd0d14a87d..609680f03dd9 100644--- a/nodejs/src/ingestion/pipelines/ai/pipeline.ts+++ b/nodejs/src/ingestion/pipelines/ai/pipeline.ts@@ -43,6 +43,8 @@ import { createNormalizeProcessPersonFlagStep } from '~/ingestion/common/steps/eimport { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'import { createReadOnlyProcessGroupsStep } from '~/ingestion/common/steps/event-processing/readonly-process-groups-step'import { createStripPersonUpdatePropertiesStep } from '~/ingestion/common/steps/event-processing/strip-person-update-properties-step'+import { prefetchHogFunctionsStep } from '~/ingestion/common/steps/prefetch-hog-functions-step'+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'import {createEventUsageBeforeBatchStep,@@ -87,6 +89,8 @@ export interface AiIngestionPipelineConfig {overflowLaneTTLRefreshService: OverflowRedirectServiceconcurrentBatches: numbereventSchemaEnforcementEnabled: boolean+ teamsPrefetchEnabled: boolean+ hogFunctionsPrefetchEnabled: booleaneventSchemaEnforcementManager: EventSchemaEnforcementManagertopHog: TopHogRegistryaiBlobStore: BlobStore | null@@ -135,6 +139,8 @@ export function createAiIngestionPipeline<overflowLaneTTLRefreshService,concurrentBatches,eventSchemaEnforcementEnabled,+ teamsPrefetchEnabled,+ hogFunctionsPrefetchEnabled,eventSchemaEnforcementManager,topHog,aiBlobStore,@@ -170,6 +176,7 @@ export function createAiIngestionPipeline<// Kafka message key — the partition key capture computed. Cookieless// events count under token:client_ip..pipeChunk(createRateLimitToOverflowStep(preservePartitionLocality, overflowRedirectService))+ .pipeChunk(prefetchTeamsStep(teamManager, teamsPrefetchEnabled)).parseMessage().resolveTeam().pipe(createValidateHistoricalMigrationStep())@@ -187,6 +194,7 @@ export function createAiIngestionPipeline<.gather().pipeChunk(createApplyCookielessProcessingStep(cookielessManager)).pipeChunk(createOverflowLaneTTLRefreshStep(overflowLaneTTLRefreshService))+ .pipeChunk(prefetchHogFunctionsStep(hogTransformer, hogFunctionsPrefetchEnabled))// Read-only batch person fetch (no person writes). The personhog// client retries transient gRPC errors for ~150ms; this outer// retry absorbs longer blips that would otherwise crash thediff --git a/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts b/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.tsindex 598fa56ec9bb..f416027e20a9 100644--- a/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts+++ b/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts@@ -34,6 +34,7 @@ import { createFlushBatchStoresStep } from '~/ingestion/common/steps/event-proceimport { createFlushHogTransformerStep } from '~/ingestion/common/steps/event-processing/flush-hog-transformer-step'import { createGroupStoreBeforeBatchStep } from '~/ingestion/common/steps/group-store-batch-step'import { createPersonsStoreBeforeBatchStep } from '~/ingestion/common/steps/persons-store-batch-step'+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import {createEventUsageBeforeBatchStep,createFlushEventUsageStep,@@ -54,7 +55,6 @@ import {PostTeamPreprocessingSubpipelineConfig,createPostTeamPreprocessingSubpipeline,} from './post-team-preprocessing-subpipeline'-import { prefetchTeamsStep } from './steps/prefetchTeamsStep'export interface JoinedIngestionPipelineConfig {eventSchemaEnforcementEnabled: booleandiff --git a/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts b/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.tsindex 02fe4439f74e..432a1efce69f 100644--- a/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts+++ b/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts@@ -22,10 +22,10 @@ import {createValidateEventSchemaStep,} from '~/ingestion/common/steps/event-preprocessing'import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'+import { prefetchHogFunctionsStep } from '~/ingestion/common/steps/prefetch-hog-functions-step'import { ChunkPipelineBuilder } from '~/ingestion/framework/builders/chunk-pipeline-builders'import { prefetchEventSchemasStep } from '~/ingestion/pipelines/analytics/steps/prefetchEventSchemasStep'import { prefetchGroupsStep } from '~/ingestion/pipelines/analytics/steps/prefetchGroupsStep'-import { prefetchHogFunctionsStep } from '~/ingestion/pipelines/analytics/steps/prefetchHogFunctionsStep'import { prefetchPersonsStep } from '~/ingestion/pipelines/analytics/steps/prefetchPersonsStep'import { PluginEvent } from '~/plugin-scaffold'import { EventHeaders, Team } from '~/types'diff --git a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchEventSchemasStep.ts b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchEventSchemasStep.tsindex 3a905ee0881f..11454112c6a9 100644--- a/nodejs/src/ingestion/pipelines/analytics/steps/prefetchEventSchemasStep.ts+++ b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchEventSchemasStep.ts@@ -1,5 +1,5 @@import { EventSchemaEnforcementManager } from '~/common/utils/event-schema-enforcement-manager'-import { createPrefetchStep } from '~/ingestion/pipelines/analytics/steps/createPrefetchStep'+import { createPrefetchStep } from '~/ingestion/common/steps/create-prefetch-step'import { Team } from '~/types'type PrefetchEventSchemasStepInput = { team: Pick<Team, 'id'> }diff --git a/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.tsindex 2f2870776746..4f7837fc41e5 100644--- a/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts+++ b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts@@ -20,6 +20,7 @@ describe('createClientWarningsConsumer', () => {INGESTION_LANE: 'main',KAFKA_BATCH_START_LOGGING_ENABLED: false,DROP_EVENTS_BY_TOKEN_DISTINCT_ID: '',+ TEAMS_PREFETCH_ENABLED: false,...({} as IngestionOutputsConfig),}}diff --git a/nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.tsindex c307b2773c59..db6ae1db0adf 100644--- a/nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts+++ b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts@@ -16,7 +16,7 @@ import { createClientWarningsPipeline } from './pipeline'export type ClientWarningsConsumerConfig = CommonIngestionConsumerConfig &IngestionOutputsConfig &- Pick<IngestionConsumerConfig, 'DROP_EVENTS_BY_TOKEN_DISTINCT_ID'>+ Pick<IngestionConsumerConfig, 'DROP_EVENTS_BY_TOKEN_DISTINCT_ID' | 'TEAMS_PREFETCH_ENABLED'>export type ClientWarningsSharedScope = Scope<{postgres: PostgresRouter@@ -48,6 +48,6 @@ export function createClientWarningsConsumer()return new CommonIngestionConsumerScope('clientwarnings', config, scope, ({ container }) =>- createClientWarningsPipeline(container)+ createClientWarningsPipeline({ ...container, teamsPrefetchEnabled: config.TEAMS_PREFETCH_ENABLED }))}diff --git a/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.test.ts b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.test.tsindex 68738973ce9e..61e1bc7feb4c 100644--- a/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.test.ts+++ b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.test.ts@@ -91,6 +91,7 @@ describe('ClientWarningsPipeline', () => {mockTeamManager = {getTeamByToken: jest.fn().mockResolvedValue(team),+ getTeamsByTokens: jest.fn().mockResolvedValue({}),getTeam: jest.fn().mockResolvedValue(team),} as unknown as jest.Mocked<TeamManager>@@ -124,6 +125,7 @@ describe('ClientWarningsPipeline', () => {}),topHog: createNoopTopHog(),teamManager: mockTeamManager,+ teamsPrefetchEnabled: true,eventIngestionRestrictionManager: mockEventIngestionRestrictionManager,eventFilterManager: mockEventFilterManager,promiseScheduler,diff --git a/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.tsindex 4680f676967a..556d483528da 100644--- a/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts+++ b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts@@ -21,6 +21,7 @@ import {import { createApplyBasicEventRestrictionsStep } from '~/ingestion/common/steps/event-preprocessing/apply-event-restrictions'import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'import { createHandleClientIngestionWarningStep } from '~/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step'+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'import { TopHogRegistry } from '~/ingestion/framework/extensions/tophog'@@ -34,6 +35,7 @@ export interface ClientWarningsPipelineConfig {eventFilterManager: EventFilterManagerpromiseScheduler: PromiseSchedulertopHog: TopHogRegistry+ teamsPrefetchEnabled: boolean}interface ClientWarningsPipelineInput {@@ -48,8 +50,15 @@ export function createClientWarningsPipeline<TInput extends ClientWarningsPipelineInput,TContext extends ClientWarningsPipelineContext,>(config: ClientWarningsPipelineConfig) {- const { outputs, teamManager, eventIngestionRestrictionManager, eventFilterManager, promiseScheduler, topHog } =- config+ const {+ outputs,+ teamManager,+ eventIngestionRestrictionManager,+ eventFilterManager,+ promiseScheduler,+ topHog,+ teamsPrefetchEnabled,+ } = configreturn newCommonIngestionPipeline<TInput, TContext>({teamManager,@@ -62,6 +71,7 @@ export function createClientWarningsPipeline<.parseHeaders().pipe(createAllowEventsStep(['$$client_ingestion_warning'])).pipe(createApplyBasicEventRestrictionsStep(eventIngestionRestrictionManager))+ .pipeChunk(prefetchTeamsStep(teamManager, teamsPrefetchEnabled)).parseMessage().resolveTeam().pipe(createValidateHistoricalMigrationStep())diff --git a/nodejs/src/ingestion/pipelines/errortracking/consumer.ts b/nodejs/src/ingestion/pipelines/errortracking/consumer.tsindex e3fff0c2a2f0..3ab93811cfd6 100644--- a/nodejs/src/ingestion/pipelines/errortracking/consumer.ts+++ b/nodejs/src/ingestion/pipelines/errortracking/consumer.ts@@ -18,6 +18,7 @@ import { RedisOverflowRepositoryComponent } from '~/ingestion/common/overflow-reimport { eventRateStrategy } from '~/ingestion/common/overflow-redirect/overflow-strategy'import { Scope, extend } from '~/ingestion/common/scopes'import { PromiseSchedulerComponent } from '~/ingestion/common/utils/promise-scheduler'+import { IngestionConsumerConfig } from '~/ingestion/config'import { RedisPool } from '~/types'import { ErrorTrackingConsumerConfig } from './config'@@ -39,6 +40,7 @@ export type ErrorTrackingLaneConfig = CommonIngestionConsumerConfig &| 'ERROR_TRACKING_OVERFLOW_PRESERVE_PARTITION_LOCALITY'| 'INGESTION_OVERFLOW_MODE'> &+ Pick<IngestionConsumerConfig, 'TEAMS_PREFETCH_ENABLED' | 'HOG_FUNCTIONS_PREFETCH_ENABLED'> &Pick<CommonConfig, 'PLUGIN_SERVER_MODE'>/**@@ -134,6 +136,8 @@ export function createErrorTrackingConsumer(config: ErrorTrackingLaneConfig, shaoverflowLaneTTLRefreshService: container.overflowLaneTTLRefreshService,topHog: container.topHog,createEventUsageBatch,+ teamsPrefetchEnabled: config.TEAMS_PREFETCH_ENABLED,+ hogFunctionsPrefetchEnabled: config.HOG_FUNCTIONS_PREFETCH_ENABLED,}))}diff --git a/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.tsindex 19dabaa5c1fe..21a8662ee948 100644--- a/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts@@ -241,6 +241,7 @@ describe('ErrorTrackingPipeline', () => {mockTeamManager = {getTeamByToken: jest.fn().mockResolvedValue(team),+ getTeamsByTokens: jest.fn().mockResolvedValue({}),getTeam: jest.fn().mockResolvedValue(team),} as unknown as jest.Mocked<TeamManager>@@ -266,6 +267,7 @@ describe('ErrorTrackingPipeline', () => {.fn().mockImplementation((event) => Promise.resolve({ event, invocationResults: [] })),processInvocationResults: jest.fn().mockResolvedValue(undefined),+ prefetchHogFunctionsForTeams: jest.fn().mockResolvedValue(undefined),}mockCymbalClient = {@@ -323,6 +325,8 @@ describe('ErrorTrackingPipeline', () => {}),promiseScheduler,teamManager: mockTeamManager,+ teamsPrefetchEnabled: true,+ hogFunctionsPrefetchEnabled: true,personRepository: mockPersonRepository,hogTransformer: mockHogTransformer,cymbalClient: mockCymbalClient,diff --git a/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.tsindex 3f08f33bf5a0..36a3d49ef87f 100644--- a/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts@@ -32,6 +32,8 @@ import { createFetchPersonChunkStep } from '~/ingestion/common/steps/event-proceimport { createFlushHogTransformerStep } from '~/ingestion/common/steps/event-processing/flush-hog-transformer-step'import { createHogTransformEventStep } from '~/ingestion/common/steps/event-processing/hog-transform-event-step'import { createReadOnlyProcessGroupsStep } from '~/ingestion/common/steps/event-processing/readonly-process-groups-step'+import { prefetchHogFunctionsStep } from '~/ingestion/common/steps/prefetch-hog-functions-step'+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'import {EventUsageBatchContext,@@ -53,7 +55,7 @@ import { createErrorTrackingPrepareEventStep } from './prepare-event-step'/** The hog transformer methods the pipeline uses; lifecycle stays with the owning scope. */export type ErrorTrackingHogTransformer = Pick<HogTransformer,- 'transformEventAndProduceMessages' | 'processInvocationResults'+ 'transformEventAndProduceMessages' | 'processInvocationResults' | 'prefetchHogFunctionsForTeams'>export interface ErrorTrackingPipelineInput {@@ -108,6 +110,8 @@ export interface ErrorTrackingPipelineConfig {/** TopHog registry for metrics. */topHog: TopHogRegistrycreateEventUsageBatch: () => UsageRecordBatch+ teamsPrefetchEnabled: boolean+ hogFunctionsPrefetchEnabled: boolean}/**@@ -117,19 +121,21 @@ export interface ErrorTrackingPipelineConfig {* 1. Parse headers - Extract token, timestamps from Kafka message headers* 2. Apply event restrictions - Billing limits, drop/overflow* 3. Skip-cookieless rate limit - Redirect non-cookieless rate-limited events to overflow- * pre-parse (cookieless events pass through to step 6)- * 4. Parse Kafka message - Parse message body into event- * 5. Resolve team - Look up team by token- * 6. Apply cookieless processing - Rewrite distinct_id for cookieless events- * 7. Only-cookieless rate limit - Redirect cookieless rate-limited events to overflow- * using the hashed distinct_id from step 6- * 8. Cymbal processing - Symbolicate, fingerprint, and link issues- * 9. Person properties - Fetch person by distinct_id (read-only)- * 10. Hog transformations - Run team transformations (including GeoIP if enabled)- * 11. Prepare event - Convert to PreIngestionEvent format, track if person found- * 12. Group type mapping - Map group types to indexes (read-only)- * 13. Create event - Build ErrorTrackingKafkaEvent (matches Cymbal's output format)- * 14. Emit event - Produce to output topic+ * pre-parse (cookieless events pass through to step 7)+ * 4. Prefetch teams - Warm the team cache for the chunk's tokens (TEAMS_PREFETCH_ENABLED)+ * 5. Parse Kafka message - Parse message body into event+ * 6. Resolve team - Look up team by token+ * 7. Apply cookieless processing - Rewrite distinct_id for cookieless events+ * 8. Only-cookieless rate limit - Redirect cookieless rate-limited events to overflow+ * using the hashed distinct_id from step 7+ * 9. Prefetch hog functions - Warm the transformation cache for the chunk's teams (HOG_FUNCTIONS_PREFETCH_ENABLED)+ * 10. Cymbal processing - Symbolicate, fingerprint, and link issues+ * 11. Person properties - Fetch person by distinct_id (read-only)+ * 12. Hog transformations - Run team transformations (including GeoIP if enabled)+ * 13. Prepare event - Convert to PreIngestionEvent format, track if person found+ * 14. Group type mapping - Map group types to indexes (read-only)+ * 15. Create event - Build ErrorTrackingKafkaEvent (matches Cymbal's output format)+ * 16. Emit event - Produce to output topic** Note: Cymbal runs before enrichment because it only needs the raw exception data* for symbolication and fingerprinting. This reduces payload size and avoids@@ -152,6 +158,8 @@ export function createErrorTrackingPipeline(config: ErrorTrackingPipelineConfig)overflowLaneTTLRefreshService,topHog,createEventUsageBatch,+ teamsPrefetchEnabled,+ hogFunctionsPrefetchEnabled,} = configconst preCymbal = newCommonIngestionPipeline<ErrorTrackingPipelineInput, { message: Message }, OverflowOutput>({@@ -177,6 +185,7 @@ export function createErrorTrackingPipeline(config: ErrorTrackingPipelineConfig)// Kafka message key — the partition key capture computed. Cookieless// events count under token:client_ip..pipeChunk(createRateLimitToOverflowStep(preservePartitionLocality, overflowRedirectService))+ .pipeChunk(prefetchTeamsStep(teamManager, teamsPrefetchEnabled)).parseMessage().resolveTeam()// Carry the Kafka message byte size through for Cymbal batch chunking.@@ -188,6 +197,7 @@ export function createErrorTrackingPipeline(config: ErrorTrackingPipelineConfig).pipeChunk(createApplyCookielessProcessingStep(cookielessManager))// Refresh TTLs for overflow lane events (keeps Redis flags alive).pipeChunk(createOverflowLaneTTLRefreshStep(overflowLaneTTLRefreshService))+ .pipeChunk(prefetchHogFunctionsStep(hogTransformer, hogFunctionsPrefetchEnabled))const afterCymbal = preCymbal// Process through Cymbal as a batch (before enrichment - Cymbal onlydiff --git a/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.tsindex 92ba7a4406d3..25c8f94ab6cc 100644--- a/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts+++ b/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts@@ -21,6 +21,7 @@ describe('createHeatmapsConsumer', () => {INGESTION_LANE: 'main',KAFKA_BATCH_START_LOGGING_ENABLED: false,DROP_EVENTS_BY_TOKEN_DISTINCT_ID: '',+ TEAMS_PREFETCH_ENABLED: false,...({} as IngestionOutputsConfig),}}diff --git a/nodejs/src/ingestion/pipelines/heatmaps/consumer.ts b/nodejs/src/ingestion/pipelines/heatmaps/consumer.tsindex e9f15179c591..aedade6724bc 100644--- a/nodejs/src/ingestion/pipelines/heatmaps/consumer.ts+++ b/nodejs/src/ingestion/pipelines/heatmaps/consumer.ts@@ -17,7 +17,7 @@ import { createHeatmapsPipeline } from './pipeline'export type HeatmapsConsumerConfig = CommonIngestionConsumerConfig &IngestionOutputsConfig &- Pick<IngestionConsumerConfig, 'DROP_EVENTS_BY_TOKEN_DISTINCT_ID'>+ Pick<IngestionConsumerConfig, 'DROP_EVENTS_BY_TOKEN_DISTINCT_ID' | 'TEAMS_PREFETCH_ENABLED'>export type HeatmapsSharedScope = Scope<{postgres: PostgresRouter@@ -47,6 +47,6 @@ export function createHeatmapsConsumer(config: HeatmapsConsumerConfig, sharedSco)return new CommonIngestionConsumerScope('heatmaps', config, scope, ({ container }) =>- createHeatmapsPipeline(container)+ createHeatmapsPipeline({ ...container, teamsPrefetchEnabled: config.TEAMS_PREFETCH_ENABLED }))}diff --git a/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.tsindex c257a9afec11..5e226a01e7a7 100644--- a/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts+++ b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts@@ -105,6 +105,7 @@ describe('HeatmapsPipeline', () => {mockTeamManager = {getTeamByToken: jest.fn().mockResolvedValue(team),+ getTeamsByTokens: jest.fn().mockResolvedValue({}),getTeam: jest.fn().mockResolvedValue(team),} as unknown as jest.Mocked<TeamManager>@@ -150,6 +151,7 @@ describe('HeatmapsPipeline', () => {}),topHog: createNoopTopHog(),teamManager: mockTeamManager,+ teamsPrefetchEnabled: true,eventIngestionRestrictionManager: mockEventIngestionRestrictionManager,eventFilterManager: mockEventFilterManager,cookielessManager: mockCookielessManager,diff --git a/nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.tsindex 450b354b26cc..e145a720389d 100644--- a/nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts+++ b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts@@ -24,6 +24,7 @@ import { createApplyBasicEventRestrictionsStep } from '~/ingestion/common/steps/import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'import { createNormalizeEventStep } from '~/ingestion/common/steps/event-processing/normalize-event-step'import { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'+import { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'import { TopHogRegistry } from '~/ingestion/framework/extensions/tophog'@@ -43,6 +44,7 @@ export interface HeatmapsPipelineConfig {cookielessManager: CookielessManagerpromiseScheduler: PromiseSchedulertopHog: TopHogRegistry+ teamsPrefetchEnabled: boolean}interface HeatmapsPipelineInput {@@ -64,6 +66,7 @@ export function createHeatmapsPipeline<TInput extends HeatmapsPipelineInput, TCocookielessManager,promiseScheduler,topHog,+ teamsPrefetchEnabled,} = configreturn (@@ -78,6 +81,7 @@ export function createHeatmapsPipeline<TInput extends HeatmapsPipelineInput, TCo.parseHeaders().pipe(createAllowEventsStep(['$$heatmap'])).pipe(createApplyBasicEventRestrictionsStep(eventIngestionRestrictionManager))+ .pipeChunk(prefetchTeamsStep(teamManager, teamsPrefetchEnabled)).parseMessage().resolveTeam().pipe(createValidateHistoricalMigrationStep())diff --git a/nodejs/src/servers/error-tracking-server.ts b/nodejs/src/servers/error-tracking-server.tsindex a5213e727a82..9548849bc5be 100644--- a/nodejs/src/servers/error-tracking-server.ts+++ b/nodejs/src/servers/error-tracking-server.ts@@ -79,7 +79,10 @@ export type ErrorTrackingServerConfig = BaseServerConfig &PersonHogConfig &UsageIngestionConfig &CookielessServerConfig &- Pick<IngestionConsumerConfig, 'KAFKA_BATCH_START_LOGGING_ENABLED'> &+ Pick<+ IngestionConsumerConfig,+ 'KAFKA_BATCH_START_LOGGING_ENABLED' | 'TEAMS_PREFETCH_ENABLED' | 'HOG_FUNCTIONS_PREFETCH_ENABLED'+ > &Pick<CommonConfig,| 'LOG_LEVEL'