Skip to content

: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.

chore(nodejs): separate ingestion code from CDP (#64506)

José Sequeira853f95fdb5f4
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.yml
index 67e170b9f578..098a4ae77438 100644
--- a/.github/workflows/ci-nodejs.yml
+++ b/.github/workflows/ci-nodejs.yml
@@ -144,6 +144,16 @@ jobs:
- name: Lint with ESLint
run: pnpm --filter=@posthog/nodejs lint
+ # Guards the cdp/ingestion separation: fails on new lane->lane or shared->lane
+ # imports. Presence-checked so branches without the guard yet are unaffected.
+ - name: Check ingestion boundaries
+ run: |
+ if [ -f nodejs/bin/check-ingestion-boundaries.mjs ]; then
+ node nodejs/bin/check-ingestion-boundaries.mjs
+ else
+ echo "Ingestion boundary guard not present on this branch; skipping."
+ fi
+
build:
if: needs.changes.outputs.nodejs == 'true'
name: Node.js Build (depot-ubuntu-latest)
diff --git a/nodejs/.eslintrc.js b/nodejs/.eslintrc.js
index 1af0804ea45b..9898c95b9254 100644
--- a/nodejs/.eslintrc.js
+++ b/nodejs/.eslintrc.js
@@ -81,6 +81,41 @@ module.exports = {
'@typescript-eslint/no-floating-promises': 'off',
},
},
+ {
+ // Ingestion is standardized on the ~/ alias. Ban parent-relative
+ // (../) imports so the structure stays codemod-friendly through future moves; keep ./ siblings.
+ // Overrides replace rule options, so the global fetch/node-fetch/undici bans are repeated here.
+ files: ['src/ingestion/**/*.ts'],
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ paths: [
+ {
+ name: 'node-fetch',
+ message: 'Use the request util from ~/utils/request instead of node-fetch',
+ },
+ {
+ name: 'undici',
+ message: 'Use the request util from ~/utils/request instead of undici',
+ },
+ ],
+ patterns: [
+ {
+ group: ['fetch'],
+ message:
+ 'Use the request util from ~/utils/request instead of importing fetch directly',
+ },
+ {
+ group: ['../*', '../**'],
+ message:
+ 'Within src/ingestion, import via the ~/ alias instead of parent-relative (../) paths.',
+ },
+ ],
+ },
+ ],
+ },
+ },
],
root: true,
reportUnusedDisableDirectives: true,
diff --git a/nodejs/.prettierignore b/nodejs/.prettierignore
index 9651b4acf042..e3770b506bc5 100644
--- a/nodejs/.prettierignore
+++ b/nodejs/.prettierignore
@@ -4,3 +4,4 @@ dist/
node_modules/
coverage/
.tmp/
+bin/ingestion-boundaries.baseline.json
diff --git a/nodejs/bin/check-ingestion-boundaries.mjs b/nodejs/bin/check-ingestion-boundaries.mjs
new file mode 100644
index 000000000000..4f9e90d891b5
--- /dev/null
+++ b/nodejs/bin/check-ingestion-boundaries.mjs
@@ -0,0 +1,196 @@
+#!/usr/bin/env node
+/**
+ * Ingestion boundary guard.
+ *
+ * Enforces the ingestion-separation invariant during the cdp/ingestion refactor:
+ * - an ingestion pipeline must not import another pipeline's internals
+ * - shared/common ingestion code must not import a pipeline
+ * - no ingestion code may import cdp directly (ingestion and cdp meet only through common/)
+ *
+ * Import specifiers are resolved (tsconfig "~/*" alias + relative paths) to real
+ * files, so cross-pipeline *relative* imports (e.g. `../heatmaps/x` from `analytics/`)
+ * are caught — something a string-based eslint rule cannot reliably do.
+ *
+ * A baseline records the violations that already exist; the check fails only on
+ * NEW violations. As the refactor removes edges, regenerate the baseline with
+ * `--write` so it shrinks toward empty (an empty baseline = invariant achieved).
+ *
+ * Usage:
+ * node bin/check-ingestion-boundaries.mjs # check against baseline
+ * node bin/check-ingestion-boundaries.mjs --write # (re)generate the baseline
+ */
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
+const SRC = path.join(ROOT, 'src')
+const ING = path.join(SRC, 'ingestion')
+const CDP = path.join(SRC, 'cdp')
+const BASELINE = path.join(ROOT, 'bin', 'ingestion-boundaries.baseline.json')
+
+// Ingestion pipelines — each is an isolated unit. A pipeline may not import another pipeline,
+// and shared/common ingestion code may not import any pipeline.
+const SHARED = '(shared)'
+const PIPELINES = new Set([
+ 'analytics',
+ 'heatmaps',
+ 'clientwarnings',
+ 'ai',
+ 'errortracking',
+ 'sessionreplay',
+ 'metrics',
+])
+
+const SKIP_DIRS = new Set(['node_modules', 'dist', '__snapshots__'])
+
+// The guard enforces the *production* import DAG. Test files (unit/integration/e2e) act as
+// composition roots — they wire real implementations across domains (e.g. cdp's HogTransformer,
+// the ai sub-pipeline factory) the same way the servers do — so they legitimately cross pipelines.
+// Test-file organization is a separate concern, owned by Phase 3 ("split mixed tests").
+const isTestFile = (name) => name.endsWith('.test.ts') || name.endsWith('.spec.ts')
+
+// Composition roots assemble and run a pipeline — they wire pipelines together the way the
+// servers do (e.g. ingestion-consumer builds and runs the analytics pipeline), so like the servers
+// they are allowed to import a pipeline. Keyed by path relative to src/ingestion.
+const COMPOSITION_ROOTS = new Set(['ingestion-consumer.ts'])
+const isCompositionRoot = (absPath) => COMPOSITION_ROOTS.has(path.relative(ING, absPath))
+
+function walk(dir) {
+ const out = []
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ if (entry.isDirectory()) {
+ if (SKIP_DIRS.has(entry.name)) {
+ continue
+ }
+ out.push(...walk(path.join(dir, entry.name)))
+ } else if (entry.name.endsWith('.ts') && !isTestFile(entry.name)) {
+ out.push(path.join(dir, entry.name))
+ }
+ }
+ return out
+}
+
+// The ingestion pipeline a path belongs to: a pipeline name, SHARED for other ingestion
+// code, or null for non-ingestion / external paths.
+function pipelineOf(absPath) {
+ const rel = path.relative(ING, absPath)
+ if (rel.startsWith('..') || path.isAbsolute(rel)) {
+ return null
+ }
+ const seg = rel.split(path.sep)
+ // Pipelines live under `pipelines/<name>/`.
+ if (seg[0] === 'pipelines') {
+ return seg[1] && PIPELINES.has(seg[1]) ? seg[1] : SHARED
+ }
+ return PIPELINES.has(seg[0]) ? seg[0] : SHARED
+}
+
+// Whether an absolute path lives under src/cdp. Ingestion must reach cdp only through common/.
+function isCdp(absPath) {
+ const rel = path.relative(CDP, absPath)
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel))
+}
+
+const IMPORT_PATTERNS = [
+ /\bfrom\s*['"]([^'"]+)['"]/g, // import ... from / export ... from
+ /\bimport\s*['"]([^'"]+)['"]/g, // side-effect import
+ /\bimport\(\s*['"]([^'"]+)['"]\s*\)/g, // dynamic import()
+ /\brequire\(\s*['"]([^'"]+)['"]\s*\)/g, // require()
+]
+
+function importSpecifiers(source) {
+ const specs = new Set()
+ for (const re of IMPORT_PATTERNS) {
+ re.lastIndex = 0
+ let match
+ while ((match = re.exec(source))) {
+ specs.add(match[1])
+ }
+ }
+ return specs
+}
+
+// Resolve a specifier to an absolute path, or null for bare/node-module imports.
+function resolveSpecifier(spec, importer) {
+ if (spec.startsWith('~/tests/')) {
+ return path.join(ROOT, 'tests', spec.slice('~/tests/'.length))
+ }
+ if (spec.startsWith('~/')) {
+ return path.join(SRC, spec.slice(2))
+ }
+ if (spec.startsWith('.')) {
+ return path.resolve(path.dirname(importer), spec)
+ }
+ return null
+}
+
+function computeViolations() {
+ const violations = new Set()
+ for (const file of walk(ING)) {
+ const fromPipeline = pipelineOf(file)
+ if (fromPipeline === null) {
+ continue
+ }
+ if (isCompositionRoot(file)) {
+ continue // composition roots (like the servers) may wire a pipeline
+ }
+ for (const spec of importSpecifiers(fs.readFileSync(file, 'utf8'))) {
+ const target = resolveSpecifier(spec, file)
+ if (target === null) {
+ continue
+ }
+ if (isCdp(target)) {
+ violations.add(`${path.relative(ROOT, file)} -> cdp`)
+ continue
+ }
+ const toPipeline = pipelineOf(target)
+ if (toPipeline === null || toPipeline === SHARED) {
+ continue // importing shared code (or leaving ingestion) is always allowed
+ }
+ if (fromPipeline !== toPipeline) {
+ violations.add(`${path.relative(ROOT, file)} -> pipeline:${toPipeline}`)
+ }
+ }
+ }
+ return [...violations].sort()
+}
+
+function main() {
+ const current = computeViolations()
+
+ if (process.argv.includes('--write')) {
+ fs.writeFileSync(BASELINE, JSON.stringify(current, null, 2) + '\n')
+ console.log(`Wrote ${current.length} baselined boundary violation(s) to ${path.relative(ROOT, BASELINE)}`)
+ return
+ }
+
+ const baseline = fs.existsSync(BASELINE) ? JSON.parse(fs.readFileSync(BASELINE, 'utf8')) : []
+ const baselineSet = new Set(baseline)
+ const currentSet = new Set(current)
+ const novel = current.filter((v) => !baselineSet.has(v))
+ const resolved = baseline.filter((v) => !currentSet.has(v))
+
+ if (resolved.length) {
+ console.log(`✓ ${resolved.length} baselined violation(s) resolved — run with --write to shrink the baseline.`)
+ }
+
+ if (novel.length) {
+ console.error(`\n✗ ${novel.length} new ingestion boundary violation(s):\n`)
+ for (const v of novel) {
+ console.error(` ${v}`)
+ }
+ console.error(
+ '\nA pipeline must not import another pipeline, shared ingestion code must not import a pipeline,\n' +
+ 'and no ingestion code may import cdp directly.'
+ )
+ console.error('Fix: move the shared dependency into common/ (the cdp∩ingestion meeting point),')
+ console.error('or keep the dependency within the importing pipeline.')
+ process.exitCode = 1
+ return
+ }
+
+ console.log(`✓ No new ingestion boundary violations (${current.length} baselined).`)
+}
+
+main()
diff --git a/nodejs/bin/ingestion-boundaries.baseline.json b/nodejs/bin/ingestion-boundaries.baseline.json
new file mode 100644
index 000000000000..fe51488c7066
--- /dev/null
+++ b/nodejs/bin/ingestion-boundaries.baseline.json
@@ -0,0 +1 @@
+[]
diff --git a/nodejs/jest.config.js b/nodejs/jest.config.js
index 16b96f74a3e7..c0e29ac38826 100644
--- a/nodejs/jest.config.js
+++ b/nodejs/jest.config.js
@@ -18,13 +18,16 @@ module.exports = {
// NOTE: This should be kept in sync with tsconfig.json
moduleNameMapper: {
+ // `~/...` -> src/, `~/tests/...` -> tests/. The `.js`-suffixed variants come first to strip the
+ // nodenext extension: the production tsconfig is module: nodenext, which forces import()
+ // specifiers to carry `.js` (TS2835/TS2307), so ts-jest emits e.g. `~/foo.js` while only a
+ // `.ts` exists on disk. Jest only strips `.js` from *relative* specifiers (last rule), not from
+ // `~/` aliases — without these, an alias would resolve to a non-existent `src/foo.js`.
+ '^~/tests/(.*)\\.js$': '<rootDir>/tests/$1',
'^~/tests/(.*)$': '<rootDir>/tests/$1',
+ '^~/(.*)\\.js$': '<rootDir>/src/$1',
'^~/(.*)$': '<rootDir>/src/$1',
// Strip .js from relative imports so Jest resolves to the .ts source.
- // Production tsconfig is module: nodenext, which forces relative import()
- // specifiers to carry .js extensions (TS2835). ts-jest emits those strings
- // verbatim, but no .js file exists on disk, so the mapper rewrites the
- // request before Jest's resolver runs.
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}
diff --git a/nodejs/package.json b/nodejs/package.json
index 5620eeaac5fb..57fb3550eca6 100644
--- a/nodejs/package.json
+++ b/nodejs/package.json
@@ -25,11 +25,14 @@
"typescript:check:tsgo": "tsgo --noEmit -p .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
+ "check:boundaries": "node bin/check-ingestion-boundaries.mjs",
+ "check:boundaries:write": "node bin/check-ingestion-boundaries.mjs --write",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepublishOnly": "pnpm build",
"setup:dev:clickhouse": "cd .. && DEBUG=1 python manage.py migrate_clickhouse",
"setup:test": "cd .. && TEST=1 python manage.py setup_test_environment && cd nodejs && pnpm run setup:test:rust",
+ "test:full": "docker compose -f ../docker-compose.dev.yml up -d && pnpm setup:test && pnpm test && pnpm test:postgres-parity && pnpm test:rust-ingestion-e2e",
"setup:test:rust": "CYCLOTRON_DATABASE_NAME=test_cyclotron CYCLOTRON_NODE_DATABASE_NAME=test_cyclotron_node PERSONS_DATABASE_NAME=test_persons BEHAVIORAL_COHORTS_DATABASE_NAME=test_behavioral_cohorts ../rust/bin/migrate-entry all --fresh",
"setup:test:persons-parity": "PERSONS_DATABASE_NAME=test_persons_parity ../rust/bin/migrate-entry persons --fresh",
"migrate:persons": "../rust/bin/migrate-persons",
diff --git a/nodejs/src/cdp/cdp-api.test.ts b/nodejs/src/cdp/cdp-api.test.ts
index 7d45871ece58..2a514c868725 100644
--- a/nodejs/src/cdp/cdp-api.test.ts
+++ b/nodejs/src/cdp/cdp-api.test.ts
@@ -7,6 +7,7 @@ import supertest from 'supertest'
import express from 'ultimate-express'
import { setupExpressApp } from '~/api/router'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { HogFlow } from '~/schema/hogflow'
@@ -25,7 +26,6 @@ import {
insertIntegration,
} from './_tests/fixtures'
import { insertHogFlow as _insertHogFlow } from './_tests/fixtures-hogflows'
-import { deleteKeysWithPrefix } from './_tests/redis'
import { CdpApi } from './cdp-api'
import { CdpConsumerBaseDeps } from './consumers/cdp-base.consumer'
import { posthogFilterOutPlugin } from './legacy-plugins/_transformations/posthog-filter-out-plugin/template'
diff --git a/nodejs/src/cdp/cdp-services.ts b/nodejs/src/cdp/cdp-services.ts
index 337362d4db54..8dc275673761 100644
--- a/nodejs/src/cdp/cdp-services.ts
+++ b/nodejs/src/cdp/cdp-services.ts
@@ -1,11 +1,11 @@
+import { AppMetricsOutput, HogInvocationResultsOutput, LogEntriesOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { getRedisHost } from '~/utils/db/redis'
import type { CommonConfig } from '../common/config'
import { InternalCaptureService } from '../common/services/internal-capture'
-import { AppMetricsOutput, HogInvocationResultsOutput, LogEntriesOutput } from '../ingestion/common/outputs'
-import { IngestionOutputs } from '../ingestion/outputs/ingestion-outputs'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
import { PostgresRouter } from '../utils/db/postgres'
import { logger } from '../utils/logger'
import { PubSub } from '../utils/pubsub'
diff --git a/nodejs/src/cdp/consumers/cdp-base.consumer.ts b/nodejs/src/cdp/consumers/cdp-base.consumer.ts
index e581cd492c4f..79cc62f6d2aa 100644
--- a/nodejs/src/cdp/consumers/cdp-base.consumer.ts
+++ b/nodejs/src/cdp/consumers/cdp-base.consumer.ts
@@ -1,3 +1,5 @@
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { RedisV2 } from '~/common/redis/redis-v2'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
@@ -5,8 +7,6 @@ import type { CommonConfig } from '../../common/config'
import { HealthCheckResult, PluginServerService, TeamId } from '../../types'
import { GeoIPService } from '../../utils/geoip'
import { logger } from '../../utils/logger'
-import { GroupReadRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
-import { PersonReadRepository } from '../../worker/ingestion/persons/repositories/person-repository'
import {
CdpCoreServicesConfig,
CdpCoreServicesDeps,
diff --git a/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow-personhog.test.ts b/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow-personhog.test.ts
index 511565710bba..7538f6bc27cd 100644
--- a/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow-personhog.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow-personhog.test.ts
@@ -2,10 +2,10 @@ import { createMockJobQueue } from '~/tests/helpers/mocks/job-queue.mock'
import { DateTime } from 'luxon'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { HogFlow } from '~/schema/hogflow'
import { createCdpConsumerDeps } from '~/tests/helpers/cdp'
import { getFirstTeam, resetTestDatabase } from '~/tests/helpers/sql'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
import { Hub, InternalPerson, Team } from '../../types'
import { closeHub, createHub } from '../../utils/db/hub'
diff --git a/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow.test.ts b/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow.test.ts
index 2c7d5c4b7a19..6ce116f6f970 100644
--- a/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-cyclotron-worker-hogflow.test.ts
@@ -2,15 +2,12 @@ import { createMockJobQueue } from '~/tests/helpers/mocks/job-queue.mock'
import { DateTime } from 'luxon'
+import { InternalPersonWithDistinctId, PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { HogFlow } from '~/schema/hogflow'
import { createCdpConsumerDeps } from '~/tests/helpers/cdp'
import { createTeam, getFirstTeam, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
import { PostgresUse } from '~/utils/db/postgres'
import { UUIDT } from '~/utils/utils'
-import {
- InternalPersonWithDistinctId,
- PersonReadRepository,
-} from '~/worker/ingestion/persons/repositories/person-repository'
import { Hub, InternalPerson, Team } from '../../types'
import { closeHub, createHub } from '../../utils/db/hub'
diff --git a/nodejs/src/cdp/consumers/cdp-events-consumer.test.ts b/nodejs/src/cdp/consumers/cdp-events-consumer.test.ts
index fc9ef70581f5..e817a4d28101 100644
--- a/nodejs/src/cdp/consumers/cdp-events-consumer.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-events-consumer.test.ts
@@ -1,6 +1,7 @@
import { createMockJobQueue } from '../../../tests/helpers/mocks/job-queue.mock'
import { mockProducerObserver } from '../../../tests/helpers/mocks/producer.mock'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
import { HogFlow } from '~/schema/hogflow'
import { createCdpConsumerDeps } from '../../../tests/helpers/cdp'
@@ -14,7 +15,6 @@ import {
} from '../../../tests/helpers/sql'
import { Hub, Team } from '../../types'
import { closeHub, createHub } from '../../utils/db/hub'
-import { GroupReadRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
import { FixtureHogFlowBuilder } from '../_tests/builders/hogflow.builder'
import { HOG_EXAMPLES, HOG_FILTERS_EXAMPLES, HOG_INPUTS_EXAMPLES } from '../_tests/examples'
import {
diff --git a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts b/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
index 84cb6a633eed..9136130a1701 100644
--- a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
+++ b/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
@@ -1,5 +1,7 @@
import { Counter, Gauge, Histogram } from 'prom-client'
+import { HogTransformationResult, HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { instrumentFn } from '~/common/tracing/tracing-utils'
import { PluginEvent } from '~/plugin-scaffold'
@@ -7,7 +9,6 @@ import { PluginEvent } from '~/plugin-scaffold'
import { CyclotronJobInvocationResult, HogFunctionInvocationGlobals, HogFunctionType } from '../../cdp/types'
import { isLegacyPluginHogFunction } from '../../cdp/utils'
import type { CommonConfig } from '../../common/config'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
import { PostgresRouter } from '../../utils/db/postgres'
import { GeoIPService, GeoIp } from '../../utils/geoip'
import { logger } from '../../utils/logger'
@@ -74,12 +75,12 @@ export const hogTransformationUnexpectedErrors = new Counter({
help: 'Number of unexpected errors during transformation execution. Any occurrence should trigger an alert as the transformation is skipped.',
})
-export interface TransformationResult {
+export interface TransformationResult extends HogTransformationResult {
event: PluginEvent | null
invocationResults: CyclotronJobInvocationResult[]
}
-export class HogTransformerService {
+export class HogTransformerService implements HogTransformer {
private cachedStates: Record<string, HogWatcherState> = {}
private invocationResults: CyclotronJobInvocationResult[] = []
private cachedGeoIp?: GeoIp
@@ -432,6 +433,18 @@ export class HogTransformerService {
this.cachedStates = {}
}
}
+
+ public async prefetchTransformationStatesForTeams(teamIds: number[]): Promise<void> {
+ this.clearHogFunctionStates()
+ if (teamIds.length === 0) {
+ return
+ }
+ const teamHogFunctionIds = await this.hogFunctionManager.getHogFunctionIdsForTeams(teamIds, ['transformation'])
+ const allHogFunctionIds = Object.values(teamHogFunctionIds).flat()
+ if (allHogFunctionIds.length > 0) {
+ await this.fetchAndCacheHogFunctionStates(allHogFunctionIds)
+ }
+ }
}
/**
diff --git a/nodejs/src/cdp/outputs/outputs.ts b/nodejs/src/cdp/outputs/outputs.ts
index eea3396fce40..ef47965b4979 100644
--- a/nodejs/src/cdp/outputs/outputs.ts
+++ b/nodejs/src/cdp/outputs/outputs.ts
@@ -2,7 +2,7 @@
* Output names registered by the CDP deployments.
*
* Shared names (`APP_METRICS_OUTPUT`, `LOG_ENTRIES_OUTPUT`) live in
- * `ingestion/common/outputs` and are re-used by the CDP monitoring path.
+ * `common/outputs` and are re-used by the CDP monitoring path.
* Names declared here are CDP-local — the topic each one resolves to is
* driven by the registry build in `registry.ts`.
*/
diff --git a/nodejs/src/cdp/outputs/producer-registry.ts b/nodejs/src/cdp/outputs/producer-registry.ts
index 0f3b564154a1..cecfe9a85579 100644
--- a/nodejs/src/cdp/outputs/producer-registry.ts
+++ b/nodejs/src/cdp/outputs/producer-registry.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerRegistryBuilder } from '../../ingestion/outputs/kafka-producer-registry-builder'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
+
import {
WAREHOUSE_PRODUCER,
WAREHOUSE_PRODUCER_CONFIG_MAP,
diff --git a/nodejs/src/cdp/outputs/producers.ts b/nodejs/src/cdp/outputs/producers.ts
index 6b8f076e4d47..57aa924f53bc 100644
--- a/nodejs/src/cdp/outputs/producers.ts
+++ b/nodejs/src/cdp/outputs/producers.ts
@@ -5,7 +5,7 @@
* vars share the same prefix so deployment config is unambiguous (e.g.
* `WARPSTREAM_INGESTION_PRODUCER` ↔ `KAFKA_WARPSTREAM_INGESTION_PRODUCER_*`).
*/
-import { AllowedConfigKey } from '../../ingestion/outputs/kafka-producer-config'
+import { AllowedConfigKey } from '~/common/outputs/kafka-producer-config'
/** Targets the shared Warpstream cluster used by ingestion. Current default for CDP. */
export const WARPSTREAM_INGESTION_PRODUCER = 'WARPSTREAM_INGESTION_PRODUCER' as const
diff --git a/nodejs/src/cdp/outputs/registry.ts b/nodejs/src/cdp/outputs/registry.ts
index 3e5c10468b15..5dcde6f48725 100644
--- a/nodejs/src/cdp/outputs/registry.ts
+++ b/nodejs/src/cdp/outputs/registry.ts
@@ -1,5 +1,6 @@
-import { APP_METRICS_OUTPUT, HOG_INVOCATION_RESULTS_OUTPUT, LOG_ENTRIES_OUTPUT } from '../../ingestion/common/outputs'
-import { IngestionOutputsBuilder } from '../../ingestion/outputs/ingestion-outputs-builder'
+import { APP_METRICS_OUTPUT, HOG_INVOCATION_RESULTS_OUTPUT, LOG_ENTRIES_OUTPUT } from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+
import {
BATCH_HOGFLOW_REQUESTS_OUTPUT,
PRECALCULATED_PERSON_PROPERTIES_OUTPUT,
diff --git a/nodejs/src/cdp/rerun/rerun-e2e.test.ts b/nodejs/src/cdp/rerun/rerun-e2e.test.ts
index cd2c4a5cc5db..785a16841317 100644
--- a/nodejs/src/cdp/rerun/rerun-e2e.test.ts
+++ b/nodejs/src/cdp/rerun/rerun-e2e.test.ts
@@ -6,12 +6,12 @@ import { KafkaProducerObserver } from '~/tests/helpers/mocks/producer.spy'
import { DateTime } from 'luxon'
import { Pool } from 'pg'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { createCdpConsumerDeps } from '~/tests/helpers/cdp'
import { Clickhouse } from '~/tests/helpers/clickhouse'
import { waitForExpect } from '~/tests/helpers/expectations'
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
import { getFirstTeam, resetTestDatabase } from '~/tests/helpers/sql'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
import { KAFKA_HOG_INVOCATION_RESULTS } from '../../config/kafka-topics'
import { KafkaProducerWrapper } from '../../kafka/producer'
diff --git a/nodejs/src/cdp/services/batch-export-hog-function.service.test.ts b/nodejs/src/cdp/services/batch-export-hog-function.service.test.ts
index ffcb2b1b92d2..cb58fbcfe6a1 100644
--- a/nodejs/src/cdp/services/batch-export-hog-function.service.test.ts
+++ b/nodejs/src/cdp/services/batch-export-hog-function.service.test.ts
@@ -11,6 +11,7 @@ import { HOG_EXAMPLES, HOG_FILTERS_EXAMPLES, HOG_INPUTS_EXAMPLES } from '~/cdp/_
import { insertHogFunction as _insertHogFunction, insertBatchExport } from '~/cdp/_tests/fixtures'
import { CdpApi } from '~/cdp/cdp-api'
import { HogFunctionType } from '~/cdp/types'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
import { createCdpConsumerDeps } from '~/tests/helpers/cdp'
import { getFirstTeam, resetTestDatabase, updateOrganizationAvailableFeatures } from '~/tests/helpers/sql'
import { Hub, Team } from '~/types'
@@ -19,7 +20,6 @@ import { UUIDT } from '~/utils/utils'
import { GroupTypeIndex, TeamId } from '../../types'
import { parseJSON } from '../../utils/json-parse'
-import { GroupReadRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
import { GroupsManagerService } from './managers/groups-manager.service'
describe('BatchExportHogFunctionService', () => {
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-duplicate-observer.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-duplicate-observer.service.test.ts
index b19f5b91908f..0769777e67a5 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-duplicate-observer.service.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-duplicate-observer.service.test.ts
@@ -1,10 +1,10 @@
import { register } from 'prom-client'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
-import { deleteKeysWithPrefix } from '../../_tests/redis'
import { CyclotronJobInvocationHogFlow } from '../../types'
import { HogFlowDuplicateObserverService } from './hogflow-duplicate-observer.service'
diff --git a/nodejs/src/cdp/services/managers/groups-manager.service.test.ts b/nodejs/src/cdp/services/managers/groups-manager.service.test.ts
index 6d624461ba2e..adadcbcea8c5 100644
--- a/nodejs/src/cdp/services/managers/groups-manager.service.test.ts
+++ b/nodejs/src/cdp/services/managers/groups-manager.service.test.ts
@@ -1,5 +1,5 @@
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
import { TeamManager } from '~/utils/team-manager'
-import { GroupReadRepository } from '~/worker/ingestion/groups/repositories/group-repository.interface'
import { createHogExecutionGlobals } from '../../_tests/fixtures'
import { GroupsManagerService } from './groups-manager.service'
diff --git a/nodejs/src/cdp/services/managers/groups-manager.service.ts b/nodejs/src/cdp/services/managers/groups-manager.service.ts
index 93457129f12c..d2c00d85ddd0 100644
--- a/nodejs/src/cdp/services/managers/groups-manager.service.ts
+++ b/nodejs/src/cdp/services/managers/groups-manager.service.ts
@@ -1,8 +1,8 @@
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
import { sanitizeString } from '~/utils/db/utils'
import { LazyLoader } from '~/utils/lazy-loader'
import { logger } from '~/utils/logger'
import { TeamManager } from '~/utils/team-manager'
-import { GroupReadRepository } from '~/worker/ingestion/groups/repositories/group-repository.interface'
import { GroupTypeIndex, Team } from '../../../types'
import { GroupType, HogFunctionInvocationGlobals } from '../../types'
diff --git a/nodejs/src/cdp/services/managers/persons-manager.service.test.ts b/nodejs/src/cdp/services/managers/persons-manager.service.test.ts
index b64b0fee3a50..f83cb88a413b 100644
--- a/nodejs/src/cdp/services/managers/persons-manager.service.test.ts
+++ b/nodejs/src/cdp/services/managers/persons-manager.service.test.ts
@@ -2,6 +2,8 @@ import { create } from '@bufbuild/protobuf'
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'
import { DateTime } from 'luxon'
+import { PersonHogClient } from '~/common/personhog/client'
+import { PersonHogPersonReadRepository } from '~/common/personhog/personhog-person-read-repository'
import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
import { TeamDistinctIdSchema } from '~/generated/personhog/personhog/types/v1/common_pb'
import {
@@ -13,8 +15,6 @@ import {
PersonsResponseSchema,
} from '~/generated/personhog/personhog/types/v1/person_pb'
-import { PersonHogClient } from '../../../ingestion/personhog/client'
-import { PersonHogPersonReadRepository } from '../../../ingestion/personhog/personhog-person-read-repository'
import { PersonsManagerService } from './persons-manager.service'
jest.mock('../../../utils/logger')
diff --git a/nodejs/src/cdp/services/managers/persons-manager.service.ts b/nodejs/src/cdp/services/managers/persons-manager.service.ts
index a1b35bbcc3f8..a2bec5d311a4 100644
--- a/nodejs/src/cdp/services/managers/persons-manager.service.ts
+++ b/nodejs/src/cdp/services/managers/persons-manager.service.ts
@@ -1,7 +1,8 @@
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
+
import { LazyLoader } from '../../../utils/lazy-loader'
import { logger } from '../../../utils/logger'
import { TeamManager } from '../../../utils/team-manager'
-import { PersonReadRepository } from '../../../worker/ingestion/persons/repositories/person-repository'
import { CyclotronPerson } from '../../types'
import { getPersonDisplayName } from '../../utils'
diff --git a/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.ts b/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.ts
index de8634d69828..e755b21229cf 100644
--- a/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.ts
+++ b/nodejs/src/cdp/services/monitoring/hog-function-monitoring.service.ts
@@ -1,8 +1,8 @@
import { Counter, Gauge, Histogram } from 'prom-client'
+import { AppMetricsOutput, LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { AppMetricsAggregator } from '~/common/services/app-metrics-aggregator'
-import { AppMetricsOutput, LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
import { safeClickhouseString } from '../../../utils/db/utils'
import { logger } from '../../../utils/logger'
diff --git a/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.test.ts b/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.test.ts
index a347c32c4223..dd88fee409eb 100644
--- a/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.test.ts
+++ b/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.test.ts
@@ -1,6 +1,6 @@
import { DateTime } from 'luxon'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { parseJSON } from '../../../utils/json-parse'
import { createExampleInvocation } from '../../_tests/fixtures'
diff --git a/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.ts b/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.ts
index bde2ba9d603f..6e9bf9eba73e 100644
--- a/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.ts
+++ b/nodejs/src/cdp/services/monitoring/hog-invocation-results.service.ts
@@ -2,8 +2,8 @@ import { promisify } from 'node:util'
import { gunzip, gzip } from 'node:zlib'
import { Counter, Gauge } from 'prom-client'
-import { HOG_INVOCATION_RESULTS_OUTPUT, HogInvocationResultsOutput } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
+import { HOG_INVOCATION_RESULTS_OUTPUT, HogInvocationResultsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { safeClickhouseString } from '../../../utils/db/utils'
import { parseJSON } from '../../../utils/json-parse'
diff --git a/nodejs/src/cdp/services/monitoring/hog-masker.service.test.ts b/nodejs/src/cdp/services/monitoring/hog-masker.service.test.ts
index ee083565dd7c..e70afc8cf93b 100644
--- a/nodejs/src/cdp/services/monitoring/hog-masker.service.test.ts
+++ b/nodejs/src/cdp/services/monitoring/hog-masker.service.test.ts
@@ -1,3 +1,4 @@
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { HogFlow } from '~/schema/hogflow'
import { Hub } from '~/types'
@@ -7,7 +8,6 @@ import { delay } from '~/utils/utils'
import { HOG_FLOW_MASK_EXAMPLES, HOG_MASK_EXAMPLES } from '../../_tests/examples'
import { createExampleInvocation, createHogExecutionGlobals, createHogFunction } from '../../_tests/fixtures'
import { createExampleHogFlowInvocation } from '../../_tests/fixtures-hogflows'
-import { deleteKeysWithPrefix } from '../../_tests/redis'
import { CyclotronJobInvocationHogFunction, HogFunctionType } from '../../types'
import { BASE_REDIS_KEY, HogMaskerService } from './hog-masker.service'
diff --git a/nodejs/src/cdp/services/monitoring/hog-watcher.service.test.ts b/nodejs/src/cdp/services/monitoring/hog-watcher.service.test.ts
index 9e286d224890..0a805a357d59 100644
--- a/nodejs/src/cdp/services/monitoring/hog-watcher.service.test.ts
+++ b/nodejs/src/cdp/services/monitoring/hog-watcher.service.test.ts
@@ -1,10 +1,10 @@
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { logger } from '~/utils/logger'
import { Hub, ProjectId, Team } from '../../../types'
import { closeHub, createHub } from '../../../utils/db/hub'
import { createExampleInvocation, createHogFunction } from '../../_tests/fixtures'
-import { deleteKeysWithPrefix } from '../../_tests/redis'
import { CyclotronJobInvocationHogFunction, CyclotronJobInvocationResult, HogFunctionType } from '../../types'
import { createInvocationResult } from '../../utils/invocation-utils'
import { BASE_REDIS_KEY, HogWatcherConfig, HogWatcherService, HogWatcherState } from './hog-watcher.service'
diff --git a/nodejs/src/cdp/services/rate-limiter/rate-limiter.service.test.ts b/nodejs/src/cdp/services/rate-limiter/rate-limiter.service.test.ts
index ab61d331caf5..6a528bb06292 100644
--- a/nodejs/src/cdp/services/rate-limiter/rate-limiter.service.test.ts
+++ b/nodejs/src/cdp/services/rate-limiter/rate-limiter.service.test.ts
@@ -1,10 +1,10 @@
import { register } from 'prom-client'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
-import { deleteKeysWithPrefix } from '../../_tests/redis'
import { RateLimiterService } from './rate-limiter.service'
const KEY = '@posthog-test/ses-rate-limiter/bucket'
diff --git a/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.test.ts b/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.test.ts
index e747a819f8fc..13a367b5e715 100644
--- a/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.test.ts
+++ b/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.test.ts
@@ -1,4 +1,5 @@
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+
import { parseJSON } from '../../../utils/json-parse'
import { WAREHOUSE_SOURCE_WEBHOOKS_OUTPUT, WarehouseSourceWebhooksOutput } from '../../outputs/outputs'
import { CyclotronJobInvocationResult, WarehouseWebhookPayload } from '../../types'
diff --git a/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.ts b/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.ts
index f799b6b2b8cb..4e8282d80ce9 100644
--- a/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.ts
+++ b/nodejs/src/cdp/services/warehouse/warehouse-webhooks.service.ts
@@ -1,6 +1,7 @@
import { Gauge } from 'prom-client'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+
import { logger } from '../../../utils/logger'
import { captureException } from '../../../utils/posthog'
import { WAREHOUSE_SOURCE_WEBHOOKS_OUTPUT, WarehouseSourceWebhooksOutput } from '../../outputs/outputs'
diff --git a/nodejs/src/cdp/workflows-e2e.test.ts b/nodejs/src/cdp/workflows-e2e.test.ts
index b9a25b3bff60..fe5e626598a7 100644
--- a/nodejs/src/cdp/workflows-e2e.test.ts
+++ b/nodejs/src/cdp/workflows-e2e.test.ts
@@ -19,6 +19,8 @@ import { DateTime } from 'luxon'
import { Pool } from 'pg'
import { register } from 'prom-client'
+import { InternalPersonWithDistinctId, PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { createCdpConsumerDeps } from '~/tests/helpers/cdp'
import { waitForExpect } from '~/tests/helpers/expectations'
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
@@ -31,16 +33,11 @@ import { Hub, Team } from '../../src/types'
import { closeHub, createHub } from '../../src/utils/db/hub'
import { PostgresUse } from '../../src/utils/db/postgres'
import { UUIDT } from '../../src/utils/utils'
-import {
- InternalPersonWithDistinctId,
- PersonReadRepository,
-} from '../../src/worker/ingestion/persons/repositories/person-repository'
import { createRedisV2PoolFromConfig } from '../common/redis/redis-v2'
import { FixtureHogFlowBuilder } from './_tests/builders/hogflow.builder'
import { HOG_FILTERS_EXAMPLES } from './_tests/examples'
import { createHogExecutionGlobals, insertHogFunctionTemplate, insertIntegration } from './_tests/fixtures'
import { insertHogFlow } from './_tests/fixtures-hogflows'
-import { deleteKeysWithPrefix } from './_tests/redis'
import { CdpCyclotronWorkerEmail } from './consumers/cdp-cyclotron-worker-email.consumer'
import { CdpCyclotronWorkerHogFlow } from './consumers/cdp-cyclotron-worker-hogflow.consumer'
import { CdpEventsConsumer } from './consumers/cdp-events.consumer'
diff --git a/nodejs/src/worker/ingestion/group-type-manager.test.ts b/nodejs/src/common/groups/group-type-manager.test.ts
similarity index 97%
rename from nodejs/src/worker/ingestion/group-type-manager.test.ts
rename to nodejs/src/common/groups/group-type-manager.test.ts
index 8e5175a509bc..9978f68cf1de 100644
--- a/nodejs/src/worker/ingestion/group-type-manager.test.ts
+++ b/nodejs/src/common/groups/group-type-manager.test.ts
@@ -1,13 +1,13 @@
import { DateTime } from 'luxon'
-import { createTeam, getTeam, resetTestDatabase } from '../../../tests/helpers/sql'
-import { Hub, ProjectId, TeamId } from '../../types'
-import { closeHub, createHub } from '../../utils/db/hub'
-import { PostgresUse } from '../../utils/db/postgres'
-import { captureTeamEvent } from '../../utils/posthog'
-import { GroupTypeManager } from './group-type-manager'
-
-jest.mock('../../utils/posthog', () => ({
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { createTeam, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, ProjectId, TeamId } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresUse } from '~/utils/db/postgres'
+import { captureTeamEvent } from '~/utils/posthog'
+
+jest.mock('~/utils/posthog', () => ({
captureTeamEvent: jest.fn(),
}))
diff --git a/nodejs/src/worker/ingestion/group-type-manager.ts b/nodejs/src/common/groups/group-type-manager.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/group-type-manager.ts
rename to nodejs/src/common/groups/group-type-manager.ts
index 415f7a215686..1bb86f42f9b1 100644
--- a/nodejs/src/worker/ingestion/group-type-manager.ts
+++ b/nodejs/src/common/groups/group-type-manager.ts
@@ -1,11 +1,11 @@
import { DateTime } from 'luxon'
-import { GroupTypeIndex, GroupTypeToColumnIndex, GroupTypesByProjectId, ProjectId, Team, TeamId } from '../../types'
-import { timeoutGuard } from '../../utils/db/utils'
-import { LazyLoader } from '../../utils/lazy-loader'
-import { captureTeamEvent } from '../../utils/posthog'
-import { TeamManager } from '../../utils/team-manager'
-import { GroupRepository } from './groups/repositories/group-repository.interface'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { GroupTypeIndex, GroupTypeToColumnIndex, GroupTypesByProjectId, ProjectId, Team, TeamId } from '~/types'
+import { timeoutGuard } from '~/utils/db/utils'
+import { LazyLoader } from '~/utils/lazy-loader'
+import { captureTeamEvent } from '~/utils/posthog'
+import { TeamManager } from '~/utils/team-manager'
/** How many unique group types to allow per team */
export const MAX_GROUP_TYPES_PER_TEAM = 5
diff --git a/nodejs/src/worker/ingestion/readonly-group-type-manager.ts b/nodejs/src/common/groups/readonly-group-type-manager.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/readonly-group-type-manager.ts
rename to nodejs/src/common/groups/readonly-group-type-manager.ts
index f6e4d91ee28c..5cdce1cb30fe 100644
--- a/nodejs/src/worker/ingestion/readonly-group-type-manager.ts
+++ b/nodejs/src/common/groups/readonly-group-type-manager.ts
@@ -1,7 +1,7 @@
-import { GroupTypeToColumnIndex, GroupTypesByProjectId, ProjectId } from '../../types'
-import { timeoutGuard } from '../../utils/db/utils'
-import { LazyLoader } from '../../utils/lazy-loader'
-import { GroupReadRepository } from './groups/repositories/group-repository.interface'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
+import { GroupTypeToColumnIndex, GroupTypesByProjectId, ProjectId } from '~/types'
+import { timeoutGuard } from '~/utils/db/utils'
+import { LazyLoader } from '~/utils/lazy-loader'
/**
* Read-only group type manager backed by a GroupReadRepository. Provides
diff --git a/nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.test.ts b/nodejs/src/common/groups/repositories/clickhouse-group-repository.test.ts
similarity index 88%
rename from nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.test.ts
rename to nodejs/src/common/groups/repositories/clickhouse-group-repository.test.ts
index 8c6d86acfcd0..4040518ae52a 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.test.ts
+++ b/nodejs/src/common/groups/repositories/clickhouse-group-repository.test.ts
@@ -1,9 +1,9 @@
import { DateTime } from 'luxon'
-import { GROUPS_OUTPUT, GroupsOutput } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
+import { GROUPS_OUTPUT, GroupsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { GroupTypeIndex, TeamId } from '~/types'
-import { GroupTypeIndex, TeamId } from '../../../../types'
import { ClickhouseGroupRepository } from './clickhouse-group-repository'
describe('ClickhouseGroupRepository', () => {
diff --git a/nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.ts b/nodejs/src/common/groups/repositories/clickhouse-group-repository.ts
similarity index 77%
rename from nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.ts
rename to nodejs/src/common/groups/repositories/clickhouse-group-repository.ts
index 15683697ee66..cf021e6ecd49 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/clickhouse-group-repository.ts
+++ b/nodejs/src/common/groups/repositories/clickhouse-group-repository.ts
@@ -1,11 +1,10 @@
import { DateTime } from 'luxon'
+import { GROUPS_OUTPUT, GroupsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { Properties } from '~/plugin-scaffold'
-
-import { GROUPS_OUTPUT, GroupsOutput } from '../../../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../../../ingestion/outputs/ingestion-outputs'
-import { GroupTypeIndex, TeamId, TimestampFormat } from '../../../../types'
-import { castTimestampOrNow } from '../../../../utils/utils'
+import { GroupTypeIndex, TeamId, TimestampFormat } from '~/types'
+import { castTimestampOrNow } from '~/utils/utils'
export class ClickhouseGroupRepository {
constructor(private outputs: IngestionOutputs<GroupsOutput>) {}
diff --git a/nodejs/src/worker/ingestion/groups/repositories/group-repository-transaction.interface.ts b/nodejs/src/common/groups/repositories/group-repository-transaction.interface.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/groups/repositories/group-repository-transaction.interface.ts
rename to nodejs/src/common/groups/repositories/group-repository-transaction.interface.ts
index 7fe8d99dae50..72ba37aeec06 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/group-repository-transaction.interface.ts
+++ b/nodejs/src/common/groups/repositories/group-repository-transaction.interface.ts
@@ -1,15 +1,7 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
-
-import {
- Group,
- GroupTypeIndex,
- ProjectId,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- TeamId,
-} from '../../../../types'
+import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '~/types'
export interface GroupRepositoryTransaction {
fetchGroup(
diff --git a/nodejs/src/worker/ingestion/groups/repositories/group-repository.interface.ts b/nodejs/src/common/groups/repositories/group-repository.interface.ts
similarity index 96%
rename from nodejs/src/worker/ingestion/groups/repositories/group-repository.interface.ts
rename to nodejs/src/common/groups/repositories/group-repository.interface.ts
index f717e774f8d8..7494cd23bb80 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/group-repository.interface.ts
+++ b/nodejs/src/common/groups/repositories/group-repository.interface.ts
@@ -1,15 +1,8 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
+import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '~/types'
-import {
- Group,
- GroupTypeIndex,
- ProjectId,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- TeamId,
-} from '../../../../types'
import { GroupRepositoryTransaction } from './group-repository-transaction.interface'
/**
diff --git a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository-transaction.ts b/nodejs/src/common/groups/repositories/postgres-group-repository-transaction.ts
similarity index 93%
rename from nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository-transaction.ts
rename to nodejs/src/common/groups/repositories/postgres-group-repository-transaction.ts
index 91fe00365058..fa020fd12893 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository-transaction.ts
+++ b/nodejs/src/common/groups/repositories/postgres-group-repository-transaction.ts
@@ -1,16 +1,9 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
+import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '~/types'
+import { TransactionClient } from '~/utils/db/postgres'
-import {
- Group,
- GroupTypeIndex,
- ProjectId,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- TeamId,
-} from '../../../../types'
-import { TransactionClient } from '../../../../utils/db/postgres'
import { GroupRepositoryTransaction } from './group-repository-transaction.interface'
import { RawPostgresGroupRepository } from './raw-postgres-group-repository.interface'
diff --git a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.integration.test.ts b/nodejs/src/common/groups/repositories/postgres-group-repository.integration.test.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.integration.test.ts
rename to nodejs/src/common/groups/repositories/postgres-group-repository.integration.test.ts
index 24de84fb81bb..9759e0ce000f 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.integration.test.ts
+++ b/nodejs/src/common/groups/repositories/postgres-group-repository.integration.test.ts
@@ -1,6 +1,6 @@
import { DateTime } from 'luxon'
-import { insertRow, resetTestDatabase } from '../../../../../tests/helpers/sql'
+import { insertRow, resetTestDatabase } from '~/tests/helpers/sql'
import {
GroupTypeIndex,
Hub,
@@ -9,10 +9,11 @@ import {
PropertiesLastUpdatedAt,
PropertyUpdateOperation,
TeamId,
-} from '../../../../types'
-import { closeHub, createHub } from '../../../../utils/db/hub'
-import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'
-import { UUIDT } from '../../../../utils/utils'
+} from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { UUIDT } from '~/utils/utils'
+
import { PostgresGroupRepository } from './postgres-group-repository'
const TEST_TIMESTAMP = DateTime.fromISO('2020-01-01T00:00:00.000Z', { zone: 'utc' })
diff --git a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.ts b/nodejs/src/common/groups/repositories/postgres-group-repository.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.ts
rename to nodejs/src/common/groups/repositories/postgres-group-repository.ts
index 04c25a76f417..7683ba86fe72 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/postgres-group-repository.ts
+++ b/nodejs/src/common/groups/repositories/postgres-group-repository.ts
@@ -2,8 +2,6 @@ import { DateTime } from 'luxon'
import { QueryResult } from 'pg'
import { Properties } from '~/plugin-scaffold'
-import { sanitizeJsonbValue } from '~/utils/db/utils'
-
import {
Group,
GroupTypeIndex,
@@ -12,9 +10,11 @@ import {
PropertiesLastUpdatedAt,
RawGroup,
TeamId,
-} from '../../../../types'
-import { PostgresRouter, PostgresUse, TransactionClient } from '../../../../utils/db/postgres'
-import { RaceConditionError } from '../../../../utils/utils'
+} from '~/types'
+import { PostgresRouter, PostgresUse, TransactionClient } from '~/utils/db/postgres'
+import { sanitizeJsonbValue } from '~/utils/db/utils'
+import { RaceConditionError } from '~/utils/utils'
+
import { GroupRepositoryTransaction } from './group-repository-transaction.interface'
import { GroupRepository } from './group-repository.interface'
import { PostgresGroupRepositoryTransaction } from './postgres-group-repository-transaction'
diff --git a/nodejs/src/worker/ingestion/groups/repositories/raw-postgres-group-repository.interface.ts b/nodejs/src/common/groups/repositories/raw-postgres-group-repository.interface.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/groups/repositories/raw-postgres-group-repository.interface.ts
rename to nodejs/src/common/groups/repositories/raw-postgres-group-repository.interface.ts
index 7a1804889ceb..0c4ed795b6c6 100644
--- a/nodejs/src/worker/ingestion/groups/repositories/raw-postgres-group-repository.interface.ts
+++ b/nodejs/src/common/groups/repositories/raw-postgres-group-repository.interface.ts
@@ -1,16 +1,8 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
-
-import {
- Group,
- GroupTypeIndex,
- ProjectId,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- TeamId,
-} from '../../../../types'
-import { TransactionClient } from '../../../../utils/db/postgres'
+import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '~/types'
+import { TransactionClient } from '~/utils/db/postgres'
export interface RawPostgresGroupRepository {
fetchGroup(
diff --git a/nodejs/src/common/hog-transformations/hog-transformer.interface.ts b/nodejs/src/common/hog-transformations/hog-transformer.interface.ts
new file mode 100644
index 000000000000..9d800658b844
--- /dev/null
+++ b/nodejs/src/common/hog-transformations/hog-transformer.interface.ts
@@ -0,0 +1,25 @@
+import { PluginEvent } from '~/plugin-scaffold'
+
+/**
+ * Contract for the hog transformation service, consumed by ingestion.
+ *
+ * The concrete implementation (`HogTransformerService`) lives in cdp because it depends on the
+ * full hog execution machinery (executor, managers, templates, plugins). Ingestion depends only
+ * on this interface and receives an instance by injection from the server wiring layer, so
+ * ingestion never imports cdp.
+ */
+export interface HogTransformationResult {
+ event: PluginEvent | null
+ // Opaque to ingestion (it only reads `.length`); cdp narrows this to its concrete result type.
+ invocationResults: unknown[]
+}
+
+export interface HogTransformer {
+ start(): Promise<void>
+ stop(): Promise<void>
+ processInvocationResults(): Promise<void>
+ transformEventAndProduceMessages(event: PluginEvent): Promise<HogTransformationResult>
+ // Refresh cached transformation hog-function states for the given teams (used by the ingestion
+ // prefetch step). Encapsulates the hog-function-manager lookup ingestion would otherwise reach into.
+ prefetchTransformationStatesForTeams(teamIds: number[]): Promise<void>
+}
diff --git a/nodejs/src/ingestion/outputs/README.md b/nodejs/src/common/outputs/README.md
similarity index 100%
rename from nodejs/src/ingestion/outputs/README.md
rename to nodejs/src/common/outputs/README.md
diff --git a/nodejs/src/ingestion/outputs/dual-write-ingestion-output.test.ts b/nodejs/src/common/outputs/dual-write-ingestion-output.test.ts
similarity index 99%
rename from nodejs/src/ingestion/outputs/dual-write-ingestion-output.test.ts
rename to nodejs/src/common/outputs/dual-write-ingestion-output.test.ts
index 7e4eab5b4603..23d8b4ea02eb 100644
--- a/nodejs/src/ingestion/outputs/dual-write-ingestion-output.test.ts
+++ b/nodejs/src/common/outputs/dual-write-ingestion-output.test.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+
import {
DualWriteIngestionOutput,
keyHashBucket,
diff --git a/nodejs/src/ingestion/outputs/dual-write-ingestion-output.ts b/nodejs/src/common/outputs/dual-write-ingestion-output.ts
similarity index 99%
rename from nodejs/src/ingestion/outputs/dual-write-ingestion-output.ts
rename to nodejs/src/common/outputs/dual-write-ingestion-output.ts
index 01eccf1c0b40..08a79cb42072 100644
--- a/nodejs/src/ingestion/outputs/dual-write-ingestion-output.ts
+++ b/nodejs/src/common/outputs/dual-write-ingestion-output.ts
@@ -1,4 +1,5 @@
-import { MessageKey } from '../../kafka/producer'
+import { MessageKey } from '~/kafka/producer'
+
import { IngestionOutput } from './ingestion-output'
import { SingleIngestionOutput } from './single-ingestion-output'
import { DualWriteMode, IngestionOutputMessage } from './types'
diff --git a/nodejs/src/ingestion/common/outputs/index.ts b/nodejs/src/common/outputs/index.ts
similarity index 91%
rename from nodejs/src/ingestion/common/outputs/index.ts
rename to nodejs/src/common/outputs/index.ts
index 31aa79304c30..87cedcaa3c18 100644
--- a/nodejs/src/ingestion/common/outputs/index.ts
+++ b/nodejs/src/common/outputs/index.ts
@@ -1,8 +1,16 @@
// Output names shared across pipelines
+export * from './persons'
+
export const EVENTS_OUTPUT = 'events' as const
export type EventOutput = typeof EVENTS_OUTPUT
+export const AI_EVENTS_OUTPUT = 'ai_events' as const
+export type AiEventOutput = typeof AI_EVENTS_OUTPUT
+
+export const ASYNC_OUTPUT = 'async' as const
+export type AsyncOutput = typeof ASYNC_OUTPUT
+
export const INGESTION_WARNINGS_OUTPUT = 'ingestion_warnings' as const
export type IngestionWarningsOutput = typeof INGESTION_WARNINGS_OUTPUT
diff --git a/nodejs/src/ingestion/outputs/ingestion-output.ts b/nodejs/src/common/outputs/ingestion-output.ts
similarity index 89%
rename from nodejs/src/ingestion/outputs/ingestion-output.ts
rename to nodejs/src/common/outputs/ingestion-output.ts
index d8470d1ee36d..e6e009c3867e 100644
--- a/nodejs/src/ingestion/outputs/ingestion-output.ts
+++ b/nodejs/src/common/outputs/ingestion-output.ts
@@ -1,4 +1,5 @@
-import { MessageKey } from '../../kafka/producer'
+import { MessageKey } from '~/kafka/producer'
+
import { IngestionOutputMessage } from './types'
/** A resolved Kafka output that pipeline steps produce to. */
diff --git a/nodejs/src/ingestion/outputs/ingestion-outputs-builder.test.ts b/nodejs/src/common/outputs/ingestion-outputs-builder.test.ts
similarity index 99%
rename from nodejs/src/ingestion/outputs/ingestion-outputs-builder.test.ts
rename to nodejs/src/common/outputs/ingestion-outputs-builder.test.ts
index 01153ce8554d..4e632922f6d7 100644
--- a/nodejs/src/ingestion/outputs/ingestion-outputs-builder.test.ts
+++ b/nodejs/src/common/outputs/ingestion-outputs-builder.test.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+
import { IngestionOutputsBuilder, parseTeamDenylist } from './ingestion-outputs-builder'
import { KafkaProducerRegistry } from './kafka-producer-registry'
diff --git a/nodejs/src/ingestion/outputs/ingestion-outputs-builder.ts b/nodejs/src/common/outputs/ingestion-outputs-builder.ts
similarity index 100%
rename from nodejs/src/ingestion/outputs/ingestion-outputs-builder.ts
rename to nodejs/src/common/outputs/ingestion-outputs-builder.ts
diff --git a/nodejs/src/ingestion/outputs/ingestion-outputs.test.ts b/nodejs/src/common/outputs/ingestion-outputs.test.ts
similarity index 99%
rename from nodejs/src/ingestion/outputs/ingestion-outputs.test.ts
rename to nodejs/src/common/outputs/ingestion-outputs.test.ts
index 362549135b05..acdb7a3518be 100644
--- a/nodejs/src/ingestion/outputs/ingestion-outputs.test.ts
+++ b/nodejs/src/common/outputs/ingestion-outputs.test.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+
import { DualWriteIngestionOutput } from './dual-write-ingestion-output'
import { IngestionOutputs } from './ingestion-outputs'
import { SingleIngestionOutput } from './single-ingestion-output'
diff --git a/nodejs/src/ingestion/outputs/ingestion-outputs.ts b/nodejs/src/common/outputs/ingestion-outputs.ts
similarity index 97%
rename from nodejs/src/ingestion/outputs/ingestion-outputs.ts
rename to nodejs/src/common/outputs/ingestion-outputs.ts
index 30f9978836ec..fd930cef0036 100644
--- a/nodejs/src/ingestion/outputs/ingestion-outputs.ts
+++ b/nodejs/src/common/outputs/ingestion-outputs.ts
@@ -1,5 +1,6 @@
-import { MessageKey } from '../../kafka/producer'
-import { logger } from '../../utils/logger'
+import { MessageKey } from '~/kafka/producer'
+import { logger } from '~/utils/logger'
+
import { IngestionOutput } from './ingestion-output'
import { IngestionOutputMessage } from './types'
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-config.test.ts b/nodejs/src/common/outputs/kafka-producer-config.test.ts
similarity index 100%
rename from nodejs/src/ingestion/outputs/kafka-producer-config.test.ts
rename to nodejs/src/common/outputs/kafka-producer-config.test.ts
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-config.ts b/nodejs/src/common/outputs/kafka-producer-config.ts
similarity index 100%
rename from nodejs/src/ingestion/outputs/kafka-producer-config.ts
rename to nodejs/src/common/outputs/kafka-producer-config.ts
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-registry-builder.test.ts b/nodejs/src/common/outputs/kafka-producer-registry-builder.test.ts
similarity index 97%
rename from nodejs/src/ingestion/outputs/kafka-producer-registry-builder.test.ts
rename to nodejs/src/common/outputs/kafka-producer-registry-builder.test.ts
index 828bcc8b6301..3a53ea3aba47 100644
--- a/nodejs/src/ingestion/outputs/kafka-producer-registry-builder.test.ts
+++ b/nodejs/src/common/outputs/kafka-producer-registry-builder.test.ts
@@ -1,8 +1,9 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+
import { AllowedConfigKey } from './kafka-producer-config'
import { KafkaProducerRegistryBuilder } from './kafka-producer-registry-builder'
-jest.mock('../../kafka/producer')
+jest.mock('~/kafka/producer')
describe('KafkaProducerRegistryBuilder', () => {
beforeEach(() => {
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-registry-builder.ts b/nodejs/src/common/outputs/kafka-producer-registry-builder.ts
similarity index 97%
rename from nodejs/src/ingestion/outputs/kafka-producer-registry-builder.ts
rename to nodejs/src/common/outputs/kafka-producer-registry-builder.ts
index 2e08feb7817a..69d572375866 100644
--- a/nodejs/src/ingestion/outputs/kafka-producer-registry-builder.ts
+++ b/nodejs/src/common/outputs/kafka-producer-registry-builder.ts
@@ -1,7 +1,8 @@
import { ProducerGlobalConfig } from 'node-rdkafka'
-import { KafkaProducerWrapper } from '../../kafka/producer'
-import { logger } from '../../utils/logger'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { logger } from '~/utils/logger'
+
import { AllowedConfigKey, parseProducerConfig } from './kafka-producer-config'
import { KafkaProducerRegistry } from './kafka-producer-registry'
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-registry.test.ts b/nodejs/src/common/outputs/kafka-producer-registry.test.ts
similarity index 97%
rename from nodejs/src/ingestion/outputs/kafka-producer-registry.test.ts
rename to nodejs/src/common/outputs/kafka-producer-registry.test.ts
index a5b205600e9e..f6089b6d2631 100644
--- a/nodejs/src/ingestion/outputs/kafka-producer-registry.test.ts
+++ b/nodejs/src/common/outputs/kafka-producer-registry.test.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+
import { KafkaProducerRegistry } from './kafka-producer-registry'
type TestProducer = 'ALPHA' | 'BETA'
diff --git a/nodejs/src/ingestion/outputs/kafka-producer-registry.ts b/nodejs/src/common/outputs/kafka-producer-registry.ts
similarity index 93%
rename from nodejs/src/ingestion/outputs/kafka-producer-registry.ts
rename to nodejs/src/common/outputs/kafka-producer-registry.ts
index fc6614ca995e..e252aa3596d0 100644
--- a/nodejs/src/ingestion/outputs/kafka-producer-registry.ts
+++ b/nodejs/src/common/outputs/kafka-producer-registry.ts
@@ -1,5 +1,5 @@
-import { KafkaProducerWrapper } from '../../kafka/producer'
-import { logger } from '../../utils/logger'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { logger } from '~/utils/logger'
/**
* Typed producer registry that holds pre-created Kafka producers by name.
diff --git a/nodejs/src/ingestion/outputs/metrics.ts b/nodejs/src/common/outputs/metrics.ts
similarity index 100%
rename from nodejs/src/ingestion/outputs/metrics.ts
rename to nodejs/src/common/outputs/metrics.ts
diff --git a/nodejs/src/common/outputs/persons.ts b/nodejs/src/common/outputs/persons.ts
new file mode 100644
index 000000000000..20b1505c0fd1
--- /dev/null
+++ b/nodejs/src/common/outputs/persons.ts
@@ -0,0 +1,6 @@
+// Person-data output names, shared by the common persons data layer and the analytics lane.
+export const PERSONS_OUTPUT = 'persons' as const
+export type PersonsOutput = typeof PERSONS_OUTPUT
+
+export const PERSON_DISTINCT_IDS_OUTPUT = 'person_distinct_ids' as const
+export type PersonDistinctIdsOutput = typeof PERSON_DISTINCT_IDS_OUTPUT
diff --git a/nodejs/src/ingestion/common/outputs/registry.ts b/nodejs/src/common/outputs/registry.ts
similarity index 85%
rename from nodejs/src/ingestion/common/outputs/registry.ts
rename to nodejs/src/common/outputs/registry.ts
index e8e1740139d7..d986c51a693a 100644
--- a/nodejs/src/ingestion/common/outputs/registry.ts
+++ b/nodejs/src/common/outputs/registry.ts
@@ -1,8 +1,11 @@
import { INGESTION_DOWNSTREAM_PRODUCER, INGESTION_UPSTREAM_PRODUCER, ProducerName } from '.'
-import { KafkaProducerRegistry } from '../../outputs/kafka-producer-registry'
-import { KafkaProducerRegistryBuilder } from '../../outputs/kafka-producer-registry-builder'
-import { INGESTION_DOWNSTREAM_PRODUCER_CONFIG_MAP, INGESTION_UPSTREAM_PRODUCER_CONFIG_MAP } from '../config'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
+import {
+ INGESTION_DOWNSTREAM_PRODUCER_CONFIG_MAP,
+ INGESTION_UPSTREAM_PRODUCER_CONFIG_MAP,
+} from '~/ingestion/common/config'
/**
* The consolidated UPSTREAM/DOWNSTREAM producer slots, for the analytics-family servers
diff --git a/nodejs/src/ingestion/outputs/single-ingestion-output.ts b/nodejs/src/common/outputs/single-ingestion-output.ts
similarity index 95%
rename from nodejs/src/ingestion/outputs/single-ingestion-output.ts
rename to nodejs/src/common/outputs/single-ingestion-output.ts
index d86b24ba6fb1..1b874aa6874a 100644
--- a/nodejs/src/ingestion/outputs/single-ingestion-output.ts
+++ b/nodejs/src/common/outputs/single-ingestion-output.ts
@@ -1,5 +1,6 @@
-import { KafkaProducerWrapper, MessageKey } from '../../kafka/producer'
-import { logger } from '../../utils/logger'
+import { KafkaProducerWrapper, MessageKey } from '~/kafka/producer'
+import { logger } from '~/utils/logger'
+
import { IngestionOutput } from './ingestion-output'
import {
ingestionOutputsBatchSize,
diff --git a/nodejs/src/ingestion/outputs/types.ts b/nodejs/src/common/outputs/types.ts
similarity index 96%
rename from nodejs/src/ingestion/outputs/types.ts
rename to nodejs/src/common/outputs/types.ts
index 51b09cb6d4f0..1dfa146ef9c7 100644
--- a/nodejs/src/ingestion/outputs/types.ts
+++ b/nodejs/src/common/outputs/types.ts
@@ -1,4 +1,4 @@
-import { MessageKey } from '../../kafka/producer'
+import { MessageKey } from '~/kafka/producer'
/** A Kafka message with a Buffer value, used by IngestionOutputs. */
export type IngestionOutputMessage = {
diff --git a/nodejs/src/ingestion/personhog/client.test.ts b/nodejs/src/common/personhog/client.test.ts
similarity index 99%
rename from nodejs/src/ingestion/personhog/client.test.ts
rename to nodejs/src/common/personhog/client.test.ts
index a7d18cb8198d..5bd7c57736ed 100644
--- a/nodejs/src/ingestion/personhog/client.test.ts
+++ b/nodejs/src/common/personhog/client.test.ts
@@ -2,24 +2,25 @@ import { create } from '@bufbuild/protobuf'
import { Code, ConnectError, type ServiceImpl, createRouterTransport } from '@connectrpc/connect'
import { DateTime } from 'luxon'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { ConsistencyLevel } from '../../generated/personhog/personhog/types/v1/common_pb'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { ConsistencyLevel } from '~/generated/personhog/personhog/types/v1/common_pb'
import {
GroupSchema,
GroupTypeMappingSchema,
GroupTypeMappingsByKeySchema,
-} from '../../generated/personhog/personhog/types/v1/group_pb'
+} from '~/generated/personhog/personhog/types/v1/group_pb'
import type {
GetGroupRequest,
GetGroupTypeMappingsByProjectIdsRequest,
GetGroupTypeMappingsByTeamIdsRequest,
GetGroupsBatchRequest,
-} from '../../generated/personhog/personhog/types/v1/group_pb'
-import { PersonSchema } from '../../generated/personhog/personhog/types/v1/person_pb'
+} from '~/generated/personhog/personhog/types/v1/group_pb'
+import { PersonSchema } from '~/generated/personhog/personhog/types/v1/person_pb'
import type {
GetPersonsByDistinctIdsRequest,
GetPersonsByUuidsRequest,
-} from '../../generated/personhog/personhog/types/v1/person_pb'
+} from '~/generated/personhog/personhog/types/v1/person_pb'
+
import {
PersonHogClient,
parseRolloutTeamIds,
diff --git a/nodejs/src/ingestion/personhog/client.ts b/nodejs/src/common/personhog/client.ts
similarity index 97%
rename from nodejs/src/ingestion/personhog/client.ts
rename to nodejs/src/common/personhog/client.ts
index 42dd6b0f2c97..3f473e95b0d3 100644
--- a/nodejs/src/ingestion/personhog/client.ts
+++ b/nodejs/src/common/personhog/client.ts
@@ -3,9 +3,10 @@ import { Interceptor, Transport, createClient } from '@connectrpc/connect'
import { Http2SessionManager, createGrpcTransport } from '@connectrpc/connect-node'
import { DateTime } from 'luxon'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { ConsistencyLevel, ReadOptionsSchema } from '../../generated/personhog/personhog/types/v1/common_pb'
-import { parseJSON } from '../../utils/json-parse'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { ConsistencyLevel, ReadOptionsSchema } from '~/generated/personhog/personhog/types/v1/common_pb'
+import { parseJSON } from '~/utils/json-parse'
+
import { PersonHogGroupOperations } from './groups'
import { PersonHogPersonOperations } from './persons'
import { SessionStateMonitor } from './session-state-monitor'
diff --git a/nodejs/src/ingestion/personhog/groups.ts b/nodejs/src/common/personhog/groups.ts
similarity index 93%
rename from nodejs/src/ingestion/personhog/groups.ts
rename to nodejs/src/common/personhog/groups.ts
index 0934d3c68c57..2f366b267f3c 100644
--- a/nodejs/src/ingestion/personhog/groups.ts
+++ b/nodejs/src/common/personhog/groups.ts
@@ -1,16 +1,17 @@
import { create } from '@bufbuild/protobuf'
import { Client } from '@connectrpc/connect'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { GroupKeySchema } from '../../generated/personhog/personhog/types/v1/common_pb'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { GroupKeySchema } from '~/generated/personhog/personhog/types/v1/common_pb'
import {
GetGroupRequestSchema,
GetGroupTypeMappingsByProjectIdsRequestSchema,
GetGroupTypeMappingsByTeamIdsRequestSchema,
GetGroupsBatchRequestSchema,
-} from '../../generated/personhog/personhog/types/v1/group_pb'
-import type { Group as ProtoGroup } from '../../generated/personhog/personhog/types/v1/group_pb'
-import { Group as DomainGroup, GroupTypeIndex } from '../../types'
+} from '~/generated/personhog/personhog/types/v1/group_pb'
+import type { Group as ProtoGroup } from '~/generated/personhog/personhog/types/v1/group_pb'
+import { Group as DomainGroup, GroupTypeIndex } from '~/types'
+
import { epochMsToDateTime, eventualReadOptions, parseJsonBytes } from './client'
const PERSONHOG_BATCH_SIZE = 100
diff --git a/nodejs/src/ingestion/personhog/grpc-retry.test.ts b/nodejs/src/common/personhog/grpc-retry.test.ts
similarity index 100%
rename from nodejs/src/ingestion/personhog/grpc-retry.test.ts
rename to nodejs/src/common/personhog/grpc-retry.test.ts
diff --git a/nodejs/src/ingestion/personhog/grpc-retry.ts b/nodejs/src/common/personhog/grpc-retry.ts
similarity index 97%
rename from nodejs/src/ingestion/personhog/grpc-retry.ts
rename to nodejs/src/common/personhog/grpc-retry.ts
index fbbe1c08ce14..e216af0a47bf 100644
--- a/nodejs/src/ingestion/personhog/grpc-retry.ts
+++ b/nodejs/src/common/personhog/grpc-retry.ts
@@ -1,6 +1,7 @@
import { Code, ConnectError } from '@connectrpc/connect'
-import { logger } from '../../utils/logger'
+import { logger } from '~/utils/logger'
+
import { grpcErrorType, personhogRetriesTotal, personhogTerminalErrorsTotal } from './metrics'
const RETRYABLE_CODES = new Set([
diff --git a/nodejs/src/ingestion/personhog/index.ts b/nodejs/src/common/personhog/index.ts
similarity index 91%
rename from nodejs/src/ingestion/personhog/index.ts
rename to nodejs/src/common/personhog/index.ts
index 8577675f5dfc..42e3c32656b0 100644
--- a/nodejs/src/ingestion/personhog/index.ts
+++ b/nodejs/src/common/personhog/index.ts
@@ -1,7 +1,8 @@
-import { logger } from '../../utils/logger'
-import { GroupRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
-import { PersonRepository } from '../../worker/ingestion/persons/repositories/person-repository'
-import { PersonHogConfig } from '../config'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { PersonRepository } from '~/common/persons/repositories/person-repository'
+import { PersonHogConfig } from '~/ingestion/config'
+import { logger } from '~/utils/logger'
+
import { PersonHogClient, parseRolloutTeamIds } from './client'
import { PersonHogGroupRepository } from './personhog-group-repository'
import { PersonHogPersonRepository } from './personhog-person-repository'
diff --git a/nodejs/src/ingestion/personhog/metrics.ts b/nodejs/src/common/personhog/metrics.ts
similarity index 100%
rename from nodejs/src/ingestion/personhog/metrics.ts
rename to nodejs/src/common/personhog/metrics.ts
diff --git a/nodejs/src/ingestion/personhog/personhog-group-read-repository.test.ts b/nodejs/src/common/personhog/personhog-group-read-repository.test.ts
similarity index 98%
rename from nodejs/src/ingestion/personhog/personhog-group-read-repository.test.ts
rename to nodejs/src/common/personhog/personhog-group-read-repository.test.ts
index 61589ee6f02a..349e598cf1fe 100644
--- a/nodejs/src/ingestion/personhog/personhog-group-read-repository.test.ts
+++ b/nodejs/src/common/personhog/personhog-group-read-repository.test.ts
@@ -1,7 +1,8 @@
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { TeamId } from '../../types'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { PersonHogGroupReadRepository } from './personhog-group-read-repository'
diff --git a/nodejs/src/ingestion/personhog/personhog-group-read-repository.ts b/nodejs/src/common/personhog/personhog-group-read-repository.ts
similarity index 92%
rename from nodejs/src/ingestion/personhog/personhog-group-read-repository.ts
rename to nodejs/src/common/personhog/personhog-group-read-repository.ts
index 4e62a460eed5..f13c60b37b36 100644
--- a/nodejs/src/ingestion/personhog/personhog-group-read-repository.ts
+++ b/nodejs/src/common/personhog/personhog-group-read-repository.ts
@@ -1,5 +1,6 @@
-import { GroupTypeIndex, ProjectId, TeamId } from '../../types'
-import { GroupReadRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
+import { GroupTypeIndex, ProjectId, TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { withRetry } from './grpc-retry'
import { timedGrpc } from './metrics'
diff --git a/nodejs/src/ingestion/personhog/personhog-group-repository.test.ts b/nodejs/src/common/personhog/personhog-group-repository.test.ts
similarity index 98%
rename from nodejs/src/ingestion/personhog/personhog-group-repository.test.ts
rename to nodejs/src/common/personhog/personhog-group-repository.test.ts
index 261319c691f7..fa2343e99e96 100644
--- a/nodejs/src/ingestion/personhog/personhog-group-repository.test.ts
+++ b/nodejs/src/common/personhog/personhog-group-repository.test.ts
@@ -2,14 +2,15 @@ import { create } from '@bufbuild/protobuf'
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'
import { DateTime } from 'luxon'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
import {
GroupSchema,
GroupTypeMappingSchema,
GroupTypeMappingsByKeySchema,
-} from '../../generated/personhog/personhog/types/v1/group_pb'
-import { Group, GroupTypeIndex, ProjectId, TeamId } from '../../types'
-import { GroupRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
+} from '~/generated/personhog/personhog/types/v1/group_pb'
+import { Group, GroupTypeIndex, ProjectId, TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { PersonHogGroupRepository } from './personhog-group-repository'
diff --git a/nodejs/src/ingestion/personhog/personhog-group-repository.ts b/nodejs/src/common/personhog/personhog-group-repository.ts
similarity index 95%
rename from nodejs/src/ingestion/personhog/personhog-group-repository.ts
rename to nodejs/src/common/personhog/personhog-group-repository.ts
index b94fbcfd878e..d2c675c84c12 100644
--- a/nodejs/src/ingestion/personhog/personhog-group-repository.ts
+++ b/nodejs/src/common/personhog/personhog-group-repository.ts
@@ -1,11 +1,11 @@
import { DateTime } from 'luxon'
+import { GroupRepositoryTransaction } from '~/common/groups/repositories/group-repository-transaction.interface'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
import { Properties } from '~/plugin-scaffold'
+import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '~/types'
+import { logger } from '~/utils/logger'
-import { Group, GroupTypeIndex, ProjectId, PropertiesLastOperation, PropertiesLastUpdatedAt, TeamId } from '../../types'
-import { logger } from '../../utils/logger'
-import { GroupRepositoryTransaction } from '../../worker/ingestion/groups/repositories/group-repository-transaction.interface'
-import { GroupRepository } from '../../worker/ingestion/groups/repositories/group-repository.interface'
import { PersonHogClient, shouldUseGrpc, shouldUseGrpcForTeam, shouldUseGrpcForTeams } from './client'
import { timedGrpc, timedPostgres } from './metrics'
diff --git a/nodejs/src/ingestion/personhog/personhog-person-read-repository.test.ts b/nodejs/src/common/personhog/personhog-person-read-repository.test.ts
similarity index 97%
rename from nodejs/src/ingestion/personhog/personhog-person-read-repository.test.ts
rename to nodejs/src/common/personhog/personhog-person-read-repository.test.ts
index a9bcdb22398c..5e5b44864304 100644
--- a/nodejs/src/ingestion/personhog/personhog-person-read-repository.test.ts
+++ b/nodejs/src/common/personhog/personhog-person-read-repository.test.ts
@@ -1,9 +1,10 @@
import { create } from '@bufbuild/protobuf'
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { PersonSchema } from '../../generated/personhog/personhog/types/v1/person_pb'
-import { TeamId } from '../../types'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { PersonSchema } from '~/generated/personhog/personhog/types/v1/person_pb'
+import { TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { PersonHogPersonReadRepository } from './personhog-person-read-repository'
diff --git a/nodejs/src/ingestion/personhog/personhog-person-read-repository.ts b/nodejs/src/common/personhog/personhog-person-read-repository.ts
similarity index 93%
rename from nodejs/src/ingestion/personhog/personhog-person-read-repository.ts
rename to nodejs/src/common/personhog/personhog-person-read-repository.ts
index 148d745f87f0..71905dc46c87 100644
--- a/nodejs/src/ingestion/personhog/personhog-person-read-repository.ts
+++ b/nodejs/src/common/personhog/personhog-person-read-repository.ts
@@ -1,8 +1,6 @@
-import { InternalPerson, TeamId } from '../../types'
-import {
- InternalPersonWithDistinctId,
- PersonReadRepository,
-} from '../../worker/ingestion/persons/repositories/person-repository'
+import { InternalPersonWithDistinctId, PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { InternalPerson, TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { withRetry } from './grpc-retry'
import { timedGrpc } from './metrics'
diff --git a/nodejs/src/ingestion/personhog/personhog-person-repository.test.ts b/nodejs/src/common/personhog/personhog-person-repository.test.ts
similarity index 98%
rename from nodejs/src/ingestion/personhog/personhog-person-repository.test.ts
rename to nodejs/src/common/personhog/personhog-person-repository.test.ts
index 09fc761497d6..f5918a8d8dfb 100644
--- a/nodejs/src/ingestion/personhog/personhog-person-repository.test.ts
+++ b/nodejs/src/common/personhog/personhog-person-repository.test.ts
@@ -2,13 +2,11 @@ import { create } from '@bufbuild/protobuf'
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'
import { DateTime } from 'luxon'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { PersonSchema } from '../../generated/personhog/personhog/types/v1/person_pb'
-import { InternalPerson, TeamId } from '../../types'
-import {
- InternalPersonWithDistinctId,
- PersonRepository,
-} from '../../worker/ingestion/persons/repositories/person-repository'
+import { InternalPersonWithDistinctId, PersonRepository } from '~/common/persons/repositories/person-repository'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { PersonSchema } from '~/generated/personhog/personhog/types/v1/person_pb'
+import { InternalPerson, TeamId } from '~/types'
+
import { PersonHogClient } from './client'
import { PersonHogPersonRepository } from './personhog-person-repository'
diff --git a/nodejs/src/ingestion/personhog/personhog-person-repository.ts b/nodejs/src/common/personhog/personhog-person-repository.ts
similarity index 94%
rename from nodejs/src/ingestion/personhog/personhog-person-repository.ts
rename to nodejs/src/common/personhog/personhog-person-repository.ts
index 8838270b4946..b26a35d93b29 100644
--- a/nodejs/src/ingestion/personhog/personhog-person-repository.ts
+++ b/nodejs/src/common/personhog/personhog-person-repository.ts
@@ -1,7 +1,10 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
+import { PersonUpdate } from '~/common/persons/person-update-batch'
+import { InternalPersonWithDistinctId, PersonRepository } from '~/common/persons/repositories/person-repository'
+import { PersonRepositoryTransaction } from '~/common/persons/repositories/person-repository-transaction'
import { Properties } from '~/plugin-scaffold'
-
import {
InternalPerson,
PersonUpdateFields,
@@ -9,16 +12,10 @@ import {
PropertiesLastUpdatedAt,
Team,
TeamId,
-} from '../../types'
-import { CreatePersonResult } from '../../utils/db/db'
-import { logger } from '../../utils/logger'
-import { PersonMessage } from '../../worker/ingestion/persons/person-message'
-import { PersonUpdate } from '../../worker/ingestion/persons/person-update-batch'
-import {
- InternalPersonWithDistinctId,
- PersonRepository,
-} from '../../worker/ingestion/persons/repositories/person-repository'
-import { PersonRepositoryTransaction } from '../../worker/ingestion/persons/repositories/person-repository-transaction'
+} from '~/types'
+import { CreatePersonResult } from '~/utils/db/db'
+import { logger } from '~/utils/logger'
+
import { PersonHogClient, shouldUseGrpcForTeam, shouldUseGrpcForTeamItems } from './client'
import { timedGrpc, timedPostgres } from './metrics'
diff --git a/nodejs/src/ingestion/personhog/personhog-postgres-parity.test.ts b/nodejs/src/common/personhog/personhog-postgres-parity.test.ts
similarity index 97%
rename from nodejs/src/ingestion/personhog/personhog-postgres-parity.test.ts
rename to nodejs/src/common/personhog/personhog-postgres-parity.test.ts
index 83cbf7f20de6..b820b0837b8f 100644
--- a/nodejs/src/ingestion/personhog/personhog-postgres-parity.test.ts
+++ b/nodejs/src/common/personhog/personhog-postgres-parity.test.ts
@@ -2,22 +2,23 @@ import { create } from '@bufbuild/protobuf'
import { type ServiceImpl, createRouterTransport } from '@connectrpc/connect'
import { DateTime } from 'luxon'
-import { insertRow, resetTestDatabase } from '../../../tests/helpers/sql'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
+import { PostgresGroupRepository } from '~/common/groups/repositories/postgres-group-repository'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
import {
GroupSchema,
GroupTypeMappingSchema,
GroupTypeMappingsByKeySchema,
-} from '../../generated/personhog/personhog/types/v1/group_pb'
-import type { Group as ProtoGroup } from '../../generated/personhog/personhog/types/v1/group_pb'
-import { PersonSchema } from '../../generated/personhog/personhog/types/v1/person_pb'
-import type { Person as ProtoPerson } from '../../generated/personhog/personhog/types/v1/person_pb'
-import { GroupTypeIndex, Hub, ProjectId, PropertyUpdateOperation, RawPerson, TeamId } from '../../types'
-import { closeHub, createHub } from '../../utils/db/hub'
-import { PostgresUse } from '../../utils/db/postgres'
-import { UUIDT } from '../../utils/utils'
-import { PostgresGroupRepository } from '../../worker/ingestion/groups/repositories/postgres-group-repository'
-import { PostgresPersonRepository } from '../../worker/ingestion/persons/repositories/postgres-person-repository'
+} from '~/generated/personhog/personhog/types/v1/group_pb'
+import type { Group as ProtoGroup } from '~/generated/personhog/personhog/types/v1/group_pb'
+import { PersonSchema } from '~/generated/personhog/personhog/types/v1/person_pb'
+import type { Person as ProtoPerson } from '~/generated/personhog/personhog/types/v1/person_pb'
+import { insertRow, resetTestDatabase } from '~/tests/helpers/sql'
+import { GroupTypeIndex, Hub, ProjectId, PropertyUpdateOperation, RawPerson, TeamId } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresUse } from '~/utils/db/postgres'
+import { UUIDT } from '~/utils/utils'
+
import { PersonHogClient } from './client'
jest.mock('../../utils/logger')
diff --git a/nodejs/src/ingestion/personhog/persons.test.ts b/nodejs/src/common/personhog/persons.test.ts
similarity index 96%
rename from nodejs/src/ingestion/personhog/persons.test.ts
rename to nodejs/src/common/personhog/persons.test.ts
index 768d72717160..cfcdd04a3f1f 100644
--- a/nodejs/src/ingestion/personhog/persons.test.ts
+++ b/nodejs/src/common/personhog/persons.test.ts
@@ -1,12 +1,13 @@
import { create } from '@bufbuild/protobuf'
import { type ServiceImpl, createClient, createRouterTransport } from '@connectrpc/connect'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { PersonSchema } from '../../generated/personhog/personhog/types/v1/person_pb'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { PersonSchema } from '~/generated/personhog/personhog/types/v1/person_pb'
import type {
GetPersonsByDistinctIdsRequest,
GetPersonsByUuidsRequest,
-} from '../../generated/personhog/personhog/types/v1/person_pb'
+} from '~/generated/personhog/personhog/types/v1/person_pb'
+
import { PersonHogPersonOperations } from './persons'
const textEncoder = new TextEncoder()
diff --git a/nodejs/src/ingestion/personhog/persons.ts b/nodejs/src/common/personhog/persons.ts
similarity index 91%
rename from nodejs/src/ingestion/personhog/persons.ts
rename to nodejs/src/common/personhog/persons.ts
index 6d8330866b4b..43369c45f193 100644
--- a/nodejs/src/ingestion/personhog/persons.ts
+++ b/nodejs/src/common/personhog/persons.ts
@@ -1,16 +1,17 @@
import { create } from '@bufbuild/protobuf'
import { Client } from '@connectrpc/connect'
-import { PersonHogService } from '../../generated/personhog/personhog/service/v1/service_pb'
-import { TeamDistinctIdSchema } from '../../generated/personhog/personhog/types/v1/common_pb'
+import { InternalPersonWithDistinctId } from '~/common/persons/repositories/person-repository'
+import { PersonHogService } from '~/generated/personhog/personhog/service/v1/service_pb'
+import { TeamDistinctIdSchema } from '~/generated/personhog/personhog/types/v1/common_pb'
import {
GetDistinctIdsForPersonsRequestSchema,
GetPersonsByDistinctIdsRequestSchema,
GetPersonsByUuidsRequestSchema,
-} from '../../generated/personhog/personhog/types/v1/person_pb'
-import type { Person as ProtoPerson } from '../../generated/personhog/personhog/types/v1/person_pb'
-import { InternalPerson } from '../../types'
-import { InternalPersonWithDistinctId } from '../../worker/ingestion/persons/repositories/person-repository'
+} from '~/generated/personhog/personhog/types/v1/person_pb'
+import type { Person as ProtoPerson } from '~/generated/personhog/personhog/types/v1/person_pb'
+import { InternalPerson } from '~/types'
+
import { epochMsToDateTime, eventualReadOptions, parseJsonBytes } from './client'
function protoPersonToDomain(proto: ProtoPerson): InternalPerson {
diff --git a/nodejs/src/ingestion/personhog/session-state-monitor.test.ts b/nodejs/src/common/personhog/session-state-monitor.test.ts
similarity index 100%
rename from nodejs/src/ingestion/personhog/session-state-monitor.test.ts
rename to nodejs/src/common/personhog/session-state-monitor.test.ts
diff --git a/nodejs/src/ingestion/personhog/session-state-monitor.ts b/nodejs/src/common/personhog/session-state-monitor.ts
similarity index 100%
rename from nodejs/src/ingestion/personhog/session-state-monitor.ts
rename to nodejs/src/common/personhog/session-state-monitor.ts
diff --git a/nodejs/src/worker/ingestion/persons/metrics.ts b/nodejs/src/common/persons/metrics.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/persons/metrics.ts
rename to nodejs/src/common/persons/metrics.ts
diff --git a/nodejs/src/worker/ingestion/persons/person-message.ts b/nodejs/src/common/persons/person-message.ts
similarity index 53%
rename from nodejs/src/worker/ingestion/persons/person-message.ts
rename to nodejs/src/common/persons/person-message.ts
index 6cf8f58ecdf1..258ce3c50dc8 100644
--- a/nodejs/src/worker/ingestion/persons/person-message.ts
+++ b/nodejs/src/common/persons/person-message.ts
@@ -1,4 +1,4 @@
-import { PersonDistinctIdsOutput, PersonsOutput } from '../../../ingestion/analytics/outputs'
+import { PersonDistinctIdsOutput, PersonsOutput } from '~/common/outputs/persons'
export type PersonMessage = {
output: PersonsOutput | PersonDistinctIdsOutput
diff --git a/nodejs/src/worker/ingestion/persons/person-property-utils.ts b/nodejs/src/common/persons/person-property-utils.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/persons/person-property-utils.ts
rename to nodejs/src/common/persons/person-property-utils.ts
diff --git a/nodejs/src/worker/ingestion/persons/person-update-batch.ts b/nodejs/src/common/persons/person-update-batch.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/persons/person-update-batch.ts
rename to nodejs/src/common/persons/person-update-batch.ts
index c42c902f4df0..aa624c35ba96 100644
--- a/nodejs/src/worker/ingestion/persons/person-update-batch.ts
+++ b/nodejs/src/common/persons/person-update-batch.ts
@@ -1,8 +1,7 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
-
-import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt } from '../../../types'
+import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt } from '~/types'
export interface PersonUpdate {
id: string // bigint ID from database as string
diff --git a/nodejs/src/worker/ingestion/persons/repositories/person-repository-transaction.ts b/nodejs/src/common/persons/repositories/person-repository-transaction.ts
similarity index 83%
rename from nodejs/src/worker/ingestion/persons/repositories/person-repository-transaction.ts
rename to nodejs/src/common/persons/repositories/person-repository-transaction.ts
index 779cfe240dcc..6a69ba06d014 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/person-repository-transaction.ts
+++ b/nodejs/src/common/persons/repositories/person-repository-transaction.ts
@@ -1,16 +1,9 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
import { Properties } from '~/plugin-scaffold'
-
-import {
- InternalPerson,
- PersonUpdateFields,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- Team,
-} from '../../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../../utils/db/db'
-import { PersonMessage } from '../person-message'
+import { InternalPerson, PersonUpdateFields, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
export interface PersonRepositoryTransaction {
createPerson(
diff --git a/nodejs/src/worker/ingestion/persons/repositories/person-repository.ts b/nodejs/src/common/persons/repositories/person-repository.ts
similarity index 96%
rename from nodejs/src/worker/ingestion/persons/repositories/person-repository.ts
rename to nodejs/src/common/persons/repositories/person-repository.ts
index 0883bbd11114..77c917d40e01 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/person-repository.ts
+++ b/nodejs/src/common/persons/repositories/person-repository.ts
@@ -1,7 +1,8 @@
import { DateTime } from 'luxon'
+import type { PersonMessage } from '~/common/persons/person-message'
+import { PersonUpdate } from '~/common/persons/person-update-batch'
import { Properties } from '~/plugin-scaffold'
-
import {
InternalPerson,
PersonUpdateFields,
@@ -9,10 +10,9 @@ import {
PropertiesLastUpdatedAt,
Team,
TeamId,
-} from '../../../../types'
-import { CreatePersonResult } from '../../../../utils/db/db'
-import type { PersonMessage } from '../person-message'
-import { PersonUpdate } from '../person-update-batch'
+} from '~/types'
+import { CreatePersonResult } from '~/utils/db/db'
+
import { PersonRepositoryTransaction } from './person-repository-transaction'
export type { PersonMessage }
diff --git a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository-transaction.ts b/nodejs/src/common/persons/repositories/postgres-person-repository-transaction.ts
similarity index 89%
rename from nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository-transaction.ts
rename to nodejs/src/common/persons/repositories/postgres-person-repository-transaction.ts
index 6a1a6b6bd0c6..78f704df6d69 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository-transaction.ts
+++ b/nodejs/src/common/persons/repositories/postgres-person-repository-transaction.ts
@@ -1,17 +1,11 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson, PersonUpdateFields, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
+import { TransactionClient } from '~/utils/db/postgres'
-import {
- InternalPerson,
- PersonUpdateFields,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- Team,
-} from '../../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../../utils/db/db'
-import { TransactionClient } from '../../../../utils/db/postgres'
-import { PersonMessage } from '../person-message'
import { PersonRepositoryTransaction } from './person-repository-transaction'
import { RawPostgresPersonRepository } from './raw-postgres-person-repository'
diff --git a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.test.ts b/nodejs/src/common/persons/repositories/postgres-person-repository.test.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.test.ts
rename to nodejs/src/common/persons/repositories/postgres-person-repository.test.ts
index f104fe171b0f..d36c1385c9bc 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.test.ts
+++ b/nodejs/src/common/persons/repositories/postgres-person-repository.test.ts
@@ -2,21 +2,22 @@ import { mockProducer } from '~/tests/helpers/mocks/producer.mock'
import { DateTime } from 'luxon'
-import { KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '../../../../../src/config/kafka-topics'
-import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../../../../../src/ingestion/analytics/outputs'
-import { IngestionOutputs } from '../../../../../src/ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../../../../../src/ingestion/outputs/single-ingestion-output'
-import { createTeam, insertRow, resetTestDatabase } from '../../../../../tests/helpers/sql'
-import { Hub, InternalPerson, PropertyUpdateOperation, Team } from '../../../../types'
-import { closeHub, createHub } from '../../../../utils/db/hub'
-import { PostgresRouter, PostgresUse } from '../../../../utils/db/postgres'
-import { parseJSON } from '../../../../utils/json-parse'
-import { NoRowsUpdatedError, UUIDT } from '../../../../utils/utils'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs/persons'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '~/config/kafka-topics'
+import { createTeam, insertRow, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, InternalPerson, PropertyUpdateOperation, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { parseJSON } from '~/utils/json-parse'
+import { NoRowsUpdatedError, UUIDT } from '~/utils/utils'
+
import { PersonPropertiesSizeViolationError } from './person-repository'
import { PostgresPersonRepository } from './postgres-person-repository'
import { createPersonUpdateFields, fetchDistinctIdValues, fetchDistinctIds } from './test-helpers'
-jest.mock('../../../../utils/logger')
+jest.mock('~/utils/logger')
describe('PostgresPersonRepository', () => {
let hub: Hub
@@ -2369,7 +2370,7 @@ describe('PostgresPersonRepository', () => {
return originalQuery(use, query, values, tag)
})
- const metrics = require('../metrics')
+ const metrics = require('~/common/persons/metrics')
const mockInc = jest.fn()
const originalInc = metrics.personPropertiesSizeViolationCounter.inc
metrics.personPropertiesSizeViolationCounter.inc = mockInc
@@ -2407,7 +2408,7 @@ describe('PostgresPersonRepository', () => {
.spyOn(oversizedRepository, 'personPropertiesSize')
.mockResolvedValue(60)
- const metrics = require('../metrics')
+ const metrics = require('~/common/persons/metrics')
const mockInc = jest.fn()
const originalInc = metrics.oversizedPersonPropertiesTrimmedCounter.inc
metrics.oversizedPersonPropertiesTrimmedCounter.inc = mockInc
@@ -2645,7 +2646,7 @@ describe('PostgresPersonRepository', () => {
beforeEach(() => {
// Import the histogram
- const metricsModule = require('../metrics')
+ const metricsModule = require('~/common/persons/metrics')
personJsonFieldSizeHistogram = metricsModule.personJsonFieldSizeHistogram
// Track observe calls
diff --git a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.ts b/nodejs/src/common/persons/repositories/postgres-person-repository.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.ts
rename to nodejs/src/common/persons/repositories/postgres-person-repository.ts
index e9e7c64b2e2e..59a4136720ff 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/postgres-person-repository.ts
+++ b/nodejs/src/common/persons/repositories/postgres-person-repository.ts
@@ -1,9 +1,15 @@
import { DateTime } from 'luxon'
import { QueryResult } from 'pg'
+import { PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs/persons'
+import {
+ oversizedPersonPropertiesTrimmedCounter,
+ personJsonFieldSizeHistogram,
+ personPropertiesSizeViolationCounter,
+} from '~/common/persons/metrics'
+import { canTrimProperty } from '~/common/persons/person-property-utils'
+import { PersonUpdate } from '~/common/persons/person-update-batch'
import { Properties } from '~/plugin-scaffold'
-
-import { PERSON_DISTINCT_IDS_OUTPUT } from '../../../../ingestion/analytics/outputs'
import {
InternalPerson,
PersonDistinctId,
@@ -13,24 +19,18 @@ import {
RawPerson,
Team,
TeamId,
-} from '../../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult, PersonPropertiesSize } from '../../../../utils/db/db'
+} from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult, PersonPropertiesSize } from '~/utils/db/db'
import {
moveDistinctIdsCountHistogram,
personPropertiesSizeHistogram,
personUpdateVersionMismatchCounter,
-} from '../../../../utils/db/metrics'
-import { PostgresRouter, PostgresUse, TransactionClient } from '../../../../utils/db/postgres'
-import { generateKafkaPersonUpdateMessage, sanitizeJsonbValue, unparsePersonPartial } from '../../../../utils/db/utils'
-import { logger } from '../../../../utils/logger'
-import { NoRowsUpdatedError, sanitizeSqlIdentifier } from '../../../../utils/utils'
-import {
- oversizedPersonPropertiesTrimmedCounter,
- personJsonFieldSizeHistogram,
- personPropertiesSizeViolationCounter,
-} from '../metrics'
-import { canTrimProperty } from '../person-property-utils'
-import { PersonUpdate } from '../person-update-batch'
+} from '~/utils/db/metrics'
+import { PostgresRouter, PostgresUse, TransactionClient } from '~/utils/db/postgres'
+import { generateKafkaPersonUpdateMessage, sanitizeJsonbValue, unparsePersonPartial } from '~/utils/db/utils'
+import { logger } from '~/utils/logger'
+import { NoRowsUpdatedError, sanitizeSqlIdentifier } from '~/utils/utils'
+
import {
InternalPersonWithDistinctId,
PersonMessage,
diff --git a/nodejs/src/worker/ingestion/persons/repositories/raw-postgres-person-repository.ts b/nodejs/src/common/persons/repositories/raw-postgres-person-repository.ts
similarity index 91%
rename from nodejs/src/worker/ingestion/persons/repositories/raw-postgres-person-repository.ts
rename to nodejs/src/common/persons/repositories/raw-postgres-person-repository.ts
index 243e7e9a0534..76922a552302 100644
--- a/nodejs/src/worker/ingestion/persons/repositories/raw-postgres-person-repository.ts
+++ b/nodejs/src/common/persons/repositories/raw-postgres-person-repository.ts
@@ -1,7 +1,8 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
+import { PersonUpdate } from '~/common/persons/person-update-batch'
import { Properties } from '~/plugin-scaffold'
-
import {
InternalPerson,
PersonUpdateFields,
@@ -9,11 +10,10 @@ import {
PropertiesLastUpdatedAt,
Team,
TeamId,
-} from '../../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../../utils/db/db'
-import { TransactionClient } from '../../../../utils/db/postgres'
-import { PersonMessage } from '../person-message'
-import { PersonUpdate } from '../person-update-batch'
+} from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
+import { TransactionClient } from '~/utils/db/postgres'
+
import { InternalPersonWithDistinctId } from './person-repository'
export interface RawPostgresPersonRepository {
diff --git a/nodejs/src/worker/ingestion/persons/repositories/test-helpers.ts b/nodejs/src/common/persons/repositories/test-helpers.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/persons/repositories/test-helpers.ts
rename to nodejs/src/common/persons/repositories/test-helpers.ts
diff --git a/nodejs/src/cdp/_tests/redis.ts b/nodejs/src/common/redis/_tests/redis.ts
similarity index 100%
rename from nodejs/src/cdp/_tests/redis.ts
rename to nodejs/src/common/redis/_tests/redis.ts
diff --git a/nodejs/src/common/services/app-metrics-aggregator.test.ts b/nodejs/src/common/services/app-metrics-aggregator.test.ts
index 8b1736f3ac7c..6db2b41b52ee 100644
--- a/nodejs/src/common/services/app-metrics-aggregator.test.ts
+++ b/nodejs/src/common/services/app-metrics-aggregator.test.ts
@@ -1,5 +1,6 @@
-import { APP_METRICS_OUTPUT, AppMetricsOutput } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
+import { APP_METRICS_OUTPUT, AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+
import { parseJSON } from '../../utils/json-parse'
import { AppMetricInput, AppMetricsAggregator } from './app-metrics-aggregator'
diff --git a/nodejs/src/common/services/app-metrics-aggregator.ts b/nodejs/src/common/services/app-metrics-aggregator.ts
index 13683d3ba52a..55c8219c88e0 100644
--- a/nodejs/src/common/services/app-metrics-aggregator.ts
+++ b/nodejs/src/common/services/app-metrics-aggregator.ts
@@ -1,7 +1,8 @@
import { Counter } from 'prom-client'
-import { APP_METRICS_OUTPUT, AppMetricsOutput } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
+import { APP_METRICS_OUTPUT, AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+
import { TimestampFormat } from '../../types'
import { safeClickhouseString } from '../../utils/db/utils'
import { castTimestampOrNow } from '../../utils/utils'
diff --git a/nodejs/src/common/services/keyed-rate-limiter.service.test.ts b/nodejs/src/common/services/keyed-rate-limiter.service.test.ts
index feacfdcdc280..eb74602c6a87 100644
--- a/nodejs/src/common/services/keyed-rate-limiter.service.test.ts
+++ b/nodejs/src/common/services/keyed-rate-limiter.service.test.ts
@@ -1,8 +1,8 @@
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
-import { deleteKeysWithPrefix } from '../../cdp/_tests/redis'
import { KeyedRateLimiterService } from './keyed-rate-limiter.service'
const mockNow: jest.SpyInstance = jest.spyOn(Date, 'now')
diff --git a/nodejs/src/config/config.ts b/nodejs/src/config/config.ts
index 5e1f81efc314..64085bf39e56 100644
--- a/nodejs/src/config/config.ts
+++ b/nodejs/src/config/config.ts
@@ -1,3 +1,11 @@
+import { getDefaultErrorTrackingConsumerConfig } from '~/ingestion/pipelines/errortracking/config'
+import { getDefaultMetricsIngestionConsumerConfig } from '~/ingestion/pipelines/metrics/config'
+import {
+ getDefaultSessionRecordingApiConfig,
+ getDefaultSessionRecordingConfig,
+} from '~/ingestion/pipelines/sessionreplay/config'
+import { getDefaultLogsIngestionConsumerConfig, getDefaultTracesIngestionConsumerConfig } from '~/logs/config'
+
import { getDefaultAIObservabilityConfig } from '../ai-observability/config'
import { getDefaultCdpConfig } from '../cdp/config'
import {
@@ -8,13 +16,6 @@ import {
} from '../cdp/outputs/producers'
import { getDefaultCommonConfig } from '../common/config'
import { getDefaultIngestionConsumerConfig } from '../ingestion/config'
-import { getDefaultErrorTrackingConsumerConfig } from '../ingestion/error-tracking/config'
-import {
- getDefaultLogsIngestionConsumerConfig,
- getDefaultTracesIngestionConsumerConfig,
-} from '../logs-ingestion/config'
-import { getDefaultMetricsIngestionConsumerConfig } from '../metrics-ingestion/config'
-import { getDefaultSessionRecordingApiConfig, getDefaultSessionRecordingConfig } from '../session-recording/config'
import { PluginsServerConfig, ValueMatcher, stringToPluginServerMode } from '../types'
import { stringToBoolean } from '../utils/env-utils'
diff --git a/nodejs/src/evaluation-scheduler/evaluation-scheduler.test.ts b/nodejs/src/evaluation-scheduler/evaluation-scheduler.test.ts
index 0a0df9a5d118..c110f06408da 100644
--- a/nodejs/src/evaluation-scheduler/evaluation-scheduler.test.ts
+++ b/nodejs/src/evaluation-scheduler/evaluation-scheduler.test.ts
@@ -7,7 +7,7 @@ import {
createTagger,
} from '~/ai-observability/_tests/fixtures'
import { getDefaultAIObservabilityConfig } from '~/ai-observability/config'
-import { parseTeamsList } from '~/ingestion/event-processing/split-ai-events-step'
+import { parseTeamsList } from '~/utils/env-utils'
import { logger } from '~/utils/logger'
import {
diff --git a/nodejs/src/evaluation-scheduler/evaluation-scheduler.ts b/nodejs/src/evaluation-scheduler/evaluation-scheduler.ts
index fa594c4a8fc1..b1e0724d0ff4 100644
--- a/nodejs/src/evaluation-scheduler/evaluation-scheduler.ts
+++ b/nodejs/src/evaluation-scheduler/evaluation-scheduler.ts
@@ -36,10 +36,10 @@ import {
import { Evaluation, EvaluationConditionSet, Matchable, Tagger } from '../ai-observability/types'
import { execHog } from '../cdp/utils/hog-exec'
import { KAFKA_CLICKHOUSE_AI_EVENTS_JSON, KAFKA_EVENTS_JSON, prefix as KAFKA_PREFIX } from '../config/kafka-topics'
-import { parseTeamsList } from '../ingestion/event-processing/split-ai-events-step'
import { createKafkaConsumer } from '../kafka/consumer'
import { PluginServerService, RawKafkaEvent } from '../types'
import { PostgresRouter } from '../utils/db/postgres'
+import { parseTeamsList } from '../utils/env-utils'
import { parseJSON } from '../utils/json-parse'
import { logger } from '../utils/logger'
import { PubSub } from '../utils/pubsub'
diff --git a/nodejs/src/ingestion/ai/index.ts b/nodejs/src/ingestion/ai/index.ts
deleted file mode 100644
index 70dd38dafe77..000000000000
--- a/nodejs/src/ingestion/ai/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { AI_EVENT_TYPES, normalizeTraceProperties, processAiEvent, type EventWithProperties } from './process-ai-event'
-export { createAiEventSubpipeline, type AiEventSubpipelineConfig } from './pipelines/ai-event-subpipeline'
diff --git a/nodejs/src/ingestion/analytics/outputs/index.ts b/nodejs/src/ingestion/analytics/outputs/index.ts
deleted file mode 100644
index ce8b3fc32f78..000000000000
--- a/nodejs/src/ingestion/analytics/outputs/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export { EVENTS_OUTPUT, type EventOutput } from '../../common/outputs'
-
-export const AI_EVENTS_OUTPUT = 'ai_events' as const
-export type AiEventOutput = typeof AI_EVENTS_OUTPUT
-
-export const ASYNC_OUTPUT = 'async' as const
-export type AsyncOutput = typeof ASYNC_OUTPUT
-
-export const PERSONS_OUTPUT = 'persons' as const
-export type PersonsOutput = typeof PERSONS_OUTPUT
-
-export const PERSON_DISTINCT_IDS_OUTPUT = 'person_distinct_ids' as const
-export type PersonDistinctIdsOutput = typeof PERSON_DISTINCT_IDS_OUTPUT
diff --git a/nodejs/src/worker/ingestion/PoE.md b/nodejs/src/ingestion/common/PoE.md
similarity index 100%
rename from nodejs/src/worker/ingestion/PoE.md
rename to nodejs/src/ingestion/common/PoE.md
diff --git a/nodejs/src/ingestion/common/ai-event-types.ts b/nodejs/src/ingestion/common/ai-event-types.ts
new file mode 100644
index 000000000000..23671ac5b218
--- /dev/null
+++ b/nodejs/src/ingestion/common/ai-event-types.ts
@@ -0,0 +1,11 @@
+// AI event type names, shared by the ai lane and the ingestion steps that route AI events.
+// Canonical Node.js list. Python mirror: posthog/hogql_queries/ai/ai_table_resolver.py
+export const AI_EVENT_TYPES = new Set([
+ '$ai_generation',
+ '$ai_embedding',
+ '$ai_evaluation',
+ '$ai_span',
+ '$ai_trace',
+ '$ai_metric',
+ '$ai_feedback',
+])
diff --git a/nodejs/src/ingestion/common/ai-subpipeline.contract.ts b/nodejs/src/ingestion/common/ai-subpipeline.contract.ts
new file mode 100644
index 000000000000..e79516059301
--- /dev/null
+++ b/nodejs/src/ingestion/common/ai-subpipeline.contract.ts
@@ -0,0 +1,54 @@
+import { Message } from 'node-rdkafka'
+
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import {
+ AiEventOutput,
+ AsyncOutput,
+ EventOutput,
+ IngestionWarningsOutput,
+ PersonDistinctIdsOutput,
+ PersonsOutput,
+} from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { EmitEventStepOutput } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { EventPipelineRunnerOptions } from '~/ingestion/common/steps/event-processing/event-pipeline-options'
+import { SplitAiEventsStepConfig } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import { PipelineBuilder, StartPipelineBuilder } from '~/ingestion/framework/builders/pipeline-builders'
+import { TopHogWrapper } from '~/ingestion/framework/extensions/tophog'
+import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders, Team } from '~/types'
+import { TeamManager } from '~/utils/team-manager'
+
+export interface AiEventSubpipelineInput {
+ message: Message
+ event: PluginEvent
+ team: Team
+ headers: EventHeaders
+ personsStoreForBatch: PersonsStoreForBatch
+ groupStoreForBatch: GroupStoreForBatch
+}
+
+export interface AiEventSubpipelineConfig {
+ options: EventPipelineRunnerOptions
+ outputs: IngestionOutputs<
+ EventOutput | AiEventOutput | IngestionWarningsOutput | PersonsOutput | PersonDistinctIdsOutput
+ >
+ teamManager: TeamManager
+ groupTypeManager: GroupTypeManager
+ hogTransformer: HogTransformer
+ splitAiEventsConfig: SplitAiEventsStepConfig
+ topHog: TopHogWrapper
+}
+
+/**
+ * Abstract factory for the AI event sub-pipeline. The analytics lane composes the AI branch through
+ * this contract instead of importing the `ai` lane directly; the concrete `createAiEventSubpipeline`
+ * (ai lane) is injected at the composition root (servers). This keeps ai and analytics decoupled.
+ */
+export type AiEventSubpipelineFactory = <TInput extends AiEventSubpipelineInput, TContext>(
+ builder: StartPipelineBuilder<TInput, TContext>,
+ config: AiEventSubpipelineConfig
+) => PipelineBuilder<TInput, EmitEventStepOutput, TContext, AsyncOutput>
diff --git a/nodejs/src/ingestion/common/config.ts b/nodejs/src/ingestion/common/config.ts
index 51a743e965cf..0ea24d36072e 100644
--- a/nodejs/src/ingestion/common/config.ts
+++ b/nodejs/src/ingestion/common/config.ts
@@ -1,4 +1,4 @@
-import type { AllowedConfigKey } from '../outputs/kafka-producer-config'
+import type { AllowedConfigKey } from '~/common/outputs/kafka-producer-config'
// =============================================================================
// Cluster-accurate producer slots: INGESTION_UPSTREAM / INGESTION_DOWNSTREAM
diff --git a/nodejs/src/ingestion/cookieless/cookieless-manager.test.ts b/nodejs/src/ingestion/common/cookieless/cookieless-manager.test.ts
similarity index 99%
rename from nodejs/src/ingestion/cookieless/cookieless-manager.test.ts
rename to nodejs/src/ingestion/common/cookieless/cookieless-manager.test.ts
index 7042cf878c44..99874cbef464 100644
--- a/nodejs/src/ingestion/cookieless/cookieless-manager.test.ts
+++ b/nodejs/src/ingestion/common/cookieless/cookieless-manager.test.ts
@@ -2,18 +2,18 @@ import fs from 'fs'
import { Message } from 'node-rdkafka'
import path from 'path'
+import { cookielessRedisErrorCounter } from '~/common/metrics'
+import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'
import type { PluginEvent } from '~/plugin-scaffold'
import { createTestEventHeaders } from '~/tests/helpers/event-headers'
import { createOrganization, createTeam, getTeam } from '~/tests/helpers/sql'
+import { CookielessServerHashMode, EventHeaders, Hub, PipelineEvent, Team } from '~/types'
+import { RedisOperationError } from '~/utils/db/error'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresUse } from '~/utils/db/postgres'
+import { parseJSON } from '~/utils/json-parse'
+import { UUID7 } from '~/utils/utils'
-import { cookielessRedisErrorCounter } from '../../common/metrics'
-import { CookielessServerHashMode, EventHeaders, Hub, PipelineEvent, Team } from '../../types'
-import { RedisOperationError } from '../../utils/db/error'
-import { closeHub, createHub } from '../../utils/db/hub'
-import { PostgresUse } from '../../utils/db/postgres'
-import { parseJSON } from '../../utils/json-parse'
-import { UUID7 } from '../../utils/utils'
-import { PipelineResultType, isOkResult } from '../pipelines/results'
import {
COOKIELESS_MODE_FLAG_PROPERTY,
COOKIELESS_SENTINEL_VALUE,
@@ -1044,7 +1044,7 @@ describe('CookielessManager', () => {
// Don't import, as importing from outside our package directory will change the shape of the build directory
// instead, just find the file path and load it directly
- const TEST_CASES_PATH = path.resolve(__dirname, '../../../../rust/common/cookieless/src/test_cases.json')
+ const TEST_CASES_PATH = path.resolve(__dirname, '../../../../../rust/common/cookieless/src/test_cases.json')
const TEST_CASES: Record<string, any[]> = parseJSON(fs.readFileSync(TEST_CASES_PATH, 'utf8'))
describe('doHash', () => {
diff --git a/nodejs/src/ingestion/cookieless/cookieless-manager.ts b/nodejs/src/ingestion/common/cookieless/cookieless-manager.ts
similarity index 98%
rename from nodejs/src/ingestion/cookieless/cookieless-manager.ts
rename to nodejs/src/ingestion/common/cookieless/cookieless-manager.ts
index bcd87d55f081..331f3e6fb9e2 100644
--- a/nodejs/src/ingestion/cookieless/cookieless-manager.ts
+++ b/nodejs/src/ingestion/common/cookieless/cookieless-manager.ts
@@ -10,25 +10,18 @@ import { getDomain } from 'tldts'
import * as siphashDouble from '@posthog/siphash/lib/siphash-double'
+import { cookielessRedisErrorCounter } from '~/common/metrics'
import { instrumentFn } from '~/common/tracing/tracing-utils'
+import { toStartOfDayInTimezone, toYearMonthDayInTimezone } from '~/ingestion/common/timestamps'
+import { IngestionConsumerConfig } from '~/ingestion/config'
+import { PipelineResult, dlq, drop, isOkResult, ok } from '~/ingestion/framework/results'
import { PluginEvent, Properties } from '~/plugin-scaffold'
+import { CookielessServerHashMode, EventHeaders, IncomingEventWithTeam, PipelineEvent, RedisPool, Team } from '~/types'
+import { ConcurrencyController } from '~/utils/concurrencyController'
+import { RedisOperationError } from '~/utils/db/error'
+import { logger } from '~/utils/logger'
+import { UUID7, bufferToUint32ArrayLE, uint32ArrayLEToBuffer } from '~/utils/utils'
-import { cookielessRedisErrorCounter } from '../../common/metrics'
-import {
- CookielessServerHashMode,
- EventHeaders,
- IncomingEventWithTeam,
- PipelineEvent,
- RedisPool,
- Team,
-} from '../../types'
-import { ConcurrencyController } from '../../utils/concurrencyController'
-import { RedisOperationError } from '../../utils/db/error'
-import { logger } from '../../utils/logger'
-import { UUID7, bufferToUint32ArrayLE, uint32ArrayLEToBuffer } from '../../utils/utils'
-import { toStartOfDayInTimezone, toYearMonthDayInTimezone } from '../../worker/ingestion/timestamps'
-import { IngestionConsumerConfig } from '../config'
-import { PipelineResult, dlq, drop, isOkResult, ok } from '../pipelines/results'
import { RedisHelpers } from './redis-helpers'
/* ---------------------------------------------------------------------
diff --git a/nodejs/src/ingestion/cookieless/redis-helpers.ts b/nodejs/src/ingestion/common/cookieless/redis-helpers.ts
similarity index 97%
rename from nodejs/src/ingestion/cookieless/redis-helpers.ts
rename to nodejs/src/ingestion/common/cookieless/redis-helpers.ts
index 475007c9a595..ac12b24c4e69 100644
--- a/nodejs/src/ingestion/cookieless/redis-helpers.ts
+++ b/nodejs/src/ingestion/common/cookieless/redis-helpers.ts
@@ -3,11 +3,10 @@ import Redis from 'ioredis'
import { withSpan } from '~/common/tracing/tracing-utils'
import { CacheOptions } from '~/plugin-scaffold'
-
-import { RedisOperationError } from '../../utils/db/error'
-import { timeoutGuard } from '../../utils/db/utils'
-import { parseJSON } from '../../utils/json-parse'
-import { tryTwice } from '../../utils/utils'
+import { RedisOperationError } from '~/utils/db/error'
+import { timeoutGuard } from '~/utils/db/utils'
+import { parseJSON } from '~/utils/json-parse'
+import { tryTwice } from '~/utils/utils'
/** The recommended way of accessing the database. */
export class RedisHelpers {
diff --git a/nodejs/src/worker/ingestion/create-event.test.ts b/nodejs/src/ingestion/common/create-event.test.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/create-event.test.ts
rename to nodejs/src/ingestion/common/create-event.test.ts
index 44b1a2e16383..1afbf99ecc83 100644
--- a/nodejs/src/worker/ingestion/create-event.test.ts
+++ b/nodejs/src/ingestion/common/create-event.test.ts
@@ -1,7 +1,7 @@
import { DateTime } from 'luxon'
-import { ISOTimestamp, Person, PreIngestionEvent, ProjectId } from '../../types'
-import { createEvent, getElementsChain } from './create-event'
+import { createEvent, getElementsChain } from '~/ingestion/common/create-event'
+import { ISOTimestamp, Person, PreIngestionEvent, ProjectId } from '~/types'
describe('createEvent', () => {
const mockPreparedEvent: PreIngestionEvent = {
diff --git a/nodejs/src/worker/ingestion/create-event.ts b/nodejs/src/ingestion/common/create-event.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/create-event.ts
rename to nodejs/src/ingestion/common/create-event.ts
index eded792adb9b..4c16afb731f4 100644
--- a/nodejs/src/worker/ingestion/create-event.ts
+++ b/nodejs/src/ingestion/common/create-event.ts
@@ -1,13 +1,12 @@
import { Counter } from 'prom-client'
+import { MAX_GROUP_TYPES_PER_TEAM } from '~/common/groups/group-type-manager'
+import { uuidFromDistinctId } from '~/ingestion/common/person-uuid'
import { Properties } from '~/plugin-scaffold'
-
-import { Element, Person, PersonMode, PreIngestionEvent, ProcessedEvent } from '../../types'
-import { elementsToString, extractElements } from '../../utils/elements-chain'
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { MAX_GROUP_TYPES_PER_TEAM } from './group-type-manager'
-import { uuidFromDistinctId } from './person-uuid'
+import { Element, Person, PersonMode, PreIngestionEvent, ProcessedEvent } from '~/types'
+import { elementsToString, extractElements } from '~/utils/elements-chain'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
const elementsOrElementsChainCounter = new Counter({
name: 'events_pipeline_elements_or_elements_chain_total',
diff --git a/nodejs/src/ingestion/common/event-filters/batch-app-metrics.test.ts b/nodejs/src/ingestion/common/event-filters/batch-app-metrics.test.ts
index 46a5110305c3..cb267e28d3b4 100644
--- a/nodejs/src/ingestion/common/event-filters/batch-app-metrics.test.ts
+++ b/nodejs/src/ingestion/common/event-filters/batch-app-metrics.test.ts
@@ -1,6 +1,7 @@
-import { parseJSON } from '../../../utils/json-parse'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { AppMetricsOutput } from '../outputs'
+import { AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { parseJSON } from '~/utils/json-parse'
+
import { EventFiltersBatchAppMetrics } from './batch-app-metrics'
describe('EventFiltersBatchAppMetrics', () => {
diff --git a/nodejs/src/ingestion/common/event-filters/batch-app-metrics.ts b/nodejs/src/ingestion/common/event-filters/batch-app-metrics.ts
index c45e0450ff43..80004e0e5d66 100644
--- a/nodejs/src/ingestion/common/event-filters/batch-app-metrics.ts
+++ b/nodejs/src/ingestion/common/event-filters/batch-app-metrics.ts
@@ -1,7 +1,7 @@
-import { TimestampFormat } from '../../../types'
-import { castTimestampOrNow } from '../../../utils/utils'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { APP_METRICS_OUTPUT, AppMetricsOutput } from '../outputs'
+import { APP_METRICS_OUTPUT, AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { TimestampFormat } from '~/types'
+import { castTimestampOrNow } from '~/utils/utils'
interface AggregatedMetric {
teamId: number
diff --git a/nodejs/src/ingestion/common/event-filters/manager.ts b/nodejs/src/ingestion/common/event-filters/manager.ts
index 54fb87708817..9522fd86c484 100644
--- a/nodejs/src/ingestion/common/event-filters/manager.ts
+++ b/nodejs/src/ingestion/common/event-filters/manager.ts
@@ -1,7 +1,8 @@
-import { BackgroundRefresher } from '../../../utils/background-refresher'
-import { PostgresRouter, PostgresUse } from '../../../utils/db/postgres'
-import { logger } from '../../../utils/logger'
-import { Component } from '../scopes'
+import { Component } from '~/ingestion/common/scopes'
+import { BackgroundRefresher } from '~/utils/background-refresher'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { logger } from '~/utils/logger'
+
import { treeHasConditions } from './evaluate'
import { EventFilterRowSchema, EventFilterRule } from './schema'
diff --git a/nodejs/src/worker/ingestion/event-pipeline/metrics.ts b/nodejs/src/ingestion/common/event-pipeline/metrics.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/event-pipeline/metrics.ts
rename to nodejs/src/ingestion/common/event-pipeline/metrics.ts
diff --git a/nodejs/src/worker/ingestion/event-pipeline/transformEventStep.ts b/nodejs/src/ingestion/common/event-pipeline/transformEventStep.ts
similarity index 56%
rename from nodejs/src/worker/ingestion/event-pipeline/transformEventStep.ts
rename to nodejs/src/ingestion/common/event-pipeline/transformEventStep.ts
index 4d95853d5a98..b01a65e0764b 100644
--- a/nodejs/src/worker/ingestion/event-pipeline/transformEventStep.ts
+++ b/nodejs/src/ingestion/common/event-pipeline/transformEventStep.ts
@@ -1,11 +1,10 @@
+import { HogTransformationResult, HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
import { PluginEvent } from '~/plugin-scaffold'
-import { HogTransformerService, TransformationResult } from '../../../cdp/hog-transformations/hog-transformer.service'
-
export async function transformEventStep(
event: PluginEvent,
- hogTransformer: HogTransformerService | null
-): Promise<TransformationResult> {
+ hogTransformer: HogTransformer | null
+): Promise<HogTransformationResult> {
if (!hogTransformer) {
return { event, invocationResults: [] }
}
diff --git a/nodejs/src/worker/ingestion/groups/batch-writing-group-store.test.ts b/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts
similarity index 97%
rename from nodejs/src/worker/ingestion/groups/batch-writing-group-store.test.ts
rename to nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts
index 5af7fdae9995..d791bf86c4c0 100644
--- a/nodejs/src/worker/ingestion/groups/batch-writing-group-store.test.ts
+++ b/nodejs/src/ingestion/common/groups/batch-writing-group-store.test.ts
@@ -1,23 +1,23 @@
// sort-imports-ignore
import { DateTime } from 'luxon'
-import { Group, ProjectId, TeamId } from '../../../types'
-import { MessageSizeTooLarge } from '../../../utils/db/error'
-import { RaceConditionError } from '../../../utils/utils'
+import { Group, ProjectId, TeamId } from '~/types'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+import { RaceConditionError } from '~/utils/utils'
import { BatchWritingGroupStore } from './batch-writing-group-store'
import { groupCacheOperationsCounter } from './metrics'
-import { ClickhouseGroupRepository } from './repositories/clickhouse-group-repository'
-import { GroupRepository } from './repositories/group-repository.interface'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
// Mock the module before importing
-jest.mock('../../../ingestion/common/ingestion-warnings', () => ({
+jest.mock('~/ingestion/common/ingestion-warnings', () => ({
emitIngestionWarning: jest.fn().mockResolvedValue(undefined),
}))
-import { GroupsOutput, IngestionWarningsOutput } from '../../../ingestion/common/outputs'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
+import { GroupsOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
// Mock the DB class
diff --git a/nodejs/src/worker/ingestion/groups/batch-writing-group-store.ts b/nodejs/src/ingestion/common/groups/batch-writing-group-store.ts
similarity index 96%
rename from nodejs/src/worker/ingestion/groups/batch-writing-group-store.ts
rename to nodejs/src/ingestion/common/groups/batch-writing-group-store.ts
index 15df0978709e..5c82e3bcf763 100644
--- a/nodejs/src/worker/ingestion/groups/batch-writing-group-store.ts
+++ b/nodejs/src/ingestion/common/groups/batch-writing-group-store.ts
@@ -1,18 +1,21 @@
import { DateTime } from 'luxon'
import pLimit from 'p-limit'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { GroupRepositoryTransaction } from '~/common/groups/repositories/group-repository-transaction.interface'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { GroupsOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { FlushResult } from '~/ingestion/common/persons/persons-store'
+import { BatchWritingStoreFlushStats } from '~/ingestion/common/stores/batch-writing-store'
import { Properties } from '~/plugin-scaffold'
+import { GroupTypeIndex, TeamId } from '~/types'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+import { logger } from '~/utils/logger'
+import { promiseRetry } from '~/utils/retries'
+import { RaceConditionError } from '~/utils/utils'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import { GroupsOutput, IngestionWarningsOutput } from '../../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
-import { GroupTypeIndex, TeamId } from '../../../types'
-import { MessageSizeTooLarge } from '../../../utils/db/error'
-import { logger } from '../../../utils/logger'
-import { promiseRetry } from '../../../utils/retries'
-import { RaceConditionError } from '../../../utils/utils'
-import { FlushResult } from '../persons/persons-store'
-import { BatchWritingStoreFlushStats } from '../stores/batch-writing-store'
import { logMissingRow, logVersionMismatch } from './group-logging'
import { CacheMetrics, GroupStore } from './group-store.interface'
import { GroupUpdate, calculateUpdate, fromGroup } from './group-update'
@@ -23,9 +26,6 @@ import {
groupFetchPromisesCacheOperationsCounter,
groupOptimisticUpdateConflictsPerBatchCounter,
} from './metrics'
-import { ClickhouseGroupRepository } from './repositories/clickhouse-group-repository'
-import { GroupRepositoryTransaction } from './repositories/group-repository-transaction.interface'
-import { GroupRepository } from './repositories/group-repository.interface'
class GroupCache {
private cache: Map<string, GroupUpdate | null>
diff --git a/nodejs/src/worker/ingestion/groups/group-logging.ts b/nodejs/src/ingestion/common/groups/group-logging.ts
similarity index 81%
rename from nodejs/src/worker/ingestion/groups/group-logging.ts
rename to nodejs/src/ingestion/common/groups/group-logging.ts
index ad7306dc95b9..e440984d602f 100644
--- a/nodejs/src/worker/ingestion/groups/group-logging.ts
+++ b/nodejs/src/ingestion/common/groups/group-logging.ts
@@ -1,6 +1,6 @@
-import { GroupTypeIndex, TeamId } from '../../../types'
-import { groupUpdateVersionMismatchCounter } from '../../../utils/db/metrics'
-import { logger } from '../../../utils/logger'
+import { GroupTypeIndex, TeamId } from '~/types'
+import { groupUpdateVersionMismatchCounter } from '~/utils/db/metrics'
+import { logger } from '~/utils/logger'
export function logVersionMismatch(
teamId: TeamId,
diff --git a/nodejs/src/worker/ingestion/groups/group-store-for-batch.ts b/nodejs/src/ingestion/common/groups/group-store-for-batch.ts
similarity index 91%
rename from nodejs/src/worker/ingestion/groups/group-store-for-batch.ts
rename to nodejs/src/ingestion/common/groups/group-store-for-batch.ts
index 65db678f89b3..7ff368fe30c7 100644
--- a/nodejs/src/worker/ingestion/groups/group-store-for-batch.ts
+++ b/nodejs/src/ingestion/common/groups/group-store-for-batch.ts
@@ -1,9 +1,9 @@
import { DateTime } from 'luxon'
+import { FlushResult } from '~/ingestion/common/persons/persons-store'
import { Properties } from '~/plugin-scaffold'
+import { GroupTypeIndex, ProjectId, TeamId } from '~/types'
-import { GroupTypeIndex, ProjectId, TeamId } from '../../../types'
-import { FlushResult } from '../persons/persons-store'
import { BatchWritingGroupStore } from './batch-writing-group-store'
import { CacheMetrics, GroupStore } from './group-store.interface'
diff --git a/nodejs/src/worker/ingestion/groups/group-store.interface.ts b/nodejs/src/ingestion/common/groups/group-store.interface.ts
similarity index 83%
rename from nodejs/src/worker/ingestion/groups/group-store.interface.ts
rename to nodejs/src/ingestion/common/groups/group-store.interface.ts
index 20ae6eb7da22..50b7991d0ddf 100644
--- a/nodejs/src/worker/ingestion/groups/group-store.interface.ts
+++ b/nodejs/src/ingestion/common/groups/group-store.interface.ts
@@ -1,9 +1,8 @@
import { DateTime } from 'luxon'
+import { BatchWritingStore } from '~/ingestion/common/stores/batch-writing-store'
import { Properties } from '~/plugin-scaffold'
-
-import { GroupTypeIndex, ProjectId, TeamId } from '../../../types'
-import { BatchWritingStore } from '../stores/batch-writing-store'
+import { GroupTypeIndex, ProjectId, TeamId } from '~/types'
export interface CacheMetrics {
cacheHits: number
diff --git a/nodejs/src/worker/ingestion/groups/group-update.ts b/nodejs/src/ingestion/common/groups/group-update.ts
similarity index 96%
rename from nodejs/src/worker/ingestion/groups/group-update.ts
rename to nodejs/src/ingestion/common/groups/group-update.ts
index fb80bd57c679..a62e8ace24c8 100644
--- a/nodejs/src/worker/ingestion/groups/group-update.ts
+++ b/nodejs/src/ingestion/common/groups/group-update.ts
@@ -1,8 +1,7 @@
import { DateTime } from 'luxon'
import { Properties } from '~/plugin-scaffold'
-
-import { Group, GroupTypeIndex, TeamId } from '../../../types'
+import { Group, GroupTypeIndex, TeamId } from '~/types'
export interface GroupUpdate {
team_id: TeamId
diff --git a/nodejs/src/worker/ingestion/groups/metrics.ts b/nodejs/src/ingestion/common/groups/metrics.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/groups/metrics.ts
rename to nodejs/src/ingestion/common/groups/metrics.ts
diff --git a/nodejs/src/ingestion/common/ingestion-consumer.ts b/nodejs/src/ingestion/common/ingestion-consumer.ts
index b3962c2ab065..3037518eb7e8 100644
--- a/nodejs/src/ingestion/common/ingestion-consumer.ts
+++ b/nodejs/src/ingestion/common/ingestion-consumer.ts
@@ -2,13 +2,13 @@ import { Message } from 'node-rdkafka'
import { Gauge } from 'prom-client'
import { instrumentFn } from '~/common/tracing/tracing-utils'
+import { IngestionConsumerConfig } from '~/ingestion/config'
+import { BatchResult, FeedResult } from '~/ingestion/framework/batching-pipeline'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { OkResultWithContext } from '~/ingestion/framework/pipeline.interface'
+import { HealthCheckResult, PluginServerService } from '~/types'
+import { logger } from '~/utils/logger'
-import { HealthCheckResult, PluginServerService } from '../../types'
-import { logger } from '../../utils/logger'
-import { IngestionConsumerConfig } from '../config'
-import { BatchResult, FeedResult } from '../pipelines/batching-pipeline'
-import { createOkContext } from '../pipelines/helpers'
-import { OkResultWithContext } from '../pipelines/pipeline.interface'
import { Scope, extend } from './scopes'
import { KafkaConsumerComponent, KafkaConsumerInterface } from './utils/kafka-consumer'
import { PromiseScheduler } from './utils/promise-scheduler'
diff --git a/nodejs/src/ingestion/common/ingestion-warnings.ts b/nodejs/src/ingestion/common/ingestion-warnings.ts
index 9140c83c5cf6..8efd254ae199 100644
--- a/nodejs/src/ingestion/common/ingestion-warnings.ts
+++ b/nodejs/src/ingestion/common/ingestion-warnings.ts
@@ -1,13 +1,13 @@
import { Counter } from 'prom-client'
-import { KAFKA_INGESTION_WARNINGS } from '../../config/kafka-topics'
-import { KafkaProducerWrapper } from '../../kafka/producer'
-import { TeamId, TimestampFormat } from '../../types'
-import { logger } from '../../utils/logger'
-import { IngestionWarningLimiter } from '../../utils/token-bucket'
-import { castTimestampOrNow } from '../../utils/utils'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput } from './outputs'
+import { INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { KAFKA_INGESTION_WARNINGS } from '~/config/kafka-topics'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { TeamId, TimestampFormat } from '~/types'
+import { logger } from '~/utils/logger'
+import { IngestionWarningLimiter } from '~/utils/token-bucket'
+import { castTimestampOrNow } from '~/utils/utils'
export const ingestionWarningCounter = new Counter({
name: 'ingestion_warnings_total',
diff --git a/nodejs/src/worker/ingestion/person-uuid.ts b/nodejs/src/ingestion/common/person-uuid.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/person-uuid.ts
rename to nodejs/src/ingestion/common/person-uuid.ts
diff --git a/nodejs/src/worker/ingestion/persons/PERSON_BATCH_WRITING_FLAGS.md b/nodejs/src/ingestion/common/persons/PERSON_BATCH_WRITING_FLAGS.md
similarity index 100%
rename from nodejs/src/worker/ingestion/persons/PERSON_BATCH_WRITING_FLAGS.md
rename to nodejs/src/ingestion/common/persons/PERSON_BATCH_WRITING_FLAGS.md
diff --git a/nodejs/src/worker/ingestion/persons/batch-writing-person-store.test.ts b/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/persons/batch-writing-person-store.test.ts
rename to nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts
index 2a2ec6850c14..ecdafcf285f3 100644
--- a/nodejs/src/worker/ingestion/persons/batch-writing-person-store.test.ts
+++ b/nodejs/src/ingestion/common/persons/batch-writing-person-store.test.ts
@@ -1,29 +1,29 @@
import { DateTime } from 'luxon'
-import { PERSONS_OUTPUT, PersonDistinctIdsOutput, PersonsOutput } from '~/ingestion/analytics/outputs'
-import { INGESTION_WARNINGS_OUTPUT } from '~/ingestion/common/outputs'
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { PERSONS_OUTPUT, PersonDistinctIdsOutput, PersonsOutput } from '~/common/outputs'
+import {
+ personProfileBatchIgnoredPropertiesCounter,
+ personProfileBatchUpdateOutcomeCounter,
+ personPropertyKeyUpdateCounter,
+} from '~/common/persons/metrics'
+import { fromInternalPerson } from '~/common/persons/person-update-batch'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
import { InternalPerson, TeamId } from '~/types'
import { DependencyUnavailableError, MessageSizeTooLarge } from '~/utils/db/error'
import { PostgresRouter } from '~/utils/db/postgres'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
import { BatchWritingPersonsStore } from './batch-writing-person-store'
-import {
- personProfileBatchIgnoredPropertiesCounter,
- personProfileBatchUpdateOutcomeCounter,
- personPropertyKeyUpdateCounter,
-} from './metrics'
-import { fromInternalPerson } from './person-update-batch'
import { BatchBoundPersonsStore } from './persons-store-for-batch'
// Mock the ingestion warnings module
-jest.mock('../../../ingestion/common/ingestion-warnings', () => ({
+jest.mock('~/ingestion/common/ingestion-warnings', () => ({
emitIngestionWarning: jest.fn().mockResolvedValue(undefined),
}))
// Mock metrics
-jest.mock('./metrics', () => ({
+jest.mock('~/common/persons/metrics', () => ({
observeLatencyByVersion: jest.fn(),
personCacheOperationsCounter: { inc: jest.fn() },
personCacheSizeHistogram: { observe: jest.fn() },
diff --git a/nodejs/src/worker/ingestion/persons/batch-writing-person-store.ts b/nodejs/src/ingestion/common/persons/batch-writing-person-store.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/persons/batch-writing-person-store.ts
rename to nodejs/src/ingestion/common/persons/batch-writing-person-store.ts
index a520ac086615..4b6269a283e1 100644
--- a/nodejs/src/worker/ingestion/persons/batch-writing-person-store.ts
+++ b/nodejs/src/ingestion/common/persons/batch-writing-person-store.ts
@@ -1,21 +1,6 @@
import { DateTime } from 'luxon'
import pLimit from 'p-limit'
-import { Properties } from '~/plugin-scaffold'
-import { NoRowsUpdatedError } from '~/utils/utils'
-
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import {
- InternalPerson,
- PersonBatchWritingDbWriteMode,
- PropertiesLastOperation,
- PropertiesLastUpdatedAt,
- Team,
-} from '../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../utils/db/db'
-import { MessageSizeTooLarge } from '../../../utils/db/error'
-import { logger } from '../../../utils/logger'
-import { BatchWritingStore, BatchWritingStoreFlushStats } from '../stores/batch-writing-store'
import {
observeLatencyByVersion,
personCacheOperationsCounter,
@@ -33,15 +18,34 @@ import {
personPropertyKeyUpdateCounter,
personWriteMethodAttemptCounter,
totalPersonUpdateLatencyPerBatchHistogram,
-} from './metrics'
+} from '~/common/persons/metrics'
+import { isFilteredPersonUpdateProperty } from '~/common/persons/person-property-utils'
+import { PersonUpdate, fromInternalPerson, toInternalPerson } from '~/common/persons/person-update-batch'
+import {
+ PersonMessage,
+ PersonPropertiesSizeViolationError,
+ PersonRepository,
+} from '~/common/persons/repositories/person-repository'
+import { PersonRepositoryTransaction } from '~/common/persons/repositories/person-repository-transaction'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { BatchWritingStore, BatchWritingStoreFlushStats } from '~/ingestion/common/stores/batch-writing-store'
+import { Properties } from '~/plugin-scaffold'
+import {
+ InternalPerson,
+ PersonBatchWritingDbWriteMode,
+ PropertiesLastOperation,
+ PropertiesLastUpdatedAt,
+ Team,
+} from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+import { logger } from '~/utils/logger'
+import { NoRowsUpdatedError } from '~/utils/utils'
+
import { PersonOutputs } from './person-context'
-import { isFilteredPersonUpdateProperty } from './person-property-utils'
import { getMetricKey } from './person-update'
-import { PersonUpdate, fromInternalPerson, toInternalPerson } from './person-update-batch'
import { FlushResult, PersonsStore } from './persons-store'
import { PersonsStoreTransaction } from './persons-store-transaction'
-import { PersonMessage, PersonPropertiesSizeViolationError, PersonRepository } from './repositories/person-repository'
-import { PersonRepositoryTransaction } from './repositories/person-repository-transaction'
type MethodName =
| 'fetchForChecking'
diff --git a/nodejs/src/worker/ingestion/persons/person-context.ts b/nodejs/src/ingestion/common/persons/person-context.ts
similarity index 82%
rename from nodejs/src/worker/ingestion/persons/person-context.ts
rename to nodejs/src/ingestion/common/persons/person-context.ts
index 4006bb5adfc5..e2eb6e5e2fb9 100644
--- a/nodejs/src/worker/ingestion/persons/person-context.ts
+++ b/nodejs/src/ingestion/common/persons/person-context.ts
@@ -1,13 +1,13 @@
import { DateTime } from 'luxon'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { PersonDistinctIdsOutput, PersonsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PersonMessage } from '~/common/persons/person-message'
import { PluginEvent, Properties } from '~/plugin-scaffold'
+import { Team } from '~/types'
-import { PersonDistinctIdsOutput, PersonsOutput } from '../../../ingestion/analytics/outputs'
-import { IngestionWarningsOutput } from '../../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
-import { Team } from '../../../types'
import { MergeMode } from './person-merge-types'
-import { PersonMessage } from './person-message'
import { PersonsStoreForBatch } from './persons-store-for-batch'
export type PersonOutputs = IngestionOutputs<PersonsOutput | PersonDistinctIdsOutput | IngestionWarningsOutput>
diff --git a/nodejs/src/worker/ingestion/persons/person-create-service.test.ts b/nodejs/src/ingestion/common/persons/person-create-service.test.ts
similarity index 96%
rename from nodejs/src/worker/ingestion/persons/person-create-service.test.ts
rename to nodejs/src/ingestion/common/persons/person-create-service.test.ts
index 9074918a37db..2fedb944b261 100644
--- a/nodejs/src/worker/ingestion/persons/person-create-service.test.ts
+++ b/nodejs/src/ingestion/common/persons/person-create-service.test.ts
@@ -1,13 +1,14 @@
import { DateTime } from 'luxon'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import { UUIDT } from '../../../utils/utils'
+import { PersonPropertiesSizeViolationError } from '~/common/persons/repositories/person-repository'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { UUIDT } from '~/utils/utils'
+
import { PersonContext } from './person-context'
import { PersonCreateService } from './person-create-service'
import { createDefaultSyncMergeMode } from './person-merge-types'
-import { PersonPropertiesSizeViolationError } from './repositories/person-repository'
-jest.mock('../../../ingestion/common/ingestion-warnings', () => ({
+jest.mock('~/ingestion/common/ingestion-warnings', () => ({
emitIngestionWarning: jest.fn().mockResolvedValue(undefined),
}))
diff --git a/nodejs/src/worker/ingestion/persons/person-create-service.ts b/nodejs/src/ingestion/common/persons/person-create-service.ts
similarity index 92%
rename from nodejs/src/worker/ingestion/persons/person-create-service.ts
rename to nodejs/src/ingestion/common/persons/person-create-service.ts
index e44681e3201d..57e27c035956 100644
--- a/nodejs/src/worker/ingestion/persons/person-create-service.ts
+++ b/nodejs/src/ingestion/common/persons/person-create-service.ts
@@ -1,13 +1,13 @@
import { DateTime } from 'luxon'
+import { PersonPropertiesSizeViolationError } from '~/common/persons/repositories/person-repository'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { uuidFromDistinctId } from '~/ingestion/common/person-uuid'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson, PropertyUpdateOperation } from '~/types'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import { InternalPerson, PropertyUpdateOperation } from '../../../types'
-import { uuidFromDistinctId } from '../person-uuid'
import { PersonContext } from './person-context'
import { PersonsStoreTransactionForBatch } from './persons-store-for-batch'
-import { PersonPropertiesSizeViolationError } from './repositories/person-repository'
export class PersonCreateService {
constructor(private context: PersonContext) {}
diff --git a/nodejs/src/worker/ingestion/persons/person-event-processor.ts b/nodejs/src/ingestion/common/persons/person-event-processor.ts
similarity index 95%
rename from nodejs/src/worker/ingestion/persons/person-event-processor.ts
rename to nodejs/src/ingestion/common/persons/person-event-processor.ts
index 1085576ab0e2..5ab2e66a4996 100644
--- a/nodejs/src/worker/ingestion/persons/person-event-processor.ts
+++ b/nodejs/src/ingestion/common/persons/person-event-processor.ts
@@ -1,9 +1,9 @@
+import { ASYNC_OUTPUT, AsyncOutput } from '~/common/outputs'
+import { PipelineResult, dlq, ok, redirect } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { InternalPerson, Person } from '~/types'
+import { logger } from '~/utils/logger'
-import { ASYNC_OUTPUT, AsyncOutput } from '../../../ingestion/analytics/outputs'
-import { PipelineResult, dlq, ok, redirect } from '../../../ingestion/pipelines/results'
-import { InternalPerson, Person } from '../../../types'
-import { logger } from '../../../utils/logger'
import { PersonContext } from './person-context'
import { PersonMergeService } from './person-merge-service'
import { PersonMergeLimitExceededError, PersonMergeRaceConditionError } from './person-merge-types'
diff --git a/nodejs/src/worker/ingestion/persons/person-merge-service.ts b/nodejs/src/ingestion/common/persons/person-merge-service.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/persons/person-merge-service.ts
rename to nodejs/src/ingestion/common/persons/person-merge-service.ts
index 4b9808e82b4a..95d6f7c9be2c 100644
--- a/nodejs/src/worker/ingestion/persons/person-merge-service.ts
+++ b/nodejs/src/ingestion/common/persons/person-merge-service.ts
@@ -1,15 +1,16 @@
import { DateTime } from 'luxon'
import { Counter } from 'prom-client'
+import { personMergeFailureCounter } from '~/common/persons/metrics'
+import { PersonMessage } from '~/common/persons/person-message'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson } from '~/types'
+import { timeoutGuard } from '~/utils/db/utils'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { promiseRetry } from '~/utils/retries'
-import { emitIngestionWarning } from '../../../ingestion/common/ingestion-warnings'
-import { InternalPerson } from '../../../types'
-import { timeoutGuard } from '../../../utils/db/utils'
-import { logger } from '../../../utils/logger'
-import { captureException } from '../../../utils/posthog'
-import { promiseRetry } from '../../../utils/retries'
-import { personMergeFailureCounter } from './metrics'
import { PersonContext } from './person-context'
import { PersonCreateService } from './person-create-service'
import {
@@ -22,7 +23,6 @@ import {
mergeError,
mergeSuccess,
} from './person-merge-types'
-import { PersonMessage } from './person-message'
import { applyEventPropertyUpdates, computeEventPropertyUpdates } from './person-update'
import { PersonsStoreTransactionForBatch } from './persons-store-for-batch'
diff --git a/nodejs/src/worker/ingestion/persons/person-merge-types.ts b/nodejs/src/ingestion/common/persons/person-merge-types.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/persons/person-merge-types.ts
rename to nodejs/src/ingestion/common/persons/person-merge-types.ts
index 06df82a0b65f..69d25e270956 100644
--- a/nodejs/src/worker/ingestion/persons/person-merge-types.ts
+++ b/nodejs/src/ingestion/common/persons/person-merge-types.ts
@@ -1,4 +1,4 @@
-import { InternalPerson } from '../../../types'
+import { InternalPerson } from '~/types'
/**
* Base class for all person merge errors
diff --git a/nodejs/src/worker/ingestion/persons/person-property-service.ts b/nodejs/src/ingestion/common/persons/person-property-service.ts
similarity index 95%
rename from nodejs/src/worker/ingestion/persons/person-property-service.ts
rename to nodejs/src/ingestion/common/persons/person-property-service.ts
index 6060d569d057..b20c9521789f 100644
--- a/nodejs/src/worker/ingestion/persons/person-property-service.ts
+++ b/nodejs/src/ingestion/common/persons/person-property-service.ts
@@ -1,9 +1,10 @@
-import { InternalPerson } from '../../../types'
-import { defaultRetryConfig, promiseRetry } from '../../../utils/retries'
+import { PersonPropertiesSizeViolationError } from '~/common/persons/repositories/person-repository'
+import { InternalPerson } from '~/types'
+import { defaultRetryConfig, promiseRetry } from '~/utils/retries'
+
import { PersonContext } from './person-context'
import { PersonCreateService } from './person-create-service'
import { applyEventPropertyUpdates, computeEventPropertyUpdates } from './person-update'
-import { PersonPropertiesSizeViolationError } from './repositories/person-repository'
/**
* Service responsible for handling person property updates and person creation.
diff --git a/nodejs/src/worker/ingestion/persons/person-update.test.ts b/nodejs/src/ingestion/common/persons/person-update.test.ts
similarity index 99%
rename from nodejs/src/worker/ingestion/persons/person-update.test.ts
rename to nodejs/src/ingestion/common/persons/person-update.test.ts
index be1ff05926de..32d4914981b2 100644
--- a/nodejs/src/worker/ingestion/persons/person-update.test.ts
+++ b/nodejs/src/ingestion/common/persons/person-update.test.ts
@@ -1,10 +1,10 @@
+import { personProfileIgnoredPropertiesCounter, personProfileUpdateOutcomeCounter } from '~/common/persons/metrics'
+import { FILTERED_PERSON_UPDATE_PROPERTIES } from '~/common/persons/person-property-utils'
import { PluginEvent } from '~/plugin-scaffold'
-import { personProfileIgnoredPropertiesCounter, personProfileUpdateOutcomeCounter } from './metrics'
-import { FILTERED_PERSON_UPDATE_PROPERTIES } from './person-property-utils'
import { applyEventPropertyUpdates, computeEventPropertyUpdates } from './person-update'
-jest.mock('./metrics', () => ({
+jest.mock('~/common/persons/metrics', () => ({
personProfileUpdateOutcomeCounter: {
labels: jest.fn().mockReturnValue({
inc: jest.fn(),
diff --git a/nodejs/src/worker/ingestion/persons/person-update.ts b/nodejs/src/ingestion/common/persons/person-update.ts
similarity index 97%
rename from nodejs/src/worker/ingestion/persons/person-update.ts
rename to nodejs/src/ingestion/common/persons/person-update.ts
index 584da7d65dec..749a64f27811 100644
--- a/nodejs/src/worker/ingestion/persons/person-update.ts
+++ b/nodejs/src/ingestion/common/persons/person-update.ts
@@ -1,14 +1,13 @@
-import { PluginEvent, Properties } from '~/plugin-scaffold'
-import { cloneObject } from '~/utils/utils'
-
-import { InternalPerson } from '../../../types'
-import { logger } from '../../../utils/logger'
-import { personProfileIgnoredPropertiesCounter, personProfileUpdateOutcomeCounter } from './metrics'
+import { personProfileIgnoredPropertiesCounter, personProfileUpdateOutcomeCounter } from '~/common/persons/metrics'
import {
eventToPersonProperties,
initialEventToPersonProperties,
isFilteredPersonUpdateProperty,
-} from './person-property-utils'
+} from '~/common/persons/person-property-utils'
+import { PluginEvent, Properties } from '~/plugin-scaffold'
+import { InternalPerson } from '~/types'
+import { logger } from '~/utils/logger'
+import { cloneObject } from '~/utils/utils'
export interface PropertyUpdates {
toSet: Properties
diff --git a/nodejs/src/worker/ingestion/persons/personless-distinct-id-cache.ts b/nodejs/src/ingestion/common/persons/personless-distinct-id-cache.ts
similarity index 95%
rename from nodejs/src/worker/ingestion/persons/personless-distinct-id-cache.ts
rename to nodejs/src/ingestion/common/persons/personless-distinct-id-cache.ts
index 0c65cd10394f..8c349fbf8773 100644
--- a/nodejs/src/worker/ingestion/persons/personless-distinct-id-cache.ts
+++ b/nodejs/src/ingestion/common/persons/personless-distinct-id-cache.ts
@@ -1,7 +1,7 @@
import { LRUCache } from 'lru-cache'
import { Counter } from 'prom-client'
-import { ONE_HOUR } from '../../../config/constants'
+import { ONE_HOUR } from '~/config/constants'
export const personlessDistinctIdCacheOperationsCounter = new Counter({
name: 'personless_distinct_id_cache_operations_total',
diff --git a/nodejs/src/worker/ingestion/persons/persons-store-for-batch.ts b/nodejs/src/ingestion/common/persons/persons-store-for-batch.ts
similarity index 98%
rename from nodejs/src/worker/ingestion/persons/persons-store-for-batch.ts
rename to nodejs/src/ingestion/common/persons/persons-store-for-batch.ts
index c9d76947424c..3592d39abc05 100644
--- a/nodejs/src/worker/ingestion/persons/persons-store-for-batch.ts
+++ b/nodejs/src/ingestion/common/persons/persons-store-for-batch.ts
@@ -1,13 +1,13 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
+import { PersonRepositoryTransaction } from '~/common/persons/repositories/person-repository-transaction'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
-import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../utils/db/db'
-import { PersonMessage } from './person-message'
import { FlushResult, PersonsStore } from './persons-store'
import { PersonsStoreTransaction } from './persons-store-transaction'
-import { PersonRepositoryTransaction } from './repositories/person-repository-transaction'
export interface PersonsStoreTransactionForBatch {
createPerson(
diff --git a/nodejs/src/worker/ingestion/persons/persons-store-transaction.ts b/nodejs/src/ingestion/common/persons/persons-store-transaction.ts
similarity index 93%
rename from nodejs/src/worker/ingestion/persons/persons-store-transaction.ts
rename to nodejs/src/ingestion/common/persons/persons-store-transaction.ts
index 4dee1d39da00..2428192c3bc0 100644
--- a/nodejs/src/worker/ingestion/persons/persons-store-transaction.ts
+++ b/nodejs/src/ingestion/common/persons/persons-store-transaction.ts
@@ -1,12 +1,12 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
+import { PersonRepositoryTransaction } from '~/common/persons/repositories/person-repository-transaction'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
-import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../utils/db/db'
-import { PersonMessage } from './person-message'
import { PersonsStore } from './persons-store'
-import { PersonRepositoryTransaction } from './repositories/person-repository-transaction'
/**
* PersonsStoreTransaction that delegates to a store with a transaction.
diff --git a/nodejs/src/worker/ingestion/persons/persons-store.ts b/nodejs/src/ingestion/common/persons/persons-store.ts
similarity index 94%
rename from nodejs/src/worker/ingestion/persons/persons-store.ts
rename to nodejs/src/ingestion/common/persons/persons-store.ts
index 1464d7af54a0..6cb6344cd8c8 100644
--- a/nodejs/src/worker/ingestion/persons/persons-store.ts
+++ b/nodejs/src/ingestion/common/persons/persons-store.ts
@@ -1,13 +1,13 @@
import { DateTime } from 'luxon'
+import { PersonMessage } from '~/common/persons/person-message'
+import { PersonRepositoryTransaction } from '~/common/persons/repositories/person-repository-transaction'
+import { BatchWritingStore } from '~/ingestion/common/stores/batch-writing-store'
import { Properties } from '~/plugin-scaffold'
+import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { CreatePersonResult, MoveDistinctIdsResult } from '~/utils/db/db'
-import { InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '../../../types'
-import { CreatePersonResult, MoveDistinctIdsResult } from '../../../utils/db/db'
-import { BatchWritingStore } from '../stores/batch-writing-store'
-import { PersonMessage } from './person-message'
import { PersonsStoreTransaction } from './persons-store-transaction'
-import { PersonRepositoryTransaction } from './repositories/person-repository-transaction'
export type FlushResult = {
messages: PersonMessage[]
diff --git a/nodejs/src/worker/ingestion/pipeline-helpers.test.ts b/nodejs/src/ingestion/common/pipeline-helpers.test.ts
similarity index 95%
rename from nodejs/src/worker/ingestion/pipeline-helpers.test.ts
rename to nodejs/src/ingestion/common/pipeline-helpers.test.ts
index 591513ef6b64..245b8dc662bb 100644
--- a/nodejs/src/worker/ingestion/pipeline-helpers.test.ts
+++ b/nodejs/src/ingestion/common/pipeline-helpers.test.ts
@@ -1,20 +1,20 @@
import { Message } from 'node-rdkafka'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { emitIngestionWarning } from '../../ingestion/common/ingestion-warnings'
-import { DLQ_OUTPUT } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { logDroppedMessage, produceMessageToDLQ, redirectMessageToOutput } from './pipeline-helpers'
+import { DLQ_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { logDroppedMessage, produceMessageToDLQ, redirectMessageToOutput } from '~/ingestion/common/pipeline-helpers'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
// Mock all dependencies
-jest.mock('../../utils/logger')
-jest.mock('../../utils/posthog')
+jest.mock('~/utils/logger')
+jest.mock('~/utils/posthog')
-jest.mock('../../ingestion/common/ingestion-warnings', () => {
- const actual = jest.requireActual('../../ingestion/common/ingestion-warnings')
+jest.mock('~/ingestion/common/ingestion-warnings', () => {
+ const actual = jest.requireActual('~/ingestion/common/ingestion-warnings')
return {
...actual,
emitIngestionWarning: jest.fn(),
diff --git a/nodejs/src/worker/ingestion/pipeline-helpers.ts b/nodejs/src/ingestion/common/pipeline-helpers.ts
similarity index 94%
rename from nodejs/src/worker/ingestion/pipeline-helpers.ts
rename to nodejs/src/ingestion/common/pipeline-helpers.ts
index 8535ee67f363..cc3e1e514058 100644
--- a/nodejs/src/worker/ingestion/pipeline-helpers.ts
+++ b/nodejs/src/ingestion/common/pipeline-helpers.ts
@@ -1,11 +1,11 @@
import { Message } from 'node-rdkafka'
-import { emitIngestionWarning } from '../../ingestion/common/ingestion-warnings'
-import { DLQ_OUTPUT, DlqOutput, IngestionWarningsOutput } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
+import { DLQ_OUTPUT, DlqOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
/**
* Helper function to copy and extend headers from a Kafka message
diff --git a/nodejs/src/ingestion/common/scopes/runner.ts b/nodejs/src/ingestion/common/scopes/runner.ts
index 19bbdb8ff57b..2deb1a4ee169 100644
--- a/nodejs/src/ingestion/common/scopes/runner.ts
+++ b/nodejs/src/ingestion/common/scopes/runner.ts
@@ -1,4 +1,5 @@
-import { logger } from '../../../utils/logger'
+import { logger } from '~/utils/logger'
+
import { Component, ComponentMap, Started } from './component'
import type { Startable } from './scope'
diff --git a/nodejs/src/ingestion/common/scopes/scope.ts b/nodejs/src/ingestion/common/scopes/scope.ts
index 813876006e97..41213615fb2f 100644
--- a/nodejs/src/ingestion/common/scopes/scope.ts
+++ b/nodejs/src/ingestion/common/scopes/scope.ts
@@ -1,4 +1,5 @@
-import { logger } from '../../../utils/logger'
+import { logger } from '~/utils/logger'
+
import { CallerSet } from './caller-set'
import { Component } from './component'
import { ScopeRunner } from './runner'
diff --git a/nodejs/src/ingestion/common/steps/allow-events.test.ts b/nodejs/src/ingestion/common/steps/allow-events.test.ts
index 7a9d58dfd8c6..34013c1b7dcc 100644
--- a/nodejs/src/ingestion/common/steps/allow-events.test.ts
+++ b/nodejs/src/ingestion/common/steps/allow-events.test.ts
@@ -1,5 +1,6 @@
-import { createTestEventHeaders } from '../../../../tests/helpers/event-headers'
-import { dlq, ok } from '../../pipelines/results'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+
import { createAllowEventsStep } from './allow-events'
function makeInput(eventName: string | undefined) {
diff --git a/nodejs/src/ingestion/common/steps/allow-events.ts b/nodejs/src/ingestion/common/steps/allow-events.ts
index 02b787dd9329..094446af59b0 100644
--- a/nodejs/src/ingestion/common/steps/allow-events.ts
+++ b/nodejs/src/ingestion/common/steps/allow-events.ts
@@ -1,6 +1,6 @@
-import { EventHeaders } from '../../../types'
-import { dlq, ok } from '../../pipelines/results'
-import { ProcessingStep } from '../../pipelines/steps'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders } from '~/types'
/**
* DLQs any event whose header `event` name is not in the allow list.
diff --git a/nodejs/src/ingestion/common/steps/deny-events.test.ts b/nodejs/src/ingestion/common/steps/deny-events.test.ts
index 86e76506d3ef..9e26d47de975 100644
--- a/nodejs/src/ingestion/common/steps/deny-events.test.ts
+++ b/nodejs/src/ingestion/common/steps/deny-events.test.ts
@@ -1,5 +1,6 @@
-import { createTestEventHeaders } from '../../../../tests/helpers/event-headers'
-import { dlq, ok } from '../../pipelines/results'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+
import { createDenyEventsStep } from './deny-events'
function makeInput(eventName: string | undefined) {
diff --git a/nodejs/src/ingestion/common/steps/deny-events.ts b/nodejs/src/ingestion/common/steps/deny-events.ts
index ff9565e43054..dfd280f0d65f 100644
--- a/nodejs/src/ingestion/common/steps/deny-events.ts
+++ b/nodejs/src/ingestion/common/steps/deny-events.ts
@@ -1,6 +1,6 @@
-import { EventHeaders } from '../../../types'
-import { dlq, ok } from '../../pipelines/results'
-import { ProcessingStep } from '../../pipelines/steps'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders } from '~/types'
/**
* DLQs any event whose header `event` name is in the deny list. Reads
diff --git a/nodejs/src/ingestion/common/steps/event-filters-steps.test.ts b/nodejs/src/ingestion/common/steps/event-filters-steps.test.ts
index 753b902ed526..99f7088b915d 100644
--- a/nodejs/src/ingestion/common/steps/event-filters-steps.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-filters-steps.test.ts
@@ -1,13 +1,14 @@
-import { createTestEventHeaders } from '../../../../tests/helpers/event-headers'
-import { getMetricValues, resetMetrics } from '../../../../tests/helpers/metrics'
-import { createTestTeam } from '../../../../tests/helpers/team'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { isDropResult, isOkResult, ok } from '../../pipelines/results'
-import { EventFilterManager } from '../event-filters'
-import { EventFiltersBatchAppMetrics } from '../event-filters/batch-app-metrics'
-import { FilterNode } from '../event-filters/schema'
-import { and, cond, not, or } from '../event-filters/test-helpers'
-import { AppMetricsOutput } from '../outputs'
+import { AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { EventFiltersBatchAppMetrics } from '~/ingestion/common/event-filters/batch-app-metrics'
+import { FilterNode } from '~/ingestion/common/event-filters/schema'
+import { and, cond, not, or } from '~/ingestion/common/event-filters/test-helpers'
+import { isDropResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { getMetricValues, resetMetrics } from '~/tests/helpers/metrics'
+import { createTestTeam } from '~/tests/helpers/team'
+
import {
createApplyEventFiltersStep,
createEventFiltersBatchAppMetricsBeforeBatchStep,
diff --git a/nodejs/src/ingestion/common/steps/event-filters-steps.ts b/nodejs/src/ingestion/common/steps/event-filters-steps.ts
index e0b1b17d9e6e..25e5b9ed78f0 100644
--- a/nodejs/src/ingestion/common/steps/event-filters-steps.ts
+++ b/nodejs/src/ingestion/common/steps/event-filters-steps.ts
@@ -1,12 +1,12 @@
-import { EventHeaders, Team } from '../../../types'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { BeforeBatchStep } from '../../pipelines/batching-pipeline'
-import { PipelineResult, drop, ok } from '../../pipelines/results'
-import { ProcessingStep } from '../../pipelines/steps'
-import { EventFilterManager, evaluateFilterTree } from '../event-filters'
-import { EventFiltersBatchAppMetrics } from '../event-filters/batch-app-metrics'
-import { eventFiltersEventsEvaluated } from '../event-filters/metrics'
-import { AppMetricsOutput } from '../outputs'
+import { AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { EventFilterManager, evaluateFilterTree } from '~/ingestion/common/event-filters'
+import { EventFiltersBatchAppMetrics } from '~/ingestion/common/event-filters/batch-app-metrics'
+import { eventFiltersEventsEvaluated } from '~/ingestion/common/event-filters/metrics'
+import { BeforeBatchStep } from '~/ingestion/framework/batching-pipeline'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, Team } from '~/types'
export interface EventFiltersBatchContext {
eventFiltersBatchAppMetrics: EventFiltersBatchAppMetrics
diff --git a/nodejs/src/ingestion/event-preprocessing/apply-cookieless-processing.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-cookieless-processing.ts
similarity index 82%
rename from nodejs/src/ingestion/event-preprocessing/apply-cookieless-processing.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/apply-cookieless-processing.ts
index 49b9fd242a4b..58593038bd9b 100644
--- a/nodejs/src/ingestion/event-preprocessing/apply-cookieless-processing.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-cookieless-processing.ts
@@ -1,10 +1,9 @@
import { Message } from 'node-rdkafka'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { PipelineResult, isOkResult, ok } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
-
-import { EventHeaders, Team } from '../../types'
-import { CookielessManager } from '../cookieless/cookieless-manager'
-import { PipelineResult, isOkResult, ok } from '../pipelines/results'
+import { EventHeaders, Team } from '~/types'
type ApplyCookielessProcessingInput = { event: PluginEvent; team: Team; message: Message; headers: EventHeaders }
diff --git a/nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.test.ts
similarity index 98%
rename from nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.test.ts
index 54b2d2393b6c..7a21e6741dea 100644
--- a/nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.test.ts
@@ -1,8 +1,9 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { EventHeaders } from '../../types'
-import { EventIngestionRestrictionManager, Restriction } from '../../utils/event-ingestion-restrictions'
-import { OVERFLOW_OUTPUT } from '../common/outputs'
-import { dlq, drop, ok, redirect } from '../pipelines/results'
+import { OVERFLOW_OUTPUT } from '~/common/outputs'
+import { dlq, drop, ok, redirect } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { EventHeaders } from '~/types'
+import { EventIngestionRestrictionManager, Restriction } from '~/utils/event-ingestion-restrictions'
+
import {
RoutingConfig,
createApplyBasicEventRestrictionsStep,
diff --git a/nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.ts
similarity index 90%
rename from nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.ts
index 0dbaf3d9cf6f..7d29e09da090 100644
--- a/nodejs/src/ingestion/event-preprocessing/apply-event-restrictions.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-event-restrictions.ts
@@ -1,10 +1,10 @@
import { Counter } from 'prom-client'
-import { EventHeaders } from '../../types'
-import { EventIngestionRestrictionManager, RestrictionType } from '../../utils/event-ingestion-restrictions'
-import { OVERFLOW_OUTPUT, OverflowOutput } from '../common/outputs'
-import { dlq, drop, ok, redirect } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { OVERFLOW_OUTPUT, OverflowOutput } from '~/common/outputs'
+import { dlq, drop, ok, redirect } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders } from '~/types'
+import { EventIngestionRestrictionManager, RestrictionType } from '~/utils/event-ingestion-restrictions'
export const ingestionOverflowingMessagesTotal = new Counter({
name: 'ingestion_overflowing_messages_total',
diff --git a/nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.test.ts
similarity index 97%
rename from nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.test.ts
index 25c721223c6d..61cd5eea03ee 100644
--- a/nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.test.ts
@@ -1,8 +1,9 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { EventIngestionRestrictionManager, Restriction } from '../../utils/event-ingestion-restrictions'
-import { ok } from '../pipelines/results'
+import { ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+import { createTestTeam } from '~/tests/helpers/team'
+import { EventIngestionRestrictionManager, Restriction } from '~/utils/event-ingestion-restrictions'
+
import { createApplyPersonProcessingRestrictionsStep } from './apply-person-processing-restrictions'
describe('createApplyPersonProcessingRestrictionsStep', () => {
diff --git a/nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.ts
similarity index 86%
rename from nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.ts
index e06c08d38de9..b75cfc0e6401 100644
--- a/nodejs/src/ingestion/event-preprocessing/apply-person-processing-restrictions.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/apply-person-processing-restrictions.ts
@@ -1,7 +1,7 @@
-import { EventHeaders, PipelineEvent, Team } from '../../types'
-import { EventIngestionRestrictionManager, RestrictionType } from '../../utils/event-ingestion-restrictions'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, PipelineEvent, Team } from '~/types'
+import { EventIngestionRestrictionManager, RestrictionType } from '~/utils/event-ingestion-restrictions'
function applyPersonProcessingRestrictions(
event: PipelineEvent,
diff --git a/nodejs/src/ingestion/event-preprocessing/clickhouse-datetime-parser.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/clickhouse-datetime-parser.test.ts
similarity index 100%
rename from nodejs/src/ingestion/event-preprocessing/clickhouse-datetime-parser.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/clickhouse-datetime-parser.test.ts
diff --git a/nodejs/src/ingestion/event-preprocessing/clickhouse-datetime-parser.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/clickhouse-datetime-parser.ts
similarity index 100%
rename from nodejs/src/ingestion/event-preprocessing/clickhouse-datetime-parser.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/clickhouse-datetime-parser.ts
diff --git a/nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.test.ts
similarity index 94%
rename from nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.test.ts
index 4318760b8363..e3d0ddfb5712 100644
--- a/nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.test.ts
@@ -1,5 +1,6 @@
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+
import {
SURVEY_EVENTS,
SURVEY_PERSON_PROPERTIES,
diff --git a/nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.ts
similarity index 85%
rename from nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.ts
index aa3ef4f76276..0347419e0fdc 100644
--- a/nodejs/src/ingestion/event-preprocessing/enrich-survey-person-properties.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/enrich-survey-person-properties.ts
@@ -1,6 +1,6 @@
-import { PipelineEvent } from '../../types'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PipelineEvent } from '~/types'
export const SURVEY_EVENTS = {
SHOWN: 'survey shown',
diff --git a/nodejs/src/ingestion/event-preprocessing/index.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/index.ts
similarity index 100%
rename from nodejs/src/ingestion/event-preprocessing/index.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/index.ts
diff --git a/nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts
similarity index 87%
rename from nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts
index 277697e9e329..60e77b3a81c7 100644
--- a/nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.test.ts
@@ -1,7 +1,8 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { PipelineResultType } from '../pipelines/results'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+
import { createOverflowLaneTTLRefreshStep } from './overflow-lane-ttl-refresh-step'
import { RateLimitToOverflowStepInput } from './rate-limit-to-overflow-step'
diff --git a/nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.ts
similarity index 89%
rename from nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.ts
index d7d309949f6b..9bad39934177 100644
--- a/nodejs/src/ingestion/event-preprocessing/overflow-lane-ttl-refresh-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/overflow-lane-ttl-refresh-step.ts
@@ -1,6 +1,9 @@
-import { EventHeaders, PipelineEvent } from '../../types'
-import { PipelineResult, ok } from '../pipelines/results'
-import { OverflowEventBatch, OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import {
+ OverflowEventBatch,
+ OverflowRedirectService,
+} from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { EventHeaders, PipelineEvent } from '~/types'
export interface OverflowLaneTTLRefreshStepInput {
headers: EventHeaders
diff --git a/nodejs/src/ingestion/event-preprocessing/parse-headers.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.test.ts
similarity index 99%
rename from nodejs/src/ingestion/event-preprocessing/parse-headers.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.test.ts
index 27299bf8490d..0bca48eae41c 100644
--- a/nodejs/src/ingestion/event-preprocessing/parse-headers.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.test.ts
@@ -1,6 +1,7 @@
import { Message } from 'node-rdkafka'
-import { ok } from '../pipelines/results'
+import { ok } from '~/ingestion/framework/results'
+
import { createParseHeadersStep } from './parse-headers'
describe('createParseHeadersStep', () => {
diff --git a/nodejs/src/ingestion/event-preprocessing/parse-headers.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.ts
similarity index 67%
rename from nodejs/src/ingestion/event-preprocessing/parse-headers.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.ts
index f555dc922f6b..1969e16e2ee3 100644
--- a/nodejs/src/ingestion/event-preprocessing/parse-headers.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-headers.ts
@@ -1,9 +1,9 @@
import { Message } from 'node-rdkafka'
-import { parseEventHeaders } from '../../kafka/consumer'
-import { EventHeaders } from '../../types'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { parseEventHeaders } from '~/kafka/consumer'
+import { EventHeaders } from '~/types'
export function createParseHeadersStep<T extends { message: Pick<Message, 'headers'> }>(): ProcessingStep<
T,
diff --git a/nodejs/src/ingestion/event-preprocessing/parse-kafka-message.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.test.ts
similarity index 99%
rename from nodejs/src/ingestion/event-preprocessing/parse-kafka-message.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.test.ts
index d786e86abe62..b961a1e3955a 100644
--- a/nodejs/src/ingestion/event-preprocessing/parse-kafka-message.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.test.ts
@@ -1,11 +1,12 @@
import { Message } from 'node-rdkafka'
-import { logger } from '../../utils/logger'
-import { PipelineResultType, dlq, ok } from '../pipelines/results'
+import { PipelineResultType, dlq, ok } from '~/ingestion/framework/results'
+import { logger } from '~/utils/logger'
+
import { createParseKafkaMessageStep } from './parse-kafka-message'
// Mock dependencies
-jest.mock('../../../src/utils/logger')
+jest.mock('~/utils/logger')
const VALID_UUID = '123e4567-e89b-12d3-a456-426614174000'
diff --git a/nodejs/src/ingestion/event-preprocessing/parse-kafka-message.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.ts
similarity index 93%
rename from nodejs/src/ingestion/event-preprocessing/parse-kafka-message.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.ts
index 21b7d2662532..3bb43a33c403 100644
--- a/nodejs/src/ingestion/event-preprocessing/parse-kafka-message.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/parse-kafka-message.ts
@@ -1,13 +1,12 @@
import { Message } from 'node-rdkafka'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { IncomingEvent, PipelineEvent } from '~/types'
import { sanitizeEvent } from '~/utils/event'
-
-import { IncomingEvent, PipelineEvent } from '../../types'
-import { parseJSON } from '../../utils/json-parse'
-import { logger } from '../../utils/logger'
-import { UUID } from '../../utils/utils'
-import { dlq, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { parseJSON } from '~/utils/json-parse'
+import { logger } from '~/utils/logger'
+import { UUID } from '~/utils/utils'
export function createParseKafkaMessageStep<T extends { message: Message }>(): ProcessingStep<
T,
diff --git a/nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.test.ts
similarity index 97%
rename from nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.test.ts
index 894f8ab2e71c..81835d87ed92 100644
--- a/nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.test.ts
@@ -1,9 +1,10 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { OVERFLOW_OUTPUT } from '../common/outputs'
-import { COOKIELESS_SENTINEL_VALUE } from '../cookieless/cookieless-manager'
-import { PipelineResultType } from '../pipelines/results'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+import { OVERFLOW_OUTPUT } from '~/common/outputs'
+import { COOKIELESS_SENTINEL_VALUE } from '~/ingestion/common/cookieless/cookieless-manager'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+
import {
OnlyCookielessRateLimitToOverflowStepInput,
RateLimitToOverflowStepInput,
diff --git a/nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.ts
similarity index 92%
rename from nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.ts
index 9782fca7c9c1..9fa90c7df6ce 100644
--- a/nodejs/src/ingestion/event-preprocessing/rate-limit-to-overflow-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/rate-limit-to-overflow-step.ts
@@ -1,8 +1,11 @@
-import { EventHeaders, PipelineEvent } from '../../types'
-import { OVERFLOW_OUTPUT, OverflowOutput } from '../common/outputs'
-import { COOKIELESS_SENTINEL_VALUE } from '../cookieless/cookieless-manager'
-import { PipelineResult, ok, redirect } from '../pipelines/results'
-import { OverflowEventBatch, OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+import { OVERFLOW_OUTPUT, OverflowOutput } from '~/common/outputs'
+import { COOKIELESS_SENTINEL_VALUE } from '~/ingestion/common/cookieless/cookieless-manager'
+import { PipelineResult, ok, redirect } from '~/ingestion/framework/results'
+import {
+ OverflowEventBatch,
+ OverflowRedirectService,
+} from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { EventHeaders, PipelineEvent } from '~/types'
// `headers.distinct_id` is set by capture from Kafka headers and is never mutated by the
// pipeline. For cookieless events it stays equal to COOKIELESS_SENTINEL_VALUE even after the
diff --git a/nodejs/src/ingestion/event-preprocessing/resolve-team.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.test.ts
similarity index 92%
rename from nodejs/src/ingestion/event-preprocessing/resolve-team.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.test.ts
index 58d97555d528..1df53e921f85 100644
--- a/nodejs/src/ingestion/event-preprocessing/resolve-team.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.test.ts
@@ -1,12 +1,12 @@
+import { drop, ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { getMetricValues, resetMetrics } from '~/tests/helpers/metrics'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+import { createTestTeam } from '~/tests/helpers/team'
+import { IncomingEvent } from '~/types'
import { TeamManager } from '~/utils/team-manager'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestMessage } from '../../../tests/helpers/kafka-message'
-import { getMetricValues, resetMetrics } from '../../../tests/helpers/metrics'
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { IncomingEvent } from '../../types'
-import { drop, ok } from '../pipelines/results'
import { createResolveTeamStep } from './resolve-team'
const pipelineEvent = createTestPipelineEvent({
diff --git a/nodejs/src/ingestion/event-preprocessing/resolve-team.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.ts
similarity index 86%
rename from nodejs/src/ingestion/event-preprocessing/resolve-team.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.ts
index c43120f41038..adf502a7afd4 100644
--- a/nodejs/src/ingestion/event-preprocessing/resolve-team.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/resolve-team.ts
@@ -1,14 +1,13 @@
import { Message } from 'node-rdkafka'
+import { eventDroppedCounter } from '~/common/metrics'
+import { tokenOrTeamPresentCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders, IncomingEvent, Team } from '~/types'
import { TeamManager } from '~/utils/team-manager'
-import { eventDroppedCounter } from '../../common/metrics'
-import { EventHeaders, IncomingEvent, Team } from '../../types'
-import { tokenOrTeamPresentCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import { drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
-
export interface ResolveTeamStepInput {
message: Message
headers: EventHeaders
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.test.ts
similarity index 97%
rename from nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.test.ts
index d22d416f29c0..8fe89f6191ab 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.test.ts
@@ -1,5 +1,6 @@
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { PipelineResultType, ok } from '../pipelines/results'
+import { PipelineResultType, ok } from '~/ingestion/framework/results'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+
import { createValidateAiEventTokensStep } from './validate-ai-event-tokens'
const VALID_TOKEN_VALUES: [unknown, string][] = [
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.ts
similarity index 90%
rename from nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.ts
index 92385b7fe79e..297bd6cdc144 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-ai-event-tokens.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-ai-event-tokens.ts
@@ -1,8 +1,8 @@
-import { PipelineEvent } from '../../types'
-import { AI_EVENT_TYPES } from '../ai'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PipelineEvent } from '~/types'
const TOKEN_PROPERTIES = [
'$ai_input_tokens',
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-metadata.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.test.ts
similarity index 95%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-metadata.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.test.ts
index 60810639be54..b1660ec5f7a9 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-metadata.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.test.ts
@@ -1,6 +1,7 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { EventHeaders } from '../../types'
-import { drop, ok } from '../pipelines/results'
+import { drop, ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { EventHeaders } from '~/types'
+
import { createValidateEventMetadataStep } from './validate-event-metadata'
describe('createValidateEventMetadataStep', () => {
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-metadata.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.ts
similarity index 85%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-metadata.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.ts
index c97693c73329..ae5de1467f78 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-metadata.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-metadata.ts
@@ -1,7 +1,7 @@
-import { EventHeaders } from '../../types'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders } from '~/types'
const MAX_DISTINCT_ID_LENGTH = 400
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-properties.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.test.ts
similarity index 96%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-properties.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.test.ts
index 3007b2e3da4e..01231e5cf30c 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-properties.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.test.ts
@@ -1,5 +1,6 @@
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { drop, ok } from '../pipelines/results'
+import { drop, ok } from '~/ingestion/framework/results'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+
import { createValidateEventPropertiesStep } from './validate-event-properties'
// Mock the dependencies
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-properties.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.ts
similarity index 88%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-properties.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.ts
index 268a13596b07..43a4b46ede38 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-properties.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-properties.ts
@@ -1,6 +1,6 @@
-import { PipelineEvent } from '../../types'
-import { drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PipelineEvent } from '~/types'
export function createValidateEventPropertiesStep<T extends { event: PipelineEvent }>(): ProcessingStep<T, T> {
return async function validateEventPropertiesStep(input) {
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-schema.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.test.ts
similarity index 98%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-schema.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.test.ts
index 3fa69cbdf09b..e1319b3173d3 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-schema.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.test.ts
@@ -1,6 +1,7 @@
-import { EventSchemaEnforcement, Team } from '../../types'
-import { EventSchemaEnforcementManager } from '../../utils/event-schema-enforcement-manager'
-import { PipelineResultType, drop, ok } from '../pipelines/results'
+import { PipelineResultType, drop, ok } from '~/ingestion/framework/results'
+import { EventSchemaEnforcement, Team } from '~/types'
+import { EventSchemaEnforcementManager } from '~/utils/event-schema-enforcement-manager'
+
import { createValidateEventSchemaStep, validateEventAgainstSchema } from './validate-event-schema'
/** Creates a mock EventSchemaEnforcementManager that returns the provided schemas for any team */
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-event-schema.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.ts
similarity index 94%
rename from nodejs/src/ingestion/event-preprocessing/validate-event-schema.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.ts
index fd356bb07f29..5932e868034b 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-event-schema.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-event-schema.ts
@@ -1,7 +1,8 @@
-import { EventSchemaEnforcement, PipelineEvent, Team } from '../../types'
-import { EventSchemaEnforcementManager } from '../../utils/event-schema-enforcement-manager'
-import { drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventSchemaEnforcement, PipelineEvent, Team } from '~/types'
+import { EventSchemaEnforcementManager } from '~/utils/event-schema-enforcement-manager'
+
import { isValidClickHouseDateTime } from './clickhouse-datetime-parser'
/**
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-historical-migration.test.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.test.ts
similarity index 97%
rename from nodejs/src/ingestion/event-preprocessing/validate-historical-migration.test.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.test.ts
index a20356101db7..238355854a87 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-historical-migration.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.test.ts
@@ -1,6 +1,7 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { EventHeaders } from '../../types'
-import { ok } from '../pipelines/results'
+import { ok } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { EventHeaders } from '~/types'
+
import { createValidateHistoricalMigrationStep } from './validate-historical-migration'
const HOUR_MS = 60 * 60 * 1000
diff --git a/nodejs/src/ingestion/event-preprocessing/validate-historical-migration.ts b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.ts
similarity index 91%
rename from nodejs/src/ingestion/event-preprocessing/validate-historical-migration.ts
rename to nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.ts
index 5855a808022f..ed6c7816ee7b 100644
--- a/nodejs/src/ingestion/event-preprocessing/validate-historical-migration.ts
+++ b/nodejs/src/ingestion/common/steps/event-preprocessing/validate-historical-migration.ts
@@ -1,6 +1,6 @@
-import { EventHeaders } from '../../types'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders } from '~/types'
const HISTORICAL_MIGRATION_MIN_AGE_MS = 48 * 60 * 60 * 1000 // 48 hours in milliseconds
diff --git a/nodejs/src/ingestion/event-processing/create-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/create-event-step.test.ts
similarity index 98%
rename from nodejs/src/ingestion/event-processing/create-event-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/create-event-step.test.ts
index ea511d564559..5aa473fef084 100644
--- a/nodejs/src/ingestion/event-processing/create-event-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/create-event-step.test.ts
@@ -1,12 +1,13 @@
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestMessage } from '../../../tests/helpers/kafka-message'
-import { Person, PersonMode, PreIngestionEvent, ProjectId, TimestampFormat } from '../../types'
-import { castTimestampOrNow } from '../../utils/utils'
-import { EVENTS_OUTPUT } from '../analytics/outputs'
-import { isOkResult } from '../pipelines/results'
+import { EVENTS_OUTPUT } from '~/common/outputs'
+import { isOkResult } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { Person, PersonMode, PreIngestionEvent, ProjectId, TimestampFormat } from '~/types'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { CreateEventStepInput, createCreateEventStep } from './create-event-step'
describe('create-event-step', () => {
diff --git a/nodejs/src/ingestion/event-processing/create-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/create-event-step.ts
similarity index 83%
rename from nodejs/src/ingestion/event-processing/create-event-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/create-event-step.ts
index 3f474395353f..bfed75613c9d 100644
--- a/nodejs/src/ingestion/event-processing/create-event-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/create-event-step.ts
@@ -1,9 +1,10 @@
import { Message } from 'node-rdkafka'
-import { EventHeaders, Person, PreIngestionEvent } from '../../types'
-import { createEvent } from '../../worker/ingestion/create-event'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { createEvent } from '~/ingestion/common/create-event'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, Person, PreIngestionEvent } from '~/types'
+
import { EventToEmit } from './emit-event-step'
export interface CreateEventStepInput {
diff --git a/nodejs/src/ingestion/event-processing/drop-old-events-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.test.ts
similarity index 95%
rename from nodejs/src/ingestion/event-processing/drop-old-events-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.test.ts
index 01c64027ab34..dbd4e2b44dde 100644
--- a/nodejs/src/ingestion/event-processing/drop-old-events-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.test.ts
@@ -1,10 +1,11 @@
import { DateTime } from 'luxon'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestPipelineEvent } from '../../../tests/helpers/pipeline-event'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { EventHeaders, PipelineEvent, Team } from '../../types'
-import { PipelineResultType, isDropResult } from '../pipelines/results'
+import { PipelineResultType, isDropResult } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestPipelineEvent } from '~/tests/helpers/pipeline-event'
+import { createTestTeam } from '~/tests/helpers/team'
+import { EventHeaders, PipelineEvent, Team } from '~/types'
+
import { DropOldEventsInput, createDropOldEventsStep } from './drop-old-events-step'
describe('createDropOldEventsStep', () => {
diff --git a/nodejs/src/ingestion/event-processing/drop-old-events-step.ts b/nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.ts
similarity index 91%
rename from nodejs/src/ingestion/event-processing/drop-old-events-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.ts
index 278695b4e4ff..9606513c6b1c 100644
--- a/nodejs/src/ingestion/event-processing/drop-old-events-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/drop-old-events-step.ts
@@ -1,9 +1,9 @@
import { DateTime } from 'luxon'
-import { EventHeaders, PipelineEvent, Team } from '../../types'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { PipelineResult, drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, PipelineEvent, Team } from '~/types'
export interface DropOldEventsInput {
event: PipelineEvent
diff --git a/nodejs/src/ingestion/event-processing/emit-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts
similarity index 93%
rename from nodejs/src/ingestion/event-processing/emit-event-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts
index 04bc2415e0ff..5eee0c02e4f3 100644
--- a/nodejs/src/ingestion/event-processing/emit-event-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.test.ts
@@ -1,17 +1,18 @@
import { DateTime } from 'luxon'
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 { EventHeaders, ISOTimestamp, ProcessedEvent, ProjectId } from '../../types'
-import { MessageSizeTooLarge } from '../../utils/db/error'
-import { eventProcessedAndIngestedCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import { EVENTS_OUTPUT, EventOutput } from '../analytics/outputs'
-import { emitIngestionWarning } from '../common/ingestion-warnings'
-import { IngestionWarningsOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { isOkResult } from '../pipelines/results'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { EVENTS_OUTPUT, EventOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { eventProcessedAndIngestedCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { isOkResult } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { EventHeaders, ISOTimestamp, ProcessedEvent, ProjectId } from '~/types'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+
import {
EmitEventStepConfig,
EmitEventStepInput,
@@ -20,12 +21,12 @@ import {
serializeEvent,
} from './emit-event-step'
-jest.mock('../common/ingestion-warnings', () => ({
+jest.mock('~/ingestion/common/ingestion-warnings', () => ({
emitIngestionWarning: jest.fn().mockResolvedValue(undefined),
}))
// Mock the metrics module
-jest.mock('../../worker/ingestion/event-pipeline/metrics', () => ({
+jest.mock('~/ingestion/common/event-pipeline/metrics', () => ({
eventProcessedAndIngestedCounter: {
inc: jest.fn(),
},
diff --git a/nodejs/src/ingestion/event-processing/emit-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts
similarity index 90%
rename from nodejs/src/ingestion/event-processing/emit-event-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts
index 11cfc455af2d..b1000e35e4f7 100644
--- a/nodejs/src/ingestion/event-processing/emit-event-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/emit-event-step.ts
@@ -1,16 +1,16 @@
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
-import { EventHeaders, ProcessedEvent, RawKafkaEvent, TimestampFormat } from '../../types'
-import { MessageSizeTooLarge } from '../../utils/db/error'
-import { safeClickhouseString } from '../../utils/db/utils'
-import { castTimestampOrNow, castTimestampToClickhouseFormat } from '../../utils/utils'
-import { eventProcessedAndIngestedCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import { emitIngestionWarning } from '../common/ingestion-warnings'
-import { IngestionWarningsOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { eventProcessedAndIngestedCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, ProcessedEvent, RawKafkaEvent, TimestampFormat } from '~/types'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+import { safeClickhouseString } from '~/utils/db/utils'
+import { castTimestampOrNow, castTimestampToClickhouseFormat } from '~/utils/utils'
export interface EventToEmit<O extends string> {
event: ProcessedEvent
diff --git a/nodejs/src/ingestion/event-processing/event-pipeline-options.ts b/nodejs/src/ingestion/common/steps/event-processing/event-pipeline-options.ts
similarity index 100%
rename from nodejs/src/ingestion/event-processing/event-pipeline-options.ts
rename to nodejs/src/ingestion/common/steps/event-processing/event-pipeline-options.ts
diff --git a/nodejs/src/ingestion/event-processing/flush-batch-stores-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts
similarity index 94%
rename from nodejs/src/ingestion/event-processing/flush-batch-stores-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts
index 34bdcda082f9..5308be206cb5 100644
--- a/nodejs/src/ingestion/event-processing/flush-batch-stores-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.test.ts
@@ -1,8 +1,9 @@
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { MessageSizeTooLarge } from '../../utils/db/error'
-import { BatchWritingGroupStore } from '../../worker/ingestion/groups/batch-writing-group-store'
-import { PersonOutputs } from '../../worker/ingestion/persons/person-context'
-import { FlushResult, PersonsStore } from '../../worker/ingestion/persons/persons-store'
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { FlushResult, PersonsStore } from '~/ingestion/common/persons/persons-store'
import {
batchStoreFlushCacheEntriesHistogram,
batchStoreFlushDirtyEntriesHistogram,
@@ -12,19 +13,19 @@ import {
batchStoreFlushReferencedBatchesHistogram,
batchStoreFlushResultRecordsHistogram,
batchStoreFlushTriggerBatchSizeHistogram,
-} from '../../worker/ingestion/stores/metrics'
-import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../analytics/outputs'
-import { emitIngestionWarning } from '../common/ingestion-warnings'
-import { INGESTION_WARNINGS_OUTPUT } from '../common/outputs'
-import { AfterBatchInput } from '../pipelines/batching-pipeline'
-import { isOkResult, ok } from '../pipelines/results'
+} from '~/ingestion/common/stores/metrics'
+import { AfterBatchInput } from '~/ingestion/framework/batching-pipeline'
+import { isOkResult, ok } from '~/ingestion/framework/results'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+
import { FlushBatchStoresStepConfig, createFlushBatchStoresStep } from './flush-batch-stores-step'
-jest.mock('../common/ingestion-warnings', () => ({
+jest.mock('~/ingestion/common/ingestion-warnings', () => ({
emitIngestionWarning: jest.fn(),
}))
-jest.mock('../../worker/ingestion/stores/metrics', () => ({
+jest.mock('~/ingestion/common/stores/metrics', () => ({
batchStoreFlushCacheEntriesHistogram: { observe: jest.fn() },
batchStoreFlushDirtyEntriesHistogram: { observe: jest.fn() },
batchStoreFlushKafkaMessagesHistogram: { observe: jest.fn() },
diff --git a/nodejs/src/ingestion/event-processing/flush-batch-stores-step.ts b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts
similarity index 91%
rename from nodejs/src/ingestion/event-processing/flush-batch-stores-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts
index 79af1cb21f34..21cf3b062a64 100644
--- a/nodejs/src/ingestion/event-processing/flush-batch-stores-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/flush-batch-stores-step.ts
@@ -1,9 +1,8 @@
-import { MessageSizeTooLarge } from '../../utils/db/error'
-import { logger } from '../../utils/logger'
-import { BatchWritingGroupStore } from '../../worker/ingestion/groups/batch-writing-group-store'
-import { PersonOutputs } from '../../worker/ingestion/persons/person-context'
-import { FlushResult, PersonsStore } from '../../worker/ingestion/persons/persons-store'
-import { BatchWritingStore } from '../../worker/ingestion/stores/batch-writing-store'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { FlushResult, PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { BatchWritingStore } from '~/ingestion/common/stores/batch-writing-store'
import {
batchStoreFlushCacheEntriesHistogram,
batchStoreFlushDirtyEntriesHistogram,
@@ -13,10 +12,11 @@ import {
batchStoreFlushReferencedBatchesHistogram,
batchStoreFlushResultRecordsHistogram,
batchStoreFlushTriggerBatchSizeHistogram,
-} from '../../worker/ingestion/stores/metrics'
-import { emitIngestionWarning } from '../common/ingestion-warnings'
-import { AfterBatchStep } from '../pipelines/batching-pipeline'
-import { ok } from '../pipelines/results'
+} from '~/ingestion/common/stores/metrics'
+import { AfterBatchStep } from '~/ingestion/framework/batching-pipeline'
+import { ok } from '~/ingestion/framework/results'
+import { MessageSizeTooLarge } from '~/utils/db/error'
+import { logger } from '~/utils/logger'
export interface FlushBatchStoresStepConfig {
personsStore: PersonsStore
diff --git a/nodejs/src/ingestion/event-processing/groups.test.ts b/nodejs/src/ingestion/common/steps/event-processing/groups.test.ts
similarity index 98%
rename from nodejs/src/ingestion/event-processing/groups.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/groups.test.ts
index 140e17eb3f67..fb52461c59a3 100644
--- a/nodejs/src/ingestion/event-processing/groups.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/groups.test.ts
@@ -1,6 +1,7 @@
import { DateTime } from 'luxon'
-import { GroupTypeToColumnIndex, ProjectId } from '../../types'
+import { GroupTypeToColumnIndex, ProjectId } from '~/types'
+
import { addGroupProperties, enrichPropertiesWithGroupTypes } from './groups'
describe('enrichPropertiesWithGroupTypes', () => {
diff --git a/nodejs/src/ingestion/event-processing/groups.ts b/nodejs/src/ingestion/common/steps/event-processing/groups.ts
similarity index 90%
rename from nodejs/src/ingestion/event-processing/groups.ts
rename to nodejs/src/ingestion/common/steps/event-processing/groups.ts
index ddc0ece038f4..93ddffd1e612 100644
--- a/nodejs/src/ingestion/event-processing/groups.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/groups.ts
@@ -1,9 +1,8 @@
import { DateTime } from 'luxon'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
import { Properties } from '~/plugin-scaffold'
-
-import { GroupTypeToColumnIndex, ProjectId, TeamId } from '../../types'
-import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'
+import { GroupTypeToColumnIndex, ProjectId, TeamId } from '~/types'
export function enrichPropertiesWithGroupTypes(
properties: Properties,
diff --git a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.test.ts
similarity index 91%
rename from nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.test.ts
index 5d515e7add9a..6436b634f62e 100644
--- a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.test.ts
@@ -1,13 +1,14 @@
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 { INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PipelineResultType } from '~/ingestion/framework/results'
+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 {
HandleClientIngestionWarningStepInput,
createHandleClientIngestionWarningStep,
diff --git a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts
similarity index 83%
rename from nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts
index 9e67557eefe5..429adb03ff4b 100644
--- a/nodejs/src/ingestion/event-processing/handle-client-ingestion-warning-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step.ts
@@ -1,13 +1,13 @@
import { Message } from 'node-rdkafka'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+import { PipelineResult, dlq, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders } from '~/types'
-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 {
diff --git a/nodejs/src/ingestion/event-processing/hog-transform-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts
similarity index 94%
rename from nodejs/src/ingestion/event-processing/hog-transform-event-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts
index 57f36cff4bde..01fd89c8017e 100644
--- a/nodejs/src/ingestion/event-processing/hog-transform-event-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.test.ts
@@ -1,9 +1,9 @@
+import { HogTransformerService, TransformationResult } from '~/cdp/hog-transformations/hog-transformer.service'
+import { PipelineResultType, isDropResult, isOkResult } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
+import { createTestTeam } from '~/tests/helpers/team'
-import { createTestPluginEvent } from '../../../tests/helpers/plugin-event'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { HogTransformerService, TransformationResult } from '../../cdp/hog-transformations/hog-transformer.service'
-import { PipelineResultType, isDropResult, isOkResult } from '../pipelines/results'
import { HogTransformEventInput, createHogTransformEventStep } from './hog-transform-event-step'
type MockHogTransformer = Pick<HogTransformerService, 'transformEventAndProduceMessages'>
diff --git a/nodejs/src/ingestion/event-processing/hog-transform-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts
similarity index 80%
rename from nodejs/src/ingestion/event-processing/hog-transform-event-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts
index 82849cbc0612..579170831c9c 100644
--- a/nodejs/src/ingestion/event-processing/hog-transform-event-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/hog-transform-event-step.ts
@@ -1,9 +1,8 @@
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
-
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { Team } from '../../types'
-import { drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { Team } from '~/types'
export interface HogTransformEventInput {
event: PluginEvent
@@ -23,7 +22,7 @@ export interface HogTransformEventOutput {
* If a transformation drops the event (returns null), this step returns a `drop` result.
*/
export function createHogTransformEventStep<T extends HogTransformEventInput>(
- hogTransformer: Pick<HogTransformerService, 'transformEventAndProduceMessages'> | null
+ hogTransformer: Pick<HogTransformer, 'transformEventAndProduceMessages'> | null
): ProcessingStep<T, T & HogTransformEventOutput> {
return async function hogTransformEventStep(input) {
const { event } = input
diff --git a/nodejs/src/ingestion/event-processing/normalize-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.test.ts
similarity index 98%
rename from nodejs/src/ingestion/event-processing/normalize-event-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.test.ts
index 2fe9a9c4510f..a67e2edabe0b 100644
--- a/nodejs/src/ingestion/event-processing/normalize-event-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.test.ts
@@ -1,11 +1,11 @@
import { DateTime } from 'luxon'
+import { PipelineResultType } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestTeam } from '~/tests/helpers/team'
+import { UUIDT } from '~/utils/utils'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { UUIDT } from '../../utils/utils'
-import { PipelineResultType } from '../pipelines/results'
import { createNormalizeEventStep } from './normalize-event-step'
describe('normalizeEventStep wrapper', () => {
diff --git a/nodejs/src/ingestion/event-processing/normalize-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.ts
similarity index 76%
rename from nodejs/src/ingestion/event-processing/normalize-event-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.ts
index 46d43baeb7d6..4f059cb24af8 100644
--- a/nodejs/src/ingestion/event-processing/normalize-event-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/normalize-event-step.ts
@@ -1,12 +1,11 @@
import { DateTime } from 'luxon'
+import { parseEventTimestamp } from '~/ingestion/common/timestamps'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
-
-import { EventHeaders } from '../../types'
-import { normalizeEvent, normalizeProcessPerson } from '../../utils/event'
-import { parseEventTimestamp } from '../../worker/ingestion/timestamps'
-import { PipelineResult, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { EventHeaders } from '~/types'
+import { normalizeEvent, normalizeProcessPerson } from '~/utils/event'
type NormalizeEventInput = {
event: PluginEvent
diff --git a/nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.test.ts
similarity index 97%
rename from nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.test.ts
index 926e687759d8..e26c4e8e963a 100644
--- a/nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.test.ts
@@ -1,11 +1,11 @@
import { v4 } from 'uuid'
+import { PipelineResultType } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
import { EventHeaders } from '~/types'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestPluginEvent } from '../../../tests/helpers/plugin-event'
-import { PipelineResultType } from '../pipelines/results'
import { createNormalizeProcessPersonFlagStep } from './normalize-process-person-flag-step'
type StepInput = { event: PluginEvent; headers: EventHeaders }
diff --git a/nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.ts b/nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.ts
similarity index 93%
rename from nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.ts
index d5d06203284f..3265af2a9bcf 100644
--- a/nodejs/src/ingestion/event-processing/normalize-process-person-flag-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/normalize-process-person-flag-step.ts
@@ -1,10 +1,9 @@
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
import { EventHeaders } from '~/types'
-
-import { normalizeProcessPerson } from '../../utils/event'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { PipelineResult, drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { normalizeProcessPerson } from '~/utils/event'
type NormalizeProcessPersonFlagInput = {
event: PluginEvent
diff --git a/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts
new file mode 100644
index 000000000000..c0429e0e75e7
--- /dev/null
+++ b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts
@@ -0,0 +1,164 @@
+import { v4 } from 'uuid'
+
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { ProjectId, Team } from '~/types'
+
+import { PrefetchHogFunctionsStepInput, createPrefetchHogFunctionsStep } from './prefetch-hog-functions-step'
+
+const createTestTeam = (overrides: Partial<Team> = {}): Team => ({
+ id: 1,
+ project_id: 1 as ProjectId,
+ organization_id: 'test-org-id',
+ uuid: v4(),
+ name: 'Test Team',
+ anonymize_ips: false,
+ api_token: 'test-api-token',
+ secret_api_token: null,
+ session_recording_opt_in: true,
+ person_processing_opt_out: null,
+ heatmaps_opt_in: null,
+ ingested_event: true,
+ person_display_name_properties: null,
+ test_account_filters: null,
+ cookieless_server_hash_mode: null,
+ timezone: 'UTC',
+ available_features: [],
+ drop_events_older_than_seconds: null,
+ extra_settings: null,
+ ...overrides,
+})
+
+const createTestInput = (team: Team): PrefetchHogFunctionsStepInput => ({
+ team,
+})
+
+describe('prefetchHogFunctionsStep', () => {
+ // The step only depends on the HogTransformer contract; it delegates the actual clear/fetch/cache
+ // work to prefetchTransformationStatesForTeams (covered by the hog-transformer service tests).
+ let prefetchTransformationStatesForTeams: jest.Mock
+ let mockHogTransformer: HogTransformer
+
+ beforeEach(() => {
+ prefetchTransformationStatesForTeams = jest.fn().mockResolvedValue(undefined)
+ mockHogTransformer = { prefetchTransformationStatesForTeams } as unknown as HogTransformer
+ })
+
+ it('refreshes transformation states for the batch team IDs', async () => {
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
+
+ await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledWith([1])
+ })
+
+ it('returns an empty array and still refreshes with no team IDs when no events provided', async () => {
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
+
+ const results = await step([])
+
+ expect(results).toEqual([])
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledWith([])
+ })
+
+ it('deduplicates team IDs across the batch', async () => {
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
+ const team1 = createTestTeam({ id: 1 })
+ const team2 = createTestTeam({ id: 2 })
+ const team3 = createTestTeam({ id: 3 })
+
+ await step([
+ createTestInput(team1),
+ createTestInput(team1),
+ createTestInput(team2),
+ createTestInput(team3),
+ createTestInput(team2),
+ ])
+
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledTimes(1)
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledWith([1, 2, 3])
+ })
+
+ it('returns all events as OK results unchanged', async () => {
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
+ const team = createTestTeam({ id: 1 })
+ const inputs = [
+ { team, extraField: 'value1' },
+ { team, extraField: 'value2' },
+ ]
+
+ const results = await step(inputs)
+
+ expect(results).toHaveLength(2)
+ expect(results[0].type).toBe(PipelineResultType.OK)
+ expect(results[1].type).toBe(PipelineResultType.OK)
+ if (results[0].type === PipelineResultType.OK && results[1].type === PipelineResultType.OK) {
+ expect(results[0].value).toEqual(inputs[0])
+ expect(results[1].value).toEqual(inputs[1])
+ }
+ })
+
+ describe('sampling rate', () => {
+ let mockRandom: jest.SpyInstance
+
+ beforeEach(() => {
+ mockRandom = jest.spyOn(Math, 'random')
+ })
+
+ afterEach(() => {
+ mockRandom.mockRestore()
+ })
+
+ it('prefetches when random value is below sample rate', async () => {
+ mockRandom.mockReturnValue(0.2)
+
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
+
+ await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledWith([1])
+ })
+
+ it('skips prefetching when random value is above sample rate', async () => {
+ mockRandom.mockReturnValue(0.4)
+
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
+
+ const results = await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ expect(prefetchTransformationStatesForTeams).not.toHaveBeenCalled()
+ expect(results).toHaveLength(1)
+ })
+
+ it('skips prefetching when random value equals sample rate', async () => {
+ mockRandom.mockReturnValue(0.3)
+
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
+
+ await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ // 0.3 < 0.3 is false, so should skip
+ expect(prefetchTransformationStatesForTeams).not.toHaveBeenCalled()
+ })
+
+ it('always prefetches when sample rate is 1', async () => {
+ mockRandom.mockReturnValue(0.999)
+
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
+
+ await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ expect(prefetchTransformationStatesForTeams).toHaveBeenCalledWith([1])
+ })
+
+ it('skips prefetching when sample rate is 0', async () => {
+ mockRandom.mockReturnValue(0.5)
+
+ const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0)
+
+ await step([createTestInput(createTestTeam({ id: 1 }))])
+
+ expect(prefetchTransformationStatesForTeams).not.toHaveBeenCalled()
+ })
+ })
+})
diff --git a/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.ts b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.ts
new file mode 100644
index 000000000000..7609f8447c30
--- /dev/null
+++ b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.ts
@@ -0,0 +1,33 @@
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { Team } from '~/types'
+
+export interface PrefetchHogFunctionsStepInput {
+ team: Team
+}
+
+export function createPrefetchHogFunctionsStep<TInput extends PrefetchHogFunctionsStepInput>(
+ hogTransformer: HogTransformer,
+ sampleRate: number
+): BatchProcessingStep<TInput, TInput> {
+ return async function prefetchHogFunctionsStep(events: TInput[]): Promise<PipelineResult<TInput>[]> {
+ // Skip prefetching if sampling determines we shouldn't run hog watcher
+ const shouldRunHogWatcher = Math.random() < sampleRate
+ if (!shouldRunHogWatcher) {
+ return events.map((event) => ok(event))
+ }
+
+ // Extract unique team IDs from the batch
+ const teamIds = new Set<number>()
+ for (const event of events) {
+ teamIds.add(event.team.id)
+ }
+
+ // Refresh cached transformation states for the teams in this batch
+ await hogTransformer.prefetchTransformationStatesForTeams(Array.from(teamIds))
+
+ // Return events unchanged
+ return events.map((event) => ok(event))
+ }
+}
diff --git a/nodejs/src/ingestion/event-processing/prepare-event-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.test.ts
similarity index 92%
rename from nodejs/src/ingestion/event-processing/prepare-event-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.test.ts
index a2b68ba25ca5..ee4de371de54 100644
--- a/nodejs/src/ingestion/event-processing/prepare-event-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.test.ts
@@ -1,20 +1,20 @@
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
+import { parseEventTimestamp } from '~/ingestion/common/timestamps'
+import { PipelineResultType } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createTestPerson } from '~/tests/helpers/person'
+import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
+import { createTestTeam } from '~/tests/helpers/team'
+import { EventHeaders, Person, Team } from '~/types'
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createTestMessage } from '../../../tests/helpers/kafka-message'
-import { createTestPerson } from '../../../tests/helpers/person'
-import { createTestPluginEvent } from '../../../tests/helpers/plugin-event'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { EventHeaders, Person, Team } from '../../types'
-import { parseEventTimestamp } from '../../worker/ingestion/timestamps'
-import { PipelineResultType } from '../pipelines/results'
import { createPrepareEventStep } from './prepare-event-step'
import { BLOAT_PROPERTIES } from './strip-bloat-properties'
-jest.mock('../../worker/ingestion/timestamps')
+jest.mock('~/ingestion/common/timestamps')
type TestInput = {
normalizedEvent: PluginEvent
diff --git a/nodejs/src/ingestion/event-processing/prepare-event-step.ts b/nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.ts
similarity index 83%
rename from nodejs/src/ingestion/event-processing/prepare-event-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.ts
index 56ec6924210a..2ffdaeb5f986 100644
--- a/nodejs/src/ingestion/event-processing/prepare-event-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/prepare-event-step.ts
@@ -1,12 +1,12 @@
+import { invalidTimestampCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { parseEventTimestamp } from '~/ingestion/common/timestamps'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders, ISOTimestamp, PreIngestionEvent, Team } from '~/types'
+import { sanitizeEventName } from '~/utils/db/utils'
-import { EventHeaders, ISOTimestamp, PreIngestionEvent, Team } from '../../types'
-import { sanitizeEventName } from '../../utils/db/utils'
-import { invalidTimestampCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import { parseEventTimestamp } from '../../worker/ingestion/timestamps'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
import { stripBloatProperties } from './strip-bloat-properties'
export type PrepareEventStepInput = {
diff --git a/nodejs/src/ingestion/event-processing/process-groups-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/process-groups-step.test.ts
similarity index 94%
rename from nodejs/src/ingestion/event-processing/process-groups-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/process-groups-step.test.ts
index 835a35343c7c..cc1d324a3ba9 100644
--- a/nodejs/src/ingestion/event-processing/process-groups-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/process-groups-step.test.ts
@@ -1,12 +1,13 @@
import { DateTime } from 'luxon'
-import { createTestTeam } from '../../../tests/helpers/team'
-import { PreIngestionEvent, ProjectId, Team, TimestampFormat } from '../../types'
-import { TeamManager } from '../../utils/team-manager'
-import { castTimestampOrNow } from '../../utils/utils'
-import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'
-import { GroupStoreForBatch } from '../../worker/ingestion/groups/group-store-for-batch'
-import { PipelineResultType } from '../pipelines/results'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { createTestTeam } from '~/tests/helpers/team'
+import { PreIngestionEvent, ProjectId, Team, TimestampFormat } from '~/types'
+import { TeamManager } from '~/utils/team-manager'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { createProcessGroupsStep } from './process-groups-step'
const createTestPreIngestionEvent = (overrides: Partial<PreIngestionEvent> = {}): PreIngestionEvent => ({
diff --git a/nodejs/src/ingestion/event-processing/process-groups-step.ts b/nodejs/src/ingestion/common/steps/event-processing/process-groups-step.ts
similarity index 87%
rename from nodejs/src/ingestion/event-processing/process-groups-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/process-groups-step.ts
index 7e4ccdd285b9..03efd7324617 100644
--- a/nodejs/src/ingestion/event-processing/process-groups-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/process-groups-step.ts
@@ -1,16 +1,16 @@
import { DateTime } from 'luxon'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { Properties } from '~/plugin-scaffold'
+import { PreIngestionEvent, ProjectId, Team, TeamId } from '~/types'
+import { sanitizeString } from '~/utils/db/utils'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { TeamManager } from '~/utils/team-manager'
-import { PreIngestionEvent, ProjectId, Team, TeamId } from '../../types'
-import { sanitizeString } from '../../utils/db/utils'
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { TeamManager } from '../../utils/team-manager'
-import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'
-import { GroupStoreForBatch } from '../../worker/ingestion/groups/group-store-for-batch'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
import { EventPipelineRunnerOptions } from './event-pipeline-options'
import { addGroupProperties } from './groups'
diff --git a/nodejs/src/ingestion/event-processing/process-personless-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/process-personless-step.test.ts
similarity index 96%
rename from nodejs/src/ingestion/event-processing/process-personless-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/process-personless-step.test.ts
index abf9cbd148df..ea60f53a6f14 100644
--- a/nodejs/src/ingestion/event-processing/process-personless-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/process-personless-step.test.ts
@@ -2,22 +2,22 @@ import { mockProducer } from '~/tests/helpers/mocks/producer.mock'
import { DateTime } from 'luxon'
-import { PipelineResultType, isOkResult } from '~/ingestion/pipelines/results'
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '~/config/kafka-topics'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { BatchBoundPersonsStore } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'
import { PluginEvent, Properties } from '~/plugin-scaffold'
-import { BatchWritingPersonsStore } from '~/worker/ingestion/persons/batch-writing-person-store'
-import { BatchBoundPersonsStore } from '~/worker/ingestion/persons/persons-store-for-batch'
-import { PostgresPersonRepository } from '~/worker/ingestion/persons/repositories/postgres-person-repository'
-
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { createOrganization, createTeam, getTeam, resetTestDatabase } from '../../../tests/helpers/sql'
-import { KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '../../config/kafka-topics'
-import { EventHeaders, Hub, InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '../../types'
-import { closeHub, createHub } from '../../utils/db/hub'
-import { UUIDT } from '../../utils/utils'
-import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../analytics/outputs'
-import { INGESTION_WARNINGS_OUTPUT } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../outputs/single-ingestion-output'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createOrganization, createTeam, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { EventHeaders, Hub, InternalPerson, PropertiesLastOperation, PropertiesLastUpdatedAt, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { UUIDT } from '~/utils/utils'
+
import { createNormalizeEventStep } from './normalize-event-step'
import { createNormalizeProcessPersonFlagStep } from './normalize-process-person-flag-step'
import { ProcessPersonlessInput, createProcessPersonlessStep } from './process-personless-step'
diff --git a/nodejs/src/ingestion/event-processing/process-personless-step.ts b/nodejs/src/ingestion/common/steps/event-processing/process-personless-step.ts
similarity index 94%
rename from nodejs/src/ingestion/event-processing/process-personless-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/process-personless-step.ts
index b2f4ff4f50a1..9c483f59b1f4 100644
--- a/nodejs/src/ingestion/event-processing/process-personless-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/process-personless-step.ts
@@ -1,20 +1,19 @@
import { DateTime } from 'luxon'
-import { PluginEvent } from '~/plugin-scaffold'
-
-import { buildIntegerMatcher } from '../../config/config'
-import { Person, Team } from '../../types'
-import { normalizeProcessPerson } from '../../utils/event'
-import { uuidFromDistinctId } from '../../worker/ingestion/person-uuid'
+import { buildIntegerMatcher } from '~/config/config'
+import { uuidFromDistinctId } from '~/ingestion/common/person-uuid'
import {
hasInsertedPersonlessDistinctId,
markPersonlessDistinctIdInserted,
personlessDistinctIdCacheOperationsCounter,
-} from '../../worker/ingestion/persons/personless-distinct-id-cache'
-import { PersonsStoreForBatch } from '../../worker/ingestion/persons/persons-store-for-batch'
-import { DEFAULT_FLAG_CALLED_PERSONLESS_DEFAULT_TEAMS } from '../config'
-import { PipelineResult, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+} from '~/ingestion/common/persons/personless-distinct-id-cache'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { DEFAULT_FLAG_CALLED_PERSONLESS_DEFAULT_TEAMS } from '~/ingestion/config'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PluginEvent } from '~/plugin-scaffold'
+import { Person, Team } from '~/types'
+import { normalizeProcessPerson } from '~/utils/event'
export type ProcessPersonlessInput = {
normalizedEvent: PluginEvent
diff --git a/nodejs/src/ingestion/event-processing/process-persons-step.ts b/nodejs/src/ingestion/common/steps/event-processing/process-persons-step.ts
similarity index 74%
rename from nodejs/src/ingestion/event-processing/process-persons-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/process-persons-step.ts
index 1cd6262e5bd0..95160691b8db 100644
--- a/nodejs/src/ingestion/event-processing/process-persons-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/process-persons-step.ts
@@ -1,17 +1,17 @@
import { DateTime } from 'luxon'
+import { AsyncOutput } from '~/common/outputs'
+import { PersonContext, PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { PersonEventProcessor } from '~/ingestion/common/persons/person-event-processor'
+import { PersonMergeService } from '~/ingestion/common/persons/person-merge-service'
+import { determineMergeMode } from '~/ingestion/common/persons/person-merge-types'
+import { PersonPropertyService } from '~/ingestion/common/persons/person-property-service'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
+import { Person, Team } from '~/types'
-import { Person, Team } from '../../types'
-import { PersonContext, PersonOutputs } from '../../worker/ingestion/persons/person-context'
-import { PersonEventProcessor } from '../../worker/ingestion/persons/person-event-processor'
-import { PersonMergeService } from '../../worker/ingestion/persons/person-merge-service'
-import { determineMergeMode } from '../../worker/ingestion/persons/person-merge-types'
-import { PersonPropertyService } from '../../worker/ingestion/persons/person-property-service'
-import { PersonsStoreForBatch } from '../../worker/ingestion/persons/persons-store-for-batch'
-import { AsyncOutput } from '../analytics/outputs'
-import { PipelineResult, isOkResult, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
import { EventPipelineRunnerOptions } from './event-pipeline-options'
export type ProcessPersonsInput = {
diff --git a/nodejs/src/ingestion/event-processing/readonly-process-groups-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.test.ts
similarity index 93%
rename from nodejs/src/ingestion/event-processing/readonly-process-groups-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.test.ts
index 120784cfb6d4..a557efae0688 100644
--- a/nodejs/src/ingestion/event-processing/readonly-process-groups-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.test.ts
@@ -1,8 +1,9 @@
-import { createTestTeam } from '../../../tests/helpers/team'
-import { PreIngestionEvent, ProjectId, Team, TimestampFormat } from '../../types'
-import { castTimestampOrNow } from '../../utils/utils'
-import { ReadOnlyGroupTypeManager } from '../../worker/ingestion/readonly-group-type-manager'
-import { PipelineResultType } from '../pipelines/results'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { createTestTeam } from '~/tests/helpers/team'
+import { PreIngestionEvent, ProjectId, Team, TimestampFormat } from '~/types'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { createReadOnlyProcessGroupsStep } from './readonly-process-groups-step'
const createTestPreIngestionEvent = (overrides: Partial<PreIngestionEvent> = {}): PreIngestionEvent => ({
diff --git a/nodejs/src/ingestion/event-processing/readonly-process-groups-step.ts b/nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.ts
similarity index 77%
rename from nodejs/src/ingestion/event-processing/readonly-process-groups-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.ts
index 4243c64c710b..a00cbe7e26cc 100644
--- a/nodejs/src/ingestion/event-processing/readonly-process-groups-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/readonly-process-groups-step.ts
@@ -1,7 +1,8 @@
-import { PreIngestionEvent, Team } from '../../types'
-import { ReadOnlyGroupTypeManager } from '../../worker/ingestion/readonly-group-type-manager'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PreIngestionEvent, Team } from '~/types'
+
import { enrichPropertiesWithGroupTypes } from './groups'
export interface ReadOnlyProcessGroupsStepInput {
diff --git a/nodejs/src/ingestion/event-processing/split-ai-events-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.test.ts
similarity index 99%
rename from nodejs/src/ingestion/event-processing/split-ai-events-step.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.test.ts
index ae728b82f040..8e95c5ad3b9a 100644
--- a/nodejs/src/ingestion/event-processing/split-ai-events-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.test.ts
@@ -1,6 +1,7 @@
-import { ISOTimestamp, ProcessedEvent, ProjectId } from '../../types'
-import { AI_EVENTS_OUTPUT, EVENTS_OUTPUT } from '../analytics/outputs'
-import { isOkResult } from '../pipelines/results'
+import { AI_EVENTS_OUTPUT, EVENTS_OUTPUT } from '~/common/outputs'
+import { isOkResult } from '~/ingestion/framework/results'
+import { ISOTimestamp, ProcessedEvent, ProjectId } from '~/types'
+
import { SplitAiEventsStepConfig, createSplitAiEventsStep, parseSplitAiEventsConfig } from './split-ai-events-step'
function createProcessedEvent(
diff --git a/nodejs/src/ingestion/event-processing/split-ai-events-step.ts b/nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.ts
similarity index 90%
rename from nodejs/src/ingestion/event-processing/split-ai-events-step.ts
rename to nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.ts
index feadfc18a0bb..5ae7438f928a 100644
--- a/nodejs/src/ingestion/event-processing/split-ai-events-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/split-ai-events-step.ts
@@ -1,8 +1,10 @@
-import { ProcessedEvent } from '../../types'
-import { AI_EVENT_TYPES } from '../ai'
-import { AI_EVENTS_OUTPUT, AiEventOutput, EventOutput } from '../analytics/outputs'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { AI_EVENTS_OUTPUT, AiEventOutput, EventOutput } from '~/common/outputs'
+import { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { ProcessedEvent } from '~/types'
+import { parseTeamsList } from '~/utils/env-utils'
+
import { EventToEmit } from './emit-event-step'
const LARGE_AI_PROPERTIES = new Set([
@@ -85,16 +87,6 @@ function maybeStripAiProperties(
]
}
-export function parseTeamsList(teamsStr: string): number[] | '*' {
- if (teamsStr === '*') {
- return '*'
- }
- return teamsStr
- .split(',')
- .map((s) => parseInt(s.trim(), 10))
- .filter((n) => !isNaN(n))
-}
-
function clampPercentage(pct: number): number {
if (Number.isNaN(pct) || pct <= 0) {
return 0
diff --git a/nodejs/src/ingestion/event-processing/strip-bloat-properties.test.ts b/nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.test.ts
similarity index 93%
rename from nodejs/src/ingestion/event-processing/strip-bloat-properties.test.ts
rename to nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.test.ts
index 17833d310904..7f68e86d8673 100644
--- a/nodejs/src/ingestion/event-processing/strip-bloat-properties.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.test.ts
@@ -1,7 +1,8 @@
-import { droppedBloatPropertyCounter } from '../../worker/ingestion/event-pipeline/metrics'
+import { droppedBloatPropertyCounter } from '~/ingestion/common/event-pipeline/metrics'
+
import { BLOAT_PROPERTIES, stripBloatProperties } from './strip-bloat-properties'
-jest.mock('../../worker/ingestion/event-pipeline/metrics', () => ({
+jest.mock('~/ingestion/common/event-pipeline/metrics', () => ({
droppedBloatPropertyCounter: {
labels: jest.fn().mockReturnValue({ inc: jest.fn() }),
},
diff --git a/nodejs/src/ingestion/event-processing/strip-bloat-properties.ts b/nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.ts
similarity index 88%
rename from nodejs/src/ingestion/event-processing/strip-bloat-properties.ts
rename to nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.ts
index 0fb54303d16c..70c4457eae0b 100644
--- a/nodejs/src/ingestion/event-processing/strip-bloat-properties.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/strip-bloat-properties.ts
@@ -1,4 +1,4 @@
-import { droppedBloatPropertyCounter } from '../../worker/ingestion/event-pipeline/metrics'
+import { droppedBloatPropertyCounter } from '~/ingestion/common/event-pipeline/metrics'
// Persistence cache keys that leak from older posthog-js versions into event
// payloads. The SDK stopped sending these in posthog-js#3392; this server-side
diff --git a/nodejs/src/ingestion/common/steps/group-store-batch-step.ts b/nodejs/src/ingestion/common/steps/group-store-batch-step.ts
index e0c8885caca8..2ebc587ac2f1 100644
--- a/nodejs/src/ingestion/common/steps/group-store-batch-step.ts
+++ b/nodejs/src/ingestion/common/steps/group-store-batch-step.ts
@@ -1,7 +1,7 @@
-import { BatchWritingGroupStore } from '../../../worker/ingestion/groups/batch-writing-group-store'
-import { BatchBoundGroupStore, GroupStoreForBatch } from '../../../worker/ingestion/groups/group-store-for-batch'
-import { BeforeBatchStep } from '../../pipelines/batching-pipeline'
-import { ok } from '../../pipelines/results'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { BatchBoundGroupStore, GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { BeforeBatchStep } from '~/ingestion/framework/batching-pipeline'
+import { ok } from '~/ingestion/framework/results'
export interface GroupStoreBatchContext {
groupStoreForBatch: GroupStoreForBatch
diff --git a/nodejs/src/ingestion/common/steps/persons-store-batch-step.ts b/nodejs/src/ingestion/common/steps/persons-store-batch-step.ts
index 5bc083e1864e..faac2d20dfec 100644
--- a/nodejs/src/ingestion/common/steps/persons-store-batch-step.ts
+++ b/nodejs/src/ingestion/common/steps/persons-store-batch-step.ts
@@ -1,7 +1,7 @@
-import { PersonsStore } from '../../../worker/ingestion/persons/persons-store'
-import { BatchBoundPersonsStore, PersonsStoreForBatch } from '../../../worker/ingestion/persons/persons-store-for-batch'
-import { BeforeBatchStep } from '../../pipelines/batching-pipeline'
-import { ok } from '../../pipelines/results'
+import { PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { BatchBoundPersonsStore, PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { BeforeBatchStep } from '~/ingestion/framework/batching-pipeline'
+import { ok } from '~/ingestion/framework/results'
export interface PersonsStoreBatchContext {
personsStoreForBatch: PersonsStoreForBatch
diff --git a/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts b/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts
index c1e34f61b774..b67fef6e8e5c 100644
--- a/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts
+++ b/nodejs/src/ingestion/common/steps/record-ingestion-lag.test.ts
@@ -1,6 +1,7 @@
-import { ingestionLagGauge, ingestionLagHistogram } from '../../../common/metrics'
-import { IngestedEventInfo } from '../../event-processing/emit-event-step'
-import { isOkResult } from '../../pipelines/results'
+import { ingestionLagGauge, ingestionLagHistogram } from '~/common/metrics'
+import { IngestedEventInfo } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { isOkResult } from '~/ingestion/framework/results'
+
import { RecordIngestionLagInput, createRecordIngestionLagStep } from './record-ingestion-lag'
const FAKE_NOW_MS = 1702654321987 // 2023-12-15T14:32:01.987Z
diff --git a/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts b/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts
index 79c0a109d21b..64b79491840b 100644
--- a/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts
+++ b/nodejs/src/ingestion/common/steps/record-ingestion-lag.ts
@@ -1,7 +1,7 @@
-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'
+import { ingestionLagGauge, ingestionLagHistogram } from '~/common/metrics'
+import { IngestedEventInfo } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
export interface RecordIngestionLagInput {
ingested: Promise<IngestedEventInfo | null>[]
diff --git a/nodejs/src/worker/ingestion/stores/batch-writing-store.ts b/nodejs/src/ingestion/common/stores/batch-writing-store.ts
similarity index 93%
rename from nodejs/src/worker/ingestion/stores/batch-writing-store.ts
rename to nodejs/src/ingestion/common/stores/batch-writing-store.ts
index c144610b65f7..4808a36a1dd8 100644
--- a/nodejs/src/worker/ingestion/stores/batch-writing-store.ts
+++ b/nodejs/src/ingestion/common/stores/batch-writing-store.ts
@@ -1,4 +1,4 @@
-import { FlushResult } from '../persons/persons-store'
+import { FlushResult } from '~/ingestion/common/persons/persons-store'
export interface BatchWritingStoreFlushStats {
dirtyEntryCount: number
diff --git a/nodejs/src/worker/ingestion/stores/metrics.ts b/nodejs/src/ingestion/common/stores/metrics.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/stores/metrics.ts
rename to nodejs/src/ingestion/common/stores/metrics.ts
diff --git a/nodejs/src/ingestion/common/subpipelines/helpers.ts b/nodejs/src/ingestion/common/subpipelines/helpers.ts
index 52a15f33e753..1b656c2b6107 100644
--- a/nodejs/src/ingestion/common/subpipelines/helpers.ts
+++ b/nodejs/src/ingestion/common/subpipelines/helpers.ts
@@ -1,5 +1,5 @@
-import { EventHeaders, Team } from '../../../types'
-import { OkResultWithContext } from '../../pipelines/pipeline.interface'
+import { OkResultWithContext } from '~/ingestion/framework/pipeline.interface'
+import { EventHeaders, Team } from '~/types'
/**
* Helper for `filterMap` after team resolution: lifts the resolved team from
diff --git a/nodejs/src/worker/ingestion/timestamps.ts b/nodejs/src/ingestion/common/timestamps.ts
similarity index 100%
rename from nodejs/src/worker/ingestion/timestamps.ts
rename to nodejs/src/ingestion/common/timestamps.ts
diff --git a/nodejs/src/worker/ingestion/utils.ts b/nodejs/src/ingestion/common/utils.ts
similarity index 84%
rename from nodejs/src/worker/ingestion/utils.ts
rename to nodejs/src/ingestion/common/utils.ts
index 567ba34a46b5..13bf147e3708 100644
--- a/nodejs/src/worker/ingestion/utils.ts
+++ b/nodejs/src/ingestion/common/utils.ts
@@ -1,18 +1,17 @@
import { DateTime } from 'luxon'
+import { KAFKA_EVENTS_DEAD_LETTER_QUEUE } from '~/config/kafka-topics'
+import { TopicMessage } from '~/kafka/producer'
import { PluginEvent, ProcessedPluginEvent } from '~/plugin-scaffold'
-
-import { TopicMessage } from '../../kafka/producer'
-import { PipelineEvent, TimestampFormat } from '../../types'
-import { safeClickhouseString } from '../../utils/db/utils'
-import { UUIDT, castTimestampToClickhouseFormat } from '../../utils/utils'
-import { KAFKA_EVENTS_DEAD_LETTER_QUEUE } from './../../config/kafka-topics'
+import { PipelineEvent, TimestampFormat } from '~/types'
+import { safeClickhouseString } from '~/utils/db/utils'
+import { UUIDT, castTimestampToClickhouseFormat } from '~/utils/utils'
export {
ingestionWarningCounter,
captureIngestionWarning,
emitIngestionWarning,
-} from '../../ingestion/common/ingestion-warnings'
+} from '~/ingestion/common/ingestion-warnings'
function getClickhouseTimestampOrNull(isoTimestamp?: string): string | null {
return isoTimestamp
diff --git a/nodejs/src/ingestion/common/utils/kafka-consumer.ts b/nodejs/src/ingestion/common/utils/kafka-consumer.ts
index 63ff044fc841..6501c20956c2 100644
--- a/nodejs/src/ingestion/common/utils/kafka-consumer.ts
+++ b/nodejs/src/ingestion/common/utils/kafka-consumer.ts
@@ -1,12 +1,11 @@
import { Message } from 'node-rdkafka'
import { instrumentFn } from '~/common/tracing/tracing-utils'
+import { Component } from '~/ingestion/common/scopes'
+import { KafkaConsumerInterface, createKafkaConsumer } from '~/kafka/consumer'
-import { KafkaConsumerInterface, createKafkaConsumer } from '../../../kafka/consumer'
-import { Component } from '../scopes'
-
-export { createKafkaConsumer } from '../../../kafka/consumer'
-export type { KafkaConsumerInterface } from '../../../kafka/consumer'
+export { createKafkaConsumer } from '~/kafka/consumer'
+export type { KafkaConsumerInterface } from '~/kafka/consumer'
/**
* Owns a Kafka consumer's lifetime as a scope entry. Start creates the
diff --git a/nodejs/src/ingestion/common/utils/promise-scheduler.ts b/nodejs/src/ingestion/common/utils/promise-scheduler.ts
index 4254c13f9450..34be140456de 100644
--- a/nodejs/src/ingestion/common/utils/promise-scheduler.ts
+++ b/nodejs/src/ingestion/common/utils/promise-scheduler.ts
@@ -1,7 +1,7 @@
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { Component } from '../scopes'
+import { Component } from '~/ingestion/common/scopes'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
-export { PromiseScheduler } from '../../../utils/promise-scheduler'
+export { PromiseScheduler } from '~/utils/promise-scheduler'
/**
* Wraps an internally-owned `PromiseScheduler` as a scope entry. Start is
diff --git a/nodejs/src/ingestion/config.ts b/nodejs/src/ingestion/config.ts
index d6c5a7fab72f..cb1964730568 100644
--- a/nodejs/src/ingestion/config.ts
+++ b/nodejs/src/ingestion/config.ts
@@ -1,4 +1,5 @@
-import type { CommonConfig } from '../common/config'
+import type { CommonConfig } from '~/common/config'
+import { INGESTION_DOWNSTREAM_PRODUCER, INGESTION_UPSTREAM_PRODUCER, type ProducerName } from '~/common/outputs'
import {
KAFKA_APP_METRICS_2,
KAFKA_CLICKHOUSE_AI_EVENTS_JSON,
@@ -14,10 +15,9 @@ import {
KAFKA_LOG_ENTRIES,
KAFKA_PERSON,
KAFKA_PERSON_DISTINCT_ID,
-} from '../config/kafka-topics'
-import type { PostgresRouterConfig } from '../utils/db/postgres'
-import { isDevEnv, isProdEnv } from '../utils/env-utils'
-import { INGESTION_DOWNSTREAM_PRODUCER, INGESTION_UPSTREAM_PRODUCER, type ProducerName } from './common/outputs'
+} from '~/config/kafka-topics'
+import type { PostgresRouterConfig } from '~/utils/db/postgres'
+import { isDevEnv, isProdEnv } from '~/utils/env-utils'
/** Default for FLAG_CALLED_PERSONLESS_DEFAULT_TEAMS: '' disables the personless default so it is opt-in per team via config. */
export const DEFAULT_FLAG_CALLED_PERSONLESS_DEFAULT_TEAMS = ''
diff --git a/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.test.ts b/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.test.ts
deleted file mode 100644
index 260f0e044f7e..000000000000
--- a/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.test.ts
+++ /dev/null
@@ -1,254 +0,0 @@
-import { v4 } from 'uuid'
-
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { ProjectId, Team } from '../../types'
-import { PipelineResultType } from '../pipelines/results'
-import { PrefetchHogFunctionsStepInput, createPrefetchHogFunctionsStep } from './prefetch-hog-functions-step'
-
-const createTestTeam = (overrides: Partial<Team> = {}): Team => ({
- id: 1,
- project_id: 1 as ProjectId,
- organization_id: 'test-org-id',
- uuid: v4(),
- name: 'Test Team',
- anonymize_ips: false,
- api_token: 'test-api-token',
- secret_api_token: null,
- session_recording_opt_in: true,
- person_processing_opt_out: null,
- heatmaps_opt_in: null,
- ingested_event: true,
- person_display_name_properties: null,
- test_account_filters: null,
- cookieless_server_hash_mode: null,
- timezone: 'UTC',
- available_features: [],
- drop_events_older_than_seconds: null,
- extra_settings: null,
- ...overrides,
-})
-
-const createTestInput = (team: Team): PrefetchHogFunctionsStepInput => ({
- team,
-})
-
-describe('prefetchHogFunctionsStep', () => {
- let mockHogTransformer: jest.Mocked<HogTransformerService>
- let mockGetHogFunctionIdsForTeams: jest.Mock
-
- beforeEach(() => {
- mockGetHogFunctionIdsForTeams = jest.fn()
- mockHogTransformer = {
- clearHogFunctionStates: jest.fn(),
- fetchAndCacheHogFunctionStates: jest.fn(),
- hogFunctionManager: {
- getHogFunctionIdsForTeams: mockGetHogFunctionIdsForTeams,
- },
- } as unknown as jest.Mocked<HogTransformerService>
- })
-
- it('clears cached hog function states before processing', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({})
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const input = createTestInput(createTestTeam())
-
- await step([input])
-
- expect(mockHogTransformer.clearHogFunctionStates).toHaveBeenCalledTimes(1)
- })
-
- it('returns events unchanged when no events provided', async () => {
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
-
- const results = await step([])
-
- expect(results).toEqual([])
- expect(mockHogTransformer.clearHogFunctionStates).toHaveBeenCalledTimes(1)
- expect(mockGetHogFunctionIdsForTeams).not.toHaveBeenCalled()
- })
-
- it('extracts unique team IDs and fetches hog function IDs', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({ 1: ['func-1', 'func-2'] })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const team = createTestTeam({ id: 1 })
- const inputs = [createTestInput(team), createTestInput(team), createTestInput(team)]
-
- await step(inputs)
-
- expect(mockGetHogFunctionIdsForTeams).toHaveBeenCalledWith([1], ['transformation'])
- })
-
- it('handles multiple teams and deduplicates team IDs', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({
- 1: ['func-1'],
- 2: ['func-2'],
- 3: ['func-3'],
- })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const team1 = createTestTeam({ id: 1 })
- const team2 = createTestTeam({ id: 2 })
- const team3 = createTestTeam({ id: 3 })
- const inputs = [
- createTestInput(team1),
- createTestInput(team1),
- createTestInput(team2),
- createTestInput(team3),
- createTestInput(team2),
- ]
-
- await step(inputs)
-
- expect(mockGetHogFunctionIdsForTeams).toHaveBeenCalledTimes(1)
- const calledTeamIds = mockGetHogFunctionIdsForTeams.mock.calls[0][0]
- expect(calledTeamIds).toHaveLength(3)
- expect(calledTeamIds).toContain(1)
- expect(calledTeamIds).toContain(2)
- expect(calledTeamIds).toContain(3)
- })
-
- it('fetches and caches hog function states when functions exist', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({
- 1: ['func-1', 'func-2'],
- 2: ['func-3'],
- })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const inputs = [createTestInput(createTestTeam({ id: 1 })), createTestInput(createTestTeam({ id: 2 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.fetchAndCacheHogFunctionStates).toHaveBeenCalledWith(['func-1', 'func-2', 'func-3'])
- })
-
- it('does not fetch hog function states when no functions exist', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({})
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.fetchAndCacheHogFunctionStates).not.toHaveBeenCalled()
- })
-
- it('returns all events as OK results unchanged', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({ 1: ['func-1'] })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const team = createTestTeam({ id: 1 })
- const inputs = [
- { team, extraField: 'value1' },
- { team, extraField: 'value2' },
- ]
-
- const results = await step(inputs)
-
- expect(results).toHaveLength(2)
- expect(results[0].type).toBe(PipelineResultType.OK)
- expect(results[1].type).toBe(PipelineResultType.OK)
- if (results[0].type === PipelineResultType.OK && results[1].type === PipelineResultType.OK) {
- expect(results[0].value).toEqual(inputs[0])
- expect(results[1].value).toEqual(inputs[1])
- }
- })
-
- it('handles teams with empty hog function arrays', async () => {
- mockGetHogFunctionIdsForTeams.mockResolvedValue({
- 1: [],
- 2: [],
- })
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const inputs = [createTestInput(createTestTeam({ id: 1 })), createTestInput(createTestTeam({ id: 2 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.fetchAndCacheHogFunctionStates).not.toHaveBeenCalled()
- })
-
- describe('sampling rate', () => {
- let mockRandom: jest.SpyInstance
-
- beforeEach(() => {
- mockRandom = jest.spyOn(Math, 'random')
- })
-
- afterEach(() => {
- mockRandom.mockRestore()
- })
-
- it('prefetches when random value is below sample rate', async () => {
- mockRandom.mockReturnValue(0.2)
- mockGetHogFunctionIdsForTeams.mockResolvedValue({ 1: ['func-1'] })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.clearHogFunctionStates).toHaveBeenCalled()
- expect(mockGetHogFunctionIdsForTeams).toHaveBeenCalled()
- expect(mockHogTransformer.fetchAndCacheHogFunctionStates).toHaveBeenCalledWith(['func-1'])
- })
-
- it('skips prefetching when random value is above sample rate', async () => {
- mockRandom.mockReturnValue(0.4)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.clearHogFunctionStates).not.toHaveBeenCalled()
- expect(mockGetHogFunctionIdsForTeams).not.toHaveBeenCalled()
- expect(mockHogTransformer.fetchAndCacheHogFunctionStates).not.toHaveBeenCalled()
- })
-
- it('skips prefetching when random value equals sample rate', async () => {
- mockRandom.mockReturnValue(0.3)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0.3)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- // 0.3 < 0.3 is false, so should skip
- expect(mockHogTransformer.clearHogFunctionStates).not.toHaveBeenCalled()
- expect(mockGetHogFunctionIdsForTeams).not.toHaveBeenCalled()
- })
-
- it('always prefetches when sample rate is 1', async () => {
- mockRandom.mockReturnValue(0.999)
- mockGetHogFunctionIdsForTeams.mockResolvedValue({ 1: ['func-1'] })
- mockHogTransformer.fetchAndCacheHogFunctionStates.mockResolvedValue(undefined)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 1)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.clearHogFunctionStates).toHaveBeenCalled()
- expect(mockGetHogFunctionIdsForTeams).toHaveBeenCalled()
- })
-
- it('skips prefetching when sample rate is 0', async () => {
- mockRandom.mockReturnValue(0.5)
-
- const step = createPrefetchHogFunctionsStep(mockHogTransformer, 0)
- const inputs = [createTestInput(createTestTeam({ id: 1 }))]
-
- await step(inputs)
-
- expect(mockHogTransformer.clearHogFunctionStates).not.toHaveBeenCalled()
- expect(mockGetHogFunctionIdsForTeams).not.toHaveBeenCalled()
- })
- })
-})
diff --git a/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.ts b/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.ts
deleted file mode 100644
index 0240fee9b982..000000000000
--- a/nodejs/src/ingestion/event-processing/prefetch-hog-functions-step.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { Team } from '../../types'
-import { BatchProcessingStep } from '../pipelines/base-batch-pipeline'
-import { PipelineResult, ok } from '../pipelines/results'
-
-export interface PrefetchHogFunctionsStepInput {
- team: Team
-}
-
-export function createPrefetchHogFunctionsStep<TInput extends PrefetchHogFunctionsStepInput>(
- hogTransformer: HogTransformerService,
- sampleRate: number
-): BatchProcessingStep<TInput, TInput> {
- return async function prefetchHogFunctionsStep(events: TInput[]): Promise<PipelineResult<TInput>[]> {
- // Skip prefetching if sampling determines we shouldn't run hog watcher
- const shouldRunHogWatcher = Math.random() < sampleRate
- if (!shouldRunHogWatcher) {
- return events.map((event) => ok(event))
- }
-
- // Clear cached hog function states before fetching new ones
- hogTransformer.clearHogFunctionStates()
-
- // Extract unique team IDs from the batch
- const teamIds = new Set<number>()
- for (const event of events) {
- teamIds.add(event.team.id)
- }
-
- if (teamIds.size === 0) {
- return events.map((event) => ok(event))
- }
-
- // Get hog function IDs for transformations
- const teamHogFunctionIds = await hogTransformer['hogFunctionManager'].getHogFunctionIdsForTeams(
- Array.from(teamIds),
- ['transformation']
- )
-
- // Flatten all hog function IDs into a single array
- const allHogFunctionIds = Object.values(teamHogFunctionIds).flat()
-
- if (allHogFunctionIds.length > 0) {
- // Cache the hog function states
- await hogTransformer.fetchAndCacheHogFunctionStates(allHogFunctionIds)
- }
-
- // Return events unchanged
- return events.map((event) => ok(event))
- }
-}
diff --git a/nodejs/src/ingestion/pipelines/TODO.md b/nodejs/src/ingestion/framework/TODO.md
similarity index 100%
rename from nodejs/src/ingestion/pipelines/TODO.md
rename to nodejs/src/ingestion/framework/TODO.md
diff --git a/nodejs/src/ingestion/pipelines/base-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/base-batch-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/base-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/base-batch-pipeline.test.ts
index d592c72ba96f..e7e7d25acf6d 100644
--- a/nodejs/src/ingestion/pipelines/base-batch-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/base-batch-pipeline.test.ts
@@ -1,6 +1,7 @@
import { Message } from 'node-rdkafka'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+
import { BaseBatchPipeline } from './base-batch-pipeline'
import { createBatch, createContext, createNewBatchPipeline, createOkContext } from './helpers'
import { dlq, drop, ok } from './results'
diff --git a/nodejs/src/ingestion/pipelines/base-batch-pipeline.ts b/nodejs/src/ingestion/framework/base-batch-pipeline.ts
similarity index 98%
rename from nodejs/src/ingestion/pipelines/base-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/base-batch-pipeline.ts
index 09efa621ad44..7ed7ecdb4454 100644
--- a/nodejs/src/ingestion/pipelines/base-batch-pipeline.ts
+++ b/nodejs/src/ingestion/framework/base-batch-pipeline.ts
@@ -1,4 +1,5 @@
-import { instrumentFn } from '../../common/tracing/tracing-utils'
+import { instrumentFn } from '~/common/tracing/tracing-utils'
+
import { BatchPipeline, BatchPipelineResultWithContext, OkResultWithContext } from './batch-pipeline.interface'
import { pipelineStepDurationHistogram } from './metrics'
import { PipelineResultWithContext } from './pipeline.interface'
diff --git a/nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.test.ts b/nodejs/src/ingestion/framework/batch-pipeline-unwrapper.test.ts
similarity index 98%
rename from nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.test.ts
rename to nodejs/src/ingestion/framework/batch-pipeline-unwrapper.test.ts
index 6e8c846e1504..ae0e18c506a5 100644
--- a/nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.test.ts
+++ b/nodejs/src/ingestion/framework/batch-pipeline-unwrapper.test.ts
@@ -1,15 +1,16 @@
import { Message } from 'node-rdkafka'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
-import { logger } from '../../utils/logger'
-import { OVERFLOW_OUTPUT } from '../common/outputs'
+import { OVERFLOW_OUTPUT } from '~/common/outputs'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+import { logger } from '~/utils/logger'
+
import { BatchPipelineUnwrapper } from './batch-pipeline-unwrapper'
import { BatchPipeline } from './batch-pipeline.interface'
import { DefaultContext, createContext, createNewBatchPipeline, createOkContext } from './helpers'
import { dlq, drop, ok, redirect } from './results'
// Mock the logger
-jest.mock('../../utils/logger', () => ({
+jest.mock('~/utils/logger', () => ({
logger: {
warn: jest.fn(),
},
diff --git a/nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.ts b/nodejs/src/ingestion/framework/batch-pipeline-unwrapper.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.ts
rename to nodejs/src/ingestion/framework/batch-pipeline-unwrapper.ts
index 90032c25aa99..b4ea2188ef55 100644
--- a/nodejs/src/ingestion/pipelines/batch-pipeline-unwrapper.ts
+++ b/nodejs/src/ingestion/framework/batch-pipeline-unwrapper.ts
@@ -1,4 +1,5 @@
-import { logger } from '../../utils/logger'
+import { logger } from '~/utils/logger'
+
import { BatchPipeline, OkResultWithContext } from './batch-pipeline.interface'
import { isOkResult } from './results'
diff --git a/nodejs/src/ingestion/pipelines/batch-pipeline.interface.ts b/nodejs/src/ingestion/framework/batch-pipeline.interface.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/batch-pipeline.interface.ts
rename to nodejs/src/ingestion/framework/batch-pipeline.interface.ts
diff --git a/nodejs/src/ingestion/pipelines/batch-retry.test.ts b/nodejs/src/ingestion/framework/batch-retry.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/batch-retry.test.ts
rename to nodejs/src/ingestion/framework/batch-retry.test.ts
index 2208429eb4ad..d766e7dfeb6d 100644
--- a/nodejs/src/ingestion/pipelines/batch-retry.test.ts
+++ b/nodejs/src/ingestion/framework/batch-retry.test.ts
@@ -7,7 +7,7 @@ import { getRetryAttempts } from './metrics.test-utils'
import { drop, isDlqResult, isDropResult, isOkResult, ok } from './results'
// Suppress logger output during tests
-jest.mock('../../utils/logger', () => ({
+jest.mock('~/utils/logger', () => ({
logger: {
debug: jest.fn(),
info: jest.fn(),
@@ -16,7 +16,7 @@ jest.mock('../../utils/logger', () => ({
},
}))
-jest.mock('../../utils/posthog', () => ({
+jest.mock('~/utils/posthog', () => ({
captureException: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/pipelines/batch-retry.ts b/nodejs/src/ingestion/framework/batch-retry.ts
similarity index 94%
rename from nodejs/src/ingestion/pipelines/batch-retry.ts
rename to nodejs/src/ingestion/framework/batch-retry.ts
index 96c511f807ff..fc7be8f76578 100644
--- a/nodejs/src/ingestion/pipelines/batch-retry.ts
+++ b/nodejs/src/ingestion/framework/batch-retry.ts
@@ -1,6 +1,7 @@
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { retryIfRetriable } from '../../utils/retries'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { retryIfRetriable } from '~/utils/retries'
+
import { BatchProcessingStep } from './base-batch-pipeline'
import { pipelineRetryAttemptsHistogram } from './metrics'
import { dlq } from './results'
diff --git a/nodejs/src/ingestion/pipelines/batching-pipeline.test.ts b/nodejs/src/ingestion/framework/batching-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/batching-pipeline.test.ts
rename to nodejs/src/ingestion/framework/batching-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/batching-pipeline.ts b/nodejs/src/ingestion/framework/batching-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/batching-pipeline.ts
rename to nodejs/src/ingestion/framework/batching-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/branching-pipeline.test.ts b/nodejs/src/ingestion/framework/branching-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/branching-pipeline.test.ts
rename to nodejs/src/ingestion/framework/branching-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/branching-pipeline.ts b/nodejs/src/ingestion/framework/branching-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/branching-pipeline.ts
rename to nodejs/src/ingestion/framework/branching-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/buffering-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/buffering-batch-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/buffering-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/buffering-batch-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/buffering-batch-pipeline.ts b/nodejs/src/ingestion/framework/buffering-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/buffering-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/buffering-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/builders/batch-pipeline-builders.ts b/nodejs/src/ingestion/framework/builders/batch-pipeline-builders.ts
similarity index 87%
rename from nodejs/src/ingestion/pipelines/builders/batch-pipeline-builders.ts
rename to nodejs/src/ingestion/framework/builders/batch-pipeline-builders.ts
index f07460e29359..f770c525ee09 100644
--- a/nodejs/src/ingestion/pipelines/builders/batch-pipeline-builders.ts
+++ b/nodejs/src/ingestion/framework/builders/batch-pipeline-builders.ts
@@ -1,21 +1,25 @@
import { Message } from 'node-rdkafka'
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { IngestionWarningsOutput } from '../../common/outputs'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { BaseBatchPipeline, BatchProcessingStep } from '../base-batch-pipeline'
-import { BatchPipeline } from '../batch-pipeline.interface'
-import { BatchRetryOptions, withBatchRetry } from '../batch-retry'
-import { BufferingBatchPipeline } from '../buffering-batch-pipeline'
-import { ConcurrentBatchProcessingPipeline } from '../concurrent-batch-pipeline'
-import { ConcurrentlyGroupingBatchPipeline, GroupingFunction } from '../concurrently-grouping-batch-pipeline'
-import { FilterMapBatchPipeline, FilterMapMappingFunction } from '../filter-map-batch-pipeline'
-import { GatheringBatchPipeline } from '../gathering-batch-pipeline'
-import { IngestionWarningHandlingBatchPipeline } from '../ingestion-warning-handling-batch-pipeline'
-import { Pipeline } from '../pipeline.interface'
-import { PipelineConfig, ResultHandlingPipeline } from '../result-handling-pipeline'
-import { SequentialBatchPipeline } from '../sequential-batch-pipeline'
-import { SideEffectHandlingPipeline } from '../side-effect-handling-pipeline'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { BaseBatchPipeline, BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { BatchPipeline } from '~/ingestion/framework/batch-pipeline.interface'
+import { BatchRetryOptions, withBatchRetry } from '~/ingestion/framework/batch-retry'
+import { BufferingBatchPipeline } from '~/ingestion/framework/buffering-batch-pipeline'
+import { ConcurrentBatchProcessingPipeline } from '~/ingestion/framework/concurrent-batch-pipeline'
+import {
+ ConcurrentlyGroupingBatchPipeline,
+ GroupingFunction,
+} from '~/ingestion/framework/concurrently-grouping-batch-pipeline'
+import { FilterMapBatchPipeline, FilterMapMappingFunction } from '~/ingestion/framework/filter-map-batch-pipeline'
+import { GatheringBatchPipeline } from '~/ingestion/framework/gathering-batch-pipeline'
+import { IngestionWarningHandlingBatchPipeline } from '~/ingestion/framework/ingestion-warning-handling-batch-pipeline'
+import { Pipeline } from '~/ingestion/framework/pipeline.interface'
+import { PipelineConfig, ResultHandlingPipeline } from '~/ingestion/framework/result-handling-pipeline'
+import { SequentialBatchPipeline } from '~/ingestion/framework/sequential-batch-pipeline'
+import { SideEffectHandlingPipeline } from '~/ingestion/framework/side-effect-handling-pipeline'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { PipelineBuilder, StartPipelineBuilder } from './pipeline-builders'
/**
diff --git a/nodejs/src/ingestion/pipelines/builders/helpers.ts b/nodejs/src/ingestion/framework/builders/helpers.ts
similarity index 94%
rename from nodejs/src/ingestion/pipelines/builders/helpers.ts
rename to nodejs/src/ingestion/framework/builders/helpers.ts
index eb2c5ddecf65..ee4b4d547a76 100644
--- a/nodejs/src/ingestion/pipelines/builders/helpers.ts
+++ b/nodejs/src/ingestion/framework/builders/helpers.ts
@@ -6,8 +6,9 @@ import {
BatchingPipelineOptions,
BeforeBatchInput,
BeforeBatchOutput,
-} from '../batching-pipeline'
-import { BufferingBatchPipeline } from '../buffering-batch-pipeline'
+} from '~/ingestion/framework/batching-pipeline'
+import { BufferingBatchPipeline } from '~/ingestion/framework/buffering-batch-pipeline'
+
import { BatchPipelineBuilder } from './batch-pipeline-builders'
import { PipelineBuilder, StartPipelineBuilder } from './pipeline-builders'
diff --git a/nodejs/src/ingestion/pipelines/builders/index.ts b/nodejs/src/ingestion/framework/builders/index.ts
similarity index 84%
rename from nodejs/src/ingestion/pipelines/builders/index.ts
rename to nodejs/src/ingestion/framework/builders/index.ts
index 51e38896330e..cfd02403849f 100644
--- a/nodejs/src/ingestion/pipelines/builders/index.ts
+++ b/nodejs/src/ingestion/framework/builders/index.ts
@@ -5,6 +5,6 @@ export {
MessageAwareBatchPipelineBuilder,
TeamAwareBatchPipelineBuilder,
} from './batch-pipeline-builders'
-export type { BatchRetryOptions } from '../batch-retry'
+export type { BatchRetryOptions } from '~/ingestion/framework/batch-retry'
export { BranchingPipelineBuilder, PipelineBuilder, StartPipelineBuilder } from './pipeline-builders'
export { newBatchPipelineBuilder, newBatchingPipeline, newPipelineBuilder } from './helpers'
diff --git a/nodejs/src/ingestion/pipelines/builders/pipeline-builders.ts b/nodejs/src/ingestion/framework/builders/pipeline-builders.ts
similarity index 90%
rename from nodejs/src/ingestion/pipelines/builders/pipeline-builders.ts
rename to nodejs/src/ingestion/framework/builders/pipeline-builders.ts
index 3d010a36bfc7..129fd6b84371 100644
--- a/nodejs/src/ingestion/pipelines/builders/pipeline-builders.ts
+++ b/nodejs/src/ingestion/framework/builders/pipeline-builders.ts
@@ -1,9 +1,9 @@
-import { BranchDecisionFn, BranchingPipeline } from '../branching-pipeline'
-import { Pipeline } from '../pipeline.interface'
-import { RetryingPipeline, RetryingPipelineOptions } from '../retrying-pipeline'
-import { StartPipeline } from '../start-pipeline'
-import { StepPipeline } from '../step-pipeline'
-import { ProcessingStep } from '../steps'
+import { BranchDecisionFn, BranchingPipeline } from '~/ingestion/framework/branching-pipeline'
+import { Pipeline } from '~/ingestion/framework/pipeline.interface'
+import { RetryingPipeline, RetryingPipelineOptions } from '~/ingestion/framework/retrying-pipeline'
+import { StartPipeline } from '~/ingestion/framework/start-pipeline'
+import { StepPipeline } from '~/ingestion/framework/step-pipeline'
+import { ProcessingStep } from '~/ingestion/framework/steps'
export class StartPipelineBuilder<T, C> {
pipe<U, R extends string = never>(step: ProcessingStep<T, U, R>): PipelineBuilder<T, U, C, R> {
diff --git a/nodejs/src/ingestion/pipelines/concurrent-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/concurrent-batch-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/concurrent-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/concurrent-batch-pipeline.test.ts
index 4e6617ceaf80..710535089d50 100644
--- a/nodejs/src/ingestion/pipelines/concurrent-batch-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/concurrent-batch-pipeline.test.ts
@@ -1,6 +1,7 @@
import { Message } from 'node-rdkafka'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+
import { ConcurrentBatchProcessingPipeline } from './concurrent-batch-pipeline'
import { createContext, createNewBatchPipeline, createNewPipeline, createOkContext } from './helpers'
import { dlq, drop, ok } from './results'
diff --git a/nodejs/src/ingestion/pipelines/concurrent-batch-pipeline.ts b/nodejs/src/ingestion/framework/concurrent-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/concurrent-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/concurrent-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/concurrently-grouping-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/concurrently-grouping-batch-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/concurrently-grouping-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/concurrently-grouping-batch-pipeline.test.ts
index 9a3c04bbb8db..36178efc43b2 100644
--- a/nodejs/src/ingestion/pipelines/concurrently-grouping-batch-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/concurrently-grouping-batch-pipeline.test.ts
@@ -1,7 +1,8 @@
import { Message } from 'node-rdkafka'
-import { createTestMessage } from '../../../tests/helpers/kafka-message'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+
import { ConcurrentlyGroupingBatchPipeline } from './concurrently-grouping-batch-pipeline'
import { createContext, createNewBatchPipeline, createNewPipeline, createOkContext } from './helpers'
import { PipelineResultWithContext } from './pipeline.interface'
diff --git a/nodejs/src/ingestion/pipelines/concurrently-grouping-batch-pipeline.ts b/nodejs/src/ingestion/framework/concurrently-grouping-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/concurrently-grouping-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/concurrently-grouping-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/docs/01-introduction.test.ts b/nodejs/src/ingestion/framework/docs/01-introduction.test.ts
similarity index 98%
rename from nodejs/src/ingestion/pipelines/docs/01-introduction.test.ts
rename to nodejs/src/ingestion/framework/docs/01-introduction.test.ts
index 2343b24a77d9..212922a1df8f 100644
--- a/nodejs/src/ingestion/pipelines/docs/01-introduction.test.ts
+++ b/nodejs/src/ingestion/framework/docs/01-introduction.test.ts
@@ -26,10 +26,10 @@
* }
* ```
*/
-import { newBatchPipelineBuilder, newPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineResult, dlq, drop, isOkResult, ok, redirect } from '../results'
-import { ProcessingStep } from '../steps'
+import { newBatchPipelineBuilder, newPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineResult, dlq, drop, isOkResult, ok, redirect } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
/**
* Type for batch processing steps - takes an array of values and returns
diff --git a/nodejs/src/ingestion/pipelines/docs/02-batch-pipelines.test.ts b/nodejs/src/ingestion/framework/docs/02-batch-pipelines.test.ts
similarity index 96%
rename from nodejs/src/ingestion/pipelines/docs/02-batch-pipelines.test.ts
rename to nodejs/src/ingestion/framework/docs/02-batch-pipelines.test.ts
index bebb95a8ad6b..85a602aec38b 100644
--- a/nodejs/src/ingestion/pipelines/docs/02-batch-pipelines.test.ts
+++ b/nodejs/src/ingestion/framework/docs/02-batch-pipelines.test.ts
@@ -17,9 +17,9 @@
* - External API calls with batch endpoints
* - Bulk writes (batch INSERT)
*/
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineResult, dlq, isOkResult, ok } from '../results'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineResult, dlq, isOkResult, ok } from '~/ingestion/framework/results'
/**
* Type for batch processing steps - takes an array of values and returns
diff --git a/nodejs/src/ingestion/pipelines/docs/03-concurrent-processing.test.ts b/nodejs/src/ingestion/framework/docs/03-concurrent-processing.test.ts
similarity index 94%
rename from nodejs/src/ingestion/pipelines/docs/03-concurrent-processing.test.ts
rename to nodejs/src/ingestion/framework/docs/03-concurrent-processing.test.ts
index 03a2126014ea..9572d78b4e0a 100644
--- a/nodejs/src/ingestion/pipelines/docs/03-concurrent-processing.test.ts
+++ b/nodejs/src/ingestion/framework/docs/03-concurrent-processing.test.ts
@@ -19,10 +19,11 @@
* - **Order**: Results maintain input order (but returned one by one)
* - **Resources**: More concurrent connections/requests (unbounded)
*/
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+
import { consumeAll } from './helpers'
describe('Concurrent Processing', () => {
diff --git a/nodejs/src/ingestion/pipelines/docs/04-sequential-processing.test.ts b/nodejs/src/ingestion/framework/docs/04-sequential-processing.test.ts
similarity index 94%
rename from nodejs/src/ingestion/pipelines/docs/04-sequential-processing.test.ts
rename to nodejs/src/ingestion/framework/docs/04-sequential-processing.test.ts
index dadee6208802..457453110ed8 100644
--- a/nodejs/src/ingestion/pipelines/docs/04-sequential-processing.test.ts
+++ b/nodejs/src/ingestion/framework/docs/04-sequential-processing.test.ts
@@ -20,10 +20,11 @@
* - **Resources**: Minimal concurrent connections
* - **Batching**: Results returned together (not streamed)
*/
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+
import { consumeAll } from './helpers'
describe('Sequential Processing', () => {
diff --git a/nodejs/src/ingestion/pipelines/docs/05-grouping.test.ts b/nodejs/src/ingestion/framework/docs/05-grouping.test.ts
similarity index 98%
rename from nodejs/src/ingestion/pipelines/docs/05-grouping.test.ts
rename to nodejs/src/ingestion/framework/docs/05-grouping.test.ts
index e1bde74021cc..51b2517e489d 100644
--- a/nodejs/src/ingestion/pipelines/docs/05-grouping.test.ts
+++ b/nodejs/src/ingestion/framework/docs/05-grouping.test.ts
@@ -32,10 +32,11 @@
* - Team-scoped processing: Teams can be processed in parallel
* - User event ordering: Events for the same user maintain order
*/
-import { GroupProcessingBuilder, newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { GroupProcessingBuilder, newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+
import { consumeAll } from './helpers'
interface Event {
diff --git a/nodejs/src/ingestion/pipelines/docs/06-gathering.test.ts b/nodejs/src/ingestion/framework/docs/06-gathering.test.ts
similarity index 96%
rename from nodejs/src/ingestion/pipelines/docs/06-gathering.test.ts
rename to nodejs/src/ingestion/framework/docs/06-gathering.test.ts
index 1923ae39cb6e..bfd28ed52c01 100644
--- a/nodejs/src/ingestion/pipelines/docs/06-gathering.test.ts
+++ b/nodejs/src/ingestion/framework/docs/06-gathering.test.ts
@@ -18,10 +18,11 @@
*
* With gather(), all results are collected and returned in a single batch.
*/
-import { GroupProcessingBuilder, newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { GroupProcessingBuilder, newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+
import { collectBatches } from './helpers'
interface Event {
diff --git a/nodejs/src/ingestion/pipelines/docs/07-result-handling.test.ts b/nodejs/src/ingestion/framework/docs/07-result-handling.test.ts
similarity index 95%
rename from nodejs/src/ingestion/pipelines/docs/07-result-handling.test.ts
rename to nodejs/src/ingestion/framework/docs/07-result-handling.test.ts
index 6330747276f1..64539818a806 100644
--- a/nodejs/src/ingestion/pipelines/docs/07-result-handling.test.ts
+++ b/nodejs/src/ingestion/framework/docs/07-result-handling.test.ts
@@ -52,13 +52,22 @@
*/
import { Message } from 'node-rdkafka'
-import { createTestMessage } from '../../../../tests/helpers/kafka-message'
-import { createMockIngestionOutputs } from '../../../../tests/helpers/mock-ingestion-outputs'
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '../../common/outputs'
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineResult, dlq, drop, isDlqResult, isDropResult, isRedirectResult, ok, redirect } from '../results'
+import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '~/common/outputs'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import {
+ PipelineResult,
+ dlq,
+ drop,
+ isDlqResult,
+ isDropResult,
+ isRedirectResult,
+ ok,
+ redirect,
+} from '~/ingestion/framework/results'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
type BatchProcessingStep<T, U, R extends string = never> = (values: T[]) => Promise<PipelineResult<U, R>[]>
diff --git a/nodejs/src/ingestion/pipelines/docs/08-side-effects.test.ts b/nodejs/src/ingestion/framework/docs/08-side-effects.test.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/docs/08-side-effects.test.ts
rename to nodejs/src/ingestion/framework/docs/08-side-effects.test.ts
index 657d72cd35e6..40e027e4d8a4 100644
--- a/nodejs/src/ingestion/pipelines/docs/08-side-effects.test.ts
+++ b/nodejs/src/ingestion/framework/docs/08-side-effects.test.ts
@@ -25,11 +25,11 @@
* - **Decoupling**: Main processing doesn't depend on side effect success
* - **Batching**: Side effects can be batched for efficiency
*/
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { newBatchPipelineBuilder, newPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineResult, isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { newBatchPipelineBuilder, newPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
type BatchProcessingStep<T, U> = (values: T[]) => Promise<PipelineResult<U>[]>
diff --git a/nodejs/src/ingestion/pipelines/docs/09-ingestion-warnings.test.ts b/nodejs/src/ingestion/framework/docs/09-ingestion-warnings.test.ts
similarity index 96%
rename from nodejs/src/ingestion/pipelines/docs/09-ingestion-warnings.test.ts
rename to nodejs/src/ingestion/framework/docs/09-ingestion-warnings.test.ts
index 615e0df261be..926e116573a7 100644
--- a/nodejs/src/ingestion/pipelines/docs/09-ingestion-warnings.test.ts
+++ b/nodejs/src/ingestion/framework/docs/09-ingestion-warnings.test.ts
@@ -43,15 +43,15 @@
* ignored and never sent to Kafka. Always ensure `handleIngestionWarnings()`
* is called within a `teamAware()` block to process warnings.
*/
-import { createMockIngestionOutputs } from '../../../../tests/helpers/mock-ingestion-outputs'
-import { createTestTeam } from '../../../../tests/helpers/team'
-import { Team } from '../../../types'
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { IngestionWarningsOutput } from '../../common/outputs'
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineWarning } from '../pipeline.interface'
-import { PipelineResult, isOkResult, ok } from '../results'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { createTestTeam } from '~/tests/helpers/team'
+import { Team } from '~/types'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
type BatchProcessingStep<T, U> = (values: T[]) => Promise<PipelineResult<U>[]>
diff --git a/nodejs/src/ingestion/pipelines/docs/10-branching.test.ts b/nodejs/src/ingestion/framework/docs/10-branching.test.ts
similarity index 95%
rename from nodejs/src/ingestion/pipelines/docs/10-branching.test.ts
rename to nodejs/src/ingestion/framework/docs/10-branching.test.ts
index 968d0b41f9e2..6459e094310f 100644
--- a/nodejs/src/ingestion/pipelines/docs/10-branching.test.ts
+++ b/nodejs/src/ingestion/framework/docs/10-branching.test.ts
@@ -18,10 +18,10 @@
* - Priority handling: High-priority items get special processing
* - Feature flags: Route to different implementations
*/
-import { newPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { isDlqResult, isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { newPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { isDlqResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
type Event = {
type: 'pageview' | 'click' | 'custom'
diff --git a/nodejs/src/ingestion/pipelines/docs/11-retries.test.ts b/nodejs/src/ingestion/framework/docs/11-retries.test.ts
similarity index 98%
rename from nodejs/src/ingestion/pipelines/docs/11-retries.test.ts
rename to nodejs/src/ingestion/framework/docs/11-retries.test.ts
index d41c465cf26f..81927d93d2af 100644
--- a/nodejs/src/ingestion/pipelines/docs/11-retries.test.ts
+++ b/nodejs/src/ingestion/framework/docs/11-retries.test.ts
@@ -19,10 +19,10 @@
* - Transient failures (network, timeout) - should retry
* - Permanent failures (validation, permission) - should not retry
*/
-import { newPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { isDlqResult, isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { newPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { isDlqResult, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
class RetriableError extends Error {
isRetriable = true
diff --git a/nodejs/src/ingestion/pipelines/docs/12-filter-map.test.ts b/nodejs/src/ingestion/framework/docs/12-filter-map.test.ts
similarity index 91%
rename from nodejs/src/ingestion/pipelines/docs/12-filter-map.test.ts
rename to nodejs/src/ingestion/framework/docs/12-filter-map.test.ts
index 692392b6b5ec..4e8b8097cafa 100644
--- a/nodejs/src/ingestion/pipelines/docs/12-filter-map.test.ts
+++ b/nodejs/src/ingestion/framework/docs/12-filter-map.test.ts
@@ -18,16 +18,16 @@
*/
import { Message } from 'node-rdkafka'
-import { createTestMessage } from '../../../../tests/helpers/kafka-message'
-import { createMockIngestionOutputs } from '../../../../tests/helpers/mock-ingestion-outputs'
-import { createTestTeam } from '../../../../tests/helpers/team'
-import { Team } from '../../../types'
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput, OVERFLOW_OUTPUT } from '../../common/outputs'
-import { newBatchPipelineBuilder } from '../builders'
-import { createOkContext } from '../helpers'
-import { PipelineWarning } from '../pipeline.interface'
-import { PipelineResult, dlq, isOkResult, ok, redirect } from '../results'
+import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput, OVERFLOW_OUTPUT } from '~/common/outputs'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, dlq, isOkResult, ok, redirect } from '~/ingestion/framework/results'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { createTestTeam } from '~/tests/helpers/team'
+import { Team } from '~/types'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
type BatchProcessingStep<T, U, R extends string = never> = (values: T[]) => Promise<PipelineResult<U, R>[]>
diff --git a/nodejs/src/ingestion/pipelines/docs/13-conventions.test.ts b/nodejs/src/ingestion/framework/docs/13-conventions.test.ts
similarity index 95%
rename from nodejs/src/ingestion/pipelines/docs/13-conventions.test.ts
rename to nodejs/src/ingestion/framework/docs/13-conventions.test.ts
index f694f5c2d736..0035bd4e65d8 100644
--- a/nodejs/src/ingestion/pipelines/docs/13-conventions.test.ts
+++ b/nodejs/src/ingestion/framework/docs/13-conventions.test.ts
@@ -31,19 +31,19 @@
*/
import { Message } from 'node-rdkafka'
-import { createTestMessage } from '../../../../tests/helpers/kafka-message'
-import { createMockIngestionOutputs } from '../../../../tests/helpers/mock-ingestion-outputs'
-import { createTestTeam } from '../../../../tests/helpers/team'
-import { Team } from '../../../types'
-import { parseJSON } from '../../../utils/json-parse'
-import { PromiseScheduler } from '../../../utils/promise-scheduler'
-import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput, OVERFLOW_OUTPUT } from '../../common/outputs'
-import { newBatchPipelineBuilder, newPipelineBuilder } from '../builders'
-import { PipelineBuilder, StartPipelineBuilder } from '../builders/pipeline-builders'
-import { createOkContext } from '../helpers'
-import { PipelineConfig } from '../result-handling-pipeline'
-import { dlq, isOkResult, ok } from '../results'
-import { ProcessingStep } from '../steps'
+import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, IngestionWarningsOutput, OVERFLOW_OUTPUT } from '~/common/outputs'
+import { newBatchPipelineBuilder, newPipelineBuilder } from '~/ingestion/framework/builders'
+import { PipelineBuilder, StartPipelineBuilder } from '~/ingestion/framework/builders/pipeline-builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { dlq, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { createTestTeam } from '~/tests/helpers/team'
+import { Team } from '~/types'
+import { parseJSON } from '~/utils/json-parse'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
describe('Factory Functions', () => {
/**
diff --git a/nodejs/src/ingestion/pipelines/docs/helpers.ts b/nodejs/src/ingestion/framework/docs/helpers.ts
similarity index 93%
rename from nodejs/src/ingestion/pipelines/docs/helpers.ts
rename to nodejs/src/ingestion/framework/docs/helpers.ts
index 0afcb815519c..3751760b30f5 100644
--- a/nodejs/src/ingestion/pipelines/docs/helpers.ts
+++ b/nodejs/src/ingestion/framework/docs/helpers.ts
@@ -1,5 +1,5 @@
-import { BatchPipeline } from '../batch-pipeline.interface'
-import { isOkResult } from '../results'
+import { BatchPipeline } from '~/ingestion/framework/batch-pipeline.interface'
+import { isOkResult } from '~/ingestion/framework/results'
/**
* Consumes all results from a batch pipeline, advancing fake timers as needed.
diff --git a/nodejs/src/ingestion/pipelines/extensions/helpers.ts b/nodejs/src/ingestion/framework/extensions/helpers.ts
similarity index 74%
rename from nodejs/src/ingestion/pipelines/extensions/helpers.ts
rename to nodejs/src/ingestion/framework/extensions/helpers.ts
index ac99216ca6d1..af3ce076e5d9 100644
--- a/nodejs/src/ingestion/pipelines/extensions/helpers.ts
+++ b/nodejs/src/ingestion/framework/extensions/helpers.ts
@@ -1,5 +1,5 @@
-import type { PipelineResult } from '../results'
-import type { ProcessingStep } from '../steps'
+import type { PipelineResult } from '~/ingestion/framework/results'
+import type { ProcessingStep } from '~/ingestion/framework/steps'
export function wrapStep<T, U, R extends string = never>(
step: ProcessingStep<T, U, R>,
diff --git a/nodejs/src/ingestion/pipelines/extensions/tophog.test.ts b/nodejs/src/ingestion/framework/extensions/tophog.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/extensions/tophog.test.ts
rename to nodejs/src/ingestion/framework/extensions/tophog.test.ts
index adb1261dde85..420a2946269a 100644
--- a/nodejs/src/ingestion/pipelines/extensions/tophog.test.ts
+++ b/nodejs/src/ingestion/framework/extensions/tophog.test.ts
@@ -1,6 +1,7 @@
-import { newPipelineBuilder } from '../builders/helpers'
-import { createOkContext } from '../helpers'
-import { PipelineResult, dlq, isOkResult, ok } from '../results'
+import { newPipelineBuilder } from '~/ingestion/framework/builders/helpers'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineResult, dlq, isOkResult, ok } from '~/ingestion/framework/results'
+
import {
TopHogRegistry,
average,
diff --git a/nodejs/src/ingestion/pipelines/extensions/tophog.ts b/nodejs/src/ingestion/framework/extensions/tophog.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/extensions/tophog.ts
rename to nodejs/src/ingestion/framework/extensions/tophog.ts
index 2c4b24500214..373b8c8b119b 100644
--- a/nodejs/src/ingestion/pipelines/extensions/tophog.ts
+++ b/nodejs/src/ingestion/framework/extensions/tophog.ts
@@ -1,6 +1,7 @@
-import { MetricConfig } from '../../tophog/tophog'
-import { PipelineResult, isOkResult } from '../results'
-import type { ProcessingStep } from '../steps'
+import { PipelineResult, isOkResult } from '~/ingestion/framework/results'
+import type { ProcessingStep } from '~/ingestion/framework/steps'
+import { MetricConfig } from '~/ingestion/framework/tophog/tophog'
+
import { wrapStep } from './helpers'
type Recorder = { record(key: Record<string, string>, value: number): void }
diff --git a/nodejs/src/ingestion/pipelines/filter-map-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/filter-map-batch-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/filter-map-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/filter-map-batch-pipeline.test.ts
index 935b909f98af..ef15ae1897a3 100644
--- a/nodejs/src/ingestion/pipelines/filter-map-batch-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/filter-map-batch-pipeline.test.ts
@@ -1,7 +1,8 @@
import { Message } from 'node-rdkafka'
-import { createTestMessage } from '../../../tests/helpers/kafka-message'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+
import { BatchPipelineResultWithContext } from './batch-pipeline.interface'
import { FilterMapBatchPipeline, FilterMapMappingFunction } from './filter-map-batch-pipeline'
import { createContext, createNewBatchPipeline, createOkContext } from './helpers'
diff --git a/nodejs/src/ingestion/pipelines/filter-map-batch-pipeline.ts b/nodejs/src/ingestion/framework/filter-map-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/filter-map-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/filter-map-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/gathering-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/gathering-batch-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/gathering-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/gathering-batch-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/gathering-batch-pipeline.ts b/nodejs/src/ingestion/framework/gathering-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/gathering-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/gathering-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/helpers.ts b/nodejs/src/ingestion/framework/helpers.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/helpers.ts
rename to nodejs/src/ingestion/framework/helpers.ts
diff --git a/nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts
index 5c443a542a62..bb1423c03142 100644
--- a/nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.test.ts
@@ -1,15 +1,16 @@
import { Message } from 'node-rdkafka'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { Team } from '../../types'
-import * as ingestionWarnings from '../common/ingestion-warnings'
-import { IngestionWarningsOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import * as ingestionWarnings from '~/ingestion/common/ingestion-warnings'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { Team } from '~/types'
+
import { createContext, createNewBatchPipeline, createOkContext } from './helpers'
import { IngestionWarningHandlingBatchPipeline } from './ingestion-warning-handling-batch-pipeline'
import { ok } from './results'
-jest.mock('../common/ingestion-warnings')
+jest.mock('~/ingestion/common/ingestion-warnings')
function createTestMessage(overrides: Partial<Message> = {}): Message {
return {
diff --git a/nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.ts b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts
similarity index 90%
rename from nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts
index ff6bbd8599a9..f11a53104bd6 100644
--- a/nodejs/src/ingestion/pipelines/ingestion-warning-handling-batch-pipeline.ts
+++ b/nodejs/src/ingestion/framework/ingestion-warning-handling-batch-pipeline.ts
@@ -1,6 +1,7 @@
-import { emitIngestionWarning } from '../common/ingestion-warnings'
-import { IngestionWarningsOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { emitIngestionWarning } from '~/ingestion/common/ingestion-warnings'
+
import { BatchPipeline, BatchPipelineResultWithContext, OkResultWithContext } from './batch-pipeline.interface'
import { TeamIdContext } from './builders/batch-pipeline-builders'
diff --git a/nodejs/src/ingestion/pipelines/interleaving-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/interleaving-batch-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/interleaving-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/interleaving-batch-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/interleaving-batch-pipeline.ts b/nodejs/src/ingestion/framework/interleaving-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/interleaving-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/interleaving-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/metrics.test-utils.ts b/nodejs/src/ingestion/framework/metrics.test-utils.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/metrics.test-utils.ts
rename to nodejs/src/ingestion/framework/metrics.test-utils.ts
diff --git a/nodejs/src/ingestion/pipelines/metrics.ts b/nodejs/src/ingestion/framework/metrics.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/metrics.ts
rename to nodejs/src/ingestion/framework/metrics.ts
diff --git a/nodejs/src/ingestion/pipelines/pipeline.interface.ts b/nodejs/src/ingestion/framework/pipeline.interface.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/pipeline.interface.ts
rename to nodejs/src/ingestion/framework/pipeline.interface.ts
diff --git a/nodejs/src/ingestion/pipelines/resettable-signal.test.ts b/nodejs/src/ingestion/framework/resettable-signal.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/resettable-signal.test.ts
rename to nodejs/src/ingestion/framework/resettable-signal.test.ts
diff --git a/nodejs/src/ingestion/pipelines/resettable-signal.ts b/nodejs/src/ingestion/framework/resettable-signal.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/resettable-signal.ts
rename to nodejs/src/ingestion/framework/resettable-signal.ts
diff --git a/nodejs/src/ingestion/pipelines/result-handling-pipeline.test.ts b/nodejs/src/ingestion/framework/result-handling-pipeline.test.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/result-handling-pipeline.test.ts
rename to nodejs/src/ingestion/framework/result-handling-pipeline.test.ts
index eb39ca90b87e..ee936d26e2f3 100644
--- a/nodejs/src/ingestion/pipelines/result-handling-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/result-handling-pipeline.test.ts
@@ -1,29 +1,26 @@
import { Message } from 'node-rdkafka'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { ingestionPipelineResultCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import {
- logDroppedMessage,
- produceMessageToDLQ,
- redirectMessageToOutput,
-} from '../../worker/ingestion/pipeline-helpers'
-import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '../common/outputs'
-import { OverflowOutput } from '../common/outputs'
+import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '~/common/outputs'
+import { OverflowOutput } from '~/common/outputs'
+import { ingestionPipelineResultCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { logDroppedMessage, produceMessageToDLQ, redirectMessageToOutput } from '~/ingestion/common/pipeline-helpers'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { createContext } from './helpers'
import { PipelineConfig, ResultHandlingPipeline } from './result-handling-pipeline'
import { dlq, drop, ok, redirect } from './results'
// Mock the pipeline helpers
-jest.mock('../../worker/ingestion/pipeline-helpers', () => ({
+jest.mock('~/ingestion/common/pipeline-helpers', () => ({
logDroppedMessage: jest.fn(),
redirectMessageToOutput: jest.fn(),
produceMessageToDLQ: jest.fn(),
}))
// Mock the metrics
-jest.mock('../../worker/ingestion/event-pipeline/metrics', () => ({
+jest.mock('~/ingestion/common/event-pipeline/metrics', () => ({
ingestionPipelineResultCounter: {
labels: jest.fn().mockReturnValue({
inc: jest.fn(),
diff --git a/nodejs/src/ingestion/pipelines/result-handling-pipeline.ts b/nodejs/src/ingestion/framework/result-handling-pipeline.ts
similarity index 91%
rename from nodejs/src/ingestion/pipelines/result-handling-pipeline.ts
rename to nodejs/src/ingestion/framework/result-handling-pipeline.ts
index 78f823152c55..9f7904db0cfa 100644
--- a/nodejs/src/ingestion/pipelines/result-handling-pipeline.ts
+++ b/nodejs/src/ingestion/framework/result-handling-pipeline.ts
@@ -1,14 +1,11 @@
import { Message } from 'node-rdkafka'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { ingestionPipelineResultCounter } from '../../worker/ingestion/event-pipeline/metrics'
-import {
- logDroppedMessage,
- produceMessageToDLQ,
- redirectMessageToOutput,
-} from '../../worker/ingestion/pipeline-helpers'
-import { DlqOutput, IngestionWarningsOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
+import { DlqOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { ingestionPipelineResultCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { logDroppedMessage, produceMessageToDLQ, redirectMessageToOutput } from '~/ingestion/common/pipeline-helpers'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { BatchPipeline, BatchPipelineResultWithContext, OkResultWithContext } from './batch-pipeline.interface'
import {
PipelineResult,
diff --git a/nodejs/src/ingestion/pipelines/results.ts b/nodejs/src/ingestion/framework/results.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/results.ts
rename to nodejs/src/ingestion/framework/results.ts
diff --git a/nodejs/src/ingestion/pipelines/retrying-pipeline.test.ts b/nodejs/src/ingestion/framework/retrying-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/retrying-pipeline.test.ts
rename to nodejs/src/ingestion/framework/retrying-pipeline.test.ts
index 2ef5db83edf2..16afc47b9f71 100644
--- a/nodejs/src/ingestion/pipelines/retrying-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/retrying-pipeline.test.ts
@@ -1,6 +1,7 @@
import { Message } from 'node-rdkafka'
-import { captureException } from '../../utils/posthog'
+import { captureException } from '~/utils/posthog'
+
import { createContext, createNewPipeline, createOkContext } from './helpers'
import { pipelineRetryAttemptsHistogram } from './metrics'
import { getRetryAttempts } from './metrics.test-utils'
@@ -9,7 +10,7 @@ import { RetryingPipeline, RetryingPipelineOptions } from './retrying-pipeline'
jest.setTimeout(1000)
-jest.mock('../../utils/posthog', () => ({
+jest.mock('~/utils/posthog', () => ({
captureException: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/pipelines/retrying-pipeline.ts b/nodejs/src/ingestion/framework/retrying-pipeline.ts
similarity index 93%
rename from nodejs/src/ingestion/pipelines/retrying-pipeline.ts
rename to nodejs/src/ingestion/framework/retrying-pipeline.ts
index b910b3373fc5..c6ace549c359 100644
--- a/nodejs/src/ingestion/pipelines/retrying-pipeline.ts
+++ b/nodejs/src/ingestion/framework/retrying-pipeline.ts
@@ -1,6 +1,7 @@
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { retryIfRetriable } from '../../utils/retries'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { retryIfRetriable } from '~/utils/retries'
+
import { pipelineRetryAttemptsHistogram } from './metrics'
import { OkResultWithContext, Pipeline, PipelineResultWithContext } from './pipeline.interface'
import { dlq } from './results'
diff --git a/nodejs/src/ingestion/pipelines/sequential-batch-pipeline.test.ts b/nodejs/src/ingestion/framework/sequential-batch-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/sequential-batch-pipeline.test.ts
rename to nodejs/src/ingestion/framework/sequential-batch-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/sequential-batch-pipeline.ts b/nodejs/src/ingestion/framework/sequential-batch-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/sequential-batch-pipeline.ts
rename to nodejs/src/ingestion/framework/sequential-batch-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/side-effect-handling-pipeline.test.ts b/nodejs/src/ingestion/framework/side-effect-handling-pipeline.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/side-effect-handling-pipeline.test.ts
rename to nodejs/src/ingestion/framework/side-effect-handling-pipeline.test.ts
index 6cf34202e051..620df81c80a3 100644
--- a/nodejs/src/ingestion/pipelines/side-effect-handling-pipeline.test.ts
+++ b/nodejs/src/ingestion/framework/side-effect-handling-pipeline.test.ts
@@ -1,6 +1,7 @@
import { Message } from 'node-rdkafka'
-import { createMockPipeline } from '../../../tests/helpers/mock-pipeline'
+import { createMockPipeline } from '~/tests/helpers/mock-pipeline'
+
import { createBatch, createContext, createNewBatchPipeline, createOkContext } from './helpers'
import { sideEffectResultCounter } from './metrics'
import { dlq, drop, ok } from './results'
diff --git a/nodejs/src/ingestion/pipelines/side-effect-handling-pipeline.ts b/nodejs/src/ingestion/framework/side-effect-handling-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/side-effect-handling-pipeline.ts
rename to nodejs/src/ingestion/framework/side-effect-handling-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/start-pipeline.test.ts b/nodejs/src/ingestion/framework/start-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/start-pipeline.test.ts
rename to nodejs/src/ingestion/framework/start-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/start-pipeline.ts b/nodejs/src/ingestion/framework/start-pipeline.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/start-pipeline.ts
rename to nodejs/src/ingestion/framework/start-pipeline.ts
diff --git a/nodejs/src/ingestion/pipelines/step-pipeline.test.ts b/nodejs/src/ingestion/framework/step-pipeline.test.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/step-pipeline.test.ts
rename to nodejs/src/ingestion/framework/step-pipeline.test.ts
diff --git a/nodejs/src/ingestion/pipelines/step-pipeline.ts b/nodejs/src/ingestion/framework/step-pipeline.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/step-pipeline.ts
rename to nodejs/src/ingestion/framework/step-pipeline.ts
index c0de2c76ba4f..39d5b8b07c88 100644
--- a/nodejs/src/ingestion/pipelines/step-pipeline.ts
+++ b/nodejs/src/ingestion/framework/step-pipeline.ts
@@ -1,4 +1,5 @@
-import { instrumentFn } from '../../common/tracing/tracing-utils'
+import { instrumentFn } from '~/common/tracing/tracing-utils'
+
import { pipelineStepDurationHistogram } from './metrics'
import { OkResultWithContext, Pipeline, PipelineResultWithContext } from './pipeline.interface'
import { PipelineResult, PipelineResultType, isOkResult } from './results'
diff --git a/nodejs/src/ingestion/pipelines/steps.ts b/nodejs/src/ingestion/framework/steps.ts
similarity index 100%
rename from nodejs/src/ingestion/pipelines/steps.ts
rename to nodejs/src/ingestion/framework/steps.ts
diff --git a/nodejs/src/ingestion/tophog/README.md b/nodejs/src/ingestion/framework/tophog/README.md
similarity index 100%
rename from nodejs/src/ingestion/tophog/README.md
rename to nodejs/src/ingestion/framework/tophog/README.md
diff --git a/nodejs/src/ingestion/tophog/index.ts b/nodejs/src/ingestion/framework/tophog/index.ts
similarity index 100%
rename from nodejs/src/ingestion/tophog/index.ts
rename to nodejs/src/ingestion/framework/tophog/index.ts
diff --git a/nodejs/src/ingestion/tophog/metric-tracker.test.ts b/nodejs/src/ingestion/framework/tophog/metric-tracker.test.ts
similarity index 100%
rename from nodejs/src/ingestion/tophog/metric-tracker.test.ts
rename to nodejs/src/ingestion/framework/tophog/metric-tracker.test.ts
diff --git a/nodejs/src/ingestion/tophog/metric-tracker.ts b/nodejs/src/ingestion/framework/tophog/metric-tracker.ts
similarity index 98%
rename from nodejs/src/ingestion/tophog/metric-tracker.ts
rename to nodejs/src/ingestion/framework/tophog/metric-tracker.ts
index 2dd7c07983f0..d07739cd220f 100644
--- a/nodejs/src/ingestion/tophog/metric-tracker.ts
+++ b/nodejs/src/ingestion/framework/tophog/metric-tracker.ts
@@ -1,4 +1,4 @@
-import { parseJSON } from '../../utils/json-parse'
+import { parseJSON } from '~/utils/json-parse'
export interface Tracker {
readonly metricName: string
diff --git a/nodejs/src/ingestion/tophog/tophog.test.ts b/nodejs/src/ingestion/framework/tophog/tophog.test.ts
similarity index 98%
rename from nodejs/src/ingestion/tophog/tophog.test.ts
rename to nodejs/src/ingestion/framework/tophog/tophog.test.ts
index 79d8b2a77e74..f8826f58e5e2 100644
--- a/nodejs/src/ingestion/tophog/tophog.test.ts
+++ b/nodejs/src/ingestion/framework/tophog/tophog.test.ts
@@ -1,6 +1,7 @@
-import { parseJSON } from '../../utils/json-parse'
-import { TOPHOG_OUTPUT, TophogOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
+import { TOPHOG_OUTPUT, TophogOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { parseJSON } from '~/utils/json-parse'
+
import { TopHog, TopHogOptionalConfig, TopHogRequiredConfig } from './tophog'
describe('TopHog', () => {
diff --git a/nodejs/src/ingestion/tophog/tophog.ts b/nodejs/src/ingestion/framework/tophog/tophog.ts
similarity index 96%
rename from nodejs/src/ingestion/tophog/tophog.ts
rename to nodejs/src/ingestion/framework/tophog/tophog.ts
index 31ca101a11c6..4d7227faa75b 100644
--- a/nodejs/src/ingestion/tophog/tophog.ts
+++ b/nodejs/src/ingestion/framework/tophog/tophog.ts
@@ -1,6 +1,7 @@
-import { logger } from '../../utils/logger'
-import { TOPHOG_OUTPUT, TophogOutput } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
+import { TOPHOG_OUTPUT, TophogOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { logger } from '~/utils/logger'
+
import { AverageMetricTracker, MaxMetricTracker, SummingMetricTracker, Tracker } from './metric-tracker'
export interface MetricConfig {
diff --git a/nodejs/src/ingestion/ingestion-consumer.test.ts b/nodejs/src/ingestion/ingestion-consumer.test.ts
index c6be1280ad2d..41ffda60952c 100644
--- a/nodejs/src/ingestion/ingestion-consumer.test.ts
+++ b/nodejs/src/ingestion/ingestion-consumer.test.ts
@@ -6,31 +6,35 @@ import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
import { insertHogFunction as _insertHogFunction } from '~/cdp/_tests/fixtures'
+import { HogTransformerService, createHogTransformerService } from '~/cdp/hog-transformations/hog-transformer.service'
import { template as geoipTemplate } from '~/cdp/templates/_transformations/geoip/geoip.template'
import { compileHog } from '~/cdp/templates/compiler'
-import { COOKIELESS_MODE_FLAG_PROPERTY, COOKIELESS_SENTINEL_VALUE } from '~/ingestion/cookieless/cookieless-manager'
+import { HogFunctionType } from '~/cdp/types'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import {
+ COOKIELESS_MODE_FLAG_PROPERTY,
+ COOKIELESS_SENTINEL_VALUE,
+} from '~/ingestion/common/cookieless/cookieless-manager'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import { createTestIngestionOutputs, createTestMonitoringOutputs } from '~/tests/helpers/ingestion-outputs'
import { forSnapshot } from '~/tests/helpers/snapshots'
import { createTeam, fetchPostgresPersons, getFirstTeam, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { CookielessServerHashMode, Hub, PipelineEvent, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresUse } from '~/utils/db/postgres'
+import { parseJSON } from '~/utils/json-parse'
+import { logger } from '~/utils/logger'
+import { UUIDT } from '~/utils/utils'
-import { CookielessServerHashMode, Hub, PipelineEvent, Team } from '../../src/types'
-import { closeHub, createHub } from '../../src/utils/db/hub'
-import { createTestIngestionOutputs, createTestMonitoringOutputs } from '../../tests/helpers/ingestion-outputs'
-import { createHogTransformerService } from '../cdp/hog-transformations/hog-transformer.service'
-import { HogFunctionType } from '../cdp/types'
-import { PostgresUse } from '../utils/db/postgres'
-import { parseJSON } from '../utils/json-parse'
-import { logger } from '../utils/logger'
-import { UUIDT } from '../utils/utils'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { BatchWritingPersonsStore } from '../worker/ingestion/persons/batch-writing-person-store'
-import { createPrepareEventStep } from './event-processing/prepare-event-step'
import { IngestionConsumer } from './ingestion-consumer'
const DEFAULT_TEST_TIMEOUT = 5000
jest.setTimeout(DEFAULT_TEST_TIMEOUT)
-jest.mock('../utils/posthog', () => {
- const original = jest.requireActual('../utils/posthog')
+jest.mock('~/utils/posthog', () => {
+ const original = jest.requireActual('~/utils/posthog')
return {
...original,
captureException: jest.fn(),
@@ -38,15 +42,15 @@ jest.mock('../utils/posthog', () => {
})
// Mock the prepare event step for error testing
-jest.mock('./event-processing/prepare-event-step', () => ({
+jest.mock('~/ingestion/common/steps/event-processing/prepare-event-step', () => ({
createPrepareEventStep: jest.fn(),
}))
// Mock the IngestionWarningLimiter to always allow warnings (prevents rate limiting between tests)
-jest.mock('../utils/token-bucket', () => {
+jest.mock('~/utils/token-bucket', () => {
const mockConsume = jest.fn().mockReturnValue(true)
return {
- ...jest.requireActual('../utils/token-bucket'),
+ ...jest.requireActual('~/utils/token-bucket'),
IngestionWarningLimiter: {
consume: mockConsume,
},
@@ -111,6 +115,7 @@ describe('IngestionConsumer', () => {
...hub,
outputs,
clickhouseGroupRepository: new ClickhouseGroupRepository(outputs),
+ aiSubpipelineFactory: createAiEventSubpipeline,
hogTransformer: createHogTransformerService(hub, {
...hub,
monitoringOutputs: createTestMonitoringOutputs(mockProducer),
@@ -180,7 +185,7 @@ describe('IngestionConsumer', () => {
team2 = (await getTeam(hub.postgres, team2Id))!
jest.mocked(createPrepareEventStep).mockImplementation((...args) => {
- const original = jest.requireActual('./event-processing/prepare-event-step')
+ const original = jest.requireActual('~/ingestion/common/steps/event-processing/prepare-event-step')
return original.createPrepareEventStep(...args)
})
@@ -1284,10 +1289,12 @@ describe('IngestionConsumer', () => {
hub.CDP_HOG_WATCHER_SAMPLE_RATE = 1
const localIngester = await createIngestionConsumer(hub)
- // Create spies for methods after the service is configured
- const fetchAndCacheSpy = jest.spyOn(localIngester.hogTransformer, 'fetchAndCacheHogFunctionStates')
- const clearStatesSpy = jest.spyOn(localIngester.hogTransformer, 'clearHogFunctionStates')
- const observeResultsSpy = jest.spyOn(localIngester.hogTransformer['hogWatcher'], 'observeResults')
+ // Create spies for methods after the service is configured. The consumer exposes the
+ // transformer via its interface, so cast to the concrete service for these internal spies.
+ const concreteTransformer = localIngester.hogTransformer as HogTransformerService
+ const fetchAndCacheSpy = jest.spyOn(concreteTransformer, 'fetchAndCacheHogFunctionStates')
+ const clearStatesSpy = jest.spyOn(concreteTransformer, 'clearHogFunctionStates')
+ const observeResultsSpy = jest.spyOn(concreteTransformer['hogWatcher'], 'observeResults')
// Process batch with hogwatcher enabled
// in this stage we do not have the teamId on the event but the token is in kafka headers
@@ -1328,9 +1335,10 @@ describe('IngestionConsumer', () => {
hub.CDP_HOG_WATCHER_SAMPLE_RATE = 0
const localIngester = await createIngestionConsumer(hub)
- // Create spies for methods after the service is configured
- const fetchAndCacheSpy = jest.spyOn(localIngester.hogTransformer, 'fetchAndCacheHogFunctionStates')
- const clearStatesSpy = jest.spyOn(localIngester.hogTransformer, 'clearHogFunctionStates')
+ // Create spies for methods after the service is configured (cast to the concrete service)
+ const concreteTransformer = localIngester.hogTransformer as HogTransformerService
+ const fetchAndCacheSpy = jest.spyOn(concreteTransformer, 'fetchAndCacheHogFunctionStates')
+ const clearStatesSpy = jest.spyOn(concreteTransformer, 'clearHogFunctionStates')
// Process batch with hogwatcher disabled
const event = createEvent({
diff --git a/nodejs/src/ingestion/ingestion-consumer.ts b/nodejs/src/ingestion/ingestion-consumer.ts
index 51bd185fde6b..99bdd6e8b47b 100644
--- a/nodejs/src/ingestion/ingestion-consumer.ts
+++ b/nodejs/src/ingestion/ingestion-consumer.ts
@@ -1,57 +1,52 @@
import { Message } from 'node-rdkafka'
import { Gauge, Histogram } from 'prom-client'
-import { instrumentFn } from '~/common/tracing/tracing-utils'
-
-import { HogTransformerService } from '../cdp/hog-transformations/hog-transformer.service'
-import { CommonConfig } from '../common/config'
-import { KafkaConsumerInterface, createKafkaConsumer } from '../kafka/consumer'
-import {
- HealthCheckResult,
- HealthCheckResultError,
- HealthCheckResultOk,
- PluginServerService,
- RedisPool,
-} from '../types'
-import { PostgresRouter } from '../utils/db/postgres'
+import { CommonConfig } from '~/common/config'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
import {
- EventIngestionRestrictionManager,
- EventIngestionRestrictionManagerComponent,
-} from '../utils/event-ingestion-restrictions'
-import { EventSchemaEnforcementManager } from '../utils/event-schema-enforcement-manager'
-import { logger } from '../utils/logger'
-import { PromiseScheduler } from '../utils/promise-scheduler'
-import { TeamManager } from '../utils/team-manager'
-import { GroupTypeManager } from '../worker/ingestion/group-type-manager'
-import { BatchWritingGroupStore } from '../worker/ingestion/groups/batch-writing-group-store'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { GroupRepository } from '../worker/ingestion/groups/repositories/group-repository.interface'
-import { BatchWritingPersonsStore } from '../worker/ingestion/persons/batch-writing-person-store'
-import { PersonsStore } from '../worker/ingestion/persons/persons-store'
-import { PersonRepository } from '../worker/ingestion/persons/repositories/person-repository'
+ AppMetricsOutput,
+ DlqOutput,
+ GroupsOutput,
+ IngestionWarningsOutput,
+ OverflowOutput,
+ TophogOutput,
+} from '~/common/outputs'
+import { AiEventOutput, AsyncOutput, EventOutput, PersonDistinctIdsOutput, PersonsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PersonRepository } from '~/common/persons/repositories/person-repository'
+import { instrumentFn } from '~/common/tracing/tracing-utils'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { parseSplitAiEventsConfig } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { TopHog } from '~/ingestion/framework/tophog'
import {
JoinedIngestionPipelineConfig,
JoinedIngestionPipelineContext,
JoinedIngestionPipelineDeps,
JoinedIngestionPipelineInput,
createJoinedIngestionPipeline,
-} from './analytics'
-import { AiEventOutput, AsyncOutput, EventOutput, PersonDistinctIdsOutput, PersonsOutput } from './analytics/outputs'
-import { EventFilterManager, EventFilterManagerComponent } from './common/event-filters'
+} from '~/ingestion/pipelines/analytics'
+import { KafkaConsumerInterface, createKafkaConsumer } from '~/kafka/consumer'
+import { HealthCheckResult, HealthCheckResultError, HealthCheckResultOk, PluginServerService, RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
import {
- AppMetricsOutput,
- DlqOutput,
- GroupsOutput,
- IngestionWarningsOutput,
- OverflowOutput,
- TophogOutput,
-} from './common/outputs'
+ EventIngestionRestrictionManager,
+ EventIngestionRestrictionManagerComponent,
+} from '~/utils/event-ingestion-restrictions'
+import { EventSchemaEnforcementManager } from '~/utils/event-schema-enforcement-manager'
+import { logger } from '~/utils/logger'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
+
+import { AiEventSubpipelineFactory } from './common/ai-subpipeline.contract'
+import { EventFilterManager, EventFilterManagerComponent } from './common/event-filters'
import { IngestionConsumerConfig } from './config'
-import { CookielessManager } from './cookieless/cookieless-manager'
-import { parseSplitAiEventsConfig } from './event-processing/split-ai-events-step'
-import { IngestionOutputs } from './outputs/ingestion-outputs'
-import { createOkContext } from './pipelines/helpers'
-import { TopHog } from './tophog'
import { MainLaneOverflowRedirect } from './utils/overflow-redirect/main-lane-overflow-redirect'
import { OverflowLaneOverflowRedirect } from './utils/overflow-redirect/overflow-lane-overflow-redirect'
import { OverflowRedirectService } from './utils/overflow-redirect/overflow-redirect-service'
@@ -82,7 +77,8 @@ export interface IngestionConsumerDeps {
clickhouseGroupRepository: ClickhouseGroupRepository
personRepository: PersonRepository
cookielessManager: CookielessManager
- hogTransformer: HogTransformerService
+ hogTransformer: HogTransformer
+ aiSubpipelineFactory: AiEventSubpipelineFactory
}
export const latestOffsetTimestampGauge = new Gauge({
@@ -112,7 +108,7 @@ export class IngestionConsumer {
protected topic: string
protected kafkaConsumer: KafkaConsumerInterface
isStopping = false
- public hogTransformer: HogTransformerService
+ public hogTransformer: HogTransformer
private overflowRedirectService?: OverflowRedirectService
private overflowLaneTTLRefreshService?: OverflowRedirectService
private tokenDistinctIdsToDrop: string[] = []
@@ -283,6 +279,7 @@ export class IngestionConsumer {
personsStore: this.personsStore,
groupStore: this.groupStore,
hogTransformer: this.hogTransformer,
+ aiSubpipelineFactory: this.deps.aiSubpipelineFactory,
eventFilterManager: this.eventFilterManager,
eventIngestionRestrictionManager: this.eventIngestionRestrictionManager,
eventSchemaEnforcementManager: this.eventSchemaEnforcementManager,
diff --git a/nodejs/src/ingestion/ai/convert-raw-event.test.ts b/nodejs/src/ingestion/pipelines/ai/convert-raw-event.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/convert-raw-event.test.ts
rename to nodejs/src/ingestion/pipelines/ai/convert-raw-event.test.ts
diff --git a/nodejs/src/ingestion/ai/convert-raw-event.ts b/nodejs/src/ingestion/pipelines/ai/convert-raw-event.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/convert-raw-event.ts
rename to nodejs/src/ingestion/pipelines/ai/convert-raw-event.ts
diff --git a/nodejs/src/ingestion/ai/costs/cost-model-matching.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/cost-model-matching.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/cost-model-matching.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/cost-model-matching.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/cost-model-matching.ts b/nodejs/src/ingestion/pipelines/ai/costs/cost-model-matching.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/costs/cost-model-matching.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/cost-model-matching.ts
index 7377644b72c4..566d539ab3a1 100644
--- a/nodejs/src/ingestion/ai/costs/cost-model-matching.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/cost-model-matching.ts
@@ -1,6 +1,6 @@
import { Properties } from '~/plugin-scaffold'
+import { logger } from '~/utils/logger'
-import { logger } from '../../../utils/logger'
import { resolveModelCostForProvider } from './provider-matching'
import { manualCostsByModel, openRouterCostsByModel } from './providers'
import type { ModelCostRow, ResolvedModelCost } from './providers/types'
diff --git a/nodejs/src/ingestion/ai/costs/cost-utils.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/cost-utils.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/cost-utils.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/cost-utils.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/cost-utils.ts b/nodejs/src/ingestion/pipelines/ai/costs/cost-utils.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/cost-utils.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/cost-utils.ts
diff --git a/nodejs/src/ingestion/ai/costs/index.ts b/nodejs/src/ingestion/pipelines/ai/costs/index.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/costs/index.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/index.ts
index b38f086394fe..b4dd2c105492 100644
--- a/nodejs/src/ingestion/ai/costs/index.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/index.ts
@@ -1,8 +1,8 @@
import bigDecimal from 'js-big-decimal'
+import { aiCostLookupCounter, aiCostTotalOutcomeCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent, Properties } from '~/plugin-scaffold'
-import { aiCostLookupCounter, aiCostTotalOutcomeCounter } from '../metrics'
import {
CostModelResult,
CostModelSource,
diff --git a/nodejs/src/ingestion/ai/costs/input-costs.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/input-costs.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/input-costs.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/input-costs.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/input-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/input-costs.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/costs/input-costs.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/input-costs.ts
index f832d40c2f8b..ceccd3330fa2 100644
--- a/nodejs/src/ingestion/ai/costs/input-costs.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/input-costs.ts
@@ -1,8 +1,8 @@
import bigDecimal from 'js-big-decimal'
import { PluginEvent } from '~/plugin-scaffold'
+import { logger } from '~/utils/logger'
-import { logger } from '../../../utils/logger'
import { numericProperty } from './cost-utils'
import { ResolvedModelCost } from './providers/types'
diff --git a/nodejs/src/ingestion/ai/costs/modality-tokens.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.test.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/costs/modality-tokens.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.test.ts
index 0a2dc6f640cb..869b1482c34c 100644
--- a/nodejs/src/ingestion/ai/costs/modality-tokens.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.test.ts
@@ -1,4 +1,5 @@
-import { aiCostModalityExtractionCounter } from '../metrics'
+import { aiCostModalityExtractionCounter } from '~/ingestion/pipelines/ai/metrics'
+
import { extractModalityTokens } from './modality-tokens'
import { createAIEvent } from './test-helpers'
diff --git a/nodejs/src/ingestion/ai/costs/modality-tokens.ts b/nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/costs/modality-tokens.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.ts
index 61133413debb..060eeb7426a6 100644
--- a/nodejs/src/ingestion/ai/costs/modality-tokens.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/modality-tokens.ts
@@ -1,7 +1,6 @@
+import { aiCostModalityExtractionCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent, Properties } from '~/plugin-scaffold'
-import { aiCostModalityExtractionCounter } from '../metrics'
-
export interface EventWithProperties extends PluginEvent {
properties: Properties
}
diff --git a/nodejs/src/ingestion/ai/costs/output-costs.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/output-costs.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/output-costs.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/output-costs.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/output-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/output-costs.ts
similarity index 98%
rename from nodejs/src/ingestion/ai/costs/output-costs.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/output-costs.ts
index b6d35b9e8551..51332c9f1e03 100644
--- a/nodejs/src/ingestion/ai/costs/output-costs.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/output-costs.ts
@@ -1,8 +1,8 @@
import bigDecimal from 'js-big-decimal'
import { PluginEvent } from '~/plugin-scaffold'
+import { logger } from '~/utils/logger'
-import { logger } from '../../../utils/logger'
import { numericProperty } from './cost-utils'
import { ResolvedModelCost } from './providers/types'
diff --git a/nodejs/src/ingestion/ai/costs/provider-matching.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/provider-matching.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/provider-matching.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/provider-matching.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/provider-matching.ts b/nodejs/src/ingestion/pipelines/ai/costs/provider-matching.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/provider-matching.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/provider-matching.ts
diff --git a/nodejs/src/ingestion/ai/costs/providers/canonical-providers.ts b/nodejs/src/ingestion/pipelines/ai/costs/providers/canonical-providers.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/canonical-providers.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/canonical-providers.ts
diff --git a/nodejs/src/ingestion/ai/costs/providers/index.ts b/nodejs/src/ingestion/pipelines/ai/costs/providers/index.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/index.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/index.ts
diff --git a/nodejs/src/ingestion/ai/costs/providers/llm-costs.json b/nodejs/src/ingestion/pipelines/ai/costs/providers/llm-costs.json
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/llm-costs.json
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/llm-costs.json
diff --git a/nodejs/src/ingestion/ai/costs/providers/manual-providers.test.ts b/nodejs/src/ingestion/pipelines/ai/costs/providers/manual-providers.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/manual-providers.test.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/manual-providers.test.ts
diff --git a/nodejs/src/ingestion/ai/costs/providers/manual-providers.ts b/nodejs/src/ingestion/pipelines/ai/costs/providers/manual-providers.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/manual-providers.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/manual-providers.ts
diff --git a/nodejs/src/ingestion/ai/costs/providers/types.ts b/nodejs/src/ingestion/pipelines/ai/costs/providers/types.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/providers/types.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/providers/types.ts
diff --git a/nodejs/src/ingestion/ai/costs/request-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/request-costs.ts
similarity index 89%
rename from nodejs/src/ingestion/ai/costs/request-costs.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/request-costs.ts
index 9c3130e4e2f6..e6843559dfa0 100644
--- a/nodejs/src/ingestion/ai/costs/request-costs.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/request-costs.ts
@@ -1,6 +1,7 @@
import bigDecimal from 'js-big-decimal'
-import { EventWithProperties } from '../process-ai-event'
+import { EventWithProperties } from '~/ingestion/pipelines/ai/process-ai-event'
+
import { ResolvedModelCost } from './providers/types'
export const calculateRequestCost = (event: EventWithProperties, cost: ResolvedModelCost): string => {
diff --git a/nodejs/src/ingestion/ai/costs/scripts/update-ai-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/scripts/update-ai-costs.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/scripts/update-ai-costs.ts
diff --git a/nodejs/src/ingestion/ai/costs/test-helpers.ts b/nodejs/src/ingestion/pipelines/ai/costs/test-helpers.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/costs/test-helpers.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/test-helpers.ts
diff --git a/nodejs/src/ingestion/ai/costs/web-search-costs.ts b/nodejs/src/ingestion/pipelines/ai/costs/web-search-costs.ts
similarity index 88%
rename from nodejs/src/ingestion/ai/costs/web-search-costs.ts
rename to nodejs/src/ingestion/pipelines/ai/costs/web-search-costs.ts
index a77c519a3387..0355abeffd61 100644
--- a/nodejs/src/ingestion/ai/costs/web-search-costs.ts
+++ b/nodejs/src/ingestion/pipelines/ai/costs/web-search-costs.ts
@@ -1,6 +1,7 @@
import bigDecimal from 'js-big-decimal'
-import { EventWithProperties } from '../process-ai-event'
+import { EventWithProperties } from '~/ingestion/pipelines/ai/process-ai-event'
+
import { ResolvedModelCost } from './providers/types'
export const calculateWebSearchCost = (event: EventWithProperties, cost: ResolvedModelCost): string => {
diff --git a/nodejs/src/ingestion/ai/errors/index.ts b/nodejs/src/ingestion/pipelines/ai/errors/index.ts
similarity index 96%
rename from nodejs/src/ingestion/ai/errors/index.ts
rename to nodejs/src/ingestion/pipelines/ai/errors/index.ts
index 4b2009d13af1..cca68d779767 100644
--- a/nodejs/src/ingestion/ai/errors/index.ts
+++ b/nodejs/src/ingestion/pipelines/ai/errors/index.ts
@@ -1,6 +1,6 @@
+import { aiErrorNormalizationCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent } from '~/plugin-scaffold'
-import { aiErrorNormalizationCounter } from '../metrics'
import { normalizeError } from './normalize-error'
const UNKNOWN_ERROR = 'Unknown error'
diff --git a/nodejs/src/ingestion/ai/errors/normalize-error.test.ts b/nodejs/src/ingestion/pipelines/ai/errors/normalize-error.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/errors/normalize-error.test.ts
rename to nodejs/src/ingestion/pipelines/ai/errors/normalize-error.test.ts
diff --git a/nodejs/src/ingestion/ai/errors/normalize-error.ts b/nodejs/src/ingestion/pipelines/ai/errors/normalize-error.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/errors/normalize-error.ts
rename to nodejs/src/ingestion/pipelines/ai/errors/normalize-error.ts
diff --git a/nodejs/src/ingestion/pipelines/ai/index.ts b/nodejs/src/ingestion/pipelines/ai/index.ts
new file mode 100644
index 000000000000..bc42ef2996f9
--- /dev/null
+++ b/nodejs/src/ingestion/pipelines/ai/index.ts
@@ -0,0 +1,3 @@
+export { normalizeTraceProperties, processAiEvent, type EventWithProperties } from './process-ai-event'
+export { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
+export { createAiEventSubpipeline, type AiEventSubpipelineConfig } from './pipelines/ai-event-subpipeline'
diff --git a/nodejs/src/ingestion/ai/metrics.ts b/nodejs/src/ingestion/pipelines/ai/metrics.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/metrics.ts
rename to nodejs/src/ingestion/pipelines/ai/metrics.ts
diff --git a/nodejs/src/ingestion/ai/otel/attribute-mapping.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.test.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/otel/attribute-mapping.test.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.test.ts
index 3d06a813694e..9a85e5cbfa68 100644
--- a/nodejs/src/ingestion/ai/otel/attribute-mapping.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.test.ts
@@ -1,7 +1,7 @@
+import { extractToolCallNames } from '~/ingestion/pipelines/ai/tools/extract-tool-calls'
import { PluginEvent } from '~/plugin-scaffold'
+import { parseJSON } from '~/utils/json-parse'
-import { parseJSON } from '../../../utils/json-parse'
-import { extractToolCallNames } from '../tools/extract-tool-calls'
import { mapOtelAttributes } from './attribute-mapping'
import { convertOtelEvent } from './index'
diff --git a/nodejs/src/ingestion/ai/otel/attribute-mapping.ts b/nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/otel/attribute-mapping.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.ts
index 1574dd8f385c..50027fa56182 100644
--- a/nodejs/src/ingestion/ai/otel/attribute-mapping.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/attribute-mapping.ts
@@ -1,7 +1,6 @@
+import { aiOtelOlderSpecEventsCounter, aiOtelSystemInstructionsCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent } from '~/plugin-scaffold'
-
-import { parseJSON } from '../../../utils/json-parse'
-import { aiOtelOlderSpecEventsCounter, aiOtelSystemInstructionsCounter } from '../metrics'
+import { parseJSON } from '~/utils/json-parse'
const ATTRIBUTE_MAP: Record<string, string> = {
'gen_ai.input.messages': '$ai_input',
diff --git a/nodejs/src/ingestion/ai/otel/index.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/index.test.ts
similarity index 98%
rename from nodejs/src/ingestion/ai/otel/index.test.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/index.test.ts
index 346d04a0e20a..9ce594d966cc 100644
--- a/nodejs/src/ingestion/ai/otel/index.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/index.test.ts
@@ -1,9 +1,10 @@
-import { aiOtelEventTypeCounter, aiOtelMiddlewareCounter } from '../metrics'
+import { aiOtelEventTypeCounter, aiOtelMiddlewareCounter } from '~/ingestion/pipelines/ai/metrics'
+
import { mapOtelAttributes } from './attribute-mapping'
import { convertOtelEvent } from './index'
import { createEvent } from './test-helpers'
-jest.mock('../metrics', () => ({
+jest.mock('~/ingestion/pipelines/ai/metrics', () => ({
aiOtelMiddlewareCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
aiOtelEventTypeCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
}))
diff --git a/nodejs/src/ingestion/ai/otel/index.ts b/nodejs/src/ingestion/pipelines/ai/otel/index.ts
similarity index 96%
rename from nodejs/src/ingestion/ai/otel/index.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/index.ts
index e14d9956ffd2..e6d4d5211fc5 100644
--- a/nodejs/src/ingestion/ai/otel/index.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/index.ts
@@ -1,6 +1,6 @@
+import { aiOtelEventTypeCounter, aiOtelMiddlewareCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent } from '~/plugin-scaffold'
-import { aiOtelEventTypeCounter, aiOtelMiddlewareCounter } from '../metrics'
import { mapOtelAttributes } from './attribute-mapping'
import { pydanticAi } from './middleware/pydantic-ai'
import { traceloop } from './middleware/traceloop'
diff --git a/nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.test.ts
similarity index 97%
rename from nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.test.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.test.ts
index 15cdceac01d6..bb77cc46e4fa 100644
--- a/nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.test.ts
@@ -1,13 +1,13 @@
-import { mapOtelAttributes } from '../attribute-mapping'
-import { convertOtelEvent } from '../index'
-import { createEvent } from '../test-helpers'
+import { mapOtelAttributes } from '~/ingestion/pipelines/ai/otel/attribute-mapping'
+import { convertOtelEvent } from '~/ingestion/pipelines/ai/otel/index'
+import { createEvent } from '~/ingestion/pipelines/ai/otel/test-helpers'
-jest.mock('../../metrics', () => ({
+jest.mock('~/ingestion/pipelines/ai/metrics', () => ({
aiOtelMiddlewareCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
aiOtelEventTypeCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
}))
-jest.mock('../attribute-mapping', () => ({
+jest.mock('~/ingestion/pipelines/ai/otel/attribute-mapping', () => ({
mapOtelAttributes: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.ts
similarity index 98%
rename from nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.ts
index d48cc7350dd9..db0b08850e63 100644
--- a/nodejs/src/ingestion/ai/otel/middleware/pydantic-ai.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/pydantic-ai.ts
@@ -1,6 +1,6 @@
import { PluginEvent } from '~/plugin-scaffold'
+import { parseJSON } from '~/utils/json-parse'
-import { parseJSON } from '../../../../utils/json-parse'
import { OtelLibraryMiddleware } from './types'
const LOGFIRE_STRIP_KEYS = [
diff --git a/nodejs/src/ingestion/ai/otel/middleware/traceloop.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/traceloop.test.ts
similarity index 97%
rename from nodejs/src/ingestion/ai/otel/middleware/traceloop.test.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/traceloop.test.ts
index 5f81fbc9974b..6c4ac368c3c5 100644
--- a/nodejs/src/ingestion/ai/otel/middleware/traceloop.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/traceloop.test.ts
@@ -1,8 +1,9 @@
-import { mapOtelAttributes } from '../attribute-mapping'
-import { createEvent } from '../test-helpers'
+import { mapOtelAttributes } from '~/ingestion/pipelines/ai/otel/attribute-mapping'
+import { createEvent } from '~/ingestion/pipelines/ai/otel/test-helpers'
+
import { reassembleIndexedAttributes, traceloop } from './traceloop'
-jest.mock('../attribute-mapping', () => ({
+jest.mock('~/ingestion/pipelines/ai/otel/attribute-mapping', () => ({
mapOtelAttributes: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/ai/otel/middleware/traceloop.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/traceloop.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/otel/middleware/traceloop.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/traceloop.ts
diff --git a/nodejs/src/ingestion/ai/otel/middleware/types.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/types.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/otel/middleware/types.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/types.ts
diff --git a/nodejs/src/ingestion/ai/otel/middleware/vercel-ai.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
similarity index 98%
rename from nodejs/src/ingestion/ai/otel/middleware/vercel-ai.test.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
index e893bb96e69d..dd8bd36fc6d6 100644
--- a/nodejs/src/ingestion/ai/otel/middleware/vercel-ai.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
@@ -1,14 +1,14 @@
-import { parseJSON } from '../../../../utils/json-parse'
-import { mapOtelAttributes } from '../attribute-mapping'
-import { convertOtelEvent } from '../index'
-import { createEvent } from '../test-helpers'
+import { mapOtelAttributes } from '~/ingestion/pipelines/ai/otel/attribute-mapping'
+import { convertOtelEvent } from '~/ingestion/pipelines/ai/otel/index'
+import { createEvent } from '~/ingestion/pipelines/ai/otel/test-helpers'
+import { parseJSON } from '~/utils/json-parse'
-jest.mock('../../metrics', () => ({
+jest.mock('~/ingestion/pipelines/ai/metrics', () => ({
aiOtelMiddlewareCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
aiOtelEventTypeCounter: { labels: jest.fn().mockReturnValue({ inc: jest.fn() }) },
}))
-jest.mock('../attribute-mapping', () => ({
+jest.mock('~/ingestion/pipelines/ai/otel/attribute-mapping', () => ({
mapOtelAttributes: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/ai/otel/middleware/vercel-ai.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
similarity index 98%
rename from nodejs/src/ingestion/ai/otel/middleware/vercel-ai.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
index d71d1b5e8f4b..5cc5c3f895c2 100644
--- a/nodejs/src/ingestion/ai/otel/middleware/vercel-ai.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
@@ -1,7 +1,7 @@
+import { mustAddReasoningCost } from '~/ingestion/pipelines/ai/costs/output-costs'
import { PluginEvent } from '~/plugin-scaffold'
+import { parseJSON } from '~/utils/json-parse'
-import { parseJSON } from '../../../../utils/json-parse'
-import { mustAddReasoningCost } from '../../costs/output-costs'
import { OtelLibraryMiddleware } from './types'
// Vercel AI SDK attributes to strip after processing. Includes both
diff --git a/nodejs/src/ingestion/ai/otel/test-helpers.ts b/nodejs/src/ingestion/pipelines/ai/otel/test-helpers.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/otel/test-helpers.ts
rename to nodejs/src/ingestion/pipelines/ai/otel/test-helpers.ts
diff --git a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts b/nodejs/src/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.ts
similarity index 56%
rename from nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts
rename to nodejs/src/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.ts
index 9e47600084c4..cad3735988c2 100644
--- a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.ts
+++ b/nodejs/src/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.ts
@@ -1,54 +1,23 @@
-import { Message } from 'node-rdkafka'
+import { AsyncOutput, EVENTS_OUTPUT } from '~/common/outputs'
+import type { AiEventSubpipelineConfig, AiEventSubpipelineInput } from '~/ingestion/common/ai-subpipeline.contract'
+import { createCreateEventStep } from '~/ingestion/common/steps/event-processing/create-event-step'
+import { EmitEventStepOutput, createEmitEventStep } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { createHogTransformEventStep } from '~/ingestion/common/steps/event-processing/hog-transform-event-step'
+import { createNormalizeEventStep } from '~/ingestion/common/steps/event-processing/normalize-event-step'
+import { createNormalizeProcessPersonFlagStep } from '~/ingestion/common/steps/event-processing/normalize-process-person-flag-step'
+import { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'
+import { createProcessGroupsStep } from '~/ingestion/common/steps/event-processing/process-groups-step'
+import { createProcessPersonlessStep } from '~/ingestion/common/steps/event-processing/process-personless-step'
+import { createProcessPersonsStep } from '~/ingestion/common/steps/event-processing/process-persons-step'
+import { createSplitAiEventsStep } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'
+import { PipelineBuilder, StartPipelineBuilder } from '~/ingestion/framework/builders/pipeline-builders'
+import { sum, sumOk, sumResult, timer } from '~/ingestion/framework/extensions/tophog'
+import { isDropResult } from '~/ingestion/framework/results'
-import { createProcessGroupsStep } from '~/ingestion/event-processing/process-groups-step'
-import { PluginEvent } from '~/plugin-scaffold'
-
-import { HogTransformerService } from '../../../cdp/hog-transformations/hog-transformer.service'
-import { EventHeaders, Team } from '../../../types'
-import { TeamManager } from '../../../utils/team-manager'
-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 { 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 { 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'
-import { createNormalizeProcessPersonFlagStep } from '../../event-processing/normalize-process-person-flag-step'
-import { createPrepareEventStep } from '../../event-processing/prepare-event-step'
-import { createProcessPersonlessStep } from '../../event-processing/process-personless-step'
-import { createProcessPersonsStep } from '../../event-processing/process-persons-step'
-import { SplitAiEventsStepConfig, createSplitAiEventsStep } from '../../event-processing/split-ai-events-step'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { PipelineBuilder, StartPipelineBuilder } from '../../pipelines/builders/pipeline-builders'
-import { TopHogWrapper, sum, sumOk, sumResult, timer } from '../../pipelines/extensions/tophog'
-import { isDropResult } from '../../pipelines/results'
import { createProcessAiEventStep } from './steps/process-ai-event-step'
-export interface AiEventSubpipelineInput {
- message: Message
- event: PluginEvent
- team: Team
- headers: EventHeaders
- personsStoreForBatch: PersonsStoreForBatch
- groupStoreForBatch: GroupStoreForBatch
-}
-
-export interface AiEventSubpipelineConfig {
- options: EventPipelineRunnerOptions
- outputs: IngestionOutputs<
- EventOutput | AiEventOutput | IngestionWarningsOutput | PersonsOutput | PersonDistinctIdsOutput
- >
- teamManager: TeamManager
- groupTypeManager: GroupTypeManager
- hogTransformer: HogTransformerService
- splitAiEventsConfig: SplitAiEventsStepConfig
- topHog: TopHogWrapper
-}
+export type { AiEventSubpipelineConfig, AiEventSubpipelineInput } from '~/ingestion/common/ai-subpipeline.contract'
export function createAiEventSubpipeline<TInput extends AiEventSubpipelineInput, TContext>(
builder: StartPipelineBuilder<TInput, TContext>,
diff --git a/nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.test.ts b/nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.test.ts
similarity index 89%
rename from nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.test.ts
rename to nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.test.ts
index 569f8e9aa81d..2b5d0bcd9424 100644
--- a/nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.test.ts
@@ -1,17 +1,17 @@
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { processAiEvent } from '~/ingestion/pipelines/ai/process-ai-event'
import { PluginEvent } from '~/plugin-scaffold'
+import { captureException } from '~/utils/posthog'
+import { UUIDT } from '~/utils/utils'
-import { captureException } from '../../../../utils/posthog'
-import { UUIDT } from '../../../../utils/utils'
-import { PipelineResultType } from '../../../pipelines/results'
-import { processAiEvent } from '../../process-ai-event'
import { createProcessAiEventStep } from './process-ai-event-step'
-jest.mock('../../../../utils/posthog', () => ({
+jest.mock('~/utils/posthog', () => ({
captureException: jest.fn(),
}))
-jest.mock('../../process-ai-event', () => {
- const actual = jest.requireActual('../../process-ai-event')
+jest.mock('~/ingestion/pipelines/ai/process-ai-event', () => {
+ const actual = jest.requireActual('~/ingestion/pipelines/ai/process-ai-event')
return {
AI_EVENT_TYPES: actual.AI_EVENT_TYPES,
processAiEvent: jest.fn((event: PluginEvent) => ({
diff --git a/nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.ts b/nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.ts
similarity index 80%
rename from nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.ts
rename to nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.ts
index aae61b5fbfac..7047584b30a1 100644
--- a/nodejs/src/ingestion/ai/pipelines/steps/process-ai-event-step.ts
+++ b/nodejs/src/ingestion/pipelines/ai/pipelines/steps/process-ai-event-step.ts
@@ -1,10 +1,10 @@
+import { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
+import { dlq, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { processAiEvent } from '~/ingestion/pipelines/ai/process-ai-event'
import { PluginEvent } from '~/plugin-scaffold'
-
-import { logger } from '../../../../utils/logger'
-import { captureException } from '../../../../utils/posthog'
-import { dlq, ok } from '../../../pipelines/results'
-import { ProcessingStep } from '../../../pipelines/steps'
-import { AI_EVENT_TYPES, processAiEvent } from '../../process-ai-event'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
type ProcessAiEventInput = {
normalizedEvent: PluginEvent
diff --git a/nodejs/src/ingestion/ai/process-ai-event.test.ts b/nodejs/src/ingestion/pipelines/ai/process-ai-event.test.ts
similarity index 99%
rename from nodejs/src/ingestion/ai/process-ai-event.test.ts
rename to nodejs/src/ingestion/pipelines/ai/process-ai-event.test.ts
index b41fc40d1ed8..4cdde3993f97 100644
--- a/nodejs/src/ingestion/ai/process-ai-event.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/process-ai-event.test.ts
@@ -1,11 +1,11 @@
import { PluginEvent } from '~/plugin-scaffold'
+import { logger } from '~/utils/logger'
-import { logger } from '../../utils/logger'
import { CostModelSource } from './costs/cost-model-matching'
import type { ModelCost, ModelCostRow } from './costs/providers/types'
import { normalizeTraceProperties, processAiEvent } from './process-ai-event'
-jest.mock('../../utils/logger', () => ({
+jest.mock('~/utils/logger', () => ({
logger: {
warn: jest.fn(),
},
diff --git a/nodejs/src/ingestion/ai/process-ai-event.ts b/nodejs/src/ingestion/pipelines/ai/process-ai-event.ts
similarity index 91%
rename from nodejs/src/ingestion/ai/process-ai-event.ts
rename to nodejs/src/ingestion/pipelines/ai/process-ai-event.ts
index 017813a5921a..91f88339d5f5 100644
--- a/nodejs/src/ingestion/ai/process-ai-event.ts
+++ b/nodejs/src/ingestion/pipelines/ai/process-ai-event.ts
@@ -7,9 +7,10 @@
* - Cost calculation (for generation/embedding/evaluation events)
* - Model parameter extraction (for generation/embedding/evaluation events)
*/
+import { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
import { PluginEvent } from '~/plugin-scaffold'
+import { logger } from '~/utils/logger'
-import { logger } from '../../utils/logger'
import { convertRawEvent } from './convert-raw-event'
import { EventWithProperties, extractCoreModelParams, processCost } from './costs'
import { processAiErrorNormalization } from './errors'
@@ -21,17 +22,6 @@ const isEventWithProperties = (event: PluginEvent): event is EventWithProperties
return event.properties !== undefined && event.properties !== null
}
-// Canonical Node.js list. Python mirror: posthog/hogql_queries/ai/ai_table_resolver.py
-export const AI_EVENT_TYPES = new Set([
- '$ai_generation',
- '$ai_embedding',
- '$ai_evaluation',
- '$ai_span',
- '$ai_trace',
- '$ai_metric',
- '$ai_feedback',
-])
-
/**
* Process an AI event through the enrichment pipeline.
*
diff --git a/nodejs/src/ingestion/ai/tools/extract-tool-calls.test.ts b/nodejs/src/ingestion/pipelines/ai/tools/extract-tool-calls.test.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/tools/extract-tool-calls.test.ts
rename to nodejs/src/ingestion/pipelines/ai/tools/extract-tool-calls.test.ts
diff --git a/nodejs/src/ingestion/ai/tools/extract-tool-calls.ts b/nodejs/src/ingestion/pipelines/ai/tools/extract-tool-calls.ts
similarity index 100%
rename from nodejs/src/ingestion/ai/tools/extract-tool-calls.ts
rename to nodejs/src/ingestion/pipelines/ai/tools/extract-tool-calls.ts
diff --git a/nodejs/src/ingestion/ai/tools/index.ts b/nodejs/src/ingestion/pipelines/ai/tools/index.ts
similarity index 97%
rename from nodejs/src/ingestion/ai/tools/index.ts
rename to nodejs/src/ingestion/pipelines/ai/tools/index.ts
index 293dd1f181f8..7389f73bf9bf 100644
--- a/nodejs/src/ingestion/ai/tools/index.ts
+++ b/nodejs/src/ingestion/pipelines/ai/tools/index.ts
@@ -1,7 +1,7 @@
+import { aiToolCallExtractionCounter } from '~/ingestion/pipelines/ai/metrics'
import { PluginEvent } from '~/plugin-scaffold'
+import { parseJSON } from '~/utils/json-parse'
-import { parseJSON } from '../../../utils/json-parse'
-import { aiToolCallExtractionCounter } from '../metrics'
import { extractToolCallNames, sanitizeToolName } from './extract-tool-calls'
const TOOL_CALL_INDICATORS = ['tool_call', 'tool_use', 'function_call', '"function"', 'tool-call']
diff --git a/nodejs/src/ingestion/analytics/event-subpipeline.ts b/nodejs/src/ingestion/pipelines/analytics/event-subpipeline.ts
similarity index 67%
rename from nodejs/src/ingestion/analytics/event-subpipeline.ts
rename to nodejs/src/ingestion/pipelines/analytics/event-subpipeline.ts
index b1a6ca6c6dd8..f7e15b2c112e 100644
--- a/nodejs/src/ingestion/analytics/event-subpipeline.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/event-subpipeline.ts
@@ -1,29 +1,29 @@
import { Message } from 'node-rdkafka'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { createCreateEventStep } from '~/ingestion/common/steps/event-processing/create-event-step'
+import { EmitEventStepOutput, createEmitEventStep } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { EventPipelineRunnerOptions } from '~/ingestion/common/steps/event-processing/event-pipeline-options'
+import { createHogTransformEventStep } from '~/ingestion/common/steps/event-processing/hog-transform-event-step'
+import { createNormalizeEventStep } from '~/ingestion/common/steps/event-processing/normalize-event-step'
+import { createNormalizeProcessPersonFlagStep } from '~/ingestion/common/steps/event-processing/normalize-process-person-flag-step'
+import { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'
+import { createProcessGroupsStep } from '~/ingestion/common/steps/event-processing/process-groups-step'
+import { createProcessPersonlessStep } from '~/ingestion/common/steps/event-processing/process-personless-step'
+import { createProcessPersonsStep } from '~/ingestion/common/steps/event-processing/process-persons-step'
+import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'
+import { PipelineBuilder, StartPipelineBuilder } from '~/ingestion/framework/builders/pipeline-builders'
+import { TopHogWrapper, sum, sumOk, sumResult, timer } from '~/ingestion/framework/extensions/tophog'
+import { isDropResult } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders, Team } from '~/types'
+import { TeamManager } from '~/utils/team-manager'
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { EventHeaders, Team } from '../../types'
-import { TeamManager } from '../../utils/team-manager'
-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 { 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'
-import { createNormalizeProcessPersonFlagStep } from '../event-processing/normalize-process-person-flag-step'
-import { createPrepareEventStep } from '../event-processing/prepare-event-step'
-import { createProcessGroupsStep } from '../event-processing/process-groups-step'
-import { createProcessPersonlessStep } from '../event-processing/process-personless-step'
-import { createProcessPersonsStep } from '../event-processing/process-persons-step'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { PipelineBuilder, StartPipelineBuilder } from '../pipelines/builders/pipeline-builders'
-import { TopHogWrapper, sum, sumOk, sumResult, timer } from '../pipelines/extensions/tophog'
-import { isDropResult } from '../pipelines/results'
import { AsyncOutput, EVENTS_OUTPUT, EventOutput, PersonDistinctIdsOutput, PersonsOutput } from './outputs'
export interface EventSubpipelineInput {
@@ -40,7 +40,7 @@ export interface EventSubpipelineConfig {
outputs: IngestionOutputs<EventOutput | IngestionWarningsOutput | PersonsOutput | PersonDistinctIdsOutput>
teamManager: TeamManager
groupTypeManager: GroupTypeManager
- hogTransformer: HogTransformerService
+ hogTransformer: HogTransformer
topHog: TopHogWrapper
}
diff --git a/nodejs/src/ingestion/analytics/index.ts b/nodejs/src/ingestion/pipelines/analytics/index.ts
similarity index 100%
rename from nodejs/src/ingestion/analytics/index.ts
rename to nodejs/src/ingestion/pipelines/analytics/index.ts
diff --git a/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts b/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts
similarity index 79%
rename from nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts
rename to nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts
index 80a72eb4caca..8e5d87b0d093 100644
--- a/nodejs/src/ingestion/analytics/joined-ingestion-pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/joined-ingestion-pipeline.ts
@@ -1,25 +1,20 @@
import { Message } from 'node-rdkafka'
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { Team } from '../../types'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { EventSchemaEnforcementManager } from '../../utils/event-schema-enforcement-manager'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { TeamManager } from '../../utils/team-manager'
-import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'
-import { BatchWritingGroupStore } from '../../worker/ingestion/groups/batch-writing-group-store'
-import { PersonsStore } from '../../worker/ingestion/persons/persons-store'
-import { EventFilterManager } from '../common/event-filters'
-import { AppMetricsOutput, DlqOutput, GroupsOutput, IngestionWarningsOutput, OverflowOutput } from '../common/outputs'
-import { createDenyEventsStep } from '../common/steps/deny-events'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { AppMetricsOutput, DlqOutput, GroupsOutput, IngestionWarningsOutput, OverflowOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { AiEventSubpipelineFactory } from '~/ingestion/common/ai-subpipeline.contract'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { createDenyEventsStep } from '~/ingestion/common/steps/deny-events'
import {
EventFiltersBatchContext,
createEventFiltersBatchAppMetricsBeforeBatchStep,
createFlushEventFiltersBatchAppMetricsStep,
-} from '../common/steps/event-filters-steps'
-import { GroupStoreBatchContext, createGroupStoreBeforeBatchStep } from '../common/steps/group-store-batch-step'
-import { PersonsStoreBatchContext, createPersonsStoreBeforeBatchStep } from '../common/steps/persons-store-batch-step'
-import { CookielessManager } from '../cookieless/cookieless-manager'
+} from '~/ingestion/common/steps/event-filters-steps'
import {
createApplyEventRestrictionsStep,
createEnrichSurveyPersonPropertiesStep,
@@ -29,17 +24,30 @@ import {
createSkipCookielessRateLimitToOverflowStep,
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'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { newBatchingPipeline } from '../pipelines/builders'
-import { TopHogRegistry, createTopHogWrapper } from '../pipelines/extensions/tophog'
-import { OkResultWithContext } from '../pipelines/pipeline.interface'
-import { PipelineConfig } from '../pipelines/result-handling-pipeline'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+} from '~/ingestion/common/steps/event-preprocessing'
+import { EmitEventStepOutput } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { EventPipelineRunnerOptions } from '~/ingestion/common/steps/event-processing/event-pipeline-options'
+import { createFlushBatchStoresStep } from '~/ingestion/common/steps/event-processing/flush-batch-stores-step'
+import { SplitAiEventsStepConfig } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import {
+ GroupStoreBatchContext,
+ createGroupStoreBeforeBatchStep,
+} from '~/ingestion/common/steps/group-store-batch-step'
+import {
+ PersonsStoreBatchContext,
+ createPersonsStoreBeforeBatchStep,
+} from '~/ingestion/common/steps/persons-store-batch-step'
+import { newBatchingPipeline } from '~/ingestion/framework/builders'
+import { TopHogRegistry, createTopHogWrapper } from '~/ingestion/framework/extensions/tophog'
+import { OkResultWithContext } from '~/ingestion/framework/pipeline.interface'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { Team } from '~/types'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { EventSchemaEnforcementManager } from '~/utils/event-schema-enforcement-manager'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
+
import { AiEventOutput, AsyncOutput, EventOutput, PersonDistinctIdsOutput, PersonsOutput } from './outputs'
import {
PerDistinctIdPipelineConfig,
@@ -84,7 +92,8 @@ export interface JoinedIngestionPipelineConfig {
export interface JoinedIngestionPipelineDeps {
personsStore: PersonsStore
groupStore: BatchWritingGroupStore
- hogTransformer: HogTransformerService
+ hogTransformer: HogTransformer
+ aiSubpipelineFactory: AiEventSubpipelineFactory
eventFilterManager: EventFilterManager
eventIngestionRestrictionManager: EventIngestionRestrictionManager
eventSchemaEnforcementManager: EventSchemaEnforcementManager
@@ -155,6 +164,7 @@ export function createJoinedIngestionPipeline<
cookielessManager,
groupTypeManager,
topHog,
+ aiSubpipelineFactory,
} = deps
const topHogWrapper = createTopHogWrapper(topHog)
@@ -182,6 +192,7 @@ export function createJoinedIngestionPipeline<
options: perDistinctIdOptions,
outputs,
splitAiEventsConfig,
+ aiSubpipelineFactory,
teamManager,
groupTypeManager,
hogTransformer,
diff --git a/nodejs/src/ingestion/pipelines/analytics/outputs/index.ts b/nodejs/src/ingestion/pipelines/analytics/outputs/index.ts
new file mode 100644
index 000000000000..512ffbb1afe0
--- /dev/null
+++ b/nodejs/src/ingestion/pipelines/analytics/outputs/index.ts
@@ -0,0 +1,2 @@
+// All ingestion output names live in common/outputs; re-exported here for analytics-lane callers.
+export * from '~/common/outputs'
diff --git a/nodejs/src/ingestion/analytics/outputs/registry.ts b/nodejs/src/ingestion/pipelines/analytics/outputs/registry.ts
similarity index 95%
rename from nodejs/src/ingestion/analytics/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/analytics/outputs/registry.ts
index 06bec3ab726a..0e570b8bd968 100644
--- a/nodejs/src/ingestion/analytics/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/outputs/registry.ts
@@ -8,8 +8,8 @@ import {
LOG_ENTRIES_OUTPUT,
OVERFLOW_OUTPUT,
TOPHOG_OUTPUT,
-} from '../../common/outputs'
-import { IngestionOutputsBuilder } from '../../outputs/ingestion-outputs-builder'
+} from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
/** Register all analytics ingestion outputs on the builder. Call `.build(registry, config)` to resolve. */
export function createOutputsRegistry() {
diff --git a/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts b/nodejs/src/ingestion/pipelines/analytics/per-distinct-id-pipeline.ts
similarity index 62%
rename from nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts
rename to nodejs/src/ingestion/pipelines/analytics/per-distinct-id-pipeline.ts
index 418128710f71..52109c257dff 100644
--- a/nodejs/src/ingestion/analytics/per-distinct-id-pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/per-distinct-id-pipeline.ts
@@ -1,18 +1,19 @@
import { Message } from 'node-rdkafka'
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { Team } from '../../types'
-import { TeamManager } from '../../utils/team-manager'
-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'
-import { PipelineBuilder, StartPipelineBuilder } from '../pipelines/builders/pipeline-builders'
-import { TopHogWrapper } from '../pipelines/extensions/tophog'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { AI_EVENT_TYPES } from '~/ingestion/common/ai-event-types'
+import { AiEventSubpipelineFactory, AiEventSubpipelineInput } from '~/ingestion/common/ai-subpipeline.contract'
+import { EmitEventStepOutput } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { EventPipelineRunnerOptions } from '~/ingestion/common/steps/event-processing/event-pipeline-options'
+import { SplitAiEventsStepConfig } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import { PipelineBuilder, StartPipelineBuilder } from '~/ingestion/framework/builders/pipeline-builders'
+import { TopHogWrapper } from '~/ingestion/framework/extensions/tophog'
+import { Team } from '~/types'
+import { TeamManager } from '~/utils/team-manager'
+
import { EventSubpipelineInput, createEventSubpipeline } from './event-subpipeline'
import { AiEventOutput, AsyncOutput, EventOutput, PersonDistinctIdsOutput, PersonsOutput } from './outputs'
@@ -24,9 +25,10 @@ export interface PerDistinctIdPipelineConfig {
EventOutput | AiEventOutput | IngestionWarningsOutput | PersonsOutput | PersonDistinctIdsOutput
>
splitAiEventsConfig: SplitAiEventsStepConfig
+ aiSubpipelineFactory: AiEventSubpipelineFactory
teamManager: TeamManager
groupTypeManager: GroupTypeManager
- hogTransformer: HogTransformerService
+ hogTransformer: HogTransformer
topHog: TopHogWrapper
}
@@ -49,14 +51,23 @@ export function createPerDistinctIdPipeline<TInput extends PerDistinctIdPipeline
builder: StartPipelineBuilder<TInput, TContext>,
config: PerDistinctIdPipelineConfig
): PipelineBuilder<TInput, EmitEventStepOutput, TContext, AsyncOutput> {
- const { options, outputs, splitAiEventsConfig, teamManager, groupTypeManager, hogTransformer, topHog } = config
+ const {
+ options,
+ outputs,
+ splitAiEventsConfig,
+ aiSubpipelineFactory,
+ teamManager,
+ groupTypeManager,
+ hogTransformer,
+ topHog,
+ } = config
return builder.retry(
(e) =>
e.branching(classifyEvent, (branches) =>
branches
.branch('ai', (b) =>
- createAiEventSubpipeline(b, {
+ aiSubpipelineFactory(b, {
options,
outputs,
teamManager,
diff --git a/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts b/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts
similarity index 75%
rename from nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts
rename to nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts
index c0e800264c5f..9339e5f445ed 100644
--- a/nodejs/src/ingestion/analytics/post-team-preprocessing-subpipeline.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/post-team-preprocessing-subpipeline.ts
@@ -1,18 +1,11 @@
import { Message } from 'node-rdkafka'
-import { PluginEvent } from '~/plugin-scaffold'
-import { processPersonlessDistinctIdsBatchStep } from '~/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep'
-
-import { HogTransformerService } from '../../cdp/hog-transformations/hog-transformer.service'
-import { EventHeaders, Team } from '../../types'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { EventSchemaEnforcementManager } from '../../utils/event-schema-enforcement-manager'
-import { prefetchPersonsStep } from '../../worker/ingestion/event-pipeline/prefetchPersonsStep'
-import { PersonsStoreForBatch } from '../../worker/ingestion/persons/persons-store-for-batch'
-import { EventFilterManager } from '../common/event-filters'
-import { EventFiltersBatchAppMetrics } from '../common/event-filters/batch-app-metrics'
-import { createApplyEventFiltersStep } from '../common/steps/event-filters-steps'
-import { CookielessManager } from '../cookieless/cookieless-manager'
+import { HogTransformer } from '~/common/hog-transformations/hog-transformer.interface'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { EventFiltersBatchAppMetrics } from '~/ingestion/common/event-filters/batch-app-metrics'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { createApplyEventFiltersStep } from '~/ingestion/common/steps/event-filters-steps'
import {
createApplyCookielessProcessingStep,
createApplyPersonProcessingRestrictionsStep,
@@ -21,11 +14,17 @@ import {
createValidateEventMetadataStep,
createValidateEventPropertiesStep,
createValidateEventSchemaStep,
-} from '../event-preprocessing'
-import { createDropOldEventsStep } from '../event-processing/drop-old-events-step'
-import { createPrefetchHogFunctionsStep } from '../event-processing/prefetch-hog-functions-step'
-import { BatchPipelineBuilder } from '../pipelines/builders/batch-pipeline-builders'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+} from '~/ingestion/common/steps/event-preprocessing'
+import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'
+import { createPrefetchHogFunctionsStep } from '~/ingestion/common/steps/event-processing/prefetch-hog-functions-step'
+import { BatchPipelineBuilder } from '~/ingestion/framework/builders/batch-pipeline-builders'
+import { prefetchPersonsStep } from '~/ingestion/pipelines/analytics/steps/prefetchPersonsStep'
+import { processPersonlessDistinctIdsBatchStep } from '~/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { PluginEvent } from '~/plugin-scaffold'
+import { EventHeaders, Team } from '~/types'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { EventSchemaEnforcementManager } from '~/utils/event-schema-enforcement-manager'
export interface PostTeamPreprocessingSubpipelineInput {
message: Message
@@ -46,7 +45,7 @@ export interface PostTeamPreprocessingSubpipelineConfig {
overflowRedirectService?: OverflowRedirectService
overflowLaneTTLRefreshService?: OverflowRedirectService
personsPrefetchEnabled: boolean
- hogTransformer: HogTransformerService
+ hogTransformer: HogTransformer
cdpHogWatcherSampleRate: number
}
diff --git a/nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.test.ts
similarity index 86%
rename from nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts
rename to nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.test.ts
index ba45f556087a..eebd37298549 100644
--- a/nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.test.ts
@@ -1,9 +1,8 @@
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'
+import { prefetchPersonsStep } from '~/ingestion/pipelines/analytics/steps/prefetchPersonsStep'
import { PipelineEvent, Team } from '~/types'
-import { PipelineResultType, isOkResult } from '../../../ingestion/pipelines/results'
-import { PersonsStoreForBatch } from '../persons/persons-store-for-batch'
-import { prefetchPersonsStep } from './prefetchPersonsStep'
-
type TestInput = { event: PipelineEvent; team: Team; personsStoreForBatch: PersonsStoreForBatch }
function createStore(batchId: number): PersonsStoreForBatch {
diff --git a/nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.ts b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.ts
similarity index 91%
rename from nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.ts
rename to nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.ts
index aebf431bcf6a..37ce367f449a 100644
--- a/nodejs/src/worker/ingestion/event-pipeline/prefetchPersonsStep.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/steps/prefetchPersonsStep.ts
@@ -1,8 +1,7 @@
-import { PipelineResult, ok } from '~/ingestion/pipelines/results'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
import { PipelineEvent, Team } from '~/types'
-import { PersonsStoreForBatch } from '../persons/persons-store-for-batch'
-
type PrefetchPersonsStepInput = { event: PipelineEvent; team: Team; personsStoreForBatch: PersonsStoreForBatch }
export function prefetchPersonsStep<T extends PrefetchPersonsStepInput>(enabled: boolean) {
diff --git a/nodejs/src/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.ts b/nodejs/src/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep.ts
similarity index 94%
rename from nodejs/src/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.ts
rename to nodejs/src/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep.ts
index 8cd89aae7e3c..dafb9e4500c3 100644
--- a/nodejs/src/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.ts
+++ b/nodejs/src/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep.ts
@@ -1,12 +1,11 @@
-import { PipelineResult, ok } from '~/ingestion/pipelines/results'
-import { PipelineEvent, Team } from '~/types'
-
import {
hasInsertedPersonlessDistinctId,
markPersonlessDistinctIdInserted,
personlessDistinctIdCacheOperationsCounter,
-} from '../persons/personless-distinct-id-cache'
-import { PersonsStoreForBatch } from '../persons/persons-store-for-batch'
+} from '~/ingestion/common/persons/personless-distinct-id-cache'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { PipelineEvent, Team } from '~/types'
type ProcessPersonlessDistinctIdsBatchStepInput = {
event: PipelineEvent
diff --git a/nodejs/src/ingestion/clientwarnings/consumer.test.ts b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts
similarity index 85%
rename from nodejs/src/ingestion/clientwarnings/consumer.test.ts
rename to nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts
index 5a32245470b3..ee4371c6f289 100644
--- a/nodejs/src/ingestion/clientwarnings/consumer.test.ts
+++ b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.test.ts
@@ -1,10 +1,11 @@
-import { RedisPool } from '../../types'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { TeamManagerComponent } from '../../utils/team-manager'
-import { ProducerName } from '../common/outputs'
-import { newScope } from '../common/scopes'
-import { IngestionOutputsConfig } from '../config'
-import { KafkaProducerRegistry } from '../outputs/kafka-producer-registry'
+import { ProducerName } from '~/common/outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { newScope } from '~/ingestion/common/scopes'
+import { IngestionOutputsConfig } from '~/ingestion/config'
+import { RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { TeamManagerComponent } from '~/utils/team-manager'
+
import { ClientWarningsConsumerConfig, ClientWarningsSharedScope, createClientWarningsConsumer } from './consumer'
import * as pipelineModule from './pipeline'
diff --git a/nodejs/src/ingestion/clientwarnings/consumer.ts b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts
similarity index 69%
rename from nodejs/src/ingestion/clientwarnings/consumer.ts
rename to nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts
index a33d79a70145..02c3740dcd47 100644
--- a/nodejs/src/ingestion/clientwarnings/consumer.ts
+++ b/nodejs/src/ingestion/pipelines/clientwarnings/consumer.ts
@@ -1,15 +1,16 @@
-import { RedisPool } from '../../types'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { EventIngestionRestrictionManagerComponent } from '../../utils/event-ingestion-restrictions'
-import { TeamManager } from '../../utils/team-manager'
-import { EventFilterManagerComponent } from '../common/event-filters'
-import { CommonIngestionConsumerConfig, CommonIngestionConsumerScope } from '../common/ingestion-consumer'
-import { ProducerName } from '../common/outputs'
-import { Scope, extend } from '../common/scopes'
-import { PromiseSchedulerComponent } from '../common/utils/promise-scheduler'
-import { IngestionConsumerConfig, IngestionOutputsConfig } from '../config'
-import { IngestionOutputsComponent } from '../outputs/ingestion-outputs'
-import { KafkaProducerRegistry } from '../outputs/kafka-producer-registry'
+import { ProducerName } from '~/common/outputs'
+import { IngestionOutputsComponent } from '~/common/outputs/ingestion-outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { EventFilterManagerComponent } from '~/ingestion/common/event-filters'
+import { CommonIngestionConsumerConfig, CommonIngestionConsumerScope } from '~/ingestion/common/ingestion-consumer'
+import { Scope, extend } from '~/ingestion/common/scopes'
+import { PromiseSchedulerComponent } from '~/ingestion/common/utils/promise-scheduler'
+import { IngestionConsumerConfig, IngestionOutputsConfig } from '~/ingestion/config'
+import { RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { EventIngestionRestrictionManagerComponent } from '~/utils/event-ingestion-restrictions'
+import { TeamManager } from '~/utils/team-manager'
+
import { createOutputsRegistry } from './outputs/registry'
import { createClientWarningsPipeline } from './pipeline'
diff --git a/nodejs/src/ingestion/clientwarnings/index.ts b/nodejs/src/ingestion/pipelines/clientwarnings/index.ts
similarity index 100%
rename from nodejs/src/ingestion/clientwarnings/index.ts
rename to nodejs/src/ingestion/pipelines/clientwarnings/index.ts
diff --git a/nodejs/src/ingestion/clientwarnings/outputs/registry.ts b/nodejs/src/ingestion/pipelines/clientwarnings/outputs/registry.ts
similarity index 87%
rename from nodejs/src/ingestion/clientwarnings/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/clientwarnings/outputs/registry.ts
index f75087553cfb..c1f59523c3fc 100644
--- a/nodejs/src/ingestion/clientwarnings/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/clientwarnings/outputs/registry.ts
@@ -1,5 +1,5 @@
-import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '../../common/outputs'
-import { IngestionOutputsBuilder } from '../../outputs/ingestion-outputs-builder'
+import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
/**
* Register the outputs the clientwarnings pipeline produces to. Call
diff --git a/nodejs/src/ingestion/clientwarnings/pipeline.ts b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts
similarity index 73%
rename from nodejs/src/ingestion/clientwarnings/pipeline.ts
rename to nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts
index b1ae42356c7c..757f82c67e57 100644
--- a/nodejs/src/ingestion/clientwarnings/pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/clientwarnings/pipeline.ts
@@ -1,19 +1,15 @@
import { Message } from 'node-rdkafka'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { TeamManager } from '../../utils/team-manager'
-import { EventFilterManager } from '../common/event-filters'
-import { AppMetricsOutput, DlqOutput, IngestionWarningsOutput } from '../common/outputs'
-import { createAllowEventsStep } from '../common/steps/allow-events'
+import { AppMetricsOutput, DlqOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { createAllowEventsStep } from '~/ingestion/common/steps/allow-events'
import {
EventFiltersBatchContext,
createApplyEventFiltersStep,
createEventFiltersBatchAppMetricsBeforeBatchStep,
createFlushEventFiltersBatchAppMetricsStep,
-} from '../common/steps/event-filters-steps'
-import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'
-import { addTeamToContext } from '../common/subpipelines/helpers'
+} from '~/ingestion/common/steps/event-filters-steps'
import {
createParseHeadersStep,
createParseKafkaMessageStep,
@@ -21,14 +17,18 @@ import {
createValidateEventMetadataStep,
createValidateEventPropertiesStep,
createValidateHistoricalMigrationStep,
-} 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'
-import { PipelineConfig } from '../pipelines/result-handling-pipeline'
+} from '~/ingestion/common/steps/event-preprocessing'
+import { createApplyBasicEventRestrictionsStep } from '~/ingestion/common/steps/event-preprocessing/apply-event-restrictions'
+import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'
+import { EmitEventStepOutput } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { createHandleClientIngestionWarningStep } from '~/ingestion/common/steps/event-processing/handle-client-ingestion-warning-step'
+import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'
+import { addTeamToContext } from '~/ingestion/common/subpipelines/helpers'
+import { newBatchingPipeline } from '~/ingestion/framework/builders'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
export interface ClientWarningsPipelineConfig {
outputs: IngestionOutputs<IngestionWarningsOutput | DlqOutput | AppMetricsOutput>
diff --git a/nodejs/src/ingestion/error-tracking/config.ts b/nodejs/src/ingestion/pipelines/errortracking/config.ts
similarity index 98%
rename from nodejs/src/ingestion/error-tracking/config.ts
rename to nodejs/src/ingestion/pipelines/errortracking/config.ts
index b6fc21e46f30..f672cd707301 100644
--- a/nodejs/src/ingestion/error-tracking/config.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/config.ts
@@ -1,3 +1,4 @@
+import { INGESTION_DOWNSTREAM_PRODUCER, INGESTION_UPSTREAM_PRODUCER, type ProducerName } from '~/common/outputs'
import {
KAFKA_APP_METRICS_2,
KAFKA_CLICKHOUSE_TOPHOG,
@@ -7,9 +8,8 @@ import {
KAFKA_EVENTS_JSON,
KAFKA_INGESTION_WARNINGS,
KAFKA_LOG_ENTRIES,
-} from '../../config/kafka-topics'
-import { INGESTION_DOWNSTREAM_PRODUCER, INGESTION_UPSTREAM_PRODUCER, type ProducerName } from '../common/outputs'
-import { IngestionLane } from '../config'
+} from '~/config/kafka-topics'
+import { IngestionLane } from '~/ingestion/config'
export type ErrorTrackingConsumerConfig = {
ERROR_TRACKING_CONSUMER_GROUP_ID: string
diff --git a/nodejs/src/ingestion/error-tracking/cymbal-processing-step.test.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.test.ts
similarity index 99%
rename from nodejs/src/ingestion/error-tracking/cymbal-processing-step.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.test.ts
index 4f6b07522440..bd7c6469fe2a 100644
--- a/nodejs/src/ingestion/error-tracking/cymbal-processing-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.test.ts
@@ -1,7 +1,7 @@
+import { PipelineResultType, isDropResult, isOkResult } from '~/ingestion/framework/results'
import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
import { createTestTeam } from '~/tests/helpers/team'
-import { PipelineResultType, isDropResult, isOkResult } from '../pipelines/results'
import { createCymbalProcessingStep } from './cymbal-processing-step'
import { CymbalClient } from './cymbal/client'
import { CymbalResponse } from './cymbal/types'
diff --git a/nodejs/src/ingestion/error-tracking/cymbal-processing-step.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.ts
similarity index 94%
rename from nodejs/src/ingestion/error-tracking/cymbal-processing-step.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.ts
index 298e076f1941..84ab70397a83 100644
--- a/nodejs/src/ingestion/error-tracking/cymbal-processing-step.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/cymbal-processing-step.ts
@@ -1,12 +1,12 @@
+import { invalidTimestampCounter } from '~/ingestion/common/event-pipeline/metrics'
+import { parseEventTimestamp } from '~/ingestion/common/timestamps'
+import { BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
import { ISOTimestamp, Team } from '~/types'
import { logger } from '~/utils/logger'
-import { invalidTimestampCounter } from '~/worker/ingestion/event-pipeline/metrics'
-import { parseEventTimestamp } from '~/worker/ingestion/timestamps'
-import { BatchProcessingStep } from '../pipelines/base-batch-pipeline'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { PipelineResult, drop, ok } from '../pipelines/results'
import { CymbalClient } from './cymbal/client'
import { CymbalResponse } from './cymbal/types'
diff --git a/nodejs/src/ingestion/error-tracking/cymbal/client.test.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal/client.test.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/cymbal/client.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal/client.test.ts
diff --git a/nodejs/src/ingestion/error-tracking/cymbal/client.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal/client.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/cymbal/client.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal/client.ts
diff --git a/nodejs/src/ingestion/error-tracking/cymbal/index.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal/index.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/cymbal/index.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal/index.ts
diff --git a/nodejs/src/ingestion/error-tracking/cymbal/types.ts b/nodejs/src/ingestion/pipelines/errortracking/cymbal/types.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/cymbal/types.ts
rename to nodejs/src/ingestion/pipelines/errortracking/cymbal/types.ts
diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.test.ts
similarity index 97%
rename from nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.test.ts
index 230d9b00fa27..cf300dc1af44 100644
--- a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.test.ts
@@ -3,6 +3,10 @@ import { mockProducer, mockProducerObserver } from '~/tests/helpers/mocks/produc
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { KafkaConsumer } from '~/kafka/consumer/consumer-v1'
import { getFirstTeam, resetTestDatabase } from '~/tests/helpers/sql'
import { Hub, PipelineEvent, Team } from '~/types'
@@ -11,11 +15,7 @@ import { PostgresUse } from '~/utils/db/postgres'
import { ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
import { parseJSON } from '~/utils/json-parse'
import { UUIDT } from '~/utils/utils'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
-import { ReadOnlyGroupTypeManager } from '~/worker/ingestion/readonly-group-type-manager'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../outputs/single-ingestion-output'
import { ErrorTrackingConsumer, ErrorTrackingHogTransformer } from './error-tracking-consumer'
/** Creates a mock KafkaConsumer for tests that don't need actual Kafka connections */
@@ -27,8 +27,8 @@ const createMockKafkaConsumer = (): jest.Mocked<Pick<KafkaConsumer, 'connect' |
jest.setTimeout(60000)
-jest.mock('../../utils/posthog', () => {
- const original = jest.requireActual('../../utils/posthog')
+jest.mock('~/utils/posthog', () => {
+ const original = jest.requireActual('~/utils/posthog')
return {
...original,
captureException: jest.fn(),
@@ -36,10 +36,10 @@ jest.mock('../../utils/posthog', () => {
})
// Mock the IngestionWarningLimiter to always allow warnings
-jest.mock('../../utils/token-bucket', () => {
+jest.mock('~/utils/token-bucket', () => {
const mockConsume = jest.fn().mockReturnValue(true)
return {
- ...jest.requireActual('../../utils/token-bucket'),
+ ...jest.requireActual('~/utils/token-bucket'),
IngestionWarningLimiter: {
consume: mockConsume,
},
@@ -47,7 +47,7 @@ jest.mock('../../utils/token-bucket', () => {
})
// Mock the logger to reduce noise
-jest.mock('../../utils/logger', () => ({
+jest.mock('~/utils/logger', () => ({
logger: {
debug: jest.fn(),
info: jest.fn(),
diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.ts
similarity index 93%
rename from nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts
rename to nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.ts
index 659ff67252c8..5731653e12eb 100644
--- a/nodejs/src/ingestion/error-tracking/error-tracking-consumer.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-consumer.ts
@@ -3,33 +3,33 @@ import { Redis } from 'ioredis'
import { Message } from 'node-rdkafka'
import { Counter, Gauge } from 'prom-client'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { HogTransformationResult } from '~/common/hog-transformations/hog-transformer.interface'
+import { OverflowOutput } from '~/common/outputs'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { AppMetricsAggregator } from '~/common/services/app-metrics-aggregator'
import { KeyedRateLimiterService } from '~/common/services/keyed-rate-limiter.service'
import { instrumentFn } from '~/common/tracing/tracing-utils'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { BatchPipelineUnwrapper } from '~/ingestion/framework/batch-pipeline-unwrapper'
+import { TopHog } from '~/ingestion/framework/tophog'
+import { MainLaneOverflowRedirect } from '~/ingestion/utils/overflow-redirect/main-lane-overflow-redirect'
+import { OverflowLaneOverflowRedirect } from '~/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { RedisOverflowRepository } from '~/ingestion/utils/overflow-redirect/overflow-redis-repository'
+import { KafkaConsumerInterface, createKafkaConsumer } from '~/kafka/consumer'
import { PluginEvent } from '~/plugin-scaffold'
+import { HealthCheckResult, IngestionLane, PluginServerService } from '~/types'
import { ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
-
-import { TransformationResult } from '../../cdp/hog-transformations/hog-transformer.service'
-import { KafkaConsumerInterface, createKafkaConsumer } from '../../kafka/consumer'
-import { HealthCheckResult, IngestionLane, PluginServerService } from '../../types'
import {
EventIngestionRestrictionManager,
EventIngestionRestrictionManagerComponent,
-} from '../../utils/event-ingestion-restrictions'
-import { logger } from '../../utils/logger'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { TeamManager } from '../../utils/team-manager'
-import { PersonReadRepository } from '../../worker/ingestion/persons/repositories/person-repository'
-import { ReadOnlyGroupTypeManager } from '../../worker/ingestion/readonly-group-type-manager'
-import { OverflowOutput } from '../common/outputs'
-import { CookielessManager } from '../cookieless/cookieless-manager'
-import { BatchPipelineUnwrapper } from '../pipelines/batch-pipeline-unwrapper'
-import { TopHog } from '../tophog'
-import { MainLaneOverflowRedirect } from '../utils/overflow-redirect/main-lane-overflow-redirect'
-import { OverflowLaneOverflowRedirect } from '../utils/overflow-redirect/overflow-lane-overflow-redirect'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
-import { RedisOverflowRepository } from '../utils/overflow-redirect/overflow-redis-repository'
+} from '~/utils/event-ingestion-restrictions'
+import { logger } from '~/utils/logger'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
+
import { CymbalClient } from './cymbal'
import {
ErrorTrackingOutputs,
@@ -82,13 +82,13 @@ export interface ErrorTrackingConsumerOptions {
}
/**
- * Interface for the HogTransformerService methods used by the error tracking consumer.
+ * Interface for the HogTransformer methods used by the error tracking consumer.
* This allows for easier mocking in tests without needing the full service implementation.
*/
export interface ErrorTrackingHogTransformer {
start(): Promise<void>
stop(): Promise<void>
- transformEventAndProduceMessages(event: PluginEvent): Promise<TransformationResult>
+ transformEventAndProduceMessages(event: PluginEvent): Promise<HogTransformationResult>
processInvocationResults(): Promise<void>
}
diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts
similarity index 98%
rename from nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts
index ec5814dc0a7f..91dfa01404d5 100644
--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.test.ts
@@ -1,6 +1,16 @@
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { TophogOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { COOKIELESS_SENTINEL_VALUE, CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { TopHogRegistry } from '~/ingestion/framework/extensions/tophog'
+import { ok } from '~/ingestion/framework/results'
+import { TopHog } from '~/ingestion/framework/tophog'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
import { KafkaProducerWrapper } from '~/kafka/producer'
import { createTestTeam } from '~/tests/helpers/team'
import { InternalPerson } from '~/types'
@@ -9,17 +19,7 @@ import { parseJSON } from '~/utils/json-parse'
import { PromiseScheduler } from '~/utils/promise-scheduler'
import { TeamManager } from '~/utils/team-manager'
import { UUIDT } from '~/utils/utils'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
-import { ReadOnlyGroupTypeManager } from '~/worker/ingestion/readonly-group-type-manager'
-
-import { TophogOutput } from '../common/outputs'
-import { COOKIELESS_SENTINEL_VALUE, CookielessManager } from '../cookieless/cookieless-manager'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../outputs/single-ingestion-output'
-import { TopHogRegistry } from '../pipelines/extensions/tophog'
-import { ok } from '../pipelines/results'
-import { TopHog } from '../tophog'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+
import { CymbalClient } from './cymbal/client'
import { CymbalResponse } from './cymbal/types'
import { ErrorTrackingHogTransformer } from './error-tracking-consumer'
diff --git a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts
similarity index 91%
rename from nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts
rename to nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts
index c97670ce90dc..8dcec3a392e6 100644
--- a/nodejs/src/ingestion/error-tracking/error-tracking-pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/error-tracking-pipeline.ts
@@ -1,13 +1,6 @@
import { Message } from 'node-rdkafka'
-import { PluginEvent } from '~/plugin-scaffold'
-import { ErrorTrackingSettings, ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
-import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
-import { PromiseScheduler } from '~/utils/promise-scheduler'
-import { TeamManager } from '~/utils/team-manager'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
-import { ReadOnlyGroupTypeManager } from '~/worker/ingestion/readonly-group-type-manager'
-
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
import {
AppMetricsOutput,
DlqOutput,
@@ -16,9 +9,10 @@ import {
IngestionWarningsOutput,
OverflowOutput,
TophogOutput,
-} from '../common/outputs'
-import { createRecordIngestionLagStep } from '../common/steps/record-ingestion-lag'
-import { CookielessManager } from '../cookieless/cookieless-manager'
+} from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
import {
createApplyCookielessProcessingStep,
createApplyEventRestrictionsStep,
@@ -28,20 +22,26 @@ import {
createParseKafkaMessageStep,
createResolveTeamStep,
createSkipCookielessRateLimitToOverflowStep,
-} from '../event-preprocessing'
-import { createCreateEventStep } from '../event-processing/create-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'
-import { BatchPipelineUnwrapper } from '../pipelines/batch-pipeline-unwrapper'
-import { newBatchPipelineBuilder } from '../pipelines/builders'
-import { BatchPipelineBuilder } from '../pipelines/builders/batch-pipeline-builders'
-import { TopHogRegistry, count, countOk, createTopHogWrapper } from '../pipelines/extensions/tophog'
-import { createBatch, createUnwrapper } from '../pipelines/helpers'
-import { PipelineConfig } from '../pipelines/result-handling-pipeline'
-import { ok } from '../pipelines/results'
-import { OverflowRedirectService } from '../utils/overflow-redirect/overflow-redirect-service'
+} from '~/ingestion/common/steps/event-preprocessing'
+import { createCreateEventStep } from '~/ingestion/common/steps/event-processing/create-event-step'
+import { EmitEventStepOutput, createEmitEventStep } from '~/ingestion/common/steps/event-processing/emit-event-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 { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'
+import { BatchPipelineUnwrapper } from '~/ingestion/framework/batch-pipeline-unwrapper'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { BatchPipelineBuilder } from '~/ingestion/framework/builders/batch-pipeline-builders'
+import { TopHogRegistry, count, countOk, createTopHogWrapper } from '~/ingestion/framework/extensions/tophog'
+import { createBatch, createUnwrapper } from '~/ingestion/framework/helpers'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { ok } from '~/ingestion/framework/results'
+import { OverflowRedirectService } from '~/ingestion/utils/overflow-redirect/overflow-redirect-service'
+import { PluginEvent } from '~/plugin-scaffold'
+import { ErrorTrackingSettings, ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
+
import { createCymbalProcessingStep } from './cymbal-processing-step'
import { CymbalClient } from './cymbal/client'
import { ErrorTrackingHogTransformer } from './error-tracking-consumer'
diff --git a/nodejs/src/ingestion/error-tracking/index.ts b/nodejs/src/ingestion/pipelines/errortracking/index.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/index.ts
rename to nodejs/src/ingestion/pipelines/errortracking/index.ts
diff --git a/nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.test.ts b/nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.test.ts
similarity index 99%
rename from nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.test.ts
index f8956b2680a2..436f4f372457 100644
--- a/nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.test.ts
@@ -4,8 +4,8 @@ import {
KeyedRateLimitRequest,
KeyedRateLimiterService,
} from '~/common/services/keyed-rate-limiter.service'
+import { isDropResult, isOkResult } from '~/ingestion/framework/results'
-import { isDropResult, isOkResult } from '../pipelines/results'
import { createKeyedRateLimiterStep } from './keyed-rate-limiter-step'
type Input = { teamId: number; key: string | null; cost?: number; bucketOverride?: number }
diff --git a/nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.ts b/nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.ts
similarity index 98%
rename from nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.ts
rename to nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.ts
index 357b7201a275..e0898a68c9f3 100644
--- a/nodejs/src/ingestion/error-tracking/keyed-rate-limiter-step.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/keyed-rate-limiter-step.ts
@@ -2,9 +2,8 @@ import { Counter } from 'prom-client'
import { AppMetricsAggregator } from '~/common/services/app-metrics-aggregator'
import { KeyedRateLimitRequest, KeyedRateLimiter } from '~/common/services/keyed-rate-limiter.service'
-
-import { BatchProcessingStep } from '../pipelines/base-batch-pipeline'
-import { drop, ok } from '../pipelines/results'
+import { BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { drop, ok } from '~/ingestion/framework/results'
const outcomeCounter = new Counter({
name: 'keyed_rate_limiter_outcomes_total',
diff --git a/nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.test.ts b/nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.test.ts
similarity index 97%
rename from nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.test.ts
index e98d1c0e1cfc..32c904d5433d 100644
--- a/nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.test.ts
@@ -1,6 +1,6 @@
+import { isOkResult } from '~/ingestion/framework/results'
import { ErrorTrackingSettings, ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
-import { isOkResult } from '../pipelines/results'
import { createLoadErrorTrackingSettingsStep } from './load-error-tracking-settings-step'
describe('createLoadErrorTrackingSettingsStep', () => {
diff --git a/nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.ts b/nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.ts
similarity index 86%
rename from nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.ts
rename to nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.ts
index 8adb78c95c93..01e19c34dbee 100644
--- a/nodejs/src/ingestion/error-tracking/load-error-tracking-settings-step.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/load-error-tracking-settings-step.ts
@@ -1,8 +1,7 @@
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { ErrorTrackingSettings, ErrorTrackingSettingsManager } from '~/utils/error-tracking-settings-manager'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
-
export interface LoadErrorTrackingSettingsInput {
team: { id: number }
}
diff --git a/nodejs/src/ingestion/error-tracking/outputs/registry.ts b/nodejs/src/ingestion/pipelines/errortracking/outputs/registry.ts
similarity index 93%
rename from nodejs/src/ingestion/error-tracking/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/errortracking/outputs/registry.ts
index 3b76da04be8b..7e8c4ce8ba53 100644
--- a/nodejs/src/ingestion/error-tracking/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/outputs/registry.ts
@@ -6,8 +6,8 @@ import {
LOG_ENTRIES_OUTPUT,
OVERFLOW_OUTPUT,
TOPHOG_OUTPUT,
-} from '../../common/outputs'
-import { IngestionOutputsBuilder } from '../../outputs/ingestion-outputs-builder'
+} from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
/** Register all error tracking outputs on the builder. Call `.build(registry, config)` to resolve. */
export function createOutputsRegistry() {
diff --git a/nodejs/src/ingestion/error-tracking/per-issue-guarded-rate-limiter.service.test.ts b/nodejs/src/ingestion/pipelines/errortracking/per-issue-guarded-rate-limiter.service.test.ts
similarity index 99%
rename from nodejs/src/ingestion/error-tracking/per-issue-guarded-rate-limiter.service.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/per-issue-guarded-rate-limiter.service.test.ts
index bdd29687e4bb..a37fd34e3dde 100644
--- a/nodejs/src/ingestion/error-tracking/per-issue-guarded-rate-limiter.service.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/per-issue-guarded-rate-limiter.service.test.ts
@@ -1,12 +1,12 @@
import { register } from 'prom-client'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { KeyedRateLimitRequest } from '~/common/services/keyed-rate-limiter.service'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
import { logger } from '~/utils/logger'
-import { deleteKeysWithPrefix } from '../../cdp/_tests/redis'
import { PerIssueGuardedRateLimiterService } from './per-issue-guarded-rate-limiter.service'
const mockNow: jest.SpyInstance = jest.spyOn(Date, 'now')
diff --git a/nodejs/src/ingestion/error-tracking/per-issue-guarded-rate-limiter.service.ts b/nodejs/src/ingestion/pipelines/errortracking/per-issue-guarded-rate-limiter.service.ts
similarity index 100%
rename from nodejs/src/ingestion/error-tracking/per-issue-guarded-rate-limiter.service.ts
rename to nodejs/src/ingestion/pipelines/errortracking/per-issue-guarded-rate-limiter.service.ts
diff --git a/nodejs/src/ingestion/error-tracking/person-properties-step.test.ts b/nodejs/src/ingestion/pipelines/errortracking/person-properties-step.test.ts
similarity index 97%
rename from nodejs/src/ingestion/error-tracking/person-properties-step.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/person-properties-step.test.ts
index 070d07103d4b..c2bb554c0a52 100644
--- a/nodejs/src/ingestion/error-tracking/person-properties-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/person-properties-step.test.ts
@@ -1,14 +1,11 @@
import { DateTime } from 'luxon'
+import { InternalPersonWithDistinctId, PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'
import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
import { createTestTeam } from '~/tests/helpers/team'
import { InternalPerson } from '~/types'
-import {
- InternalPersonWithDistinctId,
- PersonReadRepository,
-} from '~/worker/ingestion/persons/repositories/person-repository'
-import { PipelineResultType, isOkResult } from '../pipelines/results'
import { createFetchPersonBatchStep } from './person-properties-step'
describe('createFetchPersonBatchStep', () => {
diff --git a/nodejs/src/ingestion/error-tracking/person-properties-step.ts b/nodejs/src/ingestion/pipelines/errortracking/person-properties-step.ts
similarity index 90%
rename from nodejs/src/ingestion/error-tracking/person-properties-step.ts
rename to nodejs/src/ingestion/pipelines/errortracking/person-properties-step.ts
index 395dbbfeed4e..e5edf40b0eed 100644
--- a/nodejs/src/ingestion/error-tracking/person-properties-step.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/person-properties-step.ts
@@ -1,9 +1,8 @@
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
+import { BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
import { Person, Team } from '~/types'
-import { PersonReadRepository } from '~/worker/ingestion/persons/repositories/person-repository'
-
-import { BatchProcessingStep } from '../pipelines/base-batch-pipeline'
-import { PipelineResult, ok } from '../pipelines/results'
export interface PersonPropertiesInput {
event: PluginEvent
diff --git a/nodejs/src/ingestion/error-tracking/prepare-event-step.test.ts b/nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.test.ts
similarity index 98%
rename from nodejs/src/ingestion/error-tracking/prepare-event-step.test.ts
rename to nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.test.ts
index 894761c108a1..242683451b62 100644
--- a/nodejs/src/ingestion/error-tracking/prepare-event-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.test.ts
@@ -1,12 +1,12 @@
import { DateTime } from 'luxon'
+import { BLOAT_PROPERTIES } from '~/ingestion/common/steps/event-processing/strip-bloat-properties'
+import { PipelineResultType, isOkResult } from '~/ingestion/framework/results'
import { createTestEventHeaders } from '~/tests/helpers/event-headers'
import { createTestPluginEvent } from '~/tests/helpers/plugin-event'
import { createTestTeam } from '~/tests/helpers/team'
import { Person } from '~/types'
-import { BLOAT_PROPERTIES } from '../event-processing/strip-bloat-properties'
-import { PipelineResultType, isOkResult } from '../pipelines/results'
import { createErrorTrackingPrepareEventStep } from './prepare-event-step'
describe('createErrorTrackingPrepareEventStep', () => {
diff --git a/nodejs/src/ingestion/error-tracking/prepare-event-step.ts b/nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.ts
similarity index 93%
rename from nodejs/src/ingestion/error-tracking/prepare-event-step.ts
rename to nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.ts
index ead776bf7e9c..b043e0cdfa91 100644
--- a/nodejs/src/ingestion/error-tracking/prepare-event-step.ts
+++ b/nodejs/src/ingestion/pipelines/errortracking/prepare-event-step.ts
@@ -1,10 +1,9 @@
+import { stripBloatProperties } from '~/ingestion/common/steps/event-processing/strip-bloat-properties'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'
import { EventHeaders, ISOTimestamp, Person, PreIngestionEvent, Team } from '~/types'
-import { stripBloatProperties } from '../event-processing/strip-bloat-properties'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
-
export interface ErrorTrackingPrepareEventInput {
event: PluginEvent
team: Team
diff --git a/nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.test.ts
similarity index 87%
rename from nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.test.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.test.ts
index f5b403d174b3..7e8d311bf846 100644
--- a/nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.test.ts
@@ -1,6 +1,7 @@
-import { createTestTeam } from '../../../tests/helpers/team'
-import { Team } from '../../types'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { createTestTeam } from '~/tests/helpers/team'
+import { Team } from '~/types'
+
import { createCheckHeatmapOptInStep } from './check-heatmap-opt-in-step'
interface TestInput {
diff --git a/nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.ts b/nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.ts
similarity index 72%
rename from nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.ts
index 3e2cba0cc927..d8e852090c9c 100644
--- a/nodejs/src/ingestion/heatmaps/check-heatmap-opt-in-step.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/check-heatmap-opt-in-step.ts
@@ -1,6 +1,6 @@
-import { Team } from '../../types'
-import { PipelineResult, drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { Team } from '~/types'
type CheckHeatmapOptInInput = {
team: Team
diff --git a/nodejs/src/ingestion/heatmaps/consumer.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts
similarity index 83%
rename from nodejs/src/ingestion/heatmaps/consumer.test.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts
index 6edaa9d288a3..d9eaf499a0df 100644
--- a/nodejs/src/ingestion/heatmaps/consumer.test.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/consumer.test.ts
@@ -1,11 +1,12 @@
-import { RedisPool } from '../../types'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { TeamManagerComponent } from '../../utils/team-manager'
-import { ProducerName } from '../common/outputs'
-import { newScope } from '../common/scopes'
-import { IngestionOutputsConfig } from '../config'
-import { CookielessManager } from '../cookieless/cookieless-manager'
-import { KafkaProducerRegistry } from '../outputs/kafka-producer-registry'
+import { ProducerName } from '~/common/outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { newScope } from '~/ingestion/common/scopes'
+import { IngestionOutputsConfig } from '~/ingestion/config'
+import { RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { TeamManagerComponent } from '~/utils/team-manager'
+
import { HeatmapsConsumerConfig, HeatmapsSharedScope, createHeatmapsConsumer } from './consumer'
import * as pipelineModule from './pipeline'
diff --git a/nodejs/src/ingestion/heatmaps/consumer.ts b/nodejs/src/ingestion/pipelines/heatmaps/consumer.ts
similarity index 67%
rename from nodejs/src/ingestion/heatmaps/consumer.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/consumer.ts
index 79f82588302a..d1e01489d80b 100644
--- a/nodejs/src/ingestion/heatmaps/consumer.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/consumer.ts
@@ -1,16 +1,17 @@
-import { RedisPool } from '../../types'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { EventIngestionRestrictionManagerComponent } from '../../utils/event-ingestion-restrictions'
-import { TeamManager } from '../../utils/team-manager'
-import { EventFilterManagerComponent } from '../common/event-filters'
-import { CommonIngestionConsumerConfig, CommonIngestionConsumerScope } from '../common/ingestion-consumer'
-import { ProducerName } from '../common/outputs'
-import { Scope, extend } from '../common/scopes'
-import { PromiseSchedulerComponent } from '../common/utils/promise-scheduler'
-import { IngestionConsumerConfig, IngestionOutputsConfig } from '../config'
-import { CookielessManager } from '../cookieless/cookieless-manager'
-import { IngestionOutputsComponent } from '../outputs/ingestion-outputs'
-import { KafkaProducerRegistry } from '../outputs/kafka-producer-registry'
+import { ProducerName } from '~/common/outputs'
+import { IngestionOutputsComponent } from '~/common/outputs/ingestion-outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { EventFilterManagerComponent } from '~/ingestion/common/event-filters'
+import { CommonIngestionConsumerConfig, CommonIngestionConsumerScope } from '~/ingestion/common/ingestion-consumer'
+import { Scope, extend } from '~/ingestion/common/scopes'
+import { PromiseSchedulerComponent } from '~/ingestion/common/utils/promise-scheduler'
+import { IngestionConsumerConfig, IngestionOutputsConfig } from '~/ingestion/config'
+import { RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { EventIngestionRestrictionManagerComponent } from '~/utils/event-ingestion-restrictions'
+import { TeamManager } from '~/utils/team-manager'
+
import { createOutputsRegistry } from './outputs/registry'
import { createHeatmapsPipeline } from './pipeline'
diff --git a/nodejs/src/ingestion/heatmaps/disable-person-processing-step.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.test.ts
similarity index 96%
rename from nodejs/src/ingestion/heatmaps/disable-person-processing-step.test.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.test.ts
index 83f34dd5f8d1..c487a84b835c 100644
--- a/nodejs/src/ingestion/heatmaps/disable-person-processing-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.test.ts
@@ -1,4 +1,5 @@
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+
import { createDisablePersonProcessingStep } from './disable-person-processing-step'
describe('disablePersonProcessingStep', () => {
diff --git a/nodejs/src/ingestion/heatmaps/disable-person-processing-step.ts b/nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.ts
similarity index 76%
rename from nodejs/src/ingestion/heatmaps/disable-person-processing-step.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.ts
index f8b7566814ce..f568bb8ad523 100644
--- a/nodejs/src/ingestion/heatmaps/disable-person-processing-step.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/disable-person-processing-step.ts
@@ -1,5 +1,5 @@
-import { PipelineResult, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { PipelineResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
export function createDisablePersonProcessingStep<TInput>(): ProcessingStep<
TInput,
diff --git a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.test.ts
similarity index 97%
rename from nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.test.ts
index 19946f0adbae..29172d2064b9 100644
--- a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.test.ts
@@ -1,13 +1,14 @@
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 { EventHeaders, ISOTimestamp, PreIngestionEvent, ProjectId } from '../../types'
-import { parseJSON } from '../../utils/json-parse'
-import { cloneObject } from '../../utils/utils'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { PipelineResultType } from '../pipelines/results'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+import { createTestMessage } from '~/tests/helpers/kafka-message'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { EventHeaders, ISOTimestamp, PreIngestionEvent, ProjectId } from '~/types'
+import { parseJSON } from '~/utils/json-parse'
+import { cloneObject } from '~/utils/utils'
+
import { createExtractHeatmapDataStep } from './extract-heatmap-data-step'
import { HEATMAPS_OUTPUT, HeatmapsOutput } from './outputs'
diff --git a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts b/nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.ts
similarity index 92%
rename from nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.ts
index 4a67e402f606..e23b25aafb68 100644
--- a/nodejs/src/ingestion/heatmaps/extract-heatmap-data-step.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/extract-heatmap-data-step.ts
@@ -1,15 +1,16 @@
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'
-import { ProcessingStep } from '../pipelines/steps'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { isDistinctIdIllegal } from '~/ingestion/common/persons/person-merge-service'
+import { EmitEventStepOutput, IngestedEventInfo } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, drop, isOkResult, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { EventHeaders, PreIngestionEvent, RawClickhouseHeatmapEvent, TimestampFormat } from '~/types'
+import { logger } from '~/utils/logger'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { HEATMAPS_OUTPUT, HeatmapsOutput } from './outputs'
export interface ExtractHeatmapDataStepInput {
diff --git a/nodejs/src/ingestion/heatmaps/index.ts b/nodejs/src/ingestion/pipelines/heatmaps/index.ts
similarity index 100%
rename from nodejs/src/ingestion/heatmaps/index.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/index.ts
diff --git a/nodejs/src/ingestion/heatmaps/outputs/index.ts b/nodejs/src/ingestion/pipelines/heatmaps/outputs/index.ts
similarity index 100%
rename from nodejs/src/ingestion/heatmaps/outputs/index.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/outputs/index.ts
diff --git a/nodejs/src/ingestion/heatmaps/outputs/registry.ts b/nodejs/src/ingestion/pipelines/heatmaps/outputs/registry.ts
similarity index 90%
rename from nodejs/src/ingestion/heatmaps/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/outputs/registry.ts
index 68566a0b7b98..7785028cee49 100644
--- a/nodejs/src/ingestion/heatmaps/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/outputs/registry.ts
@@ -1,5 +1,6 @@
-import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '../../common/outputs'
-import { IngestionOutputsBuilder } from '../../outputs/ingestion-outputs-builder'
+import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+
import { HEATMAPS_OUTPUT } from './index'
/**
diff --git a/nodejs/src/ingestion/heatmaps/pipeline.test.ts b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts
similarity index 95%
rename from nodejs/src/ingestion/heatmaps/pipeline.test.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts
index a622c9e27c97..d16f7a6418e5 100644
--- a/nodejs/src/ingestion/heatmaps/pipeline.test.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.test.ts
@@ -1,5 +1,12 @@
import { Message } from 'node-rdkafka'
+import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { drop, ok } from '~/ingestion/framework/results'
import { KafkaProducerWrapper } from '~/kafka/producer'
import { createTestTeam } from '~/tests/helpers/team'
import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
@@ -8,13 +15,6 @@ import { PromiseScheduler } from '~/utils/promise-scheduler'
import { TeamManager } from '~/utils/team-manager'
import { UUIDT } from '~/utils/utils'
-import { EventFilterManager } from '../common/event-filters'
-import { APP_METRICS_OUTPUT, DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT } from '../common/outputs'
-import { CookielessManager } from '../cookieless/cookieless-manager'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../outputs/single-ingestion-output'
-import { createOkContext } from '../pipelines/helpers'
-import { drop, ok } from '../pipelines/results'
import { HEATMAPS_OUTPUT } from './outputs'
import { HeatmapsPipelineConfig, createHeatmapsPipeline } from './pipeline'
diff --git a/nodejs/src/ingestion/heatmaps/pipeline.ts b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts
similarity index 77%
rename from nodejs/src/ingestion/heatmaps/pipeline.ts
rename to nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts
index cf598a28dbc6..0c1c4d7846e0 100644
--- a/nodejs/src/ingestion/heatmaps/pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/heatmaps/pipeline.ts
@@ -1,20 +1,16 @@
import { Message } from 'node-rdkafka'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { TeamManager } from '../../utils/team-manager'
-import { EventFilterManager } from '../common/event-filters'
-import { AppMetricsOutput, DlqOutput, IngestionWarningsOutput } from '../common/outputs'
-import { createAllowEventsStep } from '../common/steps/allow-events'
+import { AppMetricsOutput, DlqOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { EventFilterManager } from '~/ingestion/common/event-filters'
+import { createAllowEventsStep } from '~/ingestion/common/steps/allow-events'
import {
EventFiltersBatchContext,
createApplyEventFiltersStep,
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'
+} from '~/ingestion/common/steps/event-filters-steps'
import {
createApplyCookielessProcessingStep,
createParseHeadersStep,
@@ -23,15 +19,20 @@ import {
createValidateEventMetadataStep,
createValidateEventPropertiesStep,
createValidateHistoricalMigrationStep,
-} 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'
-import { newBatchingPipeline } from '../pipelines/builders'
-import { PipelineConfig } from '../pipelines/result-handling-pipeline'
+} from '~/ingestion/common/steps/event-preprocessing'
+import { createApplyBasicEventRestrictionsStep } from '~/ingestion/common/steps/event-preprocessing/apply-event-restrictions'
+import { createDropOldEventsStep } from '~/ingestion/common/steps/event-processing/drop-old-events-step'
+import { EmitEventStepOutput } from '~/ingestion/common/steps/event-processing/emit-event-step'
+import { createNormalizeEventStep } from '~/ingestion/common/steps/event-processing/normalize-event-step'
+import { createPrepareEventStep } from '~/ingestion/common/steps/event-processing/prepare-event-step'
+import { createRecordIngestionLagStep } from '~/ingestion/common/steps/record-ingestion-lag'
+import { addTeamToContext } from '~/ingestion/common/subpipelines/helpers'
+import { newBatchingPipeline } from '~/ingestion/framework/builders'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+import { TeamManager } from '~/utils/team-manager'
+
import { createCheckHeatmapOptInStep } from './check-heatmap-opt-in-step'
import { createDisablePersonProcessingStep } from './disable-person-processing-step'
import { createExtractHeatmapDataStep } from './extract-heatmap-data-step'
diff --git a/nodejs/src/metrics-ingestion/config.ts b/nodejs/src/ingestion/pipelines/metrics/config.ts
similarity index 97%
rename from nodejs/src/metrics-ingestion/config.ts
rename to nodejs/src/ingestion/pipelines/metrics/config.ts
index fc6c868fcd65..3befe4270bf8 100644
--- a/nodejs/src/metrics-ingestion/config.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/config.ts
@@ -4,8 +4,9 @@ import {
KAFKA_METRICS_INGESTION,
KAFKA_METRICS_INGESTION_DLQ,
KAFKA_METRICS_INGESTION_OVERFLOW,
-} from '../config/kafka-topics'
-import { isProdEnv } from '../utils/env-utils'
+} from '~/config/kafka-topics'
+import { isProdEnv } from '~/utils/env-utils'
+
import { MetricsProducerName, WARPSTREAM_INGESTION_PRODUCER, WARPSTREAM_METRICS_PRODUCER } from './outputs/producers'
export type MetricsIngestionOutputsConfig = {
diff --git a/nodejs/src/metrics-ingestion/metrics-ingestion-consumer.ts b/nodejs/src/ingestion/pipelines/metrics/metrics-ingestion-consumer.ts
similarity index 98%
rename from nodejs/src/metrics-ingestion/metrics-ingestion-consumer.ts
rename to nodejs/src/ingestion/pipelines/metrics/metrics-ingestion-consumer.ts
index f338856ae970..cacd029b5b06 100644
--- a/nodejs/src/metrics-ingestion/metrics-ingestion-consumer.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/metrics-ingestion-consumer.ts
@@ -1,18 +1,18 @@
import { Message } from 'node-rdkafka'
import { Counter } from 'prom-client'
+import { AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { AppMetricsAggregator } from '~/common/services/app-metrics-aggregator'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
import { instrumentFn, instrumented } from '~/common/tracing/tracing-utils'
-import { AppMetricsOutput } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
-
-import { KafkaConsumerInterface, createKafkaConsumer, parseKafkaHeaders } from '../kafka/consumer'
-import { HealthCheckResult, PluginServerService } from '../types'
-import { isDevEnv } from '../utils/env-utils'
-import { logger } from '../utils/logger'
-import { TeamManager } from '../utils/team-manager'
+import { KafkaConsumerInterface, createKafkaConsumer, parseKafkaHeaders } from '~/kafka/consumer'
+import { HealthCheckResult, PluginServerService } from '~/types'
+import { isDevEnv } from '~/utils/env-utils'
+import { logger } from '~/utils/logger'
+import { TeamManager } from '~/utils/team-manager'
+
import { MetricsIngestionConsumerConfig } from './config'
import { METRICS_DLQ_OUTPUT, METRICS_OUTPUT, MetricsDlqOutput, MetricsOutput } from './outputs/outputs'
import { MetricsRateLimiterService } from './services/metrics-rate-limiter.service'
diff --git a/nodejs/src/metrics-ingestion/outputs/outputs.ts b/nodejs/src/ingestion/pipelines/metrics/outputs/outputs.ts
similarity index 100%
rename from nodejs/src/metrics-ingestion/outputs/outputs.ts
rename to nodejs/src/ingestion/pipelines/metrics/outputs/outputs.ts
diff --git a/nodejs/src/metrics-ingestion/outputs/producer-registry.ts b/nodejs/src/ingestion/pipelines/metrics/outputs/producer-registry.ts
similarity index 88%
rename from nodejs/src/metrics-ingestion/outputs/producer-registry.ts
rename to nodejs/src/ingestion/pipelines/metrics/outputs/producer-registry.ts
index 2169f56449d6..eab0790183c4 100644
--- a/nodejs/src/metrics-ingestion/outputs/producer-registry.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/outputs/producer-registry.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerRegistryBuilder } from '../../ingestion/outputs/kafka-producer-registry-builder'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
+
import {
WARPSTREAM_INGESTION_PRODUCER,
WARPSTREAM_INGESTION_PRODUCER_CONFIG_MAP,
diff --git a/nodejs/src/metrics-ingestion/outputs/producers.ts b/nodejs/src/ingestion/pipelines/metrics/outputs/producers.ts
similarity index 99%
rename from nodejs/src/metrics-ingestion/outputs/producers.ts
rename to nodejs/src/ingestion/pipelines/metrics/outputs/producers.ts
index 93eb5fc0a265..148a826764d3 100644
--- a/nodejs/src/metrics-ingestion/outputs/producers.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/outputs/producers.ts
@@ -5,7 +5,7 @@
* vars share the same prefix so deployment config is unambiguous (e.g.
* `WARPSTREAM_METRICS_PRODUCER` ↔ `KAFKA_WARPSTREAM_METRICS_PRODUCER_*`).
*/
-import { AllowedConfigKey } from '../../ingestion/outputs/kafka-producer-config'
+import { AllowedConfigKey } from '~/common/outputs/kafka-producer-config'
/**
* Targets the Warpstream cluster dedicated to metrics. The main metrics data
diff --git a/nodejs/src/metrics-ingestion/outputs/registry.ts b/nodejs/src/ingestion/pipelines/metrics/outputs/registry.ts
similarity index 88%
rename from nodejs/src/metrics-ingestion/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/metrics/outputs/registry.ts
index 9cb7f188a8c4..5dd44522adb0 100644
--- a/nodejs/src/metrics-ingestion/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/outputs/registry.ts
@@ -1,5 +1,6 @@
-import { APP_METRICS_OUTPUT } from '../../ingestion/common/outputs'
-import { IngestionOutputsBuilder } from '../../ingestion/outputs/ingestion-outputs-builder'
+import { APP_METRICS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+
import { METRICS_DLQ_OUTPUT, METRICS_OUTPUT } from './outputs'
/**
diff --git a/nodejs/src/metrics-ingestion/services/metrics-rate-limiter.service.ts b/nodejs/src/ingestion/pipelines/metrics/services/metrics-rate-limiter.service.ts
similarity index 98%
rename from nodejs/src/metrics-ingestion/services/metrics-rate-limiter.service.ts
rename to nodejs/src/ingestion/pipelines/metrics/services/metrics-rate-limiter.service.ts
index e5c0271d3218..3a1cd1d792e9 100644
--- a/nodejs/src/metrics-ingestion/services/metrics-rate-limiter.service.ts
+++ b/nodejs/src/ingestion/pipelines/metrics/services/metrics-rate-limiter.service.ts
@@ -1,9 +1,8 @@
import { Histogram } from 'prom-client'
import { RedisV2, getRedisPipelineResults } from '~/common/redis/redis-v2'
-
-import { MetricsIngestionConsumerConfig } from '../config'
-import { MetricsIngestionMessage } from '../types'
+import { MetricsIngestionConsumerConfig } from '~/ingestion/pipelines/metrics/config'
+import { MetricsIngestionMessage } from '~/ingestion/pipelines/metrics/types'
const msToSeconds = (ms: number): number => Math.round(ms / 1000)
const bytesToKb = (bytes: number): number => Math.ceil(bytes / 1000)
diff --git a/nodejs/src/metrics-ingestion/types.ts b/nodejs/src/ingestion/pipelines/metrics/types.ts
similarity index 100%
rename from nodejs/src/metrics-ingestion/types.ts
rename to nodejs/src/ingestion/pipelines/metrics/types.ts
diff --git a/nodejs/src/session-recording/README.md b/nodejs/src/ingestion/pipelines/sessionreplay/README.md
similarity index 100%
rename from nodejs/src/session-recording/README.md
rename to nodejs/src/ingestion/pipelines/sessionreplay/README.md
diff --git a/nodejs/src/session-recording/config.ts b/nodejs/src/ingestion/pipelines/sessionreplay/config.ts
similarity index 97%
rename from nodejs/src/session-recording/config.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/config.ts
index c322c3d6951c..e5e2d4dd8363 100644
--- a/nodejs/src/session-recording/config.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/config.ts
@@ -1,4 +1,5 @@
-import { getDefaultClickhouseConfig } from '../common/clickhouse-config'
+import { getDefaultClickhouseConfig } from '~/common/clickhouse-config'
+import { INGESTION_DOWNSTREAM_PRODUCER, type IngestionDownstreamProducer } from '~/common/outputs'
import {
KAFKA_CLICKHOUSE_SESSION_REPLAY_EVENTS,
KAFKA_CLICKHOUSE_SESSION_REPLAY_FEATURES,
@@ -8,13 +9,13 @@ import {
KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_DLQ,
KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS,
KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_OVERFLOW,
-} from '../config/kafka-topics'
-import { INGESTION_DOWNSTREAM_PRODUCER, type IngestionDownstreamProducer } from '../ingestion/common/outputs'
+} from '~/config/kafka-topics'
import {
INGESTION_SESSIONREPLAY_PRODUCER,
type IngestionSessionreplayProducer,
-} from '../session-replay/shared/outputs/producer-config'
-import { isDevEnv } from '../utils/env-utils'
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
+import { isDevEnv } from '~/utils/env-utils'
+
import { KAFKA_CONSUMER_GROUP_ID as SESSION_RECORDING_DEFAULT_GROUP_ID } from './constants'
/**
diff --git a/nodejs/src/session-recording/constants.ts b/nodejs/src/ingestion/pipelines/sessionreplay/constants.ts
similarity index 93%
rename from nodejs/src/session-recording/constants.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/constants.ts
index bb710f2ec732..eb24bf2e3c7f 100644
--- a/nodejs/src/session-recording/constants.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/constants.ts
@@ -1,7 +1,7 @@
import {
KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS,
KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_OVERFLOW,
-} from '../config/kafka-topics'
+} from '~/config/kafka-topics'
// WARNING: Do not change these - they will essentially reset the consumer
export const KAFKA_CONSUMER_GROUP_ID = 'session-recordings-blob-v2'
@@ -12,7 +12,7 @@ export const KAFKA_CONSUMER_SESSION_TIMEOUT_MS = 90_000
export { KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS, KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_OVERFLOW }
// Re-export shared retention constants so existing recording-ingestion imports still work
-export { RetentionPeriodToDaysMap, ValidRetentionPeriods } from '../session-replay/shared/constants'
+export { RetentionPeriodToDaysMap, ValidRetentionPeriods } from '~/ingestion/pipelines/sessionreplay/shared/constants'
// Maximum length of a session recording (24 hours)
export const MAX_SESSION_LENGTH_SECONDS = 24 * 60 * 60
diff --git a/nodejs/src/session-recording/consumer.ts b/nodejs/src/ingestion/pipelines/sessionreplay/consumer.ts
similarity index 90%
rename from nodejs/src/session-recording/consumer.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/consumer.ts
index 3b946b3b913f..a25e583aa318 100644
--- a/nodejs/src/session-recording/consumer.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/consumer.ts
@@ -1,45 +1,39 @@
import { S3Client, S3ClientConfig } from '@aws-sdk/client-s3'
import { CODES, Message, TopicPartition, TopicPartitionOffset, features, librdkafkaVersion } from 'node-rdkafka'
+import { DlqOutput, IngestionWarningsOutput, LogEntriesOutput, OverflowOutput, TophogOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { instrumentFn } from '~/common/tracing/tracing-utils'
-
-import { buildIntegerMatcher } from '../config/config'
-import {
- DlqOutput,
- IngestionWarningsOutput,
- LogEntriesOutput,
- OverflowOutput,
- TophogOutput,
-} from '../ingestion/common/outputs'
-import { IngestionConsumerConfig } from '../ingestion/config'
-import { IngestionOutputs } from '../ingestion/outputs/ingestion-outputs'
-import { BatchPipelineUnwrapper } from '../ingestion/pipelines/batch-pipeline-unwrapper'
+import { buildIntegerMatcher } from '~/config/config'
+import { IngestionConsumerConfig } from '~/ingestion/config'
+import { BatchPipelineUnwrapper } from '~/ingestion/framework/batch-pipeline-unwrapper'
+import { TopHog } from '~/ingestion/framework/tophog/tophog'
import {
SessionReplayPipelineInput,
SessionReplayPipelineOutput,
createSessionReplayPipeline,
runSessionReplayPipeline,
-} from '../ingestion/session_replay'
-import { TopHog } from '../ingestion/tophog/tophog'
-import { KafkaConsumer } from '../kafka/consumer/consumer-v1'
-import { getBlockEncryptor } from '../session-replay/shared/crypto'
-import { SessionFeatureStore } from '../session-replay/shared/features/session-feature-store'
-import { getKeyStore } from '../session-replay/shared/keystore'
-import { MemoryCachedKeyStore } from '../session-replay/shared/keystore/cache'
-import { SessionMetadataStore } from '../session-replay/shared/metadata/session-metadata-store'
-import { ReplayEventsOutput, SessionFeaturesOutput } from '../session-replay/shared/outputs'
-import { RetentionService } from '../session-replay/shared/retention/retention-service'
-import { TeamService } from '../session-replay/shared/teams/team-service'
-import { KeyStore, RecordingEncryptor } from '../session-replay/shared/types'
-import { HealthCheckResult, PluginServerService, RedisPool, ValueMatcher } from '../types'
-import { PostgresRouter } from '../utils/db/postgres'
+} from '~/ingestion/pipelines/sessionreplay'
+import { getBlockEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/crypto'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { getKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore'
+import { MemoryCachedKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore/cache'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { ReplayEventsOutput, SessionFeaturesOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { KeyStore, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { KafkaConsumer } from '~/kafka/consumer/consumer-v1'
+import { HealthCheckResult, PluginServerService, RedisPool, ValueMatcher } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
import {
EventIngestionRestrictionManager,
EventIngestionRestrictionManagerComponent,
-} from '../utils/event-ingestion-restrictions'
-import { logger } from '../utils/logger'
-import { captureException } from '../utils/posthog'
-import { PromiseScheduler } from '../utils/promise-scheduler'
+} from '~/utils/event-ingestion-restrictions'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { SessionRecordingApiConfig, SessionRecordingConfig, SessionReplayOutputsConfig } from './config'
import { KafkaOffsetManager } from './kafka/offset-manager'
import { SessionRecordingIngesterMetrics } from './metrics'
diff --git a/nodejs/src/ingestion/session_replay/index.ts b/nodejs/src/ingestion/pipelines/sessionreplay/index.ts
similarity index 100%
rename from nodejs/src/ingestion/session_replay/index.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/index.ts
diff --git a/nodejs/src/session-recording/kafka/offset-manager.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/kafka/offset-manager.test.ts
similarity index 100%
rename from nodejs/src/session-recording/kafka/offset-manager.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/kafka/offset-manager.test.ts
diff --git a/nodejs/src/session-recording/kafka/offset-manager.ts b/nodejs/src/ingestion/pipelines/sessionreplay/kafka/offset-manager.ts
similarity index 92%
rename from nodejs/src/session-recording/kafka/offset-manager.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/kafka/offset-manager.ts
index 9e3a4d9c9322..6fa0dbf3bbc8 100644
--- a/nodejs/src/session-recording/kafka/offset-manager.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/kafka/offset-manager.ts
@@ -1,7 +1,7 @@
import { TopicPartitionOffset } from 'node-rdkafka'
-import { logger } from '../../utils/logger'
-import { PartitionOffset } from '../types'
+import { PartitionOffset } from '~/ingestion/pipelines/sessionreplay/types'
+import { logger } from '~/utils/logger'
type CommitOffsetsCallback = (offsets: TopicPartitionOffset[]) => Promise<void>
diff --git a/nodejs/src/session-recording/kafka/types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/kafka/types.ts
similarity index 100%
rename from nodejs/src/session-recording/kafka/types.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/kafka/types.ts
diff --git a/nodejs/src/ingestion/session_replay/lib-version-monitor-step.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.test.ts
similarity index 96%
rename from nodejs/src/ingestion/session_replay/lib-version-monitor-step.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.test.ts
index 1c5d3e4349ab..e8632bf2656c 100644
--- a/nodejs/src/ingestion/session_replay/lib-version-monitor-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.test.ts
@@ -1,7 +1,8 @@
import { DateTime } from 'luxon'
-import { ParsedMessageData } from '../../session-recording/kafka/types'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+
import { LibVersionMonitorStepInput, createLibVersionMonitorStep } from './lib-version-monitor-step'
describe('createLibVersionMonitorStep', () => {
diff --git a/nodejs/src/ingestion/session_replay/lib-version-monitor-step.ts b/nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.ts
similarity index 87%
rename from nodejs/src/ingestion/session_replay/lib-version-monitor-step.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.ts
index a81bfd6fa756..3e2e67ee5a21 100644
--- a/nodejs/src/ingestion/session_replay/lib-version-monitor-step.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/lib-version-monitor-step.ts
@@ -1,7 +1,7 @@
-import { ParsedMessageData } from '../../session-recording/kafka/types'
-import { PipelineWarning } from '../pipelines/pipeline.interface'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { PipelineWarning } from '~/ingestion/framework/pipeline.interface'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
export interface LibVersionMonitorStepInput {
parsedMessage: ParsedMessageData
diff --git a/nodejs/src/session-recording/metrics.ts b/nodejs/src/ingestion/pipelines/sessionreplay/metrics.ts
similarity index 100%
rename from nodejs/src/session-recording/metrics.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/metrics.ts
diff --git a/nodejs/src/session-recording/outputs/producer-registry.ts b/nodejs/src/ingestion/pipelines/sessionreplay/outputs/producer-registry.ts
similarity index 66%
rename from nodejs/src/session-recording/outputs/producer-registry.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/outputs/producer-registry.ts
index 32f98e42c170..2eb6062344d2 100644
--- a/nodejs/src/session-recording/outputs/producer-registry.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/outputs/producer-registry.ts
@@ -1,10 +1,10 @@
-import { INGESTION_DOWNSTREAM_PRODUCER_CONFIG_MAP } from '../../ingestion/common/config'
-import { INGESTION_DOWNSTREAM_PRODUCER } from '../../ingestion/common/outputs'
-import { KafkaProducerRegistryBuilder } from '../../ingestion/outputs/kafka-producer-registry-builder'
+import { INGESTION_DOWNSTREAM_PRODUCER } from '~/common/outputs'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
+import { INGESTION_DOWNSTREAM_PRODUCER_CONFIG_MAP } from '~/ingestion/common/config'
import {
INGESTION_SESSIONREPLAY_PRODUCER,
INGESTION_SESSIONREPLAY_PRODUCER_CONFIG_MAP,
-} from '../../session-replay/shared/outputs/producer-config'
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
/**
* Session replay's producer slots: DOWNSTREAM (warpstream-ingestion) for ClickHouse-bound
diff --git a/nodejs/src/session-recording/outputs/registry.ts b/nodejs/src/ingestion/pipelines/sessionreplay/outputs/registry.ts
similarity index 88%
rename from nodejs/src/session-recording/outputs/registry.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/outputs/registry.ts
index 673b4f3da47e..6164adc7719a 100644
--- a/nodejs/src/session-recording/outputs/registry.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/outputs/registry.ts
@@ -4,9 +4,9 @@ import {
LOG_ENTRIES_OUTPUT,
OVERFLOW_OUTPUT,
TOPHOG_OUTPUT,
-} from '../../ingestion/common/outputs'
-import { IngestionOutputsBuilder } from '../../ingestion/outputs/ingestion-outputs-builder'
-import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '../../session-replay/shared/outputs'
+} from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
/** Register all session replay outputs on the builder. Call `.build(registry, config)` to resolve. */
export function createOutputsRegistry() {
diff --git a/nodejs/src/ingestion/session_replay/parse-message-step.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.test.ts
similarity index 99%
rename from nodejs/src/ingestion/session_replay/parse-message-step.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.test.ts
index 02ff08b0e9e3..eb991293af8e 100644
--- a/nodejs/src/ingestion/session_replay/parse-message-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.test.ts
@@ -2,7 +2,8 @@ import { Message } from 'node-rdkafka'
import { promisify } from 'node:util'
import { gzip } from 'zlib'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+
import { ParseMessageStepInput, createParseMessageStep } from './parse-message-step'
const compressWithGzip = promisify(gzip)
diff --git a/nodejs/src/ingestion/session_replay/parse-message-step.ts b/nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.ts
similarity index 95%
rename from nodejs/src/ingestion/session_replay/parse-message-step.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.ts
index 6738c3a8f568..d43ec6976543 100644
--- a/nodejs/src/ingestion/session_replay/parse-message-step.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/parse-message-step.ts
@@ -2,18 +2,18 @@ import { DateTime } from 'luxon'
import { Message, MessageHeader } from 'node-rdkafka'
import { gunzipSync } from 'zlib'
+import { dlq, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
import {
EventSchema,
ParsedMessageData,
RawEventMessageSchema,
SnapshotEvent,
SnapshotEventSchema,
-} from '../../session-recording/kafka/types'
-import { SessionRecordingIngesterMetrics } from '../../session-recording/metrics'
-import { parseJSON } from '../../utils/json-parse'
-import { normalizeSessionId } from '../../utils/utils'
-import { dlq, drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+} from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { SessionRecordingIngesterMetrics } from '~/ingestion/pipelines/sessionreplay/metrics'
+import { parseJSON } from '~/utils/json-parse'
+import { normalizeSessionId } from '~/utils/utils'
const lz4: { decodeBlock(input: Buffer, output: Buffer): number } = require('lz4')
diff --git a/nodejs/src/ingestion/session_replay/record-session-event-step.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.test.ts
similarity index 88%
rename from nodejs/src/ingestion/session_replay/record-session-event-step.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.test.ts
index 5cf83d5555fd..1295314c3960 100644
--- a/nodejs/src/ingestion/session_replay/record-session-event-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.test.ts
@@ -1,14 +1,15 @@
import { DateTime } from 'luxon'
-import { ParsedMessageData } from '../../session-recording/kafka/types'
-import { SessionRecordingIngesterMetrics } from '../../session-recording/metrics'
-import { SessionBatchManager } from '../../session-recording/sessions/session-batch-manager'
-import { SessionBatchRecorder } from '../../session-recording/sessions/session-batch-recorder'
-import { TeamForReplay } from '../../session-recording/teams/types'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { SessionRecordingIngesterMetrics } from '~/ingestion/pipelines/sessionreplay/metrics'
+import { SessionBatchManager } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-manager'
+import { SessionBatchRecorder } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+
import { RecordSessionEventStepInput, createRecordSessionEventStep } from './record-session-event-step'
-jest.mock('../../session-recording/metrics', () => ({
+jest.mock('~/ingestion/pipelines/sessionreplay/metrics', () => ({
SessionRecordingIngesterMetrics: {
resetSessionsRevoked: jest.fn(),
observeSessionInfo: jest.fn(),
diff --git a/nodejs/src/ingestion/session_replay/record-session-event-step.ts b/nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.ts
similarity index 79%
rename from nodejs/src/ingestion/session_replay/record-session-event-step.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.ts
index 0d07d156add6..fb16b0369d3e 100644
--- a/nodejs/src/ingestion/session_replay/record-session-event-step.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/record-session-event-step.ts
@@ -1,11 +1,11 @@
-import { ParsedMessageData } from '../../session-recording/kafka/types'
-import { SessionRecordingIngesterMetrics } from '../../session-recording/metrics'
-import { SessionBatchManager } from '../../session-recording/sessions/session-batch-manager'
-import { MessageWithTeam, TeamForReplay } from '../../session-recording/teams/types'
-import { ValueMatcher } from '../../types'
-import { logger } from '../../utils/logger'
-import { ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { SessionRecordingIngesterMetrics } from '~/ingestion/pipelines/sessionreplay/metrics'
+import { SessionBatchManager } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-manager'
+import { MessageWithTeam, TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { ValueMatcher } from '~/types'
+import { logger } from '~/utils/logger'
export interface RecordSessionEventStepInput {
team: TeamForReplay
diff --git a/nodejs/src/session-recording/rrweb-types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/rrweb-types.ts
similarity index 100%
rename from nodejs/src/session-recording/rrweb-types.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/rrweb-types.ts
diff --git a/nodejs/src/session-recording/segmentation.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/segmentation.test.ts
similarity index 99%
rename from nodejs/src/session-recording/segmentation.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/segmentation.test.ts
index ed69576db488..c4530194ec5c 100644
--- a/nodejs/src/session-recording/segmentation.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/segmentation.test.ts
@@ -1,4 +1,5 @@
-import { RRWebEvent } from '../types'
+import { RRWebEvent } from '~/types'
+
import { RRWebEventSource, RRWebEventType } from './rrweb-types'
import { SegmentationEvent, activeMillisecondsFromSegmentationEvents, toSegmentationEvent } from './segmentation'
diff --git a/nodejs/src/session-recording/segmentation.ts b/nodejs/src/ingestion/pipelines/sessionreplay/segmentation.ts
similarity index 100%
rename from nodejs/src/session-recording/segmentation.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/segmentation.ts
diff --git a/nodejs/src/session-recording/session-recording-restriction-handler.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.test.ts
similarity index 99%
rename from nodejs/src/session-recording/session-recording-restriction-handler.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.test.ts
index 8bd9ebac7a25..5580ac688149 100644
--- a/nodejs/src/session-recording/session-recording-restriction-handler.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.test.ts
@@ -1,8 +1,9 @@
import { Message } from 'node-rdkafka'
-import { KafkaProducerWrapper } from '../kafka/producer'
-import { EventIngestionRestrictionManager, RestrictionType } from '../utils/event-ingestion-restrictions'
-import { PromiseScheduler } from '../utils/promise-scheduler'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { EventIngestionRestrictionManager, RestrictionType } from '~/utils/event-ingestion-restrictions'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { SessionRecordingIngesterMetrics } from './metrics'
import { SessionRecordingRestrictionHandler } from './session-recording-restriction-handler'
diff --git a/nodejs/src/session-recording/session-recording-restriction-handler.ts b/nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.ts
similarity index 92%
rename from nodejs/src/session-recording/session-recording-restriction-handler.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.ts
index b4f5cc190802..6e069bf61a75 100644
--- a/nodejs/src/session-recording/session-recording-restriction-handler.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/session-recording-restriction-handler.ts
@@ -1,10 +1,11 @@
import { Message } from 'node-rdkafka'
-import { parseEventHeaders, parseKafkaHeaders } from '../kafka/consumer'
-import { KafkaProducerWrapper } from '../kafka/producer'
-import { EventIngestionRestrictionManager, RestrictionType } from '../utils/event-ingestion-restrictions'
-import { logger } from '../utils/logger'
-import { PromiseScheduler } from '../utils/promise-scheduler'
+import { parseEventHeaders, parseKafkaHeaders } from '~/kafka/consumer'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { EventIngestionRestrictionManager, RestrictionType } from '~/utils/event-ingestion-restrictions'
+import { logger } from '~/utils/logger'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { SessionRecordingIngesterMetrics } from './metrics'
export class SessionRecordingRestrictionHandler {
diff --git a/nodejs/src/ingestion/session_replay/session-replay-pipeline.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.test.ts
similarity index 97%
rename from nodejs/src/ingestion/session_replay/session-replay-pipeline.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.test.ts
index cb26f71deb6a..819884ec9be1 100644
--- a/nodejs/src/ingestion/session_replay/session-replay-pipeline.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.test.ts
@@ -1,22 +1,23 @@
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { SessionBatchManager } from '../../session-recording/sessions/session-batch-manager'
-import { SessionBatchRecorder } from '../../session-recording/sessions/session-batch-recorder'
-import { TeamForReplay } from '../../session-recording/teams/types'
-import { TeamService } from '../../session-replay/shared/teams/team-service'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { parseJSON } from '../../utils/json-parse'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '../common/outputs'
-import { createApplyEventRestrictionsStep, createParseHeadersStep } from '../event-preprocessing'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { TopHogRegistry } from '../pipelines/extensions/tophog'
-import { drop, ok, redirect } from '../pipelines/results'
+import { DLQ_OUTPUT, INGESTION_WARNINGS_OUTPUT, OVERFLOW_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { createApplyEventRestrictionsStep, createParseHeadersStep } from '~/ingestion/common/steps/event-preprocessing'
+import { TopHogRegistry } from '~/ingestion/framework/extensions/tophog'
+import { drop, ok, redirect } from '~/ingestion/framework/results'
+import { SessionBatchManager } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-manager'
+import { SessionBatchRecorder } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { parseJSON } from '~/utils/json-parse'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { createSessionReplayPipeline, runSessionReplayPipeline } from './session-replay-pipeline'
-jest.mock('../event-preprocessing', () => ({
+jest.mock('~/ingestion/common/steps/event-preprocessing', () => ({
createParseHeadersStep: jest.fn(),
createApplyEventRestrictionsStep: jest.fn(),
}))
diff --git a/nodejs/src/ingestion/session_replay/session-replay-pipeline.ts b/nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.ts
similarity index 88%
rename from nodejs/src/ingestion/session_replay/session-replay-pipeline.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.ts
index cd6d5776bc64..2a9c091a94e1 100644
--- a/nodejs/src/ingestion/session_replay/session-replay-pipeline.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/session-replay-pipeline.ts
@@ -1,20 +1,21 @@
import { Message } from 'node-rdkafka'
-import { ParsedMessageData } from '../../session-recording/kafka/types'
-import { SessionBatchManager } from '../../session-recording/sessions/session-batch-manager'
-import { TeamForReplay } from '../../session-recording/teams/types'
-import { TeamService } from '../../session-replay/shared/teams/team-service'
-import { ValueMatcher } from '../../types'
-import { EventIngestionRestrictionManager } from '../../utils/event-ingestion-restrictions'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { DlqOutput, IngestionWarningsOutput, OverflowOutput } from '../common/outputs'
-import { createApplyEventRestrictionsStep, createParseHeadersStep } from '../event-preprocessing'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { BatchPipelineUnwrapper } from '../pipelines/batch-pipeline-unwrapper'
-import { newBatchPipelineBuilder } from '../pipelines/builders'
-import { TopHogRegistry, createTopHogWrapper, sum, timer } from '../pipelines/extensions/tophog'
-import { createBatch, createUnwrapper } from '../pipelines/helpers'
-import { PipelineConfig } from '../pipelines/result-handling-pipeline'
+import { DlqOutput, IngestionWarningsOutput, OverflowOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { createApplyEventRestrictionsStep, createParseHeadersStep } from '~/ingestion/common/steps/event-preprocessing'
+import { BatchPipelineUnwrapper } from '~/ingestion/framework/batch-pipeline-unwrapper'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { TopHogRegistry, createTopHogWrapper, sum, timer } from '~/ingestion/framework/extensions/tophog'
+import { createBatch, createUnwrapper } from '~/ingestion/framework/helpers'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { SessionBatchManager } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-manager'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { ValueMatcher } from '~/types'
+import { EventIngestionRestrictionManager } from '~/utils/event-ingestion-restrictions'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
+
import { createLibVersionMonitorStep } from './lib-version-monitor-step'
import { createParseMessageStep } from './parse-message-step'
import { createRecordSessionEventStep } from './record-session-event-step'
diff --git a/nodejs/src/session-recording/sessions/blackhole-session-batch-writer.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/blackhole-session-batch-writer.test.ts
similarity index 100%
rename from nodejs/src/session-recording/sessions/blackhole-session-batch-writer.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/blackhole-session-batch-writer.test.ts
diff --git a/nodejs/src/session-recording/sessions/blackhole-session-batch-writer.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/blackhole-session-batch-writer.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/blackhole-session-batch-writer.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/blackhole-session-batch-writer.ts
index 7fe5db2334c4..08f86094059e 100644
--- a/nodejs/src/session-recording/sessions/blackhole-session-batch-writer.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/blackhole-session-batch-writer.ts
@@ -1,4 +1,5 @@
-import { logger } from '../../utils/logger'
+import { logger } from '~/utils/logger'
+
import {
SessionBatchFileStorage,
SessionBatchFileWriter,
diff --git a/nodejs/src/session-recording/sessions/metrics.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/metrics.ts
similarity index 100%
rename from nodejs/src/session-recording/sessions/metrics.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/metrics.ts
diff --git a/nodejs/src/session-recording/sessions/retention-aware-batch-writer.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.test.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/retention-aware-batch-writer.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.test.ts
index 64834986d15d..ccd48f3d44df 100644
--- a/nodejs/src/session-recording/sessions/retention-aware-batch-writer.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.test.ts
@@ -1,12 +1,13 @@
import { S3Client } from '@aws-sdk/client-s3'
import { Upload } from '@aws-sdk/lib-storage'
-import { RetentionService } from '../../session-replay/shared/retention/retention-service'
-import { TeamId } from '../../types'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { TeamId } from '~/types'
+
import { RetentionAwareStorage } from './retention-aware-batch-writer'
jest.mock('@aws-sdk/lib-storage')
-jest.mock('../../utils/logger')
+jest.mock('~/utils/logger')
jest.setTimeout(1000)
diff --git a/nodejs/src/session-recording/sessions/retention-aware-batch-writer.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.ts
similarity index 89%
rename from nodejs/src/session-recording/sessions/retention-aware-batch-writer.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.ts
index 0dd34c9d66d4..d35d6033ea17 100644
--- a/nodejs/src/session-recording/sessions/retention-aware-batch-writer.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/retention-aware-batch-writer.ts
@@ -1,9 +1,10 @@
import { S3Client } from '@aws-sdk/client-s3'
-import { RetentionService } from '../../session-replay/shared/retention/retention-service'
-import { ValidRetentionPeriods } from '../constants'
-import { RetentionPeriodToDaysMap } from '../constants'
-import { RetentionPeriod } from '../types'
+import { ValidRetentionPeriods } from '~/ingestion/pipelines/sessionreplay/constants'
+import { RetentionPeriodToDaysMap } from '~/ingestion/pipelines/sessionreplay/constants'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { RetentionPeriod } from '~/ingestion/pipelines/sessionreplay/types'
+
import { S3SessionBatchFileStorage } from './s3-session-batch-writer'
import {
SessionBatchFileStorage,
diff --git a/nodejs/src/session-recording/sessions/s3-session-batch-writer.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/s3-session-batch-writer.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.test.ts
index 51c9a3872bb8..bcfa67f4a52c 100644
--- a/nodejs/src/session-recording/sessions/s3-session-batch-writer.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.test.ts
@@ -5,7 +5,7 @@ import { SessionBatchMetrics } from './metrics'
import { S3SessionBatchFileStorage } from './s3-session-batch-writer'
jest.mock('@aws-sdk/lib-storage')
-jest.mock('../../utils/logger')
+jest.mock('~/utils/logger')
jest.mock('./metrics', () => ({
SessionBatchMetrics: {
incrementS3BatchesStarted: jest.fn(),
diff --git a/nodejs/src/session-recording/sessions/s3-session-batch-writer.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/s3-session-batch-writer.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.ts
index bfcf0abce27c..1fcbdd8079c9 100644
--- a/nodejs/src/session-recording/sessions/s3-session-batch-writer.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/s3-session-batch-writer.ts
@@ -3,7 +3,8 @@ import { Upload } from '@aws-sdk/lib-storage'
import { randomBytes } from 'crypto'
import { PassThrough } from 'stream'
-import { logger } from '../../utils/logger'
+import { logger } from '~/utils/logger'
+
import { SessionBatchMetrics } from './metrics'
import {
SessionBatchFileStorage,
diff --git a/nodejs/src/session-recording/sessions/session-batch-file-storage.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-file-storage.ts
similarity index 98%
rename from nodejs/src/session-recording/sessions/session-batch-file-storage.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-file-storage.ts
index 7e75102a163d..e7f5d6d2d31f 100644
--- a/nodejs/src/session-recording/sessions/session-batch-file-storage.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-file-storage.ts
@@ -1,4 +1,4 @@
-import { TeamId } from '../../types'
+import { TeamId } from '~/types'
export interface WriteSessionData {
/** The serialized session block data */
diff --git a/nodejs/src/session-recording/sessions/session-batch-manager.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.test.ts
similarity index 95%
rename from nodejs/src/session-recording/sessions/session-batch-manager.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.test.ts
index fff0074f529b..ddb3cf947a16 100644
--- a/nodejs/src/session-recording/sessions/session-batch-manager.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.test.ts
@@ -1,8 +1,9 @@
-import { SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { createMockEncryptor, createMockKeyStore } from '../../session-replay/shared/test-helpers'
-import { KeyStore, RecordingEncryptor } from '../../session-replay/shared/types'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { createMockEncryptor, createMockKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/test-helpers'
+import { KeyStore, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { SessionBatchFileStorage, SessionBatchFileWriter } from './session-batch-file-storage'
import { SessionBatchManager } from './session-batch-manager'
import { SessionBatchRecorder } from './session-batch-recorder'
diff --git a/nodejs/src/session-recording/sessions/session-batch-manager.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.ts
similarity index 92%
rename from nodejs/src/session-recording/sessions/session-batch-manager.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.ts
index c67f851a2997..60cf3af99464 100644
--- a/nodejs/src/session-recording/sessions/session-batch-manager.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-manager.ts
@@ -1,8 +1,9 @@
-import { SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { KeyStore, RecordingEncryptor } from '../../session-replay/shared/types'
-import { logger } from '../../utils/logger'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { KeyStore, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { logger } from '~/utils/logger'
+
import { SessionBatchFileStorage } from './session-batch-file-storage'
import { SessionBatchRecorder } from './session-batch-recorder'
import { SessionConsoleLogStore } from './session-console-log-store'
diff --git a/nodejs/src/session-recording/sessions/session-batch-recorder.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-batch-recorder.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.test.ts
index 95060ea02f84..dd7abb5c39df 100644
--- a/nodejs/src/session-recording/sessions/session-batch-recorder.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.test.ts
@@ -1,14 +1,15 @@
import { DateTime } from 'luxon'
import { validate as uuidValidate } from 'uuid'
-import { SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { createMockEncryptor, createMockKeyStore } from '../../session-replay/shared/test-helpers'
-import { KeyStore, RecordingEncryptor } from '../../session-replay/shared/types'
-import { parseJSON } from '../../utils/json-parse'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
-import { ParsedMessageData, SnapshotEvent } from '../kafka/types'
-import { MessageWithTeam } from '../teams/types'
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import { ParsedMessageData, SnapshotEvent } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { createMockEncryptor, createMockKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/test-helpers'
+import { KeyStore, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { parseJSON } from '~/utils/json-parse'
+
import { SessionBatchMetrics } from './metrics'
import { SessionBatchFileStorage, SessionBatchFileWriter } from './session-batch-file-storage'
import { SessionBatchRecorder } from './session-batch-recorder'
diff --git a/nodejs/src/session-recording/sessions/session-batch-recorder.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.ts
similarity index 95%
rename from nodejs/src/session-recording/sessions/session-batch-recorder.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.ts
index a9fd920374aa..2f7bd7c6399f 100644
--- a/nodejs/src/session-recording/sessions/session-batch-recorder.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder.ts
@@ -1,13 +1,17 @@
import { v7 as uuidv7 } from 'uuid'
-import { SessionFeatureBlock, SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { SessionBlockMetadata } from '../../session-replay/shared/metadata/session-block-metadata'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { KeyStore, RecordingEncryptor, SessionKey } from '../../session-replay/shared/types'
-import { logger } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
-import { MessageWithTeam } from '../teams/types'
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import {
+ SessionFeatureBlock,
+ SessionFeatureStore,
+} from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionBlockMetadata } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { KeyStore, RecordingEncryptor, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { logger } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+
import { SessionBatchMetrics } from './metrics'
import { SessionBatchFileStorage } from './session-batch-file-storage'
import { SessionConsoleLogRecorder } from './session-console-log-recorder'
diff --git a/nodejs/src/session-recording/sessions/session-console-log-recorder.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-console-log-recorder.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.test.ts
index 682d819a000a..076135f8239b 100644
--- a/nodejs/src/session-recording/sessions/session-console-log-recorder.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.test.ts
@@ -1,7 +1,8 @@
import { DateTime } from 'luxon'
-import { ConsoleLogLevel, RRWebEventType } from '../rrweb-types'
-import { MessageWithTeam } from '../teams/types'
+import { ConsoleLogLevel, RRWebEventType } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+
import { SessionConsoleLogRecorder } from './session-console-log-recorder'
import { SessionConsoleLogStore } from './session-console-log-store'
diff --git a/nodejs/src/session-recording/sessions/session-console-log-recorder.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.ts
similarity index 95%
rename from nodejs/src/session-recording/sessions/session-console-log-recorder.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.ts
index 1a4f40f871d5..de152d30b9c5 100644
--- a/nodejs/src/session-recording/sessions/session-console-log-recorder.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-recorder.ts
@@ -1,11 +1,11 @@
import { DateTime } from 'luxon'
+import { ConsoleLogLevel, RRWebEventType } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { TimestampFormat } from '~/types'
import { sanitizeForUTF8 } from '~/utils/strings'
+import { castTimestampOrNow } from '~/utils/utils'
-import { TimestampFormat } from '../../types'
-import { castTimestampOrNow } from '../../utils/utils'
-import { ConsoleLogLevel, RRWebEventType } from '../rrweb-types'
-import { MessageWithTeam } from '../teams/types'
import { ConsoleLogEntry, SessionConsoleLogStore } from './session-console-log-store'
const levelMapping: Record<string, ConsoleLogLevel> = {
diff --git a/nodejs/src/session-recording/sessions/session-console-log-store.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.test.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/session-console-log-store.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.test.ts
index ef77864c49a0..e007aa405d9f 100644
--- a/nodejs/src/session-recording/sessions/session-console-log-store.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.test.ts
@@ -1,9 +1,10 @@
-import { LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { IngestionOutputMessage } from '../../ingestion/outputs/types'
-import { ClickHouseTimestamp } from '../../types'
-import { parseJSON } from '../../utils/json-parse'
-import { ConsoleLogLevel } from '../rrweb-types'
+import { LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { IngestionOutputMessage } from '~/common/outputs/types'
+import { ConsoleLogLevel } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { ClickHouseTimestamp } from '~/types'
+import { parseJSON } from '~/utils/json-parse'
+
import { SessionBatchMetrics } from './metrics'
import { ConsoleLogEntry, SessionConsoleLogStore } from './session-console-log-store'
diff --git a/nodejs/src/session-recording/sessions/session-console-log-store.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.ts
similarity index 87%
rename from nodejs/src/session-recording/sessions/session-console-log-store.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.ts
index a2e2dfaf103e..0cb7eac48c05 100644
--- a/nodejs/src/session-recording/sessions/session-console-log-store.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-console-log-store.ts
@@ -1,8 +1,9 @@
-import { LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '../../ingestion/common/outputs'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { ClickHouseTimestamp } from '../../types'
-import { logger } from '../../utils/logger'
-import { ConsoleLogLevel } from '../rrweb-types'
+import { LOG_ENTRIES_OUTPUT, LogEntriesOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { ConsoleLogLevel } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { ClickHouseTimestamp } from '~/types'
+import { logger } from '~/utils/logger'
+
import { SessionBatchMetrics } from './metrics'
export type ConsoleLogEntry = {
diff --git a/nodejs/src/session-recording/sessions/session-feature-recorder.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-feature-recorder.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.test.ts
index 70734ac123fd..3cf429dba806 100644
--- a/nodejs/src/session-recording/sessions/session-feature-recorder.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.test.ts
@@ -1,11 +1,12 @@
import { DateTime } from 'luxon'
-import { defaultConfig } from '../../config/config'
-import { ParsedMessageData, SnapshotEvent } from '../kafka/types'
-import { MouseInteractions, RRWebEventSource, RRWebEventType } from '../rrweb-types'
+import { defaultConfig } from '~/config/config'
+import { ParsedMessageData, SnapshotEvent } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { MouseInteractions, RRWebEventSource, RRWebEventType } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+
import { MAX_UNIQUE_VALUES, SessionFeatureRecorder, md5Hex } from './session-feature-recorder'
-jest.mock('../../config/config', () => ({
+jest.mock('~/config/config', () => ({
defaultConfig: {
SESSION_RECORDING_FEATURES_ENABLED: true,
SESSION_RECORDING_FEATURES_ROLLOUT_PERCENTAGE: 100,
diff --git a/nodejs/src/session-recording/sessions/session-feature-recorder.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-feature-recorder.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.ts
index c72b986e4bba..f3b45fad7bfa 100644
--- a/nodejs/src/session-recording/sessions/session-feature-recorder.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder.ts
@@ -1,8 +1,8 @@
import crypto from 'crypto'
import { DateTime } from 'luxon'
-import { defaultConfig } from '../../config/config'
-import { ParsedMessageData, SnapshotEvent } from '../kafka/types'
+import { defaultConfig } from '~/config/config'
+import { ParsedMessageData, SnapshotEvent } from '~/ingestion/pipelines/sessionreplay/kafka/types'
import {
MouseInteractions,
RRWebEventSource,
@@ -11,7 +11,7 @@ import {
isClick,
isKeypress,
isMouseActivity,
-} from '../rrweb-types'
+} from '~/ingestion/pipelines/sessionreplay/rrweb-types'
const POSTHOG_NETWORK_PLUGIN = 'posthog/network@1'
const RRWEB_NETWORK_PLUGIN = 'rrweb/network@1'
diff --git a/nodejs/src/session-recording/sessions/session-filter.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-filter.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.test.ts
index f4ea9784ef4f..37bdea0a0de4 100644
--- a/nodejs/src/session-recording/sessions/session-filter.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.test.ts
@@ -1,5 +1,6 @@
-import { RedisPool } from '../../types'
-import { Limiter } from '../../utils/token-bucket'
+import { RedisPool } from '~/types'
+import { Limiter } from '~/utils/token-bucket'
+
import { SessionBatchMetrics } from './metrics'
import { SessionFilter } from './session-filter'
@@ -13,7 +14,7 @@ jest.mock('./metrics', () => ({
},
}))
-jest.mock('../../utils/token-bucket')
+jest.mock('~/utils/token-bucket')
describe('SessionFilter', () => {
let sessionFilter: SessionFilter
diff --git a/nodejs/src/session-recording/sessions/session-filter.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/session-filter.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.ts
index 2390bb117b70..4a3514774052 100644
--- a/nodejs/src/session-recording/sessions/session-filter.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-filter.ts
@@ -1,9 +1,10 @@
import { LRUCache } from 'lru-cache'
-import { RedisPool } from '../../types'
-import { logger } from '../../utils/logger'
-import { Limiter } from '../../utils/token-bucket'
-import { SESSION_FILTER_REDIS_TTL_SECONDS } from '../constants'
+import { SESSION_FILTER_REDIS_TTL_SECONDS } from '~/ingestion/pipelines/sessionreplay/constants'
+import { RedisPool } from '~/types'
+import { logger } from '~/utils/logger'
+import { Limiter } from '~/utils/token-bucket'
+
import { SessionBatchMetrics } from './metrics'
const DEFAULT_LOCAL_CACHE_MAX_SIZE = 100_000
diff --git a/nodejs/src/session-recording/sessions/session-rate-limiter.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-rate-limiter.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.test.ts
index 0d55afe70de0..b9e5eb309701 100644
--- a/nodejs/src/session-recording/sessions/session-rate-limiter.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.test.ts
@@ -1,4 +1,5 @@
-import { ParsedMessageData } from '../kafka/types'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+
import { SessionRateLimiter } from './session-rate-limiter'
jest.mock('./metrics', () => ({
diff --git a/nodejs/src/session-recording/sessions/session-rate-limiter.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.ts
similarity index 97%
rename from nodejs/src/session-recording/sessions/session-rate-limiter.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.ts
index f562c39cebf1..c8941de7da6a 100644
--- a/nodejs/src/session-recording/sessions/session-rate-limiter.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-rate-limiter.ts
@@ -1,4 +1,5 @@
-import { ParsedMessageData } from '../kafka/types'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+
import { SessionBatchMetrics } from './metrics'
/**
diff --git a/nodejs/src/session-recording/sessions/session-tracker.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/session-tracker.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.test.ts
index 0083d10e772f..ef7c2d56f880 100644
--- a/nodejs/src/session-recording/sessions/session-tracker.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.test.ts
@@ -1,6 +1,7 @@
import { Redis } from 'ioredis'
-import { RedisPool } from '../../types'
+import { RedisPool } from '~/types'
+
import { SessionBatchMetrics } from './metrics'
import { SessionTracker } from './session-tracker'
diff --git a/nodejs/src/session-recording/sessions/session-tracker.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.ts
similarity index 94%
rename from nodejs/src/session-recording/sessions/session-tracker.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.ts
index e82ee756f07d..14eb1fe74e78 100644
--- a/nodejs/src/session-recording/sessions/session-tracker.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/session-tracker.ts
@@ -1,8 +1,9 @@
import { LRUCache } from 'lru-cache'
-import { RedisPool } from '../../types'
-import { logger } from '../../utils/logger'
-import { SESSION_TRACKER_REDIS_TTL_SECONDS } from '../constants'
+import { SESSION_TRACKER_REDIS_TTL_SECONDS } from '~/ingestion/pipelines/sessionreplay/constants'
+import { RedisPool } from '~/types'
+import { logger } from '~/utils/logger'
+
import { SessionBatchMetrics } from './metrics'
const DEFAULT_LOCAL_CACHE_MAX_SIZE = 100_000
diff --git a/nodejs/src/session-recording/sessions/snappy-session-recorder.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.test.ts
similarity index 99%
rename from nodejs/src/session-recording/sessions/snappy-session-recorder.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.test.ts
index f70c71914a5e..1b11b9ead596 100644
--- a/nodejs/src/session-recording/sessions/snappy-session-recorder.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.test.ts
@@ -1,9 +1,10 @@
import { DateTime } from 'luxon'
import snappy from 'snappy'
-import { parseJSON } from '../../utils/json-parse'
-import { ParsedMessageData } from '../kafka/types'
-import { RRWebEventType } from '../rrweb-types'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { RRWebEventType } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { parseJSON } from '~/utils/json-parse'
+
import { SnappySessionRecorder } from './snappy-session-recorder'
describe('SnappySessionRecorder', () => {
diff --git a/nodejs/src/session-recording/sessions/snappy-session-recorder.ts b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/snappy-session-recorder.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.ts
index bbf84d54d5ce..54ff76c9eb04 100644
--- a/nodejs/src/session-recording/sessions/snappy-session-recorder.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/sessions/snappy-session-recorder.ts
@@ -1,10 +1,14 @@
import { DateTime } from 'luxon'
import snappy from 'snappy'
-import { logger } from '../../utils/logger'
-import { ParsedMessageData } from '../kafka/types'
-import { hrefFrom, isClick, isKeypress, isMouseActivity } from '../rrweb-types'
-import { SegmentationEvent, activeMillisecondsFromSegmentationEvents, toSegmentationEvent } from '../segmentation'
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { hrefFrom, isClick, isKeypress, isMouseActivity } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import {
+ SegmentationEvent,
+ activeMillisecondsFromSegmentationEvents,
+ toSegmentationEvent,
+} from '~/ingestion/pipelines/sessionreplay/segmentation'
+import { logger } from '~/utils/logger'
const MAX_SNAPSHOT_FIELD_LENGTH = 1000
const MAX_URL_LENGTH = 4 * 1024 // 4KB
diff --git a/nodejs/src/session-replay/shared/constants.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/constants.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/constants.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/constants.ts
diff --git a/nodejs/src/session-replay/shared/crypto/cleartext-decryptor.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.test.ts
similarity index 95%
rename from nodejs/src/session-replay/shared/crypto/cleartext-decryptor.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.test.ts
index eea8efc7cf98..ff0bd5e9c647 100644
--- a/nodejs/src/session-replay/shared/crypto/cleartext-decryptor.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.test.ts
@@ -1,4 +1,5 @@
-import { KeyStore } from '../types'
+import { KeyStore } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { CleartextRecordingDecryptor } from './cleartext-decryptor'
describe('CleartextRecordingDecryptor', () => {
diff --git a/nodejs/src/session-replay/shared/crypto/cleartext-decryptor.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.ts
similarity index 84%
rename from nodejs/src/session-replay/shared/crypto/cleartext-decryptor.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.ts
index 108ea6ec98aa..c870b81faad4 100644
--- a/nodejs/src/session-replay/shared/crypto/cleartext-decryptor.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-decryptor.ts
@@ -1,4 +1,9 @@
-import { DecryptResult, KeyStore, RecordingDecryptor, SessionKey } from '../types'
+import {
+ DecryptResult,
+ KeyStore,
+ RecordingDecryptor,
+ SessionKey,
+} from '~/ingestion/pipelines/sessionreplay/shared/types'
/**
* Cleartext decryptor used for hobby deployments and local development instances.
diff --git a/nodejs/src/session-replay/shared/crypto/cleartext-encryptor.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.test.ts
similarity index 95%
rename from nodejs/src/session-replay/shared/crypto/cleartext-encryptor.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.test.ts
index 09d9b5ef9ef3..2d0d2ffea17a 100644
--- a/nodejs/src/session-replay/shared/crypto/cleartext-encryptor.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.test.ts
@@ -1,4 +1,5 @@
-import { KeyStore } from '../types'
+import { KeyStore } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { CleartextRecordingEncryptor } from './cleartext-encryptor'
describe('CleartextRecordingEncryptor', () => {
diff --git a/nodejs/src/session-replay/shared/crypto/cleartext-encryptor.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.ts
similarity index 84%
rename from nodejs/src/session-replay/shared/crypto/cleartext-encryptor.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.ts
index e48e31411d9a..04b1a4c5f5d0 100644
--- a/nodejs/src/session-replay/shared/crypto/cleartext-encryptor.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/cleartext-encryptor.ts
@@ -1,4 +1,9 @@
-import { EncryptResult, KeyStore, RecordingEncryptor, SessionKey } from '../types'
+import {
+ EncryptResult,
+ KeyStore,
+ RecordingEncryptor,
+ SessionKey,
+} from '~/ingestion/pipelines/sessionreplay/shared/types'
/**
* Cleartext encryptor used for hobby deployments and local development instances.
diff --git a/nodejs/src/session-replay/shared/crypto/index.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.test.ts
similarity index 91%
rename from nodejs/src/session-replay/shared/crypto/index.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.test.ts
index e72b1bbe4ad5..dcf1c5035198 100644
--- a/nodejs/src/session-replay/shared/crypto/index.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.test.ts
@@ -1,13 +1,14 @@
-import * as envUtils from '../../../utils/env-utils'
-import { KeyStore, SessionKey } from '../types'
+import { KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import * as envUtils from '~/utils/env-utils'
+
import { CleartextRecordingDecryptor } from './cleartext-decryptor'
import { CleartextRecordingEncryptor } from './cleartext-encryptor'
import { getBlockDecryptor, getBlockEncryptor } from './index'
import { SodiumRecordingDecryptor } from './sodium-decryptor'
import { SodiumRecordingEncryptor } from './sodium-encryptor'
-jest.mock('../../../utils/env-utils', () => ({
- ...jest.requireActual('../../../utils/env-utils'),
+jest.mock('~/utils/env-utils', () => ({
+ ...jest.requireActual('~/utils/env-utils'),
isCloud: jest.fn(),
}))
diff --git a/nodejs/src/session-replay/shared/crypto/index.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.ts
similarity index 91%
rename from nodejs/src/session-replay/shared/crypto/index.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.ts
index 490ff8d57946..7b040ab7124d 100644
--- a/nodejs/src/session-replay/shared/crypto/index.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/index.ts
@@ -1,5 +1,6 @@
-import { isCloud } from '../../../utils/env-utils'
-import { KeyStore, RecordingDecryptor, RecordingEncryptor } from '../types'
+import { KeyStore, RecordingDecryptor, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { isCloud } from '~/utils/env-utils'
+
import { CleartextRecordingDecryptor } from './cleartext-decryptor'
import { CleartextRecordingEncryptor } from './cleartext-encryptor'
import { SodiumRecordingDecryptor } from './sodium-decryptor'
diff --git a/nodejs/src/session-replay/shared/crypto/session-key.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.test.ts
similarity index 99%
rename from nodejs/src/session-replay/shared/crypto/session-key.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.test.ts
index fb9078d3f18b..9d3083b440bd 100644
--- a/nodejs/src/session-replay/shared/crypto/session-key.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.test.ts
@@ -1,4 +1,5 @@
-import { parseJSON } from '../../../utils/json-parse'
+import { parseJSON } from '~/utils/json-parse'
+
import { deserializeSessionKey, serializeSessionKey } from './session-key'
describe('session-key serialization', () => {
diff --git a/nodejs/src/session-replay/shared/crypto/session-key.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.ts
similarity index 84%
rename from nodejs/src/session-replay/shared/crypto/session-key.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.ts
index 73ac08be7132..1e3396e567cd 100644
--- a/nodejs/src/session-replay/shared/crypto/session-key.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/session-key.ts
@@ -1,5 +1,5 @@
-import { parseJSON } from '../../../utils/json-parse'
-import { SerializedSessionKey, SessionKey } from '../types'
+import { SerializedSessionKey, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { parseJSON } from '~/utils/json-parse'
export function serializeSessionKey(key: SessionKey): string {
const serialized: SerializedSessionKey = {
diff --git a/nodejs/src/session-replay/shared/crypto/sodium-decryptor.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.test.ts
similarity index 98%
rename from nodejs/src/session-replay/shared/crypto/sodium-decryptor.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.test.ts
index df9afe16df54..c3216dc9070b 100644
--- a/nodejs/src/session-replay/shared/crypto/sodium-decryptor.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.test.ts
@@ -1,6 +1,7 @@
import sodium from 'libsodium-wrappers'
-import { KeyStore, SessionKey, SessionKeyDeletedError } from '../types'
+import { KeyStore, SessionKey, SessionKeyDeletedError } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { SodiumRecordingDecryptor } from './sodium-decryptor'
import { SodiumRecordingEncryptor } from './sodium-encryptor'
diff --git a/nodejs/src/session-replay/shared/crypto/sodium-decryptor.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.ts
similarity index 88%
rename from nodejs/src/session-replay/shared/crypto/sodium-decryptor.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.ts
index a9d43f7dc60a..225f0bbbab9a 100644
--- a/nodejs/src/session-replay/shared/crypto/sodium-decryptor.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-decryptor.ts
@@ -1,6 +1,12 @@
import sodium from 'libsodium-wrappers'
-import { DecryptResult, KeyStore, RecordingDecryptor, SessionKey, SessionKeyDeletedError } from '../types'
+import {
+ DecryptResult,
+ KeyStore,
+ RecordingDecryptor,
+ SessionKey,
+ SessionKeyDeletedError,
+} from '~/ingestion/pipelines/sessionreplay/shared/types'
export class SodiumRecordingDecryptor implements RecordingDecryptor {
constructor(private keyStore: KeyStore) {}
diff --git a/nodejs/src/session-replay/shared/crypto/sodium-encryptor.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.test.ts
similarity index 98%
rename from nodejs/src/session-replay/shared/crypto/sodium-encryptor.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.test.ts
index cacf0bce05ad..d26bd46f1a9b 100644
--- a/nodejs/src/session-replay/shared/crypto/sodium-encryptor.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.test.ts
@@ -1,6 +1,7 @@
import sodium from 'libsodium-wrappers'
-import { KeyStore, SessionKey, SessionKeyDeletedError } from '../types'
+import { KeyStore, SessionKey, SessionKeyDeletedError } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { SodiumRecordingEncryptor } from './sodium-encryptor'
describe('SodiumRecordingEncryptor', () => {
diff --git a/nodejs/src/session-replay/shared/crypto/sodium-encryptor.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.ts
similarity index 88%
rename from nodejs/src/session-replay/shared/crypto/sodium-encryptor.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.ts
index 059d8a64e431..229c0a70dfc9 100644
--- a/nodejs/src/session-replay/shared/crypto/sodium-encryptor.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/sodium-encryptor.ts
@@ -1,6 +1,12 @@
import sodium from 'libsodium-wrappers'
-import { EncryptResult, KeyStore, RecordingEncryptor, SessionKey, SessionKeyDeletedError } from '../types'
+import {
+ EncryptResult,
+ KeyStore,
+ RecordingEncryptor,
+ SessionKey,
+ SessionKeyDeletedError,
+} from '~/ingestion/pipelines/sessionreplay/shared/types'
export class SodiumRecordingEncryptor implements RecordingEncryptor {
constructor(private keyStore: KeyStore) {}
diff --git a/nodejs/src/session-replay/shared/crypto/tsconfig.json b/nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/tsconfig.json
similarity index 100%
rename from nodejs/src/session-replay/shared/crypto/tsconfig.json
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/crypto/tsconfig.json
diff --git a/nodejs/src/session-replay/shared/features/metrics.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/features/metrics.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/features/metrics.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/features/metrics.ts
diff --git a/nodejs/src/session-replay/shared/features/session-feature-store.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/features/session-feature-store.ts
similarity index 95%
rename from nodejs/src/session-replay/shared/features/session-feature-store.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/features/session-feature-store.ts
index 2fa0ca9a6f07..5eebbc45032c 100644
--- a/nodejs/src/session-replay/shared/features/session-feature-store.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/features/session-feature-store.ts
@@ -1,9 +1,10 @@
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
-import { FeatureEndResult } from '../../../session-recording/sessions/session-feature-recorder'
-import { TimestampFormat } from '../../../types'
-import { logger } from '../../../utils/logger'
-import { castTimestampOrNow } from '../../../utils/utils'
-import { SESSION_FEATURES_OUTPUT, SessionFeaturesOutput } from '../outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { FeatureEndResult } from '~/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder'
+import { SESSION_FEATURES_OUTPUT, SessionFeaturesOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { TimestampFormat } from '~/types'
+import { logger } from '~/utils/logger'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { SessionFeatureStoreMetrics } from './metrics'
interface KafkaMessage {
diff --git a/nodejs/src/session-replay/shared/keystore/cache/index.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/index.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/keystore/cache/index.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/index.ts
diff --git a/nodejs/src/session-replay/shared/keystore/cache/memory-cache.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.test.ts
similarity index 99%
rename from nodejs/src/session-replay/shared/keystore/cache/memory-cache.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.test.ts
index a54ace1a872f..d9d6900cb20e 100644
--- a/nodejs/src/session-replay/shared/keystore/cache/memory-cache.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.test.ts
@@ -1,4 +1,5 @@
-import { KeyStore, SessionKey } from '../../types'
+import { KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { MemoryCachedKeyStore } from './memory-cache'
describe('MemoryCachedKeyStore', () => {
diff --git a/nodejs/src/session-replay/shared/keystore/cache/memory-cache.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.ts
similarity index 94%
rename from nodejs/src/session-replay/shared/keystore/cache/memory-cache.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.ts
index dbca102da65b..06c3114e4b18 100644
--- a/nodejs/src/session-replay/shared/keystore/cache/memory-cache.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/memory-cache.ts
@@ -1,6 +1,6 @@
import { LRUCache } from 'lru-cache'
-import { DeleteKeyResult, KeyStore, SessionKey } from '../../types'
+import { DeleteKeyResult, KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
const MEMORY_CACHE_MAX_SIZE = 1_000_000
const MEMORY_CACHE_TTL_MS = 24 * 60 * 60 * 1000 // 24 hours
diff --git a/nodejs/src/session-replay/shared/keystore/cache/redis-cache.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.test.ts
similarity index 99%
rename from nodejs/src/session-replay/shared/keystore/cache/redis-cache.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.test.ts
index 5604ed4d8187..36542a30d168 100644
--- a/nodejs/src/session-replay/shared/keystore/cache/redis-cache.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.test.ts
@@ -1,4 +1,5 @@
-import { KeyStore, SessionKey } from '../../types'
+import { KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+
import { RedisCachedKeyStore } from './redis-cache'
describe('RedisCachedKeyStore', () => {
diff --git a/nodejs/src/session-replay/shared/keystore/cache/redis-cache.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.ts
similarity index 90%
rename from nodejs/src/session-replay/shared/keystore/cache/redis-cache.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.ts
index 6e04599eab07..694d54b2bfa0 100644
--- a/nodejs/src/session-replay/shared/keystore/cache/redis-cache.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/redis-cache.ts
@@ -1,6 +1,9 @@
-import { RedisPool } from '../../../../types'
-import { deserializeSessionKey, serializeSessionKey } from '../../crypto/session-key'
-import { DeleteKeyResult, KeyStore, SessionKey } from '../../types'
+import {
+ deserializeSessionKey,
+ serializeSessionKey,
+} from '~/ingestion/pipelines/sessionreplay/shared/crypto/session-key'
+import { DeleteKeyResult, KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { RedisPool } from '~/types'
const CACHE_KEY_PREFIX = '@posthog/replay/recording-key'
const REDIS_CACHE_TTL_SECONDS = 60 * 60 * 24 // 24 hours
diff --git a/nodejs/src/session-replay/shared/keystore/cache/tsconfig.json b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/tsconfig.json
similarity index 100%
rename from nodejs/src/session-replay/shared/keystore/cache/tsconfig.json
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cache/tsconfig.json
diff --git a/nodejs/src/session-replay/shared/keystore/cleartext-keystore.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cleartext-keystore.test.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/keystore/cleartext-keystore.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cleartext-keystore.test.ts
diff --git a/nodejs/src/session-replay/shared/keystore/cleartext-keystore.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cleartext-keystore.ts
similarity index 92%
rename from nodejs/src/session-replay/shared/keystore/cleartext-keystore.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cleartext-keystore.ts
index b2b1ea6ddc23..40d58a45822d 100644
--- a/nodejs/src/session-replay/shared/keystore/cleartext-keystore.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/cleartext-keystore.ts
@@ -1,4 +1,4 @@
-import { DeleteKeyResult, KeyStore, SessionKey } from '../types'
+import { DeleteKeyResult, KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
/**
* Cleartext key store used for hobby deployments and local development instances.
diff --git a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.test.ts
similarity index 99%
rename from nodejs/src/session-replay/shared/keystore/dynamodb-keystore.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.test.ts
index f7a8d32a67cb..483fb0924eea 100644
--- a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.test.ts
@@ -1,7 +1,8 @@
import { ConditionalCheckFailedException, DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { KMSClient } from '@aws-sdk/client-kms'
-import { RetentionService } from '../retention/retention-service'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+
import { DynamoDBKeyStore } from './dynamodb-keystore'
describe('DynamoDBKeyStore', () => {
diff --git a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.ts
similarity index 97%
rename from nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.ts
index f2b75e7c4d75..e90da35db743 100644
--- a/nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/dynamodb-keystore.ts
@@ -8,8 +8,8 @@ import {
import { DecryptCommand, GenerateDataKeyCommand, KMSClient } from '@aws-sdk/client-kms'
import sodium from 'libsodium-wrappers'
-import { RetentionService } from '../retention/retention-service'
-import { DeleteKeyResult, KeyStore, SessionKey } from '../types'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { DeleteKeyResult, KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
const KEYS_TABLE_NAME = 'session-recording-keys'
const TOMBSTONE_TTL_SECONDS = 30 * 24 * 60 * 60 // 30 days
diff --git a/nodejs/src/session-replay/shared/keystore/index.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts
similarity index 85%
rename from nodejs/src/session-replay/shared/keystore/index.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts
index efc20b42048a..dd146aad8667 100644
--- a/nodejs/src/session-replay/shared/keystore/index.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts
@@ -1,11 +1,12 @@
-import * as envUtils from '../../../utils/env-utils'
-import { RetentionService } from '../retention/retention-service'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import * as envUtils from '~/utils/env-utils'
+
import { CleartextKeyStore } from './cleartext-keystore'
import { DynamoDBKeyStore } from './dynamodb-keystore'
import { getKeyStore } from './index'
-jest.mock('../../../utils/env-utils', () => ({
- ...jest.requireActual('../../../utils/env-utils'),
+jest.mock('~/utils/env-utils', () => ({
+ ...jest.requireActual('~/utils/env-utils'),
isCloud: jest.fn(),
}))
diff --git a/nodejs/src/session-replay/shared/keystore/index.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.ts
similarity index 83%
rename from nodejs/src/session-replay/shared/keystore/index.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.ts
index 1dafd43e47ef..c81465327d62 100644
--- a/nodejs/src/session-replay/shared/keystore/index.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.ts
@@ -1,10 +1,11 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { KMSClient } from '@aws-sdk/client-kms'
-import { isCloud } from '../../../utils/env-utils'
-import { logger } from '../../../utils/logger'
-import { RetentionService } from '../retention/retention-service'
-import { KeyStore } from '../types'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { KeyStore } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { isCloud } from '~/utils/env-utils'
+import { logger } from '~/utils/logger'
+
import { CleartextKeyStore } from './cleartext-keystore'
import { DynamoDBKeyStore } from './dynamodb-keystore'
diff --git a/nodejs/src/session-replay/shared/keystore/memory-keystore.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/memory-keystore.test.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/keystore/memory-keystore.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/memory-keystore.test.ts
diff --git a/nodejs/src/session-replay/shared/keystore/memory-keystore.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/memory-keystore.ts
similarity index 95%
rename from nodejs/src/session-replay/shared/keystore/memory-keystore.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/memory-keystore.ts
index b4dae23343ad..2f4775e92b6e 100644
--- a/nodejs/src/session-replay/shared/keystore/memory-keystore.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/memory-keystore.ts
@@ -1,6 +1,6 @@
import sodium from 'libsodium-wrappers'
-import { DeleteKeyResult, KeyStore, SessionKey } from '../types'
+import { DeleteKeyResult, KeyStore, SessionKey } from '~/ingestion/pipelines/sessionreplay/shared/types'
/**
* In-memory key store for testing purposes.
diff --git a/nodejs/src/session-replay/shared/keystore/tsconfig.json b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/tsconfig.json
similarity index 100%
rename from nodejs/src/session-replay/shared/keystore/tsconfig.json
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/tsconfig.json
diff --git a/nodejs/src/session-replay/shared/metadata/session-block-metadata.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/metadata/session-block-metadata.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata.ts
diff --git a/nodejs/src/session-replay/shared/metadata/session-metadata-store.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.test.ts
similarity index 98%
rename from nodejs/src/session-replay/shared/metadata/session-metadata-store.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.test.ts
index 6458cf8c1e7c..b29bcda68c64 100644
--- a/nodejs/src/session-replay/shared/metadata/session-metadata-store.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.test.ts
@@ -1,8 +1,9 @@
import { DateTime } from 'luxon'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
-import { parseJSON } from '../../../utils/json-parse'
-import { REPLAY_EVENTS_OUTPUT, ReplayEventsOutput } from '../outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { REPLAY_EVENTS_OUTPUT, ReplayEventsOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { parseJSON } from '~/utils/json-parse'
+
import { SessionMetadataStore } from './session-metadata-store'
function parseValue(value: Buffer | null): any {
diff --git a/nodejs/src/session-replay/shared/metadata/session-metadata-store.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.ts
similarity index 88%
rename from nodejs/src/session-replay/shared/metadata/session-metadata-store.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.ts
index 4ac3a22c180f..1aef5bae399a 100644
--- a/nodejs/src/session-replay/shared/metadata/session-metadata-store.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store.ts
@@ -1,10 +1,11 @@
import { randomUUID } from 'crypto'
-import { IngestionOutputs } from '../../../ingestion/outputs/ingestion-outputs'
-import { TimestampFormat } from '../../../types'
-import { logger } from '../../../utils/logger'
-import { castTimestampOrNow } from '../../../utils/utils'
-import { REPLAY_EVENTS_OUTPUT, ReplayEventsOutput } from '../outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { REPLAY_EVENTS_OUTPUT, ReplayEventsOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { TimestampFormat } from '~/types'
+import { logger } from '~/utils/logger'
+import { castTimestampOrNow } from '~/utils/utils'
+
import { SessionBlockMetadata } from './session-block-metadata'
export class SessionMetadataStore {
diff --git a/nodejs/src/session-replay/shared/outputs/index.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/index.ts
similarity index 87%
rename from nodejs/src/session-replay/shared/outputs/index.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/index.ts
index 299bd9618c0d..de9df5dea613 100644
--- a/nodejs/src/session-replay/shared/outputs/index.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/index.ts
@@ -1,6 +1,6 @@
// Output names shared between the session-recording consumer and the
// session-replay recording-api. Generic outputs (DLQ, ingestion warnings,
-// overflow, etc.) live in `ingestion/common/outputs`.
+// overflow, etc.) live in `common/outputs`.
export const REPLAY_EVENTS_OUTPUT = 'replay_events' as const
export type ReplayEventsOutput = typeof REPLAY_EVENTS_OUTPUT
diff --git a/nodejs/src/session-replay/shared/outputs/producer-config.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/producer-config.ts
similarity index 97%
rename from nodejs/src/session-replay/shared/outputs/producer-config.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/producer-config.ts
index 53df122e3a6b..2697b61463bb 100644
--- a/nodejs/src/session-replay/shared/outputs/producer-config.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/outputs/producer-config.ts
@@ -1,4 +1,4 @@
-import type { AllowedConfigKey } from '../../../ingestion/outputs/kafka-producer-config'
+import type { AllowedConfigKey } from '~/common/outputs/kafka-producer-config'
/**
* SESSIONREPLAY producer — the replay-domain Kafka cluster (warpstream-replay), carrying
diff --git a/nodejs/src/session-replay/shared/retention/metrics.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/metrics.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/retention/metrics.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/metrics.ts
diff --git a/nodejs/src/session-replay/shared/retention/retention-service.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.test.ts
similarity index 97%
rename from nodejs/src/session-replay/shared/retention/retention-service.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.test.ts
index 01b4f331eddc..54a785b3d077 100644
--- a/nodejs/src/session-replay/shared/retention/retention-service.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.test.ts
@@ -1,7 +1,8 @@
import { Redis } from 'ioredis'
-import { RedisPool, TeamId } from '../../../types'
-import { TeamService } from '../teams/team-service'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { RedisPool, TeamId } from '~/types'
+
import { RetentionServiceMetrics } from './metrics'
import { RetentionService } from './retention-service'
diff --git a/nodejs/src/session-replay/shared/retention/retention-service.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.ts
similarity index 90%
rename from nodejs/src/session-replay/shared/retention/retention-service.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.ts
index fc6e61b8c94d..15102f8b5ad3 100644
--- a/nodejs/src/session-replay/shared/retention/retention-service.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/retention/retention-service.ts
@@ -1,6 +1,11 @@
-import { RedisPool, TeamId } from '../../../types'
-import { RetentionPeriod, RetentionPeriodToDaysMap, ValidRetentionPeriods } from '../constants'
-import { TeamService } from '../teams/team-service'
+import {
+ RetentionPeriod,
+ RetentionPeriodToDaysMap,
+ ValidRetentionPeriods,
+} from '~/ingestion/pipelines/sessionreplay/shared/constants'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { RedisPool, TeamId } from '~/types'
+
import { RetentionServiceMetrics } from './metrics'
function isValidRetentionPeriod(retentionPeriod: string): retentionPeriod is RetentionPeriod {
diff --git a/nodejs/src/session-replay/shared/teams/metrics.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/metrics.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/teams/metrics.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/metrics.ts
diff --git a/nodejs/src/session-replay/shared/teams/team-service.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.test.ts
similarity index 99%
rename from nodejs/src/session-replay/shared/teams/team-service.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.test.ts
index 838d1b0ba081..442e35acec06 100644
--- a/nodejs/src/session-replay/shared/teams/team-service.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.test.ts
@@ -1,4 +1,5 @@
-import { PostgresRouter } from '../../../utils/db/postgres'
+import { PostgresRouter } from '~/utils/db/postgres'
+
import { TeamService } from './team-service'
describe('TeamService', () => {
diff --git a/nodejs/src/session-replay/shared/teams/team-service.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.ts
similarity index 90%
rename from nodejs/src/session-replay/shared/teams/team-service.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.ts
index 95b554c0324a..87b8abfb1f14 100644
--- a/nodejs/src/session-replay/shared/teams/team-service.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/team-service.ts
@@ -1,8 +1,9 @@
-import { Team, TeamId } from '../../../types'
-import { BackgroundRefresher } from '../../../utils/background-refresher'
-import { PostgresRouter, PostgresUse } from '../../../utils/db/postgres'
-import { logger } from '../../../utils/logger'
-import { RetentionPeriod } from '../constants'
+import { RetentionPeriod } from '~/ingestion/pipelines/sessionreplay/shared/constants'
+import { Team, TeamId } from '~/types'
+import { BackgroundRefresher } from '~/utils/background-refresher'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { logger } from '~/utils/logger'
+
import { TeamServiceMetrics } from './metrics'
import { TeamForReplay } from './types'
diff --git a/nodejs/src/session-replay/shared/teams/types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/types.ts
similarity index 70%
rename from nodejs/src/session-replay/shared/teams/types.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/types.ts
index 2f5213b9dd94..0199ebf917d8 100644
--- a/nodejs/src/session-replay/shared/teams/types.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/teams/types.ts
@@ -1,4 +1,4 @@
-import { TeamId } from '../../../types'
+import { TeamId } from '~/types'
export interface TeamForReplay {
teamId: TeamId
diff --git a/nodejs/src/session-replay/shared/test-helpers.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/test-helpers.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/test-helpers.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/test-helpers.ts
diff --git a/nodejs/src/session-replay/shared/types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/types.ts
similarity index 100%
rename from nodejs/src/session-replay/shared/types.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/shared/types.ts
diff --git a/nodejs/src/ingestion/session_replay/team-filter-step.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.test.ts
similarity index 95%
rename from nodejs/src/ingestion/session_replay/team-filter-step.test.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.test.ts
index 5a2c4da0d6a5..46ffec4ca056 100644
--- a/nodejs/src/ingestion/session_replay/team-filter-step.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.test.ts
@@ -1,6 +1,7 @@
-import { createTestEventHeaders } from '../../../tests/helpers/event-headers'
-import { TeamForReplay } from '../../session-recording/teams/types'
-import { PipelineResultType } from '../pipelines/results'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { createTestEventHeaders } from '~/tests/helpers/event-headers'
+
import { TeamFilterStepInput, TeamTokenResolver, createTeamFilterStep } from './team-filter-step'
describe('createTeamFilterStep', () => {
diff --git a/nodejs/src/ingestion/session_replay/team-filter-step.ts b/nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.ts
similarity index 83%
rename from nodejs/src/ingestion/session_replay/team-filter-step.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.ts
index c2e6e59ae20a..4d297d613ec3 100644
--- a/nodejs/src/ingestion/session_replay/team-filter-step.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/team-filter-step.ts
@@ -1,8 +1,8 @@
-import { TeamForReplay } from '../../session-recording/teams/types'
-import { TeamService } from '../../session-replay/shared/teams/team-service'
-import { EventHeaders } from '../../types'
-import { dlq, drop, ok } from '../pipelines/results'
-import { ProcessingStep } from '../pipelines/steps'
+import { dlq, drop, ok } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { EventHeaders } from '~/types'
export type TeamTokenResolver = Pick<TeamService, 'getTeamByToken' | 'getRetentionPeriodByTeamId'>
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/teams/types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/teams/types.ts
new file mode 100644
index 000000000000..2a11bb75061b
--- /dev/null
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/teams/types.ts
@@ -0,0 +1,9 @@
+import { ParsedMessageData } from '~/ingestion/pipelines/sessionreplay/kafka/types'
+import { TeamForReplay } from '~/ingestion/pipelines/sessionreplay/shared/teams/types'
+
+export type { TeamForReplay }
+
+export interface MessageWithTeam {
+ team: TeamForReplay
+ message: ParsedMessageData
+}
diff --git a/nodejs/src/session-recording/types.ts b/nodejs/src/ingestion/pipelines/sessionreplay/types.ts
similarity index 85%
rename from nodejs/src/session-recording/types.ts
rename to nodejs/src/ingestion/pipelines/sessionreplay/types.ts
index a75a5e90a948..417bdb93c6bd 100644
--- a/nodejs/src/session-recording/types.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/types.ts
@@ -2,7 +2,7 @@
import { Message } from 'node-rdkafka'
// Re-export shared RetentionPeriod so existing recording-ingestion imports still work
-export type { RetentionPeriod } from '../session-replay/shared/constants'
+export type { RetentionPeriod } from '~/ingestion/pipelines/sessionreplay/shared/constants'
export type PersistedRecordingMessage = {
window_id?: string
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.test.ts b/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.test.ts
index 882be1a1119e..59acf75e4756 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.test.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.test.ts
@@ -1,4 +1,5 @@
-import { HealthCheckResultOk } from '../../../types'
+import { HealthCheckResultOk } from '~/types'
+
import { MainLaneOverflowRedirect, MainLaneOverflowRedirectConfig } from './main-lane-overflow-redirect'
import { OverflowEventBatch } from './overflow-redirect-service'
import { OverflowRedisRepository } from './overflow-redis-repository'
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.ts b/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.ts
index fe61cea70280..dc90017c3a9c 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/main-lane-overflow-redirect.ts
@@ -1,5 +1,6 @@
-import { HealthCheckResult } from '../../../types'
-import { MemoryRateLimiter } from '../overflow-detector'
+import { MemoryRateLimiter } from '~/ingestion/utils/overflow-detector'
+import { HealthCheckResult } from '~/types'
+
import {
overflowRedirectCacheHitsTotal,
overflowRedirectCacheSize,
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.test.ts b/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.test.ts
index 1c2d2417c493..ab78d92dd5c8 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.test.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.test.ts
@@ -1,4 +1,5 @@
-import { HealthCheckResultError, HealthCheckResultOk } from '../../../types'
+import { HealthCheckResultError, HealthCheckResultOk } from '~/types'
+
import { OverflowLaneOverflowRedirect } from './overflow-lane-overflow-redirect'
import { OverflowEventBatch } from './overflow-redirect-service'
import { OverflowRedisRepository } from './overflow-redis-repository'
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.ts b/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.ts
index d37bd23f913c..3396c3cb69bd 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect.ts
@@ -1,4 +1,5 @@
-import { HealthCheckResult } from '../../../types'
+import { HealthCheckResult } from '~/types'
+
import { overflowRedirectEventsTotal, overflowRedirectKeysTotal } from './metrics'
import { OverflowEventBatch, OverflowRedirectService } from './overflow-redirect-service'
import { OverflowRedisRepository, OverflowType } from './overflow-redis-repository'
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redirect-service.ts b/nodejs/src/ingestion/utils/overflow-redirect/overflow-redirect-service.ts
index 076d8d066d3d..e47a652b3770 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redirect-service.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/overflow-redirect-service.ts
@@ -1,4 +1,5 @@
-import { HealthCheckResult } from '../../../types'
+import { HealthCheckResult } from '~/types'
+
import { OverflowType } from './overflow-redis-repository'
// Re-export OverflowType so consumers of the interface
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.ts b/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.ts
index 6ee6f8351fcb..c93d7fd86e7a 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.ts
+++ b/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.ts
@@ -1,9 +1,10 @@
import { Pool as GenericPool } from 'generic-pool'
import { Redis } from 'ioredis'
-import { HealthCheckResult, HealthCheckResultError, HealthCheckResultOk } from '../../../types'
-import { timeoutGuard } from '../../../utils/db/utils'
-import { logger } from '../../../utils/logger'
+import { HealthCheckResult, HealthCheckResultError, HealthCheckResultOk } from '~/types'
+import { timeoutGuard } from '~/utils/db/utils'
+import { logger } from '~/utils/logger'
+
import { overflowRedirectRedisLatency, overflowRedirectRedisOpsTotal } from './metrics'
export type OverflowType = 'events' | 'recordings' | 'llm'
diff --git a/nodejs/src/logs-ingestion/__snapshots__/logs-ingestion-consumer.test.ts.snap b/nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snap
similarity index 100%
rename from nodejs/src/logs-ingestion/__snapshots__/logs-ingestion-consumer.test.ts.snap
rename to nodejs/src/logs/__snapshots__/logs-ingestion-consumer.test.ts.snap
diff --git a/nodejs/src/logs-ingestion/config.ts b/nodejs/src/logs/config.ts
similarity index 98%
rename from nodejs/src/logs-ingestion/config.ts
rename to nodejs/src/logs/config.ts
index 877db53dde8d..97ba9c2aef9c 100644
--- a/nodejs/src/logs-ingestion/config.ts
+++ b/nodejs/src/logs/config.ts
@@ -8,8 +8,9 @@ import {
KAFKA_TRACES_INGESTION,
KAFKA_TRACES_INGESTION_DLQ,
KAFKA_TRACES_INGESTION_OVERFLOW,
-} from '../config/kafka-topics'
-import { isProdEnv } from '../utils/env-utils'
+} from '~/config/kafka-topics'
+import { isProdEnv } from '~/utils/env-utils'
+
import { LogsProducerName, WARPSTREAM_INGESTION_PRODUCER, WARPSTREAM_LOGS_PRODUCER } from './outputs/producers'
export type LogsIngestionOutputsConfig = {
diff --git a/nodejs/src/logs-ingestion/log-body-parse.test.ts b/nodejs/src/logs/log-body-parse.test.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/log-body-parse.test.ts
rename to nodejs/src/logs/log-body-parse.test.ts
diff --git a/nodejs/src/logs-ingestion/log-body-parse.ts b/nodejs/src/logs/log-body-parse.ts
similarity index 95%
rename from nodejs/src/logs-ingestion/log-body-parse.ts
rename to nodejs/src/logs/log-body-parse.ts
index c526decfcc38..0903f4444c30 100644
--- a/nodejs/src/logs-ingestion/log-body-parse.ts
+++ b/nodejs/src/logs/log-body-parse.ts
@@ -1,4 +1,4 @@
-import { parseJSON } from '../utils/json-parse'
+import { parseJSON } from '~/utils/json-parse'
/**
* Single `parseJSON(record.body)` outcome for logs ingestion.
diff --git a/nodejs/src/logs-ingestion/log-pii-scrub.test.ts b/nodejs/src/logs/log-pii-scrub.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/log-pii-scrub.test.ts
rename to nodejs/src/logs/log-pii-scrub.test.ts
index 351ff2de2834..e58cc54c4e2f 100644
--- a/nodejs/src/logs-ingestion/log-pii-scrub.test.ts
+++ b/nodejs/src/logs/log-pii-scrub.test.ts
@@ -1,4 +1,5 @@
-import { parseJSON } from '../utils/json-parse'
+import { parseJSON } from '~/utils/json-parse'
+
import {
PII_REDACTED,
encodeAttributeCell,
diff --git a/nodejs/src/logs-ingestion/log-pii-scrub.ts b/nodejs/src/logs/log-pii-scrub.ts
similarity index 98%
rename from nodejs/src/logs-ingestion/log-pii-scrub.ts
rename to nodejs/src/logs/log-pii-scrub.ts
index f367383dcbbc..6cf763394a76 100644
--- a/nodejs/src/logs-ingestion/log-pii-scrub.ts
+++ b/nodejs/src/logs/log-pii-scrub.ts
@@ -9,7 +9,8 @@
* One alternated pattern with a replace callback (vs three global passes) for fewer full-string scans. Uses
* `createTrackedRE2` for linear-time matching; ASCII-explicit classes for stable behavior under node-re2 Unicode mode.
*/
-import { createTrackedRE2 } from '../utils/tracked-re2'
+import { createTrackedRE2 } from '~/utils/tracked-re2'
+
import type { LogRecord } from './log-record-avro'
export const PII_REDACTED = '{{REDACTED}}'
diff --git a/nodejs/src/logs-ingestion/log-record-avro.test.ts b/nodejs/src/logs/log-record-avro.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/log-record-avro.test.ts
rename to nodejs/src/logs/log-record-avro.test.ts
index 442983728057..911d5c6f393b 100644
--- a/nodejs/src/logs-ingestion/log-record-avro.test.ts
+++ b/nodejs/src/logs/log-record-avro.test.ts
@@ -1,6 +1,7 @@
import avro from 'avsc'
-import { parseJSON } from '../utils/json-parse'
+import { parseJSON } from '~/utils/json-parse'
+
import * as logBodyParse from './log-body-parse'
import { PII_REDACTED, encodeAttributeCell } from './log-pii-scrub'
import {
diff --git a/nodejs/src/logs-ingestion/log-record-avro.ts b/nodejs/src/logs/log-record-avro.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/log-record-avro.ts
rename to nodejs/src/logs/log-record-avro.ts
index 9a1dae498e80..dbea73f5531c 100644
--- a/nodejs/src/logs-ingestion/log-record-avro.ts
+++ b/nodejs/src/logs/log-record-avro.ts
@@ -4,8 +4,8 @@ import { Histogram } from 'prom-client'
import { Readable } from 'stream'
import { instrumented } from '~/common/tracing/tracing-utils'
+import type { LogsSettings } from '~/types'
-import type { LogsSettings } from '../types'
import { type LogBodyParseResult, parseLogBodyForIngestion } from './log-body-parse'
import { EMPTY_PII, type PiiScrubStats, scrubLogRecord } from './log-pii-scrub'
diff --git a/nodejs/src/logs-ingestion/logs-billing.test.ts b/nodejs/src/logs/logs-billing.test.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/logs-billing.test.ts
rename to nodejs/src/logs/logs-billing.test.ts
diff --git a/nodejs/src/logs-ingestion/logs-ingestion-consumer.test.ts b/nodejs/src/logs/logs-ingestion-consumer.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/logs-ingestion-consumer.test.ts
rename to nodejs/src/logs/logs-ingestion-consumer.test.ts
index d43d5935b573..bae639741d6e 100644
--- a/nodejs/src/logs-ingestion/logs-ingestion-consumer.test.ts
+++ b/nodejs/src/logs/logs-ingestion-consumer.test.ts
@@ -3,18 +3,18 @@ import { mockProducer, mockProducerObserver } from '~/tests/helpers/mocks/produc
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
-import { deleteKeysWithPrefix } from '~/cdp/_tests/redis'
+import { APP_METRICS_OUTPUT, AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
+import { KAFKA_APP_METRICS_2, KAFKA_LOGS_CLICKHOUSE, KAFKA_LOGS_INGESTION_DLQ } from '~/config/kafka-topics'
import { forSnapshot } from '~/tests/helpers/snapshots'
import { createTeam, getFirstTeam, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresUse } from '~/utils/db/postgres'
+import { parseJSON } from '~/utils/json-parse'
-import { Hub, Team } from '../../src/types'
-import { closeHub, createHub } from '../../src/utils/db/hub'
-import { PostgresUse } from '../../src/utils/db/postgres'
-import { KAFKA_APP_METRICS_2, KAFKA_LOGS_CLICKHOUSE, KAFKA_LOGS_INGESTION_DLQ } from '../config/kafka-topics'
-import { APP_METRICS_OUTPUT, AppMetricsOutput } from '../ingestion/common/outputs'
-import { IngestionOutputs } from '../ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../ingestion/outputs/single-ingestion-output'
-import { parseJSON } from '../utils/json-parse'
import { getDefaultTracesIngestionConsumerConfig } from './config'
import { LogRecord, encodeLogRecords } from './log-record-avro'
import {
@@ -41,8 +41,8 @@ import { TracesIngestionConsumer } from './traces-ingestion-consumer'
const DEFAULT_TEST_TIMEOUT = 5000
jest.setTimeout(DEFAULT_TEST_TIMEOUT)
-jest.mock('../utils/posthog', () => {
- const original = jest.requireActual('../utils/posthog')
+jest.mock('~/utils/posthog', () => {
+ const original = jest.requireActual('~/utils/posthog')
return {
...original,
captureException: jest.fn(),
diff --git a/nodejs/src/logs-ingestion/logs-ingestion-consumer.ts b/nodejs/src/logs/logs-ingestion-consumer.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/logs-ingestion-consumer.ts
rename to nodejs/src/logs/logs-ingestion-consumer.ts
index 4e5f2444b976..79a5e09af645 100644
--- a/nodejs/src/logs-ingestion/logs-ingestion-consumer.ts
+++ b/nodejs/src/logs/logs-ingestion-consumer.ts
@@ -3,19 +3,19 @@ import { Message } from 'node-rdkafka'
import pLimit from 'p-limit'
import { Counter, Histogram } from 'prom-client'
+import { AppMetricsOutput } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { AppMetricsAggregator } from '~/common/services/app-metrics-aggregator'
import { QuotaLimiting, QuotaResource } from '~/common/services/quota-limiting.service'
import { instrumentFn, instrumented } from '~/common/tracing/tracing-utils'
-import { AppMetricsOutput } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
+import { KafkaConsumerInterface, createKafkaConsumer, parseKafkaHeaders } from '~/kafka/consumer'
import type { LogsSettings } from '~/types'
+import { HealthCheckResult, PluginServerService } from '~/types'
+import { isDevEnv } from '~/utils/env-utils'
+import { logger } from '~/utils/logger'
+import { TeamManager } from '~/utils/team-manager'
-import { KafkaConsumerInterface, createKafkaConsumer, parseKafkaHeaders } from '../kafka/consumer'
-import { HealthCheckResult, PluginServerService } from '../types'
-import { isDevEnv } from '../utils/env-utils'
-import { logger } from '../utils/logger'
-import { TeamManager } from '../utils/team-manager'
import { LogsIngestionConsumerConfig } from './config'
import { type PiiScrubStats } from './log-pii-scrub'
import { processLogMessageBuffer } from './log-record-avro'
diff --git a/nodejs/src/logs-ingestion/outputs/outputs.ts b/nodejs/src/logs/outputs/outputs.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/outputs/outputs.ts
rename to nodejs/src/logs/outputs/outputs.ts
diff --git a/nodejs/src/logs-ingestion/outputs/producer-registry.ts b/nodejs/src/logs/outputs/producer-registry.ts
similarity index 88%
rename from nodejs/src/logs-ingestion/outputs/producer-registry.ts
rename to nodejs/src/logs/outputs/producer-registry.ts
index bc1b8b6e3f60..a0391851f4a9 100644
--- a/nodejs/src/logs-ingestion/outputs/producer-registry.ts
+++ b/nodejs/src/logs/outputs/producer-registry.ts
@@ -1,4 +1,5 @@
-import { KafkaProducerRegistryBuilder } from '../../ingestion/outputs/kafka-producer-registry-builder'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
+
import {
WARPSTREAM_INGESTION_PRODUCER,
WARPSTREAM_INGESTION_PRODUCER_CONFIG_MAP,
diff --git a/nodejs/src/logs-ingestion/outputs/producers.ts b/nodejs/src/logs/outputs/producers.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/outputs/producers.ts
rename to nodejs/src/logs/outputs/producers.ts
index 64a9037da46e..afb60582678d 100644
--- a/nodejs/src/logs-ingestion/outputs/producers.ts
+++ b/nodejs/src/logs/outputs/producers.ts
@@ -5,7 +5,7 @@
* vars share the same prefix so deployment config is unambiguous (e.g.
* `WARPSTREAM_LOGS_PRODUCER` ↔ `KAFKA_WARPSTREAM_LOGS_PRODUCER_*`).
*/
-import { AllowedConfigKey } from '../../ingestion/outputs/kafka-producer-config'
+import { AllowedConfigKey } from '~/common/outputs/kafka-producer-config'
/**
* Targets the Warpstream cluster dedicated to logs/traces. The main log/trace
diff --git a/nodejs/src/logs-ingestion/outputs/registry.ts b/nodejs/src/logs/outputs/registry.ts
similarity index 92%
rename from nodejs/src/logs-ingestion/outputs/registry.ts
rename to nodejs/src/logs/outputs/registry.ts
index 191eaea8f72e..a6075b4921fb 100644
--- a/nodejs/src/logs-ingestion/outputs/registry.ts
+++ b/nodejs/src/logs/outputs/registry.ts
@@ -1,5 +1,6 @@
-import { APP_METRICS_OUTPUT } from '../../ingestion/common/outputs'
-import { IngestionOutputsBuilder } from '../../ingestion/outputs/ingestion-outputs-builder'
+import { APP_METRICS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+
import { LOGS_DLQ_OUTPUT, LOGS_OUTPUT } from './outputs'
/**
diff --git a/nodejs/src/logs-ingestion/sampling-drop-probe-curl.sh b/nodejs/src/logs/sampling-drop-probe-curl.sh
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling-drop-probe-curl.sh
rename to nodejs/src/logs/sampling-drop-probe-curl.sh
diff --git a/nodejs/src/logs-ingestion/sampling-seed-services-curl.sh b/nodejs/src/logs/sampling-seed-services-curl.sh
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling-seed-services-curl.sh
rename to nodejs/src/logs/sampling-seed-services-curl.sh
diff --git a/nodejs/src/logs-ingestion/sampling/compile-rules.ts b/nodejs/src/logs/sampling/compile-rules.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling/compile-rules.ts
rename to nodejs/src/logs/sampling/compile-rules.ts
diff --git a/nodejs/src/logs-ingestion/sampling/evaluate.test.ts b/nodejs/src/logs/sampling/evaluate.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/sampling/evaluate.test.ts
rename to nodejs/src/logs/sampling/evaluate.test.ts
index 2ba4757e2b06..f8a8b7c38df9 100644
--- a/nodejs/src/logs-ingestion/sampling/evaluate.test.ts
+++ b/nodejs/src/logs/sampling/evaluate.test.ts
@@ -1,4 +1,5 @@
-import type { LogRecord } from '../log-record-avro'
+import type { LogRecord } from '~/logs/log-record-avro'
+
import { compileRuleSet } from './compile-rules'
import {
SAMPLING_DECISION_DROP,
diff --git a/nodejs/src/logs-ingestion/sampling/evaluate.ts b/nodejs/src/logs/sampling/evaluate.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/sampling/evaluate.ts
rename to nodejs/src/logs/sampling/evaluate.ts
index bc6e0cca056e..078cd8ece4c4 100644
--- a/nodejs/src/logs-ingestion/sampling/evaluate.ts
+++ b/nodejs/src/logs/sampling/evaluate.ts
@@ -1,7 +1,8 @@
import { createHash } from 'crypto'
import type RE2 from 're2'
-import type { LogRecord } from '../log-record-avro'
+import type { LogRecord } from '~/logs/log-record-avro'
+
import { type FilterGroupNode, matchFilterGroup } from './filter-group-match'
export const SAMPLING_DECISION_KEEP = 'keep' as const
diff --git a/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts b/nodejs/src/logs/sampling/filter-group-match.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts
rename to nodejs/src/logs/sampling/filter-group-match.test.ts
index b7f6aa2ab579..d65e5acf2095 100644
--- a/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts
+++ b/nodejs/src/logs/sampling/filter-group-match.test.ts
@@ -1,4 +1,5 @@
-import type { LogRecord } from '../log-record-avro'
+import type { LogRecord } from '~/logs/log-record-avro'
+
import { type FilterGroupNode, MAX_FILTER_GROUP_DEPTH, matchFilterGroup } from './filter-group-match'
const baseRecord = (overrides: Partial<LogRecord> = {}): LogRecord => ({
diff --git a/nodejs/src/logs-ingestion/sampling/filter-group-match.ts b/nodejs/src/logs/sampling/filter-group-match.ts
similarity index 98%
rename from nodejs/src/logs-ingestion/sampling/filter-group-match.ts
rename to nodejs/src/logs/sampling/filter-group-match.ts
index 9f7641655565..50181422ada5 100644
--- a/nodejs/src/logs-ingestion/sampling/filter-group-match.ts
+++ b/nodejs/src/logs/sampling/filter-group-match.ts
@@ -10,7 +10,8 @@
* The drop-rule form validates non-empty before submit; this is defense in
* depth at the worker boundary.
*/
-import type { LogRecord } from '../log-record-avro'
+import type { LogRecord } from '~/logs/log-record-avro'
+
import { type PropertyFilterLeaf, matchPropertyFilter } from './property-filter-match'
export type FilterGroupNode = {
diff --git a/nodejs/src/logs-ingestion/sampling/logs-sampling.service.test.ts b/nodejs/src/logs/sampling/logs-sampling.service.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/sampling/logs-sampling.service.test.ts
rename to nodejs/src/logs/sampling/logs-sampling.service.test.ts
index 2dbf88a5eb47..8761ddb94746 100644
--- a/nodejs/src/logs-ingestion/sampling/logs-sampling.service.test.ts
+++ b/nodejs/src/logs/sampling/logs-sampling.service.test.ts
@@ -1,9 +1,9 @@
import avro from 'avsc'
import type { RedisClientPipeline, RedisV2 } from '~/common/redis/redis-v2'
+import { type LogRecord, decodeLogRecords, encodeLogRecords } from '~/logs/log-record-avro'
import type { LogsSettings } from '~/types'
-import { type LogRecord, decodeLogRecords, encodeLogRecords } from '../log-record-avro'
import { compileRuleSet } from './compile-rules'
import { LogsSamplingService } from './logs-sampling.service'
diff --git a/nodejs/src/logs-ingestion/sampling/logs-sampling.service.ts b/nodejs/src/logs/sampling/logs-sampling.service.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/sampling/logs-sampling.service.ts
rename to nodejs/src/logs/sampling/logs-sampling.service.ts
index 31e3856f21f7..45d9d9a8f9cb 100644
--- a/nodejs/src/logs-ingestion/sampling/logs-sampling.service.ts
+++ b/nodejs/src/logs/sampling/logs-sampling.service.ts
@@ -4,16 +4,16 @@ import { Counter } from 'prom-client'
import { type RedisV2 } from '~/common/redis/redis-v2'
import { KeyedRateLimitRequest, KeyedRateLimiterService } from '~/common/services/keyed-rate-limiter.service'
import { instrumented } from '~/common/tracing/tracing-utils'
-import type { LogsSettings } from '~/types'
-import { logger } from '~/utils/logger'
-
-import { type PiiScrubStats } from '../log-pii-scrub'
+import { type PiiScrubStats } from '~/logs/log-pii-scrub'
import {
type LogRecord,
decodeLogRecords,
encodeLogRecords,
transformDecodedLogRecordsInPlace,
-} from '../log-record-avro'
+} from '~/logs/log-record-avro'
+import type { LogsSettings } from '~/types'
+import { logger } from '~/utils/logger'
+
import type { CompiledRuleSet, EvaluateResult, RateLimitPendingByRule, SamplingClassifyResult } from './evaluate'
import {
SAMPLING_DECISION_DROP,
diff --git a/nodejs/src/logs-ingestion/sampling/property-filter-match.test.ts b/nodejs/src/logs/sampling/property-filter-match.test.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling/property-filter-match.test.ts
rename to nodejs/src/logs/sampling/property-filter-match.test.ts
diff --git a/nodejs/src/logs-ingestion/sampling/property-filter-match.ts b/nodejs/src/logs/sampling/property-filter-match.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling/property-filter-match.ts
rename to nodejs/src/logs/sampling/property-filter-match.ts
diff --git a/nodejs/src/logs-ingestion/sampling/sampling-rules-cache.ts b/nodejs/src/logs/sampling/sampling-rules-cache.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/sampling/sampling-rules-cache.ts
rename to nodejs/src/logs/sampling/sampling-rules-cache.ts
diff --git a/nodejs/src/logs-ingestion/services/logs-rate-limiter.service.test.ts b/nodejs/src/logs/services/logs-rate-limiter.service.test.ts
similarity index 99%
rename from nodejs/src/logs-ingestion/services/logs-rate-limiter.service.test.ts
rename to nodejs/src/logs/services/logs-rate-limiter.service.test.ts
index 6ffbf92ef1a5..9bf4af269369 100644
--- a/nodejs/src/logs-ingestion/services/logs-rate-limiter.service.test.ts
+++ b/nodejs/src/logs/services/logs-rate-limiter.service.test.ts
@@ -1,4 +1,4 @@
-import { deleteKeysWithPrefix } from '~/cdp/_tests/redis'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
diff --git a/nodejs/src/logs-ingestion/services/logs-rate-limiter.service.ts b/nodejs/src/logs/services/logs-rate-limiter.service.ts
similarity index 98%
rename from nodejs/src/logs-ingestion/services/logs-rate-limiter.service.ts
rename to nodejs/src/logs/services/logs-rate-limiter.service.ts
index eb7ae55db2dc..2fd1c0085af3 100644
--- a/nodejs/src/logs-ingestion/services/logs-rate-limiter.service.ts
+++ b/nodejs/src/logs/services/logs-rate-limiter.service.ts
@@ -2,9 +2,8 @@ import { Histogram } from 'prom-client'
import { RedisV2 } from '~/common/redis/redis-v2'
import { KeyedRateLimitRequest, KeyedRateLimiterService } from '~/common/services/keyed-rate-limiter.service'
-
-import { LogsIngestionConsumerConfig } from '../config'
-import { LogsIngestionMessage } from '../types'
+import { LogsIngestionConsumerConfig } from '~/logs/config'
+import { LogsIngestionMessage } from '~/logs/types'
/** Convert milliseconds to seconds */
const msToSeconds = (ms: number): number => Math.round(ms / 1000)
diff --git a/nodejs/src/logs-ingestion/traces-ingestion-consumer.ts b/nodejs/src/logs/traces-ingestion-consumer.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/traces-ingestion-consumer.ts
rename to nodejs/src/logs/traces-ingestion-consumer.ts
diff --git a/nodejs/src/logs-ingestion/types.ts b/nodejs/src/logs/types.ts
similarity index 100%
rename from nodejs/src/logs-ingestion/types.ts
rename to nodejs/src/logs/types.ts
diff --git a/nodejs/src/session-replay/recording-api/README.md b/nodejs/src/recording-api/README.md
similarity index 100%
rename from nodejs/src/session-replay/recording-api/README.md
rename to nodejs/src/recording-api/README.md
diff --git a/nodejs/src/session-replay/recording-api/metrics.ts b/nodejs/src/recording-api/metrics.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-api/metrics.ts
rename to nodejs/src/recording-api/metrics.ts
diff --git a/nodejs/src/session-replay/recording-api/outputs/producer-registry.ts b/nodejs/src/recording-api/outputs/producer-registry.ts
similarity index 72%
rename from nodejs/src/session-replay/recording-api/outputs/producer-registry.ts
rename to nodejs/src/recording-api/outputs/producer-registry.ts
index 5f3fe414261d..95709c458ce8 100644
--- a/nodejs/src/session-replay/recording-api/outputs/producer-registry.ts
+++ b/nodejs/src/recording-api/outputs/producer-registry.ts
@@ -1,8 +1,8 @@
-import { KafkaProducerRegistryBuilder } from '../../../ingestion/outputs/kafka-producer-registry-builder'
+import { KafkaProducerRegistryBuilder } from '~/common/outputs/kafka-producer-registry-builder'
import {
INGESTION_SESSIONREPLAY_PRODUCER,
INGESTION_SESSIONREPLAY_PRODUCER_CONFIG_MAP,
-} from '../../shared/outputs/producer-config'
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
/** Recording API produces ClickHouse-bound deletion tombstones to the warpstream-replay cluster. */
export function createProducerRegistry(kafkaClientRack: string | undefined) {
diff --git a/nodejs/src/session-replay/recording-api/outputs/registry.ts b/nodejs/src/recording-api/outputs/registry.ts
similarity index 74%
rename from nodejs/src/session-replay/recording-api/outputs/registry.ts
rename to nodejs/src/recording-api/outputs/registry.ts
index a57b768ad964..404578d40396 100644
--- a/nodejs/src/session-replay/recording-api/outputs/registry.ts
+++ b/nodejs/src/recording-api/outputs/registry.ts
@@ -1,5 +1,5 @@
-import { IngestionOutputsBuilder } from '../../../ingestion/outputs/ingestion-outputs-builder'
-import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '../../shared/outputs'
+import { IngestionOutputsBuilder } from '~/common/outputs/ingestion-outputs-builder'
+import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
/** Register all recording-api outputs on the builder. Call `.build(registry, config)` to resolve. */
export function createOutputsRegistry() {
diff --git a/nodejs/src/session-replay/recording-api/recording-api.test.ts b/nodejs/src/recording-api/recording-api.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-api/recording-api.test.ts
rename to nodejs/src/recording-api/recording-api.test.ts
index 89063f992870..57999696c63f 100644
--- a/nodejs/src/session-replay/recording-api/recording-api.test.ts
+++ b/nodejs/src/recording-api/recording-api.test.ts
@@ -3,12 +3,13 @@ import { Server } from 'http'
import supertest from 'supertest'
import express from 'ultimate-express'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { getBlockDecryptor } from '../shared/crypto'
-import { getKeyStore } from '../shared/keystore'
-import { ReplayEventsOutput, SessionFeaturesOutput } from '../shared/outputs'
-import { RetentionService } from '../shared/retention/retention-service'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { getBlockDecryptor } from '~/ingestion/pipelines/sessionreplay/shared/crypto'
+import { getKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore'
+import { ReplayEventsOutput, SessionFeaturesOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { PostgresRouter } from '~/utils/db/postgres'
+
import { RecordingApi } from './recording-api'
import { RecordingService } from './recording-service'
import { KeyStore, RecordingApiConfig, RecordingDecryptor } from './types'
@@ -33,20 +34,20 @@ jest.mock('@aws-sdk/client-s3', () => ({
GetObjectCommand: jest.fn().mockImplementation((params) => params),
}))
-jest.mock('../shared/keystore', () => ({
+jest.mock('~/ingestion/pipelines/sessionreplay/shared/keystore', () => ({
getKeyStore: jest.fn(),
}))
-jest.mock('../shared/keystore/cache', () => ({
+jest.mock('~/ingestion/pipelines/sessionreplay/shared/keystore/cache', () => ({
MemoryCachedKeyStore: jest.fn().mockImplementation((delegate) => delegate),
RedisCachedKeyStore: jest.fn().mockImplementation((delegate) => delegate),
}))
-jest.mock('../shared/crypto', () => ({
+jest.mock('~/ingestion/pipelines/sessionreplay/shared/crypto', () => ({
getBlockDecryptor: jest.fn(),
}))
-jest.mock('../../utils/db/redis', () => ({
+jest.mock('~/utils/db/redis', () => ({
createRedisPoolFromConfig: jest.fn().mockReturnValue({
acquire: jest.fn(),
release: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-api/recording-api.ts b/nodejs/src/recording-api/recording-api.ts
similarity index 90%
rename from nodejs/src/session-replay/recording-api/recording-api.ts
rename to nodejs/src/recording-api/recording-api.ts
index a493b7516f8b..f37ff4450009 100644
--- a/nodejs/src/session-replay/recording-api/recording-api.ts
+++ b/nodejs/src/recording-api/recording-api.ts
@@ -3,26 +3,21 @@ import { ClickHouseClient, createClient as createClickHouseClient } from '@click
import https from 'https'
import express from 'ultimate-express'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import {
- HealthCheckResult,
- HealthCheckResultError,
- HealthCheckResultOk,
- PluginServerService,
- RedisPool,
-} from '../../types'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { createRedisPoolFromConfig } from '../../utils/db/redis'
-import { logger, serializeError } from '../../utils/logger'
-import { captureException } from '../../utils/posthog'
-import { getBlockDecryptor } from '../shared/crypto'
-import { SessionFeatureStore } from '../shared/features/session-feature-store'
-import { getKeyStore } from '../shared/keystore'
-import { RedisCachedKeyStore } from '../shared/keystore/cache'
-import { SessionMetadataStore } from '../shared/metadata/session-metadata-store'
-import { ReplayEventsOutput, SessionFeaturesOutput } from '../shared/outputs'
-import { RetentionService } from '../shared/retention/retention-service'
-import { TeamService } from '../shared/teams/team-service'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { getBlockDecryptor } from '~/ingestion/pipelines/sessionreplay/shared/crypto'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { getKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore'
+import { RedisCachedKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore/cache'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { ReplayEventsOutput, SessionFeaturesOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { RetentionService } from '~/ingestion/pipelines/sessionreplay/shared/retention/retention-service'
+import { TeamService } from '~/ingestion/pipelines/sessionreplay/shared/teams/team-service'
+import { HealthCheckResult, HealthCheckResultError, HealthCheckResultOk, PluginServerService, RedisPool } from '~/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { createRedisPoolFromConfig } from '~/utils/db/redis'
+import { logger, serializeError } from '~/utils/logger'
+import { captureException } from '~/utils/posthog'
+
import { RecordingService } from './recording-service'
import { DeleteRecordingsBodySchema, GetBlockQuerySchema, RecordingParamsSchema, TeamParamsSchema } from './schemas'
import { KeyStore, RecordingApiConfig, RecordingDecryptor } from './types'
diff --git a/nodejs/src/session-replay/recording-api/recording-service.test.ts b/nodejs/src/recording-api/recording-service.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-api/recording-service.test.ts
rename to nodejs/src/recording-api/recording-service.test.ts
index 5af728bc684c..959cf6e2097a 100644
--- a/nodejs/src/session-replay/recording-api/recording-service.test.ts
+++ b/nodejs/src/recording-api/recording-service.test.ts
@@ -2,9 +2,10 @@ import { NoSuchKey, S3Client } from '@aws-sdk/client-s3'
import { ClickHouseClient } from '@clickhouse/client'
import snappy from 'snappy'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { SessionFeatureStore } from '../shared/features/session-feature-store'
-import { SessionMetadataStore } from '../shared/metadata/session-metadata-store'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { PostgresRouter } from '~/utils/db/postgres'
+
import { RecordingService } from './recording-service'
import { KeyStore, RecordingDecryptor, SessionKeyDeletedError } from './types'
diff --git a/nodejs/src/session-replay/recording-api/recording-service.ts b/nodejs/src/recording-api/recording-service.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-api/recording-service.ts
rename to nodejs/src/recording-api/recording-service.ts
index 74da08c4e945..965bf6929d07 100644
--- a/nodejs/src/session-replay/recording-api/recording-service.ts
+++ b/nodejs/src/recording-api/recording-service.ts
@@ -2,12 +2,13 @@ import { GetObjectCommand, NoSuchKey, S3Client } from '@aws-sdk/client-s3'
import { ClickHouseClient } from '@clickhouse/client'
import snappy from 'snappy'
-import { PostgresRouter, PostgresUse } from '../../utils/db/postgres'
-import { logger, serializeError } from '../../utils/logger'
-import { ValidRetentionPeriods } from '../shared/constants'
-import { SessionFeatureStore } from '../shared/features/session-feature-store'
-import { createDeletionBlockMetadata } from '../shared/metadata/session-block-metadata'
-import { SessionMetadataStore } from '../shared/metadata/session-metadata-store'
+import { ValidRetentionPeriods } from '~/ingestion/pipelines/sessionreplay/shared/constants'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { createDeletionBlockMetadata } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { logger, serializeError } from '~/utils/logger'
+
import { RecordingApiMetrics } from './metrics'
import { KeyStore, RecordingBlock, RecordingDecryptor, SessionKeyDeletedError } from './types'
diff --git a/nodejs/src/session-replay/recording-api/schemas.test.ts b/nodejs/src/recording-api/schemas.test.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-api/schemas.test.ts
rename to nodejs/src/recording-api/schemas.test.ts
diff --git a/nodejs/src/session-replay/recording-api/schemas.ts b/nodejs/src/recording-api/schemas.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-api/schemas.ts
rename to nodejs/src/recording-api/schemas.ts
diff --git a/nodejs/src/session-replay/recording-api/types.ts b/nodejs/src/recording-api/types.ts
similarity index 89%
rename from nodejs/src/session-replay/recording-api/types.ts
rename to nodejs/src/recording-api/types.ts
index e63d48c54c4e..d83cab3d6504 100644
--- a/nodejs/src/session-replay/recording-api/types.ts
+++ b/nodejs/src/recording-api/types.ts
@@ -4,16 +4,13 @@
* Re-exports shared encryption types from session-replay/types.ts and adds
* Recording API-specific types.
*/
-import { CommonConfig } from '../../common/config'
-import {
- KAFKA_CLICKHOUSE_SESSION_REPLAY_EVENTS,
- KAFKA_CLICKHOUSE_SESSION_REPLAY_FEATURES,
-} from '../../config/kafka-topics'
-import { SessionRecordingApiConfig, SessionRecordingConfig } from '../../session-recording/config'
+import { CommonConfig } from '~/common/config'
+import { KAFKA_CLICKHOUSE_SESSION_REPLAY_EVENTS, KAFKA_CLICKHOUSE_SESSION_REPLAY_FEATURES } from '~/config/kafka-topics'
+import { SessionRecordingApiConfig, SessionRecordingConfig } from '~/ingestion/pipelines/sessionreplay/config'
import {
INGESTION_SESSIONREPLAY_PRODUCER,
type IngestionSessionreplayProducer,
-} from '../shared/outputs/producer-config'
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
/**
* Recording API's outputs are ClickHouse-bound deletion tombstones on the warpstream-replay
@@ -33,7 +30,7 @@ export {
type SerializedSessionKey,
type SessionKey,
type SessionState,
-} from '../shared/types'
+} from '~/ingestion/pipelines/sessionreplay/shared/types'
/**
* Configuration for the Recording API.
diff --git a/nodejs/src/session-replay/recording-rasterizer/README.md b/nodejs/src/recording-rasterizer/README.md
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/README.md
rename to nodejs/src/recording-rasterizer/README.md
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/activities.test.ts b/nodejs/src/recording-rasterizer/__tests__/activities.test.ts
similarity index 93%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/activities.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/activities.test.ts
index 7f7d9f26b297..739eadb447e1 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/activities.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/activities.test.ts
@@ -1,11 +1,11 @@
import * as fs from 'fs/promises'
-import { BrowserPool } from '../capture/browser-pool'
-import { rasterizeRecording } from '../capture/recorder'
-import { RasterizationError } from '../errors'
-import { uploadToS3 } from '../storage'
-import { createActivities } from '../temporal/activities'
-import { RasterizeRecordingInput, RecordingResult } from '../types'
+import { BrowserPool } from '~/recording-rasterizer/capture/browser-pool'
+import { rasterizeRecording } from '~/recording-rasterizer/capture/recorder'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { uploadToS3 } from '~/recording-rasterizer/storage'
+import { createActivities } from '~/recording-rasterizer/temporal/activities'
+import { RasterizeRecordingInput, RecordingResult } from '~/recording-rasterizer/types'
jest.mock('@temporalio/activity', () => ({
Context: {
@@ -31,10 +31,10 @@ jest.mock('@temporalio/common', () => ({
},
}))
-jest.mock('../capture/recorder')
-jest.mock('../storage')
-jest.mock('../metrics')
-jest.mock('../logger', () => ({
+jest.mock('~/recording-rasterizer/capture/recorder')
+jest.mock('~/recording-rasterizer/storage')
+jest.mock('~/recording-rasterizer/metrics')
+jest.mock('~/recording-rasterizer/logger', () => ({
createLogger: () => ({
info: jest.fn(),
warn: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/block-proxy.test.ts b/nodejs/src/recording-rasterizer/__tests__/block-proxy.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/block-proxy.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/block-proxy.test.ts
index f75eff4eb485..369d636a1dd1 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/block-proxy.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/block-proxy.test.ts
@@ -1,9 +1,9 @@
-import { BlockProxy } from '../capture/block-proxy'
-import { RasterizationError } from '../errors'
-import { RasterizeRecordingInput } from '../types'
+import { BlockProxy } from '~/recording-rasterizer/capture/block-proxy'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { RasterizeRecordingInput } from '~/recording-rasterizer/types'
const mockInternalFetch = jest.fn()
-jest.mock('../../../utils/request', () => ({
+jest.mock('~/utils/request', () => ({
internalFetch: (...args: any[]) => mockInternalFetch(...args),
}))
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/browser-pool.test.ts b/nodejs/src/recording-rasterizer/__tests__/browser-pool.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/browser-pool.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/browser-pool.test.ts
index 27e5a4ab0ada..85a20fed5b94 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/browser-pool.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/browser-pool.test.ts
@@ -1,8 +1,8 @@
import { Browser, Page } from 'puppeteer'
-import { BrowserPool } from '../capture/browser-pool'
+import { BrowserPool } from '~/recording-rasterizer/capture/browser-pool'
-jest.mock('../logger', () => {
+jest.mock('~/recording-rasterizer/logger', () => {
const info = jest.fn()
return {
__mockLogInfo: info,
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/capture-page.test.ts b/nodejs/src/recording-rasterizer/__tests__/capture-page.test.ts
similarity index 99%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/capture-page.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/capture-page.test.ts
index 302e3df7c664..0aaddb03696c 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/capture-page.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/capture-page.test.ts
@@ -3,7 +3,7 @@ import * as os from 'os'
import * as path from 'path'
import { Page } from 'puppeteer'
-import { CapturePage, playerHtmlCache } from '../capture/capture-page'
+import { CapturePage, playerHtmlCache } from '~/recording-rasterizer/capture/capture-page'
const mockLog = {
info: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/capture.test.ts b/nodejs/src/recording-rasterizer/__tests__/capture.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/capture.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/capture.test.ts
index 415620096402..0726d6362d57 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/capture.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/capture.test.ts
@@ -2,10 +2,10 @@ import * as fs from 'fs/promises'
import * as os from 'os'
import * as path from 'path'
-import { capturePlayback } from '../capture/capture'
-import { PlayerController } from '../capture/player'
-import { RasterizationError } from '../errors'
-import { CaptureConfig } from '../types'
+import { capturePlayback } from '~/recording-rasterizer/capture/capture'
+import { PlayerController } from '~/recording-rasterizer/capture/player'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { CaptureConfig } from '~/recording-rasterizer/types'
jest.mock(
'puppeteer-capture',
@@ -25,7 +25,7 @@ jest.mock(
{ virtual: true }
)
-jest.mock('../logger', () => ({
+jest.mock('~/recording-rasterizer/logger', () => ({
createLogger: () => ({
info: jest.fn(),
warn: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/codec.test.ts b/nodejs/src/recording-rasterizer/__tests__/codec.test.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/codec.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/codec.test.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/config.test.ts b/nodejs/src/recording-rasterizer/__tests__/config.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/config.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/config.test.ts
index 7caa94325418..69515e29d033 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/config.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/config.test.ts
@@ -1,6 +1,6 @@
-import { buildCaptureConfig, buildPlayerConfig, validateInput } from '../capture/config'
-import { parseList } from '../config'
-import { RasterizeRecordingInput } from '../types'
+import { buildCaptureConfig, buildPlayerConfig, validateInput } from '~/recording-rasterizer/capture/config'
+import { parseList } from '~/recording-rasterizer/config'
+import { RasterizeRecordingInput } from '~/recording-rasterizer/types'
function baseInput(overrides: Partial<RasterizeRecordingInput> = {}): RasterizeRecordingInput {
return {
@@ -29,7 +29,7 @@ describe('config', () => {
try {
jest.resetModules()
- const { config } = await import('../config.js')
+ const { config } = await import('~/recording-rasterizer/config.js')
expect(config.fallbackKeys).toEqual(['a', 'b'])
} finally {
if (originalFallbackKeys === undefined) {
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/errors.test.ts b/nodejs/src/recording-rasterizer/__tests__/errors.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/errors.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/errors.test.ts
index d725260ff5f0..69c521148c6f 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/errors.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/errors.test.ts
@@ -1,4 +1,4 @@
-import { RasterizationError } from '../errors'
+import { RasterizationError } from '~/recording-rasterizer/errors'
describe('RasterizationError', () => {
it('sets name, message, retryable, and code', () => {
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/player.test.ts b/nodejs/src/recording-rasterizer/__tests__/player.test.ts
similarity index 95%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/player.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/player.test.ts
index 06acee5eda78..0583b7b7ca53 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/player.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/player.test.ts
@@ -1,19 +1,19 @@
import type { PlayerConfig, PlayerMessage } from '@posthog/replay-headless/protocol'
import { PLAYER_CONFIG_KEY, PLAYER_EMIT_FN, PLAYER_START_EVENT } from '@posthog/replay-headless/protocol'
-import { BlockProxy } from '../capture/block-proxy'
-import { CapturePage } from '../capture/capture-page'
-import { PlayerController } from '../capture/player'
-import { RasterizationError } from '../errors'
+import { BlockProxy } from '~/recording-rasterizer/capture/block-proxy'
+import { CapturePage } from '~/recording-rasterizer/capture/capture-page'
+import { PlayerController } from '~/recording-rasterizer/capture/player'
+import { RasterizationError } from '~/recording-rasterizer/errors'
-jest.mock('../capture/request-interceptor', () => ({
+jest.mock('~/recording-rasterizer/capture/request-interceptor', () => ({
RequestInterceptor: jest.fn().mockImplementation(() => ({
install: jest.fn().mockResolvedValue(undefined),
waitForSettled: jest.fn().mockResolvedValue(undefined),
})),
}))
-jest.mock('../logger', () => ({
+jest.mock('~/recording-rasterizer/logger', () => ({
createLogger: () => ({
info: jest.fn(),
warn: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/postprocess.test.ts b/nodejs/src/recording-rasterizer/__tests__/postprocess.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/postprocess.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/postprocess.test.ts
index 59109bcfd97b..c6c2e3329052 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/postprocess.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/postprocess.test.ts
@@ -1,5 +1,5 @@
-import { computeVideoTimestamps } from '../postprocess'
-import { InactivityPeriod } from '../types'
+import { computeVideoTimestamps } from '~/recording-rasterizer/postprocess'
+import { InactivityPeriod } from '~/recording-rasterizer/types'
describe('computeVideoTimestamps', () => {
it('maps active periods to cumulative video time', () => {
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/recorder.test.ts b/nodejs/src/recording-rasterizer/__tests__/recorder.test.ts
similarity index 90%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/recorder.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/recorder.test.ts
index 9c12f7f79a87..c4c33a7b3d51 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/recorder.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/recorder.test.ts
@@ -1,16 +1,16 @@
-import { BlockProxy } from '../capture/block-proxy'
-import { BrowserPool } from '../capture/browser-pool'
-import { capturePlayback } from '../capture/capture'
-import { CapturePage } from '../capture/capture-page'
-import { PlayerController } from '../capture/player'
-import { rasterizeRecording } from '../capture/recorder'
-import { RasterizeRecordingInput } from '../types'
-
-jest.mock('../capture/capture')
-jest.mock('../capture/capture-page')
-jest.mock('../capture/block-proxy')
-jest.mock('../capture/player')
-jest.mock('../logger', () => ({
+import { BlockProxy } from '~/recording-rasterizer/capture/block-proxy'
+import { BrowserPool } from '~/recording-rasterizer/capture/browser-pool'
+import { capturePlayback } from '~/recording-rasterizer/capture/capture'
+import { CapturePage } from '~/recording-rasterizer/capture/capture-page'
+import { PlayerController } from '~/recording-rasterizer/capture/player'
+import { rasterizeRecording } from '~/recording-rasterizer/capture/recorder'
+import { RasterizeRecordingInput } from '~/recording-rasterizer/types'
+
+jest.mock('~/recording-rasterizer/capture/capture')
+jest.mock('~/recording-rasterizer/capture/capture-page')
+jest.mock('~/recording-rasterizer/capture/block-proxy')
+jest.mock('~/recording-rasterizer/capture/player')
+jest.mock('~/recording-rasterizer/logger', () => ({
createLogger: () => ({
info: jest.fn(),
warn: jest.fn(),
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/request-interceptor.test.ts b/nodejs/src/recording-rasterizer/__tests__/request-interceptor.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/request-interceptor.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/request-interceptor.test.ts
index 6d65ebd48e7d..2e7649d2a12d 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/request-interceptor.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/request-interceptor.test.ts
@@ -1,11 +1,11 @@
import { Frame, HTTPRequest, Page } from 'puppeteer'
-import { BlockProxy } from '../capture/block-proxy'
-import { CapturePage } from '../capture/capture-page'
-import { RequestInterceptor } from '../capture/request-interceptor'
+import { BlockProxy } from '~/recording-rasterizer/capture/block-proxy'
+import { CapturePage } from '~/recording-rasterizer/capture/capture-page'
+import { RequestInterceptor } from '~/recording-rasterizer/capture/request-interceptor'
const mockFetch = jest.fn()
-jest.mock('../../../utils/request', () => ({
+jest.mock('~/utils/request', () => ({
fetch: (...args: any[]) => mockFetch(...args),
}))
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts b/nodejs/src/recording-rasterizer/__tests__/storage.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/storage.test.ts
index 8010f565bf50..d1731111d84c 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/storage.test.ts
@@ -1,4 +1,4 @@
-import { uploadToS3 } from '../storage'
+import { uploadToS3 } from '~/recording-rasterizer/storage'
const mockDone = jest.fn().mockResolvedValue({})
const mockOn = jest.fn()
@@ -137,7 +137,7 @@ describe('S3 client proxy routing', () => {
jest.doMock('@aws-sdk/credential-provider-node', () => ({
defaultProvider: (init: unknown) => mockDefaultProvider(init),
}))
- const { uploadToS3: fresh } = require('../storage')
+ const { uploadToS3: fresh } = require('~/recording-rasterizer/storage')
await fresh('/tmp/v.mp4', 'b', 'p', 'i')
mock = require('@aws-sdk/client-s3').S3Client as jest.Mock
})
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/utils.test.ts b/nodejs/src/recording-rasterizer/__tests__/utils.test.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/__tests__/utils.test.ts
rename to nodejs/src/recording-rasterizer/__tests__/utils.test.ts
index 5baa8bce0a2b..bbaad30f1cb2 100644
--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/utils.test.ts
+++ b/nodejs/src/recording-rasterizer/__tests__/utils.test.ts
@@ -1,4 +1,4 @@
-import { elapsed } from '../utils'
+import { elapsed } from '~/recording-rasterizer/utils'
describe('elapsed', () => {
it('returns a non-negative number', () => {
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/block-proxy.ts b/nodejs/src/recording-rasterizer/capture/block-proxy.ts
similarity index 91%
rename from nodejs/src/session-replay/recording-rasterizer/capture/block-proxy.ts
rename to nodejs/src/recording-rasterizer/capture/block-proxy.ts
index b4c82e0ee310..33e269688d65 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/block-proxy.ts
+++ b/nodejs/src/recording-rasterizer/capture/block-proxy.ts
@@ -2,11 +2,11 @@ import { HTTPRequest } from 'puppeteer'
import { BLOCK_REQUEST_PREFIX } from '@posthog/replay-headless/protocol'
-import { internalFetch } from '../../../utils/request'
-import { type RecordingBlock as FullRecordingBlock } from '../../recording-api/types'
-import { RasterizationError } from '../errors'
-import { type Logger, createLogger } from '../logger'
-import { RasterizeRecordingInput } from '../types'
+import { type RecordingBlock as FullRecordingBlock } from '~/recording-api/types'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
+import { RasterizeRecordingInput } from '~/recording-rasterizer/types'
+import { internalFetch } from '~/utils/request'
type RecordingBlock = Pick<FullRecordingBlock, 'key' | 'start_byte' | 'end_byte'>
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/browser-pool.ts b/nodejs/src/recording-rasterizer/capture/browser-pool.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/capture/browser-pool.ts
rename to nodejs/src/recording-rasterizer/capture/browser-pool.ts
index 4a0c0b74265b..90495bb03af9 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/browser-pool.ts
+++ b/nodejs/src/recording-rasterizer/capture/browser-pool.ts
@@ -1,9 +1,9 @@
import { Browser, Page } from 'puppeteer'
import { launch as launchForCapture } from 'puppeteer-capture'
-import { config } from '../config'
-import { createLogger } from '../logger'
-import { RasterizationMetrics } from '../metrics'
+import { config } from '~/recording-rasterizer/config'
+import { createLogger } from '~/recording-rasterizer/logger'
+import { RasterizationMetrics } from '~/recording-rasterizer/metrics'
const log = createLogger()
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/capture-page.ts b/nodejs/src/recording-rasterizer/capture/capture-page.ts
similarity index 97%
rename from nodejs/src/session-replay/recording-rasterizer/capture/capture-page.ts
rename to nodejs/src/recording-rasterizer/capture/capture-page.ts
index 59984abd8c03..5627acedf504 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/capture-page.ts
+++ b/nodejs/src/recording-rasterizer/capture/capture-page.ts
@@ -1,8 +1,8 @@
import * as fs from 'fs/promises'
import { CDPSession, Page } from 'puppeteer'
-import { config as defaultConfig } from '../config'
-import { type Logger, createLogger } from '../logger'
+import { config as defaultConfig } from '~/recording-rasterizer/config'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
export const playerHtmlCache = {
_html: null as string | null,
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/capture.ts b/nodejs/src/recording-rasterizer/capture/capture.ts
similarity index 97%
rename from nodejs/src/session-replay/recording-rasterizer/capture/capture.ts
rename to nodejs/src/recording-rasterizer/capture/capture.ts
index 5b4e3973e716..101ad016df62 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/capture.ts
+++ b/nodejs/src/recording-rasterizer/capture/capture.ts
@@ -1,10 +1,11 @@
import * as fs from 'fs/promises'
import { capture as captureVideo } from 'puppeteer-capture'
-import { RasterizationError } from '../errors'
-import { type Logger, createLogger } from '../logger'
-import { CaptureConfig, InactivityPeriod, RasterizationProgress, RecordingResult } from '../types'
-import { elapsed } from '../utils'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
+import { CaptureConfig, InactivityPeriod, RasterizationProgress, RecordingResult } from '~/recording-rasterizer/types'
+import { elapsed } from '~/recording-rasterizer/utils'
+
import { PlayerController } from './player'
export async function capturePlayback(
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/config.ts b/nodejs/src/recording-rasterizer/capture/config.ts
similarity index 97%
rename from nodejs/src/session-replay/recording-rasterizer/capture/config.ts
rename to nodejs/src/recording-rasterizer/capture/config.ts
index d49cdc2556e6..8b44e595130c 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/config.ts
+++ b/nodejs/src/recording-rasterizer/capture/config.ts
@@ -1,7 +1,7 @@
import type { PlayerConfig } from '@posthog/replay-headless/protocol'
-import { RasterizationError } from '../errors'
-import { CaptureConfig, RasterizeRecordingInput } from '../types'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { CaptureConfig, RasterizeRecordingInput } from '~/recording-rasterizer/types'
const DEFAULT_PLAYBACK_SPEED = 4
const DEFAULT_FPS = 24
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/player.ts b/nodejs/src/recording-rasterizer/capture/player.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-rasterizer/capture/player.ts
rename to nodejs/src/recording-rasterizer/capture/player.ts
index b37b7099fae3..57116433bcd8 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/player.ts
+++ b/nodejs/src/recording-rasterizer/capture/player.ts
@@ -3,8 +3,9 @@ import type { Page } from 'puppeteer'
import { PLAYER_CONFIG_KEY, PLAYER_EMIT_FN, PLAYER_START_EVENT } from '@posthog/replay-headless/protocol'
import type { InactivityPeriod, PlayerConfig, PlayerMessage } from '@posthog/replay-headless/protocol'
-import { RasterizationError } from '../errors'
-import { type Logger, createLogger } from '../logger'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
+
import { BlockProxy } from './block-proxy'
import { CapturePage } from './capture-page'
import { RequestInterceptor } from './request-interceptor'
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/recorder.ts b/nodejs/src/recording-rasterizer/capture/recorder.ts
similarity index 94%
rename from nodejs/src/session-replay/recording-rasterizer/capture/recorder.ts
rename to nodejs/src/recording-rasterizer/capture/recorder.ts
index 874b58377ba5..7a6fa639f35d 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/recorder.ts
+++ b/nodejs/src/recording-rasterizer/capture/recorder.ts
@@ -1,9 +1,10 @@
import type { InactivityPeriod } from '@posthog/replay-headless/protocol'
-import { config as defaultConfig } from '../config'
-import { type Logger, createLogger } from '../logger'
-import { RasterizationProgress, RasterizeRecordingInput, RecordingResult } from '../types'
-import { elapsed } from '../utils'
+import { config as defaultConfig } from '~/recording-rasterizer/config'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
+import { RasterizationProgress, RasterizeRecordingInput, RecordingResult } from '~/recording-rasterizer/types'
+import { elapsed } from '~/recording-rasterizer/utils'
+
import { BlockProxy } from './block-proxy'
import { BrowserPool } from './browser-pool'
import { capturePlayback } from './capture'
diff --git a/nodejs/src/session-replay/recording-rasterizer/capture/request-interceptor.ts b/nodejs/src/recording-rasterizer/capture/request-interceptor.ts
similarity index 96%
rename from nodejs/src/session-replay/recording-rasterizer/capture/request-interceptor.ts
rename to nodejs/src/recording-rasterizer/capture/request-interceptor.ts
index c7f37c5577fb..a625ede2c82d 100644
--- a/nodejs/src/session-replay/recording-rasterizer/capture/request-interceptor.ts
+++ b/nodejs/src/recording-rasterizer/capture/request-interceptor.ts
@@ -1,7 +1,8 @@
import { Frame, HTTPRequest } from 'puppeteer'
-import { fetch } from '../../../utils/request'
-import { type Logger, createLogger } from '../logger'
+import { type Logger, createLogger } from '~/recording-rasterizer/logger'
+import { fetch } from '~/utils/request'
+
import { BLOCK_REQUEST_PREFIX, BlockProxy } from './block-proxy'
import { CapturePage } from './capture-page'
diff --git a/nodejs/src/session-replay/recording-rasterizer/config.ts b/nodejs/src/recording-rasterizer/config.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/config.ts
rename to nodejs/src/recording-rasterizer/config.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/errors.ts b/nodejs/src/recording-rasterizer/errors.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/errors.ts
rename to nodejs/src/recording-rasterizer/errors.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/index.ts b/nodejs/src/recording-rasterizer/index.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/index.ts
rename to nodejs/src/recording-rasterizer/index.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/logger.ts b/nodejs/src/recording-rasterizer/logger.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/logger.ts
rename to nodejs/src/recording-rasterizer/logger.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/metrics.ts b/nodejs/src/recording-rasterizer/metrics.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/metrics.ts
rename to nodejs/src/recording-rasterizer/metrics.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/postprocess.ts b/nodejs/src/recording-rasterizer/postprocess.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/postprocess.ts
rename to nodejs/src/recording-rasterizer/postprocess.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/storage.ts b/nodejs/src/recording-rasterizer/storage.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/storage.ts
rename to nodejs/src/recording-rasterizer/storage.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/temporal/activities.ts b/nodejs/src/recording-rasterizer/temporal/activities.ts
similarity index 87%
rename from nodejs/src/session-replay/recording-rasterizer/temporal/activities.ts
rename to nodejs/src/recording-rasterizer/temporal/activities.ts
index 99dace7834e6..7471fbb8b70e 100644
--- a/nodejs/src/session-replay/recording-rasterizer/temporal/activities.ts
+++ b/nodejs/src/recording-rasterizer/temporal/activities.ts
@@ -5,15 +5,20 @@ import * as fs from 'fs/promises'
import * as os from 'os'
import * as path from 'path'
-import { BrowserPool } from '../capture/browser-pool'
-import { rasterizeRecording } from '../capture/recorder'
-import { RasterizationError } from '../errors'
-import { createLogger } from '../logger'
-import { RasterizationMetrics } from '../metrics'
-import { computeVideoTimestamps } from '../postprocess'
-import { uploadToS3 } from '../storage'
-import { ActivityTimings, RasterizationProgress, RasterizeRecordingInput, RasterizeRecordingOutput } from '../types'
-import { elapsed } from '../utils'
+import { BrowserPool } from '~/recording-rasterizer/capture/browser-pool'
+import { rasterizeRecording } from '~/recording-rasterizer/capture/recorder'
+import { RasterizationError } from '~/recording-rasterizer/errors'
+import { createLogger } from '~/recording-rasterizer/logger'
+import { RasterizationMetrics } from '~/recording-rasterizer/metrics'
+import { computeVideoTimestamps } from '~/recording-rasterizer/postprocess'
+import { uploadToS3 } from '~/recording-rasterizer/storage'
+import {
+ ActivityTimings,
+ RasterizationProgress,
+ RasterizeRecordingInput,
+ RasterizeRecordingOutput,
+} from '~/recording-rasterizer/types'
+import { elapsed } from '~/recording-rasterizer/utils'
function toActivityError(err: unknown): Error {
if (err instanceof RasterizationError && !err.retryable) {
diff --git a/nodejs/src/session-replay/recording-rasterizer/temporal/worker.ts b/nodejs/src/recording-rasterizer/temporal/worker.ts
similarity index 95%
rename from nodejs/src/session-replay/recording-rasterizer/temporal/worker.ts
rename to nodejs/src/recording-rasterizer/temporal/worker.ts
index 2ff918189f74..4bef674bbf5d 100644
--- a/nodejs/src/session-replay/recording-rasterizer/temporal/worker.ts
+++ b/nodejs/src/recording-rasterizer/temporal/worker.ts
@@ -6,11 +6,11 @@ import * as prometheus from 'prom-client'
import express from 'ultimate-express'
import { EncryptionCodec } from '~/common/temporal/codec'
+import { BrowserPool } from '~/recording-rasterizer/capture/browser-pool'
+import { playerHtmlCache } from '~/recording-rasterizer/capture/capture-page'
+import { config } from '~/recording-rasterizer/config'
+import { createLogger } from '~/recording-rasterizer/logger'
-import { BrowserPool } from '../capture/browser-pool'
-import { playerHtmlCache } from '../capture/capture-page'
-import { config } from '../config'
-import { createLogger } from '../logger'
import { createActivities } from './activities'
prometheus.collectDefaultMetrics()
diff --git a/nodejs/src/session-replay/recording-rasterizer/types.ts b/nodejs/src/recording-rasterizer/types.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/types.ts
rename to nodejs/src/recording-rasterizer/types.ts
diff --git a/nodejs/src/session-replay/recording-rasterizer/utils.ts b/nodejs/src/recording-rasterizer/utils.ts
similarity index 100%
rename from nodejs/src/session-replay/recording-rasterizer/utils.ts
rename to nodejs/src/recording-rasterizer/utils.ts
diff --git a/nodejs/src/server.ts b/nodejs/src/server.ts
index aa655ef0dabe..a74a7641bbcf 100644
--- a/nodejs/src/server.ts
+++ b/nodejs/src/server.ts
@@ -1,4 +1,10 @@
import { IntegrationManagerService } from '~/cdp/services/managers/integration-manager.service'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { createPersonHogClient } from '~/common/personhog'
+import { PersonHogGroupReadRepository } from '~/common/personhog/personhog-group-read-repository'
+import { PersonHogPersonReadRepository } from '~/common/personhog/personhog-person-read-repository'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
import { InternalCaptureService } from '~/common/services/internal-capture'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
@@ -33,10 +39,6 @@ import { EncryptedFields } from './cdp/utils/encryption-utils'
import { defaultConfig } from './config/config'
import { createIngestionRedisConnectionConfig, createPosthogRedisConnectionConfig } from './config/redis-pools'
import { startEvaluationScheduler } from './evaluation-scheduler/evaluation-scheduler'
-import { KafkaProducerRegistry } from './ingestion/outputs/kafka-producer-registry'
-import { createPersonHogClient } from './ingestion/personhog'
-import { PersonHogGroupReadRepository } from './ingestion/personhog/personhog-group-read-repository'
-import { PersonHogPersonReadRepository } from './ingestion/personhog/personhog-person-read-repository'
import { CleanupResources, NodeServer, ServerLifecycle } from './servers/base-server'
import { PluginServerService, PluginsServerConfig, RedisPool } from './types'
import { ServerCommands } from './utils/commands'
@@ -46,8 +48,6 @@ import { GeoIPService } from './utils/geoip'
import { logger } from './utils/logger'
import { PubSub } from './utils/pubsub'
import { TeamManager } from './utils/team-manager'
-import { GroupReadRepository } from './worker/ingestion/groups/repositories/group-repository.interface'
-import { PersonReadRepository } from './worker/ingestion/persons/repositories/person-repository'
/**
* PluginServer handles CDP, logs, evaluation scheduler, and local-dev combined modes.
diff --git a/nodejs/src/servers/error-tracking-server.ts b/nodejs/src/servers/error-tracking-server.ts
index c784aba28b61..672e5a631cab 100644
--- a/nodejs/src/servers/error-tracking-server.ts
+++ b/nodejs/src/servers/error-tracking-server.ts
@@ -1,4 +1,19 @@
import { IntegrationManagerService } from '~/cdp/services/managers/integration-manager.service'
+import { ReadOnlyGroupTypeManager } from '~/common/groups/readonly-group-type-manager'
+import { ProducerName } from '~/common/outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { createIngestionProducerRegistry } from '~/common/outputs/registry'
+import { createPersonHogClient } from '~/common/personhog'
+import { PersonHogGroupReadRepository } from '~/common/personhog/personhog-group-read-repository'
+import { PersonHogPersonReadRepository } from '~/common/personhog/personhog-person-read-repository'
+import { CookielessManager, CookielessServerConfig } from '~/ingestion/common/cookieless/cookieless-manager'
+import {
+ ErrorTrackingConsumerConfig,
+ ErrorTrackingOutputsConfig,
+ getDefaultErrorTrackingOutputsConfig,
+} from '~/ingestion/pipelines/errortracking/config'
+import { ErrorTrackingConsumer } from '~/ingestion/pipelines/errortracking/error-tracking-consumer'
+import { createOutputsRegistry } from '~/ingestion/pipelines/errortracking/outputs/registry'
import { initializePrometheusLabels } from '../api/router'
import {
@@ -16,8 +31,6 @@ import {
getDefaultKafkaDownstreamProducerEnvConfig,
getDefaultKafkaUpstreamProducerEnvConfig,
} from '../ingestion/common/config'
-import { ProducerName } from '../ingestion/common/outputs'
-import { createIngestionProducerRegistry } from '../ingestion/common/outputs/registry'
import {
DatabaseConnectionConfig,
KafkaBrokerConfig,
@@ -25,18 +38,6 @@ import {
PersonHogConfig,
RedisConnectionsConfig,
} from '../ingestion/config'
-import { CookielessManager, CookielessServerConfig } from '../ingestion/cookieless/cookieless-manager'
-import {
- ErrorTrackingConsumerConfig,
- ErrorTrackingOutputsConfig,
- getDefaultErrorTrackingOutputsConfig,
-} from '../ingestion/error-tracking/config'
-import { ErrorTrackingConsumer } from '../ingestion/error-tracking/error-tracking-consumer'
-import { createOutputsRegistry } from '../ingestion/error-tracking/outputs/registry'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
-import { createPersonHogClient } from '../ingestion/personhog'
-import { PersonHogGroupReadRepository } from '../ingestion/personhog/personhog-group-read-repository'
-import { PersonHogPersonReadRepository } from '../ingestion/personhog/personhog-person-read-repository'
import { PluginServerService, RedisPool } from '../types'
import { ServerCommands } from '../utils/commands'
import { PostgresRouter } from '../utils/db/postgres'
@@ -46,7 +47,6 @@ import { GeoIPService } from '../utils/geoip'
import { logger } from '../utils/logger'
import { PubSub } from '../utils/pubsub'
import { TeamManager } from '../utils/team-manager'
-import { ReadOnlyGroupTypeManager } from '../worker/ingestion/readonly-group-type-manager'
import { BaseServerConfig, CleanupResources, NodeServer, ServerLifecycle } from './base-server'
/**
diff --git a/nodejs/src/servers/ingestion-api-server.ts b/nodejs/src/servers/ingestion-api-server.ts
index 615e708cd69c..be2eeb066cf4 100644
--- a/nodejs/src/servers/ingestion-api-server.ts
+++ b/nodejs/src/servers/ingestion-api-server.ts
@@ -2,6 +2,30 @@ import { Message } from 'node-rdkafka'
import { Counter, Gauge, Histogram } from 'prom-client'
import { IntegrationManagerService } from '~/cdp/services/managers/integration-manager.service'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { PostgresGroupRepository } from '~/common/groups/repositories/postgres-group-repository'
+import { ProducerName } from '~/common/outputs'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { createIngestionProducerRegistry } from '~/common/outputs/registry'
+import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '~/common/personhog'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { parseSplitAiEventsConfig } from '~/ingestion/common/steps/event-processing/split-ai-events-step'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { TopHog } from '~/ingestion/framework/tophog'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import {
+ JoinedIngestionPipelineConfig,
+ JoinedIngestionPipelineContext,
+ JoinedIngestionPipelineDeps,
+ JoinedIngestionPipelineInput,
+ createJoinedIngestionPipeline,
+} from '~/ingestion/pipelines/analytics/joined-ingestion-pipeline'
+import { createOutputsRegistry } from '~/ingestion/pipelines/analytics/outputs/registry'
import { initializePrometheusLabels } from '../api/router'
import {
@@ -14,14 +38,6 @@ import { EncryptedFields } from '../cdp/utils/encryption-utils'
import { CommonConfig } from '../common/config'
import { defaultConfig, overrideConfigWithEnv } from '../config/config'
import { createCookielessRedisConnectionConfig, createIngestionRedisConnectionConfig } from '../config/redis-pools'
-import {
- JoinedIngestionPipelineConfig,
- JoinedIngestionPipelineContext,
- JoinedIngestionPipelineDeps,
- JoinedIngestionPipelineInput,
- createJoinedIngestionPipeline,
-} from '../ingestion/analytics/joined-ingestion-pipeline'
-import { createOutputsRegistry } from '../ingestion/analytics/outputs/registry'
import { deserializeKafkaMessage } from '../ingestion/api/kafka-message-converter'
import { IngestBatchRequest, IngestBatchResponse } from '../ingestion/api/types'
import {
@@ -31,8 +47,6 @@ import {
getDefaultKafkaUpstreamProducerEnvConfig,
} from '../ingestion/common/config'
import { EventFilterManagerComponent } from '../ingestion/common/event-filters'
-import { ProducerName } from '../ingestion/common/outputs'
-import { createIngestionProducerRegistry } from '../ingestion/common/outputs/registry'
import {
DatabaseConnectionConfig,
IngestionConsumerConfig,
@@ -43,12 +57,6 @@ import {
RedisConnectionsConfig,
getDefaultIngestionOutputsConfig,
} from '../ingestion/config'
-import { CookielessManager } from '../ingestion/cookieless/cookieless-manager'
-import { parseSplitAiEventsConfig } from '../ingestion/event-processing/split-ai-events-step'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
-import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '../ingestion/personhog'
-import { createOkContext } from '../ingestion/pipelines/helpers'
-import { TopHog } from '../ingestion/tophog'
import { MainLaneOverflowRedirect } from '../ingestion/utils/overflow-redirect/main-lane-overflow-redirect'
import { OverflowLaneOverflowRedirect } from '../ingestion/utils/overflow-redirect/overflow-lane-overflow-redirect'
import { OverflowRedirectService } from '../ingestion/utils/overflow-redirect/overflow-redirect-service'
@@ -69,13 +77,6 @@ import { logger } from '../utils/logger'
import { PromiseScheduler } from '../utils/promise-scheduler'
import { PubSub } from '../utils/pubsub'
import { TeamManager } from '../utils/team-manager'
-import { GroupTypeManager } from '../worker/ingestion/group-type-manager'
-import { BatchWritingGroupStore } from '../worker/ingestion/groups/batch-writing-group-store'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { PostgresGroupRepository } from '../worker/ingestion/groups/repositories/postgres-group-repository'
-import { BatchWritingPersonsStore } from '../worker/ingestion/persons/batch-writing-person-store'
-import { PersonsStore } from '../worker/ingestion/persons/persons-store'
-import { PostgresPersonRepository } from '../worker/ingestion/persons/repositories/postgres-person-repository'
import { BaseServerConfig, CleanupResources, NodeServer, ServerLifecycle } from './base-server'
export type IngestionApiServerConfig = BaseServerConfig &
@@ -372,6 +373,7 @@ export class IngestionApiServer implements NodeServer {
personsStore,
groupStore,
hogTransformer: this.hogTransformer,
+ aiSubpipelineFactory: createAiEventSubpipeline,
eventFilterManager: eventFilterManagerStarted.value,
eventIngestionRestrictionManager,
eventSchemaEnforcementManager: new EventSchemaEnforcementManager(this.postgres),
diff --git a/nodejs/src/servers/ingestion-general-server.ts b/nodejs/src/servers/ingestion-general-server.ts
index 823e212b461b..cd8fd979f173 100644
--- a/nodejs/src/servers/ingestion-general-server.ts
+++ b/nodejs/src/servers/ingestion-general-server.ts
@@ -1,4 +1,15 @@
import { IntegrationManagerService } from '~/cdp/services/managers/integration-manager.service'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { PostgresGroupRepository } from '~/common/groups/repositories/postgres-group-repository'
+import { KafkaProducerRegistryComponent } from '~/common/outputs/registry'
+import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '~/common/personhog'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { CookielessManagerComponent } from '~/ingestion/common/cookieless/cookieless-manager'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import { createOutputsRegistry } from '~/ingestion/pipelines/analytics/outputs/registry'
+import { createClientWarningsConsumer } from '~/ingestion/pipelines/clientwarnings'
+import { createHeatmapsConsumer } from '~/ingestion/pipelines/heatmaps'
import { initializePrometheusLabels } from '../api/router'
import {
@@ -15,8 +26,6 @@ import {
KAFKA_EVENTS_PLUGIN_INGESTION_OVERFLOW,
} from '../config/kafka-topics'
import { createCookielessRedisConnectionConfig, createIngestionRedisConnectionConfig } from '../config/redis-pools'
-import { createOutputsRegistry } from '../ingestion/analytics/outputs/registry'
-import { createClientWarningsConsumer } from '../ingestion/clientwarnings'
import {
KafkaDownstreamProducerEnvConfig,
KafkaUpstreamProducerEnvConfig,
@@ -24,7 +33,6 @@ import {
getDefaultKafkaUpstreamProducerEnvConfig,
} from '../ingestion/common/config'
import { ingestionConsumerService } from '../ingestion/common/ingestion-consumer'
-import { KafkaProducerRegistryComponent } from '../ingestion/common/outputs/registry'
import { extend, newScope } from '../ingestion/common/scopes'
import {
DatabaseConnectionConfig,
@@ -36,10 +44,7 @@ import {
RedisConnectionsConfig,
getDefaultIngestionOutputsConfig,
} from '../ingestion/config'
-import { CookielessManagerComponent } from '../ingestion/cookieless/cookieless-manager'
-import { createHeatmapsConsumer } from '../ingestion/heatmaps'
import { IngestionConsumer, IngestionConsumerDeps } from '../ingestion/ingestion-consumer'
-import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '../ingestion/personhog'
import { PluginServerService, RedisPool } from '../types'
import { ServerCommands } from '../utils/commands'
import { PostgresRouter, PostgresRouterComponent } from '../utils/db/postgres'
@@ -48,10 +53,6 @@ import { GeoIPService } from '../utils/geoip'
import { logger } from '../utils/logger'
import { PubSub } from '../utils/pubsub'
import { TeamManagerComponent } from '../utils/team-manager'
-import { GroupTypeManager } from '../worker/ingestion/group-type-manager'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { PostgresGroupRepository } from '../worker/ingestion/groups/repositories/postgres-group-repository'
-import { PostgresPersonRepository } from '../worker/ingestion/persons/repositories/postgres-person-repository'
import { BaseServerConfig, CleanupResources, NodeServer, ServerLifecycle } from './base-server'
/**
@@ -252,6 +253,7 @@ export class IngestionGeneralServer implements NodeServer {
personRepository,
cookielessManager,
hogTransformer: createHogTransformerService(this.config, hogTransformerDeps),
+ aiSubpipelineFactory: createAiEventSubpipeline,
}
const startClientWarnings = (override?: { topic: string; groupId: string }) => {
diff --git a/nodejs/src/servers/ingestion-logs-server.ts b/nodejs/src/servers/ingestion-logs-server.ts
index 332e8f97aadf..7401c518ac4a 100644
--- a/nodejs/src/servers/ingestion-logs-server.ts
+++ b/nodejs/src/servers/ingestion-logs-server.ts
@@ -1,26 +1,26 @@
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
-
-import { CommonConfig } from '../common/config'
-import { defaultConfig, overrideConfigWithEnv } from '../config/config'
-import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
-import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
import {
LogsIngestionConsumerConfig,
LogsIngestionOutputsConfig,
getDefaultLogsIngestionOutputsConfig,
-} from '../logs-ingestion/config'
-import { LogsIngestionConsumer } from '../logs-ingestion/logs-ingestion-consumer'
-import { createProducerRegistry } from '../logs-ingestion/outputs/producer-registry'
+} from '~/logs/config'
+import { LogsIngestionConsumer } from '~/logs/logs-ingestion-consumer'
+import { createProducerRegistry } from '~/logs/outputs/producer-registry'
import {
KafkaWarpstreamIngestionProducerEnvConfig,
KafkaWarpstreamLogsProducerEnvConfig,
LogsProducerName,
getDefaultKafkaWarpstreamIngestionProducerEnvConfig,
getDefaultKafkaWarpstreamLogsProducerEnvConfig,
-} from '../logs-ingestion/outputs/producers'
-import { createLogsOutputsRegistry } from '../logs-ingestion/outputs/registry'
-import { SamplingRulesCache } from '../logs-ingestion/sampling/sampling-rules-cache'
+} from '~/logs/outputs/producers'
+import { createLogsOutputsRegistry } from '~/logs/outputs/registry'
+import { SamplingRulesCache } from '~/logs/sampling/sampling-rules-cache'
+
+import { CommonConfig } from '../common/config'
+import { defaultConfig, overrideConfigWithEnv } from '../config/config'
+import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
+import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
import { PluginServerService, RedisPool } from '../types'
import { PostgresRouter } from '../utils/db/postgres'
import { createRedisPoolFromConfig } from '../utils/db/redis'
diff --git a/nodejs/src/servers/ingestion-metrics-server.ts b/nodejs/src/servers/ingestion-metrics-server.ts
index 3394b9260331..75a2cfca7e28 100644
--- a/nodejs/src/servers/ingestion-metrics-server.ts
+++ b/nodejs/src/servers/ingestion-metrics-server.ts
@@ -1,25 +1,25 @@
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
-
-import { CommonConfig } from '../common/config'
-import { defaultConfig, overrideConfigWithEnv } from '../config/config'
-import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
-import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
import {
MetricsIngestionConsumerConfig,
MetricsIngestionOutputsConfig,
getDefaultMetricsIngestionOutputsConfig,
-} from '../metrics-ingestion/config'
-import { MetricsIngestionConsumer } from '../metrics-ingestion/metrics-ingestion-consumer'
-import { createProducerRegistry } from '../metrics-ingestion/outputs/producer-registry'
+} from '~/ingestion/pipelines/metrics/config'
+import { MetricsIngestionConsumer } from '~/ingestion/pipelines/metrics/metrics-ingestion-consumer'
+import { createProducerRegistry } from '~/ingestion/pipelines/metrics/outputs/producer-registry'
import {
KafkaWarpstreamIngestionProducerEnvConfig,
KafkaWarpstreamMetricsProducerEnvConfig,
MetricsProducerName,
getDefaultKafkaWarpstreamIngestionProducerEnvConfig,
getDefaultKafkaWarpstreamMetricsProducerEnvConfig,
-} from '../metrics-ingestion/outputs/producers'
-import { createMetricsOutputsRegistry } from '../metrics-ingestion/outputs/registry'
+} from '~/ingestion/pipelines/metrics/outputs/producers'
+import { createMetricsOutputsRegistry } from '~/ingestion/pipelines/metrics/outputs/registry'
+
+import { CommonConfig } from '../common/config'
+import { defaultConfig, overrideConfigWithEnv } from '../config/config'
+import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
+import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
import { PluginServerService, RedisPool } from '../types'
import { PostgresRouter } from '../utils/db/postgres'
import { createRedisPoolFromConfig } from '../utils/db/redis'
diff --git a/nodejs/src/servers/ingestion-session-replay-server.ts b/nodejs/src/servers/ingestion-session-replay-server.ts
index f2c440cbb519..a3a54d6adbd5 100644
--- a/nodejs/src/servers/ingestion-session-replay-server.ts
+++ b/nodejs/src/servers/ingestion-session-replay-server.ts
@@ -1,3 +1,17 @@
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import {
+ SessionReplayOutputsConfig,
+ type SessionReplayProducerName,
+ getDefaultSessionReplayOutputsConfig,
+} from '~/ingestion/pipelines/sessionreplay/config'
+import { SessionRecordingIngester, SessionRecordingIngesterConfig } from '~/ingestion/pipelines/sessionreplay/consumer'
+import { createProducerRegistry } from '~/ingestion/pipelines/sessionreplay/outputs/producer-registry'
+import { createOutputsRegistry } from '~/ingestion/pipelines/sessionreplay/outputs/registry'
+import {
+ KafkaSessionreplayProducerEnvConfig,
+ getDefaultKafkaSessionreplayProducerEnvConfig,
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
+
import { initializePrometheusLabels } from '../api/router'
import { CommonConfig } from '../common/config'
import { defaultConfig, overrideConfigWithEnv } from '../config/config'
@@ -6,19 +20,6 @@ import {
getDefaultKafkaDownstreamProducerEnvConfig,
} from '../ingestion/common/config'
import { KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
-import {
- SessionReplayOutputsConfig,
- type SessionReplayProducerName,
- getDefaultSessionReplayOutputsConfig,
-} from '../session-recording/config'
-import { SessionRecordingIngester, SessionRecordingIngesterConfig } from '../session-recording/consumer'
-import { createProducerRegistry } from '../session-recording/outputs/producer-registry'
-import { createOutputsRegistry } from '../session-recording/outputs/registry'
-import {
- KafkaSessionreplayProducerEnvConfig,
- getDefaultKafkaSessionreplayProducerEnvConfig,
-} from '../session-replay/shared/outputs/producer-config'
import { RedisPool } from '../types'
import { PostgresRouter, PostgresRouterConfig } from '../utils/db/postgres'
import { createRedisPoolFromConfig } from '../utils/db/redis'
diff --git a/nodejs/src/servers/ingestion-traces-server.ts b/nodejs/src/servers/ingestion-traces-server.ts
index ccfce73f9cb6..7bae18d7016a 100644
--- a/nodejs/src/servers/ingestion-traces-server.ts
+++ b/nodejs/src/servers/ingestion-traces-server.ts
@@ -1,26 +1,26 @@
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
-
-import { CommonConfig } from '../common/config'
-import { defaultConfig, overrideConfigWithEnv } from '../config/config'
-import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
-import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
import {
LogsIngestionConsumerConfig,
LogsIngestionOutputsConfig,
TracesIngestionConsumerConfig,
getDefaultLogsIngestionOutputsConfig,
-} from '../logs-ingestion/config'
-import { createProducerRegistry } from '../logs-ingestion/outputs/producer-registry'
+} from '~/logs/config'
+import { createProducerRegistry } from '~/logs/outputs/producer-registry'
import {
KafkaWarpstreamIngestionProducerEnvConfig,
KafkaWarpstreamLogsProducerEnvConfig,
LogsProducerName,
getDefaultKafkaWarpstreamIngestionProducerEnvConfig,
getDefaultKafkaWarpstreamLogsProducerEnvConfig,
-} from '../logs-ingestion/outputs/producers'
-import { createTracesOutputsRegistry } from '../logs-ingestion/outputs/registry'
-import { TracesIngestionConsumer } from '../logs-ingestion/traces-ingestion-consumer'
+} from '~/logs/outputs/producers'
+import { createTracesOutputsRegistry } from '~/logs/outputs/registry'
+import { TracesIngestionConsumer } from '~/logs/traces-ingestion-consumer'
+
+import { CommonConfig } from '../common/config'
+import { defaultConfig, overrideConfigWithEnv } from '../config/config'
+import { createPosthogRedisConnectionConfig } from '../config/redis-pools'
+import { DatabaseConnectionConfig, KafkaBrokerConfig, RedisConnectionsConfig } from '../ingestion/config'
import { PluginServerService, RedisPool } from '../types'
import { PostgresRouter } from '../utils/db/postgres'
import { createRedisPoolFromConfig } from '../utils/db/redis'
diff --git a/nodejs/src/servers/recording-api-server.ts b/nodejs/src/servers/recording-api-server.ts
index f8ec8dfed6b3..09577de4a3fb 100644
--- a/nodejs/src/servers/recording-api-server.ts
+++ b/nodejs/src/servers/recording-api-server.ts
@@ -1,20 +1,21 @@
-import { CommonConfig } from '../common/config'
-import { defaultConfig, overrideConfigWithEnv } from '../config/config'
-import { KafkaBrokerConfig } from '../ingestion/config'
-import { KafkaProducerRegistry } from '../ingestion/outputs/kafka-producer-registry'
-import { createProducerRegistry } from '../session-replay/recording-api/outputs/producer-registry'
-import { createOutputsRegistry } from '../session-replay/recording-api/outputs/registry'
-import { RecordingApi } from '../session-replay/recording-api/recording-api'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import {
+ KafkaSessionreplayProducerEnvConfig,
+ getDefaultKafkaSessionreplayProducerEnvConfig,
+} from '~/ingestion/pipelines/sessionreplay/shared/outputs/producer-config'
+import { createProducerRegistry } from '~/recording-api/outputs/producer-registry'
+import { createOutputsRegistry } from '~/recording-api/outputs/registry'
+import { RecordingApi } from '~/recording-api/recording-api'
import {
RecordingApiConfig,
RecordingApiOutputsConfig,
type RecordingApiProducerName,
getDefaultRecordingApiOutputsConfig,
-} from '../session-replay/recording-api/types'
-import {
- KafkaSessionreplayProducerEnvConfig,
- getDefaultKafkaSessionreplayProducerEnvConfig,
-} from '../session-replay/shared/outputs/producer-config'
+} from '~/recording-api/types'
+
+import { CommonConfig } from '../common/config'
+import { defaultConfig, overrideConfigWithEnv } from '../config/config'
+import { KafkaBrokerConfig } from '../ingestion/config'
import { PostgresRouter, PostgresRouterConfig } from '../utils/db/postgres'
import { logger } from '../utils/logger'
import { BaseServerConfig, CleanupResources, NodeServer, ServerLifecycle } from './base-server'
diff --git a/nodejs/src/session-recording/teams/types.ts b/nodejs/src/session-recording/teams/types.ts
deleted file mode 100644
index 47cab3e84204..000000000000
--- a/nodejs/src/session-recording/teams/types.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { TeamForReplay } from '../../session-replay/shared/teams/types'
-import { ParsedMessageData } from '../kafka/types'
-
-export type { TeamForReplay }
-
-export interface MessageWithTeam {
- team: TeamForReplay
- message: ParsedMessageData
-}
diff --git a/nodejs/src/types.ts b/nodejs/src/types.ts
index 870fa274469a..48ef2e22809e 100644
--- a/nodejs/src/types.ts
+++ b/nodejs/src/types.ts
@@ -3,7 +3,15 @@ import { Redis } from 'ioredis'
import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { PersonRepository } from '~/common/persons/repositories/person-repository'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
+import type { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+import type { ErrorTrackingConsumerConfig } from '~/ingestion/pipelines/errortracking/config'
+import type { MetricsIngestionConsumerConfig } from '~/ingestion/pipelines/metrics/config'
+import type { SessionRecordingApiConfig, SessionRecordingConfig } from '~/ingestion/pipelines/sessionreplay/config'
+import type { LogsIngestionConsumerConfig, TracesIngestionConsumerConfig } from '~/logs/config'
import { Element, PluginEvent, Properties } from '~/plugin-scaffold'
import type { AIObservabilityConfig } from './ai-observability/config'
@@ -18,18 +26,10 @@ import { IntegrationManagerService } from './cdp/services/managers/integration-m
import { EncryptedFields } from './cdp/utils/encryption-utils'
import type { CommonConfig } from './common/config'
import type { IngestionConsumerConfig } from './ingestion/config'
-import type { CookielessManager } from './ingestion/cookieless/cookieless-manager'
-import type { ErrorTrackingConsumerConfig } from './ingestion/error-tracking/config'
-import type { LogsIngestionConsumerConfig, TracesIngestionConsumerConfig } from './logs-ingestion/config'
-import type { MetricsIngestionConsumerConfig } from './metrics-ingestion/config'
-import type { SessionRecordingApiConfig, SessionRecordingConfig } from './session-recording/config'
import { PostgresRouter } from './utils/db/postgres'
import { GeoIPService } from './utils/geoip'
import { PubSub } from './utils/pubsub'
import { TeamManager } from './utils/team-manager'
-import { GroupTypeManager } from './worker/ingestion/group-type-manager'
-import { GroupRepository } from './worker/ingestion/groups/repositories/group-repository.interface'
-import { PersonRepository } from './worker/ingestion/persons/repositories/person-repository'
export type { Element } from '~/plugin-scaffold' // Re-export Element from scaffolding, for backwards compat.
@@ -46,10 +46,10 @@ export type {
PersonBatchWritingDbWriteMode,
PersonBatchWritingMode,
} from './ingestion/config'
-export type { ErrorTrackingConsumerConfig } from './ingestion/error-tracking/config'
-export type { LogsIngestionConsumerConfig } from './logs-ingestion/config'
-export type { MetricsIngestionConsumerConfig } from './metrics-ingestion/config'
-export type { SessionRecordingApiConfig, SessionRecordingConfig } from './session-recording/config'
+export type { ErrorTrackingConsumerConfig } from '~/ingestion/pipelines/errortracking/config'
+export type { LogsIngestionConsumerConfig } from '~/logs/config'
+export type { MetricsIngestionConsumerConfig } from '~/ingestion/pipelines/metrics/config'
+export type { SessionRecordingApiConfig, SessionRecordingConfig } from '~/ingestion/pipelines/sessionreplay/config'
interface HealthCheckResultResponse {
service: string
diff --git a/nodejs/src/utils/db/db.ts b/nodejs/src/utils/db/db.ts
index fe9c82bc01a6..a0b78b0d50a2 100644
--- a/nodejs/src/utils/db/db.ts
+++ b/nodejs/src/utils/db/db.ts
@@ -1,5 +1,6 @@
+import { PersonMessage } from '~/common/persons/person-message'
+
import { InternalPerson } from '../../types'
-import { PersonMessage } from '../../worker/ingestion/persons/person-message'
export type MoveDistinctIdsResult =
| { readonly success: true; readonly messages: PersonMessage[]; readonly distinctIdsMoved: string[] }
diff --git a/nodejs/src/utils/db/hub.ts b/nodejs/src/utils/db/hub.ts
index 3ecad7da7749..3af15e6fbe83 100644
--- a/nodejs/src/utils/db/hub.ts
+++ b/nodejs/src/utils/db/hub.ts
@@ -1,5 +1,10 @@
import { IntegrationManagerService } from '~/cdp/services/managers/integration-manager.service'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { PostgresGroupRepository } from '~/common/groups/repositories/postgres-group-repository'
+import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '~/common/personhog'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
import { QuotaLimiting } from '~/common/services/quota-limiting.service'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
import { EncryptedFields } from '../../cdp/utils/encryption-utils'
import { defaultConfig } from '../../config/config'
@@ -8,12 +13,7 @@ import {
createIngestionRedisConnectionConfig,
createPosthogRedisConnectionConfig,
} from '../../config/redis-pools'
-import { CookielessManager } from '../../ingestion/cookieless/cookieless-manager'
-import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '../../ingestion/personhog'
import { Hub, PluginsServerConfig } from '../../types'
-import { GroupTypeManager } from '../../worker/ingestion/group-type-manager'
-import { PostgresGroupRepository } from '../../worker/ingestion/groups/repositories/postgres-group-repository'
-import { PostgresPersonRepository } from '../../worker/ingestion/persons/repositories/postgres-person-repository'
import { isTestEnv } from '../env-utils'
import { GeoIPService } from '../geoip'
import { logger } from '../logger'
diff --git a/nodejs/src/utils/db/utils.ts b/nodejs/src/utils/db/utils.ts
index fe13fb828162..b9637f3f4fff 100644
--- a/nodejs/src/utils/db/utils.ts
+++ b/nodejs/src/utils/db/utils.ts
@@ -1,14 +1,14 @@
import { Counter } from 'prom-client'
+import { PERSONS_OUTPUT } from '~/common/outputs'
+import { PersonMessage } from '~/common/persons/person-message'
+import { eventToPersonProperties } from '~/common/persons/person-property-utils'
import { Properties } from '~/plugin-scaffold'
import { defaultConfig } from '../../config/config'
-import { PERSONS_OUTPUT } from '../../ingestion/analytics/outputs'
import { BasePerson, InternalPerson, RawPerson, TimestampFormat } from '../../types'
import { logger } from '../../utils/logger'
import { castTimestampOrNow } from '../../utils/utils'
-import { PersonMessage } from '../../worker/ingestion/persons/person-message'
-import { eventToPersonProperties } from '../../worker/ingestion/persons/person-property-utils'
import { captureException } from '../posthog'
export function unparsePersonPartial(person: Partial<InternalPerson>): Partial<RawPerson> {
diff --git a/nodejs/src/utils/env-utils.ts b/nodejs/src/utils/env-utils.ts
index 901b4e1bf835..05813efd2110 100644
--- a/nodejs/src/utils/env-utils.ts
+++ b/nodejs/src/utils/env-utils.ts
@@ -49,3 +49,14 @@ export function isOverflowBatchByDistinctId(): boolean {
const overflowBatchByDistinctId = process.env.INGESTION_OVERFLOW_BATCH_BY_DISTINCT_ID
return stringToBoolean(overflowBatchByDistinctId)
}
+
+// Parse a comma-separated env var of team ids into a list, or '*' for "all teams".
+export function parseTeamsList(teamsStr: string): number[] | '*' {
+ if (teamsStr === '*') {
+ return '*'
+ }
+ return teamsStr
+ .split(',')
+ .map((s) => parseInt(s.trim(), 10))
+ .filter((n) => !isNaN(n))
+}
diff --git a/nodejs/tests/helpers/cdp.ts b/nodejs/tests/helpers/cdp.ts
index 40c57d0816bd..1403352e7816 100644
--- a/nodejs/tests/helpers/cdp.ts
+++ b/nodejs/tests/helpers/cdp.ts
@@ -1,5 +1,9 @@
import { mockProducer } from './mocks/producer.mock'
+import { GroupReadRepository } from '~/common/groups/repositories/group-repository.interface'
+import { KafkaProducerRegistry } from '~/common/outputs/kafka-producer-registry'
+import { PersonReadRepository } from '~/common/persons/repositories/person-repository'
+
import { CdpConsumerBaseDeps } from '../../src/cdp/consumers/cdp-base.consumer'
import {
CdpProducerName,
@@ -9,11 +13,8 @@ import {
WARPSTREAM_INGESTION_PRODUCER,
} from '../../src/cdp/outputs/producers'
import { InternalCaptureService } from '../../src/common/services/internal-capture'
-import { KafkaProducerRegistry } from '../../src/ingestion/outputs/kafka-producer-registry'
import { KafkaProducerWrapper } from '../../src/kafka/producer'
import { Hub } from '../../src/types'
-import { GroupReadRepository } from '../../src/worker/ingestion/groups/repositories/group-repository.interface'
-import { PersonReadRepository } from '../../src/worker/ingestion/persons/repositories/person-repository'
/**
* Single shared kafkaProducer is enough for tests — point every CDP producer
diff --git a/nodejs/tests/helpers/ingestion-e2e.ts b/nodejs/tests/helpers/ingestion-e2e.ts
index a904c11af142..b6d0c5d01195 100644
--- a/nodejs/tests/helpers/ingestion-e2e.ts
+++ b/nodejs/tests/helpers/ingestion-e2e.ts
@@ -2,6 +2,14 @@ import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
import { v4 } from 'uuid'
+import { GroupTypeManager } from '~/common/groups/group-type-manager'
+import { GroupRepository } from '~/common/groups/repositories/group-repository.interface'
+import { PostgresGroupRepository } from '~/common/groups/repositories/postgres-group-repository'
+import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '~/common/personhog'
+import { PersonRepository } from '~/common/persons/repositories/person-repository'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { CookielessManager } from '~/ingestion/common/cookieless/cookieless-manager'
+
import { IntegrationManagerService } from '../../src/cdp/services/managers/integration-manager.service'
import { EncryptedFields } from '../../src/cdp/utils/encryption-utils'
import { defaultConfig } from '../../src/config/config'
@@ -10,8 +18,6 @@ import {
createCookielessRedisConnectionConfig,
createIngestionRedisConnectionConfig,
} from '../../src/config/redis-pools'
-import { CookielessManager } from '../../src/ingestion/cookieless/cookieless-manager'
-import { buildGroupRepository, buildPersonRepository, createPersonHogClient } from '../../src/ingestion/personhog'
import { KafkaProducerWrapper } from '../../src/kafka/producer'
import { PipelineEvent, PluginsServerConfig, ProjectId, RawClickHouseEvent, RedisPool, Team } from '../../src/types'
import { PostgresRouter } from '../../src/utils/db/postgres'
@@ -22,11 +28,6 @@ import { parseJSON } from '../../src/utils/json-parse'
import { PubSub } from '../../src/utils/pubsub'
import { TeamManager } from '../../src/utils/team-manager'
import { UUIDT } from '../../src/utils/utils'
-import { GroupTypeManager } from '../../src/worker/ingestion/group-type-manager'
-import { GroupRepository } from '../../src/worker/ingestion/groups/repositories/group-repository.interface'
-import { PostgresGroupRepository } from '../../src/worker/ingestion/groups/repositories/postgres-group-repository'
-import { PersonRepository } from '../../src/worker/ingestion/persons/repositories/person-repository'
-import { PostgresPersonRepository } from '../../src/worker/ingestion/persons/repositories/postgres-person-repository'
import { Clickhouse } from './clickhouse'
import { waitForExpect } from './expectations'
import { ensureKafkaTopics } from './kafka'
diff --git a/nodejs/tests/helpers/ingestion-outputs.ts b/nodejs/tests/helpers/ingestion-outputs.ts
index cea662e80c1b..c99379e6568c 100644
--- a/nodejs/tests/helpers/ingestion-outputs.ts
+++ b/nodejs/tests/helpers/ingestion-outputs.ts
@@ -1,3 +1,23 @@
+import {
+ APP_METRICS_OUTPUT,
+ DLQ_OUTPUT,
+ GROUPS_OUTPUT,
+ INGESTION_WARNINGS_OUTPUT,
+ LOG_ENTRIES_OUTPUT,
+ OVERFLOW_OUTPUT,
+ TOPHOG_OUTPUT,
+} from '~/common/outputs'
+import {
+ AI_EVENTS_OUTPUT,
+ ASYNC_OUTPUT,
+ EVENTS_OUTPUT,
+ PERSONS_OUTPUT,
+ PERSON_DISTINCT_IDS_OUTPUT,
+} from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { HEATMAPS_OUTPUT } from '~/ingestion/pipelines/heatmaps/outputs'
+
import {
KAFKA_APP_METRICS_2,
KAFKA_CLICKHOUSE_AI_EVENTS_JSON,
@@ -13,25 +33,6 @@ import {
KAFKA_PERSON,
KAFKA_PERSON_DISTINCT_ID,
} from '../../src/config/kafka-topics'
-import {
- AI_EVENTS_OUTPUT,
- ASYNC_OUTPUT,
- EVENTS_OUTPUT,
- PERSONS_OUTPUT,
- PERSON_DISTINCT_IDS_OUTPUT,
-} from '../../src/ingestion/analytics/outputs'
-import {
- APP_METRICS_OUTPUT,
- DLQ_OUTPUT,
- GROUPS_OUTPUT,
- INGESTION_WARNINGS_OUTPUT,
- LOG_ENTRIES_OUTPUT,
- OVERFLOW_OUTPUT,
- TOPHOG_OUTPUT,
-} from '../../src/ingestion/common/outputs'
-import { HEATMAPS_OUTPUT } from '../../src/ingestion/heatmaps/outputs'
-import { IngestionOutputs } from '../../src/ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../../src/ingestion/outputs/single-ingestion-output'
import { KafkaProducerWrapper } from '../../src/kafka/producer'
function testOutput(name: string, topic: string, producer: KafkaProducerWrapper): SingleIngestionOutput {
diff --git a/nodejs/tests/helpers/mock-ingestion-outputs.ts b/nodejs/tests/helpers/mock-ingestion-outputs.ts
index 54893ef1b993..e8d8a1032843 100644
--- a/nodejs/tests/helpers/mock-ingestion-outputs.ts
+++ b/nodejs/tests/helpers/mock-ingestion-outputs.ts
@@ -1,4 +1,4 @@
-import { IngestionOutputs } from '../../src/ingestion/outputs/ingestion-outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
export function createMockIngestionOutputs<O extends string>(): jest.Mocked<IngestionOutputs<O>> {
return {
diff --git a/nodejs/tests/helpers/mock-pipeline.ts b/nodejs/tests/helpers/mock-pipeline.ts
index 2af4be94faa2..50bcb607f452 100644
--- a/nodejs/tests/helpers/mock-pipeline.ts
+++ b/nodejs/tests/helpers/mock-pipeline.ts
@@ -1,6 +1,6 @@
import { Message } from 'node-rdkafka'
-import { BatchPipeline, BatchPipelineResultWithContext } from '../../src/ingestion/pipelines/batch-pipeline.interface'
+import { BatchPipeline, BatchPipelineResultWithContext } from '~/ingestion/framework/batch-pipeline.interface'
/**
* Creates a mock pipeline that returns pre-built results from next().
diff --git a/nodejs/src/ingestion/common/event-filters/manager.integration.test.ts b/nodejs/tests/ingestion/common/event-filters/manager.integration.test.ts
similarity index 98%
rename from nodejs/src/ingestion/common/event-filters/manager.integration.test.ts
rename to nodejs/tests/ingestion/common/event-filters/manager.integration.test.ts
index 80aebcc95a3f..7d4cce68e2fa 100644
--- a/nodejs/src/ingestion/common/event-filters/manager.integration.test.ts
+++ b/nodejs/tests/ingestion/common/event-filters/manager.integration.test.ts
@@ -1,11 +1,11 @@
import { v4 } from 'uuid'
-import { createOrganization, createTeam, insertRow, resetTestDatabase } from '../../../../tests/helpers/sql'
-import { defaultConfig } from '../../../config/config'
-import { PostgresRouter, PostgresUse } from '../../../utils/db/postgres'
-import { evaluateFilterTree } from './evaluate'
-import { EventFilterManager, EventFilterManagerComponent } from './manager'
-import { and, cond, not, or } from './test-helpers'
+import { defaultConfig } from '~/config/config'
+import { evaluateFilterTree } from '~/ingestion/common/event-filters/evaluate'
+import { EventFilterManager, EventFilterManagerComponent } from '~/ingestion/common/event-filters/manager'
+import { and, cond, not, or } from '~/ingestion/common/event-filters/test-helpers'
+import { createOrganization, createTeam, insertRow, resetTestDatabase } from '~/tests/helpers/sql'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
async function insertFilter(
postgres: PostgresRouter,
diff --git a/nodejs/src/ingestion/event-processing/process-persons-step.integration.test.ts b/nodejs/tests/ingestion/common/steps/event-processing/process-persons-step.integration.test.ts
similarity index 90%
rename from nodejs/src/ingestion/event-processing/process-persons-step.integration.test.ts
rename to nodejs/tests/ingestion/common/steps/event-processing/process-persons-step.integration.test.ts
index 8e604621c109..0a000c9f0650 100644
--- a/nodejs/src/ingestion/event-processing/process-persons-step.integration.test.ts
+++ b/nodejs/tests/ingestion/common/steps/event-processing/process-persons-step.integration.test.ts
@@ -2,33 +2,29 @@ import { mockProducer } from '~/tests/helpers/mocks/producer.mock'
import { DateTime } from 'luxon'
-import { ASYNC_OUTPUT } from '~/ingestion/analytics/outputs'
-import { PipelineResultType, isDlqResult, isOkResult, isRedirectResult } from '~/ingestion/pipelines/results'
-import { PluginEvent } from '~/plugin-scaffold'
-import { BatchWritingPersonsStore } from '~/worker/ingestion/persons/batch-writing-person-store'
-import { BatchBoundPersonsStore } from '~/worker/ingestion/persons/persons-store-for-batch'
-import { PostgresPersonRepository } from '~/worker/ingestion/persons/repositories/postgres-person-repository'
-
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { ASYNC_OUTPUT } from '~/common/outputs'
+import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { KAFKA_INGESTION_WARNINGS, KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '~/config/kafka-topics'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { BatchBoundPersonsStore } from '~/ingestion/common/persons/persons-store-for-batch'
+import { EventPipelineRunnerOptions } from '~/ingestion/common/steps/event-processing/event-pipeline-options'
import {
- createOrganization,
- createTeam,
- fetchPostgresPersons,
- getTeam,
- resetTestDatabase,
-} from '../../../tests/helpers/sql'
-import { KAFKA_INGESTION_WARNINGS, KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '../../config/kafka-topics'
-import { Hub, Person, Team } from '../../types'
-import { closeHub, createHub } from '../../utils/db/hub'
-import { normalizeEvent, normalizeProcessPerson } from '../../utils/event'
-import { UUIDT } from '../../utils/utils'
-import { PersonOutputs } from '../../worker/ingestion/persons/person-context'
-import { parseEventTimestamp } from '../../worker/ingestion/timestamps'
-import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../analytics/outputs'
-import { INGESTION_WARNINGS_OUTPUT } from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../outputs/single-ingestion-output'
-import { EventPipelineRunnerOptions } from './event-pipeline-options'
-import { ProcessPersonsInput, createProcessPersonsStep } from './process-persons-step'
+ ProcessPersonsInput,
+ createProcessPersonsStep,
+} from '~/ingestion/common/steps/event-processing/process-persons-step'
+import { parseEventTimestamp } from '~/ingestion/common/timestamps'
+import { PipelineResultType, isDlqResult, isOkResult, isRedirectResult } from '~/ingestion/framework/results'
+import { PluginEvent } from '~/plugin-scaffold'
+import { createOrganization, createTeam, fetchPostgresPersons, getTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, Person, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { normalizeEvent, normalizeProcessPerson } from '~/utils/event'
+import { UUIDT } from '~/utils/utils'
describe('createProcessPersonsStep', () => {
let hub: Hub
diff --git a/nodejs/src/ingestion/pipelines/batching-pipeline.integration.test.ts b/nodejs/tests/ingestion/framework/batching-pipeline.integration.test.ts
similarity index 97%
rename from nodejs/src/ingestion/pipelines/batching-pipeline.integration.test.ts
rename to nodejs/tests/ingestion/framework/batching-pipeline.integration.test.ts
index 4b2dc98625f1..51cc2e1681a5 100644
--- a/nodejs/src/ingestion/pipelines/batching-pipeline.integration.test.ts
+++ b/nodejs/tests/ingestion/framework/batching-pipeline.integration.test.ts
@@ -1,20 +1,20 @@
import { Message } from 'node-rdkafka'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { parseJSON } from '../../utils/json-parse'
-import { PromiseScheduler } from '../../utils/promise-scheduler'
-import { BatchWritingGroupStore } from '../../worker/ingestion/groups/batch-writing-group-store'
-import { PersonOutputs } from '../../worker/ingestion/persons/person-context'
-import { FlushResult, PersonsStore } from '../../worker/ingestion/persons/persons-store'
-import { BatchWritingStore, BatchWritingStoreFlushStats } from '../../worker/ingestion/stores/batch-writing-store'
-import { PERSONS_OUTPUT } from '../analytics/outputs'
-import { DlqOutput, IngestionWarningsOutput } from '../common/outputs'
-import { createFlushBatchStoresStep } from '../event-processing/flush-batch-stores-step'
-import { BatchingPipeline, BeforeBatchInput, FeedResult } from './batching-pipeline'
-import { newBatchingPipeline } from './builders'
-import { createOkContext } from './helpers'
-import { OkResultWithContext } from './pipeline.interface'
-import { PipelineResult, drop, ok } from './results'
+import { DlqOutput, IngestionWarningsOutput } from '~/common/outputs'
+import { BatchWritingGroupStore } from '~/ingestion/common/groups/batch-writing-group-store'
+import { PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { FlushResult, PersonsStore } from '~/ingestion/common/persons/persons-store'
+import { createFlushBatchStoresStep } from '~/ingestion/common/steps/event-processing/flush-batch-stores-step'
+import { BatchWritingStore, BatchWritingStoreFlushStats } from '~/ingestion/common/stores/batch-writing-store'
+import { BatchingPipeline, BeforeBatchInput, FeedResult } from '~/ingestion/framework/batching-pipeline'
+import { newBatchingPipeline } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { OkResultWithContext } from '~/ingestion/framework/pipeline.interface'
+import { PipelineResult, drop, ok } from '~/ingestion/framework/results'
+import { PERSONS_OUTPUT } from '~/ingestion/pipelines/analytics/outputs'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { parseJSON } from '~/utils/json-parse'
+import { PromiseScheduler } from '~/utils/promise-scheduler'
/**
* Integration tests for BatchingPipeline + groupBy + sequential group processing,
diff --git a/nodejs/src/ingestion/pipelines/pipelines.integration.test.ts b/nodejs/tests/ingestion/framework/pipelines.integration.test.ts
similarity index 99%
rename from nodejs/src/ingestion/pipelines/pipelines.integration.test.ts
rename to nodejs/tests/ingestion/framework/pipelines.integration.test.ts
index 5766f3af372d..34299160a395 100644
--- a/nodejs/src/ingestion/pipelines/pipelines.integration.test.ts
+++ b/nodejs/tests/ingestion/framework/pipelines.integration.test.ts
@@ -1,22 +1,22 @@
import { Message } from 'node-rdkafka'
import { v4 } from 'uuid'
-import { createMockIngestionOutputs } from '../../../tests/helpers/mock-ingestion-outputs'
-import { ProjectId, Team } from '../../types'
import {
DLQ_OUTPUT,
INGESTION_WARNINGS_OUTPUT,
IngestionWarningsOutput,
OVERFLOW_OUTPUT,
OverflowOutput,
-} from '../common/outputs'
-import { IngestionOutputs } from '../outputs/ingestion-outputs'
-import { BatchProcessingStep } from './base-batch-pipeline'
-import { newBatchPipelineBuilder } from './builders'
-import { createBatch, createNewPipeline, createUnwrapper } from './helpers'
-import { PipelineConfig } from './result-handling-pipeline'
-import { PipelineResult, dlq, drop, ok, redirect } from './results'
-import { ProcessingStep } from './steps'
+} from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { BatchProcessingStep } from '~/ingestion/framework/base-batch-pipeline'
+import { newBatchPipelineBuilder } from '~/ingestion/framework/builders'
+import { createBatch, createNewPipeline, createUnwrapper } from '~/ingestion/framework/helpers'
+import { PipelineConfig } from '~/ingestion/framework/result-handling-pipeline'
+import { PipelineResult, dlq, drop, ok, redirect } from '~/ingestion/framework/results'
+import { ProcessingStep } from '~/ingestion/framework/steps'
+import { createMockIngestionOutputs } from '~/tests/helpers/mock-ingestion-outputs'
+import { ProjectId, Team } from '~/types'
const createTestTeam = (overrides: Partial<Team> = {}): Team => ({
id: 1,
diff --git a/nodejs/src/ingestion/ingestion-e2e.test.ts b/nodejs/tests/ingestion/ingestion-e2e.test.ts
similarity index 99%
rename from nodejs/src/ingestion/ingestion-e2e.test.ts
rename to nodejs/tests/ingestion/ingestion-e2e.test.ts
index 4aee800b7b6b..b58d8b34e222 100644
--- a/nodejs/src/ingestion/ingestion-e2e.test.ts
+++ b/nodejs/tests/ingestion/ingestion-e2e.test.ts
@@ -1,9 +1,12 @@
import { DateTime } from 'luxon'
+import { createHogTransformerService } from '~/cdp/hog-transformations/hog-transformer.service'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { fetchDistinctIds } from '~/common/persons/repositories/test-helpers'
+import { IngestionConsumer } from '~/ingestion/ingestion-consumer'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import { Clickhouse } from '~/tests/helpers/clickhouse'
import { waitForExpect } from '~/tests/helpers/expectations'
-import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
-
-import { Clickhouse } from '../../tests/helpers/clickhouse'
import {
EventBuilder,
createKafkaMessages,
@@ -12,16 +15,13 @@ import {
fetchIngestionWarnings,
waitForClickHouseKafkaConsumer,
waitForKafkaMessages,
-} from '../../tests/helpers/ingestion-e2e'
-import { createTestIngestionOutputs, createTestMonitoringOutputs } from '../../tests/helpers/ingestion-outputs'
-import { createUserTeamAndOrganization, fetchPostgresPersons, resetTestDatabase } from '../../tests/helpers/sql'
-import { createHogTransformerService } from '../cdp/hog-transformations/hog-transformer.service'
-import { InternalPerson } from '../types'
-import { parseJSON } from '../utils/json-parse'
-import { UUIDT } from '../utils/utils'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { fetchDistinctIds } from '../worker/ingestion/persons/repositories/test-helpers'
-import { IngestionConsumer } from './ingestion-consumer'
+} from '~/tests/helpers/ingestion-e2e'
+import { createTestIngestionOutputs, createTestMonitoringOutputs } from '~/tests/helpers/ingestion-outputs'
+import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
+import { createUserTeamAndOrganization, fetchPostgresPersons, resetTestDatabase } from '~/tests/helpers/sql'
+import { InternalPerson } from '~/types'
+import { parseJSON } from '~/utils/json-parse'
+import { UUIDT } from '~/utils/utils'
// Mock the limiter so it always returns true
jest.mock('~/utils/token-bucket', () => {
@@ -33,7 +33,7 @@ jest.mock('~/utils/token-bucket', () => {
}
})
-jest.mock('../utils/logger')
+jest.mock('~/utils/logger')
describe.each([{ PERSONS_PREFETCH_ENABLED: false }, { PERSONS_PREFETCH_ENABLED: true }])(
'Event Pipeline E2E tests (prefetch=$PERSONS_PREFETCH_ENABLED)',
@@ -50,6 +50,7 @@ describe.each([{ PERSONS_PREFETCH_ENABLED: false }, { PERSONS_PREFETCH_ENABLED:
cookielessManager: infra.cookielessManager,
outputs,
clickhouseGroupRepository: new ClickhouseGroupRepository(outputs),
+ aiSubpipelineFactory: createAiEventSubpipeline,
hogTransformer: createHogTransformerService(infra.config, {
geoipService: infra.geoipService,
postgres: infra.postgres,
diff --git a/nodejs/src/ingestion/person-properties-metadata.e2e.test.ts b/nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts
similarity index 97%
rename from nodejs/src/ingestion/person-properties-metadata.e2e.test.ts
rename to nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts
index a27320da16e5..a87c62c8b608 100644
--- a/nodejs/src/ingestion/person-properties-metadata.e2e.test.ts
+++ b/nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts
@@ -10,18 +10,18 @@ import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
import { v4 } from 'uuid'
+import { createHogTransformerService } from '~/cdp/hog-transformations/hog-transformer.service'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { IngestionConsumer } from '~/ingestion/ingestion-consumer'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import { KafkaProducerWrapper } from '~/kafka/producer'
import { waitForExpect } from '~/tests/helpers/expectations'
+import { createTestIngestionOutputs, createTestMonitoringOutputs } from '~/tests/helpers/ingestion-outputs'
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
-
-import { createTestIngestionOutputs, createTestMonitoringOutputs } from '../../tests/helpers/ingestion-outputs'
-import { createUserTeamAndOrganization, fetchPostgresPersons, resetTestDatabase } from '../../tests/helpers/sql'
-import { createHogTransformerService } from '../cdp/hog-transformations/hog-transformer.service'
-import { KafkaProducerWrapper } from '../kafka/producer'
-import { Hub, PipelineEvent, PluginsServerConfig, ProjectId, Team } from '../types'
-import { closeHub, createHub } from '../utils/db/hub'
-import { UUIDT } from '../utils/utils'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { IngestionConsumer } from './ingestion-consumer'
+import { createUserTeamAndOrganization, fetchPostgresPersons, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, PipelineEvent, PluginsServerConfig, ProjectId, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { UUIDT } from '~/utils/utils'
jest.mock('~/utils/token-bucket', () => {
const mockConsume = jest.fn().mockReturnValue(true)
@@ -32,7 +32,7 @@ jest.mock('~/utils/token-bucket', () => {
}
})
-jest.mock('../utils/logger')
+jest.mock('~/utils/logger')
const waitForKafkaMessages = async (kafkaProducer: KafkaProducerWrapper) => {
await kafkaProducer.flush()
@@ -184,6 +184,7 @@ const createTestWithTeamIngester = (baseConfig: Partial<PluginsServerConfig> = {
const outputs = createTestIngestionOutputs(kafkaProducer)
const ingester = new IngestionConsumer(hub, {
...hub,
+ aiSubpipelineFactory: createAiEventSubpipeline,
hogTransformer: createHogTransformerService(hub, {
...hub,
monitoringOutputs: createTestMonitoringOutputs(kafkaProducer),
diff --git a/nodejs/src/ingestion/person-updates-e2e.test.ts b/nodejs/tests/ingestion/person-updates-e2e.test.ts
similarity index 97%
rename from nodejs/src/ingestion/person-updates-e2e.test.ts
rename to nodejs/tests/ingestion/person-updates-e2e.test.ts
index 998fd9546d57..c434b4cf6443 100644
--- a/nodejs/src/ingestion/person-updates-e2e.test.ts
+++ b/nodejs/tests/ingestion/person-updates-e2e.test.ts
@@ -15,19 +15,19 @@ import { DateTime } from 'luxon'
import { Message } from 'node-rdkafka'
import { v4 } from 'uuid'
+import { createHogTransformerService } from '~/cdp/hog-transformations/hog-transformer.service'
+import { ClickhouseGroupRepository } from '~/common/groups/repositories/clickhouse-group-repository'
+import { IngestionConsumer } from '~/ingestion/ingestion-consumer'
+import { createAiEventSubpipeline } from '~/ingestion/pipelines/ai'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { Clickhouse } from '~/tests/helpers/clickhouse'
import { waitForExpect } from '~/tests/helpers/expectations'
+import { createTestIngestionOutputs, createTestMonitoringOutputs } from '~/tests/helpers/ingestion-outputs'
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
-
-import { Clickhouse } from '../../tests/helpers/clickhouse'
-import { createTestIngestionOutputs, createTestMonitoringOutputs } from '../../tests/helpers/ingestion-outputs'
-import { createUserTeamAndOrganization, resetTestDatabase } from '../../tests/helpers/sql'
-import { createHogTransformerService } from '../cdp/hog-transformations/hog-transformer.service'
-import { KafkaProducerWrapper } from '../kafka/producer'
-import { Hub, PersonBatchWritingDbWriteMode, PipelineEvent, ProjectId, Team } from '../types'
-import { closeHub, createHub } from '../utils/db/hub'
-import { UUIDT } from '../utils/utils'
-import { ClickhouseGroupRepository } from '../worker/ingestion/groups/repositories/clickhouse-group-repository'
-import { IngestionConsumer } from './ingestion-consumer'
+import { createUserTeamAndOrganization, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, PersonBatchWritingDbWriteMode, PipelineEvent, ProjectId, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { UUIDT } from '~/utils/utils'
jest.mock('~/utils/token-bucket', () => {
const mockConsume = jest.fn().mockReturnValue(true)
@@ -38,7 +38,7 @@ jest.mock('~/utils/token-bucket', () => {
}
})
-jest.mock('../utils/logger')
+jest.mock('~/utils/logger')
const DEFAULT_TEAM: Team = {
id: 1,
@@ -230,6 +230,7 @@ describe.each(FLAG_COMBINATIONS)('Person Updates E2E ($#)', (config) => {
const outputs = createTestIngestionOutputs(kafkaProducer)
ingester = new IngestionConsumer(hub, {
...hub,
+ aiSubpipelineFactory: createAiEventSubpipeline,
hogTransformer: createHogTransformerService(hub, {
...hub,
monitoringOutputs: createTestMonitoringOutputs(kafkaProducer),
diff --git a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts b/nodejs/tests/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.integration.test.ts
similarity index 87%
rename from nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts
rename to nodejs/tests/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.integration.test.ts
index 11ccb37435b0..93cfe5a18e2f 100644
--- a/nodejs/src/ingestion/ai/pipelines/ai-event-subpipeline.integration.test.ts
+++ b/nodejs/tests/ingestion/pipelines/ai/pipelines/ai-event-subpipeline.integration.test.ts
@@ -1,23 +1,26 @@
import { DateTime } from 'luxon'
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { AI_EVENTS_OUTPUT, EVENTS_OUTPUT, PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { GroupStoreForBatch } from '~/ingestion/common/groups/group-store-for-batch'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { newPipelineBuilder } from '~/ingestion/framework/builders'
+import { createOkContext } from '~/ingestion/framework/helpers'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import {
+ AiEventSubpipelineConfig,
+ AiEventSubpipelineInput,
+ createAiEventSubpipeline,
+} from '~/ingestion/pipelines/ai/pipelines/ai-event-subpipeline'
import { PluginEvent } from '~/plugin-scaffold'
-
-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 { createTestTeam } from '../../../../tests/helpers/team'
-import { InternalPerson, PropertyUpdateOperation } from '../../../types'
-import { parseJSON } from '../../../utils/json-parse'
-import { GroupStoreForBatch } from '../../../worker/ingestion/groups/group-store-for-batch'
-import { PersonsStoreForBatch } from '../../../worker/ingestion/persons/persons-store-for-batch'
-import { AI_EVENTS_OUTPUT, EVENTS_OUTPUT, PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../../analytics/outputs'
-import { INGESTION_WARNINGS_OUTPUT } from '../../common/outputs'
-import { IngestionOutputs } from '../../outputs/ingestion-outputs'
-import { newPipelineBuilder } from '../../pipelines/builders'
-import { createOkContext } from '../../pipelines/helpers'
-import { PipelineResultType } from '../../pipelines/results'
-import { AiEventSubpipelineConfig, AiEventSubpipelineInput, createAiEventSubpipeline } from './ai-event-subpipeline'
+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 { createTestTeam } from '~/tests/helpers/team'
+import { InternalPerson, PropertyUpdateOperation } from '~/types'
+import { parseJSON } from '~/utils/json-parse'
const team = createTestTeam()
const message = createTestMessage()
diff --git a/nodejs/src/ingestion/clientwarnings/consumer-e2e.test.ts b/nodejs/tests/ingestion/pipelines/clientwarnings/consumer-e2e.test.ts
similarity index 90%
rename from nodejs/src/ingestion/clientwarnings/consumer-e2e.test.ts
rename to nodejs/tests/ingestion/pipelines/clientwarnings/consumer-e2e.test.ts
index 123dcf717356..1d16e7f6b9ae 100644
--- a/nodejs/src/ingestion/clientwarnings/consumer-e2e.test.ts
+++ b/nodejs/tests/ingestion/pipelines/clientwarnings/consumer-e2e.test.ts
@@ -1,5 +1,17 @@
import { Message } from 'node-rdkafka'
+import { KafkaProducerRegistryComponent } from '~/common/outputs/registry'
+import {
+ getDefaultKafkaDownstreamProducerEnvConfig,
+ getDefaultKafkaUpstreamProducerEnvConfig,
+} from '~/ingestion/common/config'
+import { Component, newScope } from '~/ingestion/common/scopes'
+import { getDefaultIngestionOutputsConfig } from '~/ingestion/config'
+import {
+ ClientWarningsConsumerConfig,
+ ClientWarningsSharedScope,
+ createClientWarningsConsumer,
+} from '~/ingestion/pipelines/clientwarnings/consumer'
import { Clickhouse } from '~/tests/helpers/clickhouse'
import { waitForExpect } from '~/tests/helpers/expectations'
import {
@@ -13,12 +25,6 @@ import {
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
import { resetTestDatabase } from '~/tests/helpers/sql'
-import { getDefaultKafkaDownstreamProducerEnvConfig, getDefaultKafkaUpstreamProducerEnvConfig } from '../common/config'
-import { KafkaProducerRegistryComponent } from '../common/outputs/registry'
-import { Component, newScope } from '../common/scopes'
-import { getDefaultIngestionOutputsConfig } from '../config'
-import { ClientWarningsConsumerConfig, ClientWarningsSharedScope, createClientWarningsConsumer } from './consumer'
-
type CapturedBatchHandler = (messages: Message[]) => Promise<{ backgroundTask?: Promise<unknown> } | void>
// Captures the per-batch handler that `KafkaConsumerComponent` wires into the
@@ -44,7 +50,7 @@ jest.mock('~/kafka/consumer', () => {
}
})
-jest.mock('../../utils/logger')
+jest.mock('~/utils/logger')
function constComponent<T extends object>(value: T): Component<T> {
return { start: () => Promise.resolve({ value, stop: () => Promise.resolve() }) }
diff --git a/nodejs/src/ingestion/heatmaps/consumer-e2e.test.ts b/nodejs/tests/ingestion/pipelines/heatmaps/consumer-e2e.test.ts
similarity index 90%
rename from nodejs/src/ingestion/heatmaps/consumer-e2e.test.ts
rename to nodejs/tests/ingestion/pipelines/heatmaps/consumer-e2e.test.ts
index 0c95ffde4808..ac8c1657f394 100644
--- a/nodejs/src/ingestion/heatmaps/consumer-e2e.test.ts
+++ b/nodejs/tests/ingestion/pipelines/heatmaps/consumer-e2e.test.ts
@@ -1,5 +1,18 @@
import { Message } from 'node-rdkafka'
+import { KafkaProducerRegistryComponent } from '~/common/outputs/registry'
+import {
+ getDefaultKafkaDownstreamProducerEnvConfig,
+ getDefaultKafkaUpstreamProducerEnvConfig,
+} from '~/ingestion/common/config'
+import { CookielessManagerComponent } from '~/ingestion/common/cookieless/cookieless-manager'
+import { Component, newScope } from '~/ingestion/common/scopes'
+import { getDefaultIngestionOutputsConfig } from '~/ingestion/config'
+import {
+ HeatmapsConsumerConfig,
+ HeatmapsSharedScope,
+ createHeatmapsConsumer,
+} from '~/ingestion/pipelines/heatmaps/consumer'
import { Clickhouse } from '~/tests/helpers/clickhouse'
import { waitForExpect } from '~/tests/helpers/expectations'
import {
@@ -12,13 +25,6 @@ import {
import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
import { resetTestDatabase } from '~/tests/helpers/sql'
-import { getDefaultKafkaDownstreamProducerEnvConfig, getDefaultKafkaUpstreamProducerEnvConfig } from '../common/config'
-import { KafkaProducerRegistryComponent } from '../common/outputs/registry'
-import { Component, newScope } from '../common/scopes'
-import { getDefaultIngestionOutputsConfig } from '../config'
-import { CookielessManagerComponent } from '../cookieless/cookieless-manager'
-import { HeatmapsConsumerConfig, HeatmapsSharedScope, createHeatmapsConsumer } from './consumer'
-
type CapturedBatchHandler = (messages: Message[]) => Promise<{ backgroundTask?: Promise<unknown> } | void>
// Captures the per-batch handler that `KafkaConsumerComponent` wires into the
@@ -44,7 +50,7 @@ jest.mock('~/kafka/consumer', () => {
}
})
-jest.mock('../../utils/logger')
+jest.mock('~/utils/logger')
function constComponent<T extends object>(value: T): Component<T> {
return { start: () => Promise.resolve({ value, stop: () => Promise.resolve() }) }
diff --git a/nodejs/src/session-recording/__snapshots__/consumer.e2e.test.ts.snap b/nodejs/tests/ingestion/pipelines/sessionreplay/__snapshots__/consumer.e2e.test.ts.snap
similarity index 100%
rename from nodejs/src/session-recording/__snapshots__/consumer.e2e.test.ts.snap
rename to nodejs/tests/ingestion/pipelines/sessionreplay/__snapshots__/consumer.e2e.test.ts.snap
diff --git a/nodejs/src/session-recording/consumer.e2e.test.ts b/nodejs/tests/ingestion/pipelines/sessionreplay/consumer.e2e.test.ts
similarity index 97%
rename from nodejs/src/session-recording/consumer.e2e.test.ts
rename to nodejs/tests/ingestion/pipelines/sessionreplay/consumer.e2e.test.ts
index 6b47e312e432..f117f9e41dc1 100644
--- a/nodejs/src/session-recording/consumer.e2e.test.ts
+++ b/nodejs/tests/ingestion/pipelines/sessionreplay/consumer.e2e.test.ts
@@ -9,35 +9,35 @@ import { HighLevelProducer } from 'node-rdkafka'
import snappy from 'snappy'
import { v4 as uuidv4 } from 'uuid'
-import { Clickhouse } from '../../tests/helpers/clickhouse'
-import { waitForExpect } from '../../tests/helpers/expectations'
-import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '../../tests/helpers/kafka'
-import { forSnapshot } from '../../tests/helpers/snapshots'
-import { createOrganization, createTeam, getFirstTeam, resetTestDatabase } from '../../tests/helpers/sql'
-import { defaultConfig, overrideWithEnv } from '../config/config'
-import {
- KAFKA_CLICKHOUSE_SESSION_REPLAY_EVENTS,
- KAFKA_CLICKHOUSE_SESSION_REPLAY_FEATURES,
- KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS,
-} from '../config/kafka-topics'
import {
DLQ_OUTPUT,
INGESTION_WARNINGS_OUTPUT,
LOG_ENTRIES_OUTPUT,
OVERFLOW_OUTPUT,
TOPHOG_OUTPUT,
-} from '../ingestion/common/outputs'
-import { IngestionOutputs } from '../ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../ingestion/outputs/single-ingestion-output'
-import { KafkaProducerWrapper } from '../kafka/producer'
-import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '../session-replay/shared/outputs'
-import { Hub, Team } from '../types'
-import { closeHub, createHub } from '../utils/db/hub'
-import { PostgresRouter, PostgresUse } from '../utils/db/postgres'
-import { REDIS_KEY_PREFIX, RedisRestrictionType } from '../utils/event-ingestion-restrictions/redis-schema'
-import { parseJSON } from '../utils/json-parse'
-import { SessionRecordingIngester } from './consumer'
-import { MouseInteractions, RRWebEventSource, RRWebEventType } from './rrweb-types'
+} from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { defaultConfig, overrideWithEnv } from '~/config/config'
+import {
+ KAFKA_CLICKHOUSE_SESSION_REPLAY_EVENTS,
+ KAFKA_CLICKHOUSE_SESSION_REPLAY_FEATURES,
+ KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS,
+} from '~/config/kafka-topics'
+import { SessionRecordingIngester } from '~/ingestion/pipelines/sessionreplay/consumer'
+import { MouseInteractions, RRWebEventSource, RRWebEventType } from '~/ingestion/pipelines/sessionreplay/rrweb-types'
+import { REPLAY_EVENTS_OUTPUT, SESSION_FEATURES_OUTPUT } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { KafkaProducerWrapper } from '~/kafka/producer'
+import { Clickhouse } from '~/tests/helpers/clickhouse'
+import { waitForExpect } from '~/tests/helpers/expectations'
+import { TEST_KAFKA_TOPICS, ensureKafkaTopics } from '~/tests/helpers/kafka'
+import { forSnapshot } from '~/tests/helpers/snapshots'
+import { createOrganization, createTeam, getFirstTeam, resetTestDatabase } from '~/tests/helpers/sql'
+import { Hub, Team } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
+import { PostgresRouter, PostgresUse } from '~/utils/db/postgres'
+import { REDIS_KEY_PREFIX, RedisRestrictionType } from '~/utils/event-ingestion-restrictions/redis-schema'
+import { parseJSON } from '~/utils/json-parse'
// Test configuration - matches local dev environment (MinIO API on port 19000)
const TEST_CONFIG = {
diff --git a/nodejs/src/session-recording/sessions/session-batch-file-format.integration.test.ts b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-batch-file-format.integration.test.ts
similarity index 87%
rename from nodejs/src/session-recording/sessions/session-batch-file-format.integration.test.ts
rename to nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-batch-file-format.integration.test.ts
index 3ad5be215590..e1d0c03d7a52 100644
--- a/nodejs/src/session-recording/sessions/session-batch-file-format.integration.test.ts
+++ b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-batch-file-format.integration.test.ts
@@ -26,21 +26,25 @@
import { DateTime } from 'luxon'
import snappy from 'snappy'
-import { SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { SessionBlockMetadata } from '../../session-replay/shared/metadata/session-block-metadata'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { createMockEncryptor, createMockKeyStore } from '../../session-replay/shared/test-helpers'
-import { KeyStore, RecordingEncryptor } from '../../session-replay/shared/types'
-import { parseJSON } from '../../utils/json-parse'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
-import { MessageWithTeam } from '../teams/types'
-import { SessionBatchFileStorage, SessionBatchFileWriter, WriteSessionData } from './session-batch-file-storage'
-import { SessionBatchRecorder } from './session-batch-recorder'
-import { SessionConsoleLogStore } from './session-console-log-store'
-import { SessionFilter } from './session-filter'
-import { SessionTracker } from './session-tracker'
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import {
+ SessionBatchFileStorage,
+ SessionBatchFileWriter,
+ WriteSessionData,
+} from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-file-storage'
+import { SessionBatchRecorder } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder'
+import { SessionConsoleLogStore } from '~/ingestion/pipelines/sessionreplay/sessions/session-console-log-store'
+import { SessionFilter } from '~/ingestion/pipelines/sessionreplay/sessions/session-filter'
+import { SessionTracker } from '~/ingestion/pipelines/sessionreplay/sessions/session-tracker'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { SessionBlockMetadata } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { createMockEncryptor, createMockKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/test-helpers'
+import { KeyStore, RecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { parseJSON } from '~/utils/json-parse'
-jest.mock('./session-feature-recorder', () => ({
+jest.mock('~/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder', () => ({
SessionFeatureRecorder: jest.fn().mockImplementation(() => ({
recordMessage: jest.fn().mockReturnValue(undefined),
end: jest.fn().mockReturnValue({
diff --git a/nodejs/src/session-recording/sessions/session-encryption.integration.test.ts b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-encryption.integration.test.ts
similarity index 90%
rename from nodejs/src/session-recording/sessions/session-encryption.integration.test.ts
rename to nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-encryption.integration.test.ts
index 78f14913d907..d961ff0aa9b2 100644
--- a/nodejs/src/session-recording/sessions/session-encryption.integration.test.ts
+++ b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-encryption.integration.test.ts
@@ -2,22 +2,26 @@ import sodium from 'libsodium-wrappers'
import { DateTime } from 'luxon'
import snappy from 'snappy'
-import { SodiumRecordingDecryptor, SodiumRecordingEncryptor } from '../../session-replay/shared/crypto'
-import { SessionFeatureStore } from '../../session-replay/shared/features/session-feature-store'
-import { MemoryKeyStore } from '../../session-replay/shared/keystore'
-import { SessionBlockMetadata } from '../../session-replay/shared/metadata/session-block-metadata'
-import { SessionMetadataStore } from '../../session-replay/shared/metadata/session-metadata-store'
-import { SessionKeyDeletedError } from '../../session-replay/shared/types'
-import { parseJSON } from '../../utils/json-parse'
-import { KafkaOffsetManager } from '../kafka/offset-manager'
-import { MessageWithTeam } from '../teams/types'
-import { SessionBatchFileStorage, SessionBatchFileWriter, WriteSessionData } from './session-batch-file-storage'
-import { SessionBatchRecorder } from './session-batch-recorder'
-import { SessionConsoleLogStore } from './session-console-log-store'
-import { SessionFilter } from './session-filter'
-import { SessionTracker } from './session-tracker'
-
-jest.mock('./session-feature-recorder', () => ({
+import { KafkaOffsetManager } from '~/ingestion/pipelines/sessionreplay/kafka/offset-manager'
+import {
+ SessionBatchFileStorage,
+ SessionBatchFileWriter,
+ WriteSessionData,
+} from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-file-storage'
+import { SessionBatchRecorder } from '~/ingestion/pipelines/sessionreplay/sessions/session-batch-recorder'
+import { SessionConsoleLogStore } from '~/ingestion/pipelines/sessionreplay/sessions/session-console-log-store'
+import { SessionFilter } from '~/ingestion/pipelines/sessionreplay/sessions/session-filter'
+import { SessionTracker } from '~/ingestion/pipelines/sessionreplay/sessions/session-tracker'
+import { SodiumRecordingDecryptor, SodiumRecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/crypto'
+import { SessionFeatureStore } from '~/ingestion/pipelines/sessionreplay/shared/features/session-feature-store'
+import { MemoryKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore'
+import { SessionBlockMetadata } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-block-metadata'
+import { SessionMetadataStore } from '~/ingestion/pipelines/sessionreplay/shared/metadata/session-metadata-store'
+import { SessionKeyDeletedError } from '~/ingestion/pipelines/sessionreplay/shared/types'
+import { MessageWithTeam } from '~/ingestion/pipelines/sessionreplay/teams/types'
+import { parseJSON } from '~/utils/json-parse'
+
+jest.mock('~/ingestion/pipelines/sessionreplay/sessions/session-feature-recorder', () => ({
SessionFeatureRecorder: jest.fn().mockImplementation(() => ({
recordMessage: jest.fn().mockReturnValue(undefined),
end: jest.fn().mockReturnValue({
diff --git a/nodejs/src/session-recording/sessions/session-filter.integration.test.ts b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-filter.integration.test.ts
similarity index 96%
rename from nodejs/src/session-recording/sessions/session-filter.integration.test.ts
rename to nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-filter.integration.test.ts
index e280b6c840c5..54366886bd20 100644
--- a/nodejs/src/session-recording/sessions/session-filter.integration.test.ts
+++ b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-filter.integration.test.ts
@@ -1,7 +1,7 @@
import { v4 as uuidv4 } from 'uuid'
-import { createRedisPoolFromConfig } from '../../utils/db/redis'
-import { SessionFilter, SessionFilterConfig } from './session-filter'
+import { SessionFilter, SessionFilterConfig } from '~/ingestion/pipelines/sessionreplay/sessions/session-filter'
+import { createRedisPoolFromConfig } from '~/utils/db/redis'
// nosemgrep: redis-unencrypted-transport (local testing only)
const REDIS_URL = process.env.REDIS_URL || 'redis://127.0.0.1'
diff --git a/nodejs/src/session-recording/sessions/session-tracker.integration.test.ts b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-tracker.integration.test.ts
similarity index 93%
rename from nodejs/src/session-recording/sessions/session-tracker.integration.test.ts
rename to nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-tracker.integration.test.ts
index b9a9ddc1200b..6cde251c2520 100644
--- a/nodejs/src/session-recording/sessions/session-tracker.integration.test.ts
+++ b/nodejs/tests/ingestion/pipelines/sessionreplay/sessions/session-tracker.integration.test.ts
@@ -1,8 +1,8 @@
import { v4 as uuidv4 } from 'uuid'
-import { RedisPool } from '../../types'
-import { createRedisPoolFromConfig } from '../../utils/db/redis'
-import { SessionTracker } from './session-tracker'
+import { SessionTracker } from '~/ingestion/pipelines/sessionreplay/sessions/session-tracker'
+import { RedisPool } from '~/types'
+import { createRedisPoolFromConfig } from '~/utils/db/redis'
// nosemgrep: redis-unencrypted-transport (local testing only)
const REDIS_URL = process.env.REDIS_URL || 'redis://127.0.0.1'
diff --git a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts b/nodejs/tests/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts
similarity index 97%
rename from nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts
rename to nodejs/tests/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts
index 1a10256d53bf..43d50d2ec34a 100644
--- a/nodejs/src/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts
+++ b/nodejs/tests/ingestion/utils/overflow-redirect/overflow-redis-repository.integration.test.ts
@@ -1,6 +1,6 @@
-import { Hub } from '../../../types'
-import { closeHub, createHub } from '../../../utils/db/hub'
-import { RedisOverflowRepository, redisKey } from './overflow-redis-repository'
+import { RedisOverflowRepository, redisKey } from '~/ingestion/utils/overflow-redirect/overflow-redis-repository'
+import { Hub } from '~/types'
+import { closeHub, createHub } from '~/utils/db/hub'
describe('RedisOverflowRepository (integration)', () => {
let hub: Hub
diff --git a/nodejs/src/logs-ingestion/sampling/logs-sampling.rate-limit-impact.integration.test.ts b/nodejs/tests/logs/sampling/logs-sampling.rate-limit-impact.integration.test.ts
similarity index 97%
rename from nodejs/src/logs-ingestion/sampling/logs-sampling.rate-limit-impact.integration.test.ts
rename to nodejs/tests/logs/sampling/logs-sampling.rate-limit-impact.integration.test.ts
index 0848fbb2f09e..6adf68828d6a 100644
--- a/nodejs/src/logs-ingestion/sampling/logs-sampling.rate-limit-impact.integration.test.ts
+++ b/nodejs/tests/logs/sampling/logs-sampling.rate-limit-impact.integration.test.ts
@@ -1,14 +1,13 @@
import avro from 'avsc'
-import { deleteKeysWithPrefix } from '~/cdp/_tests/redis'
+import { deleteKeysWithPrefix } from '~/common/redis/_tests/redis'
import { RedisV2, createRedisV2PoolFromConfig } from '~/common/redis/redis-v2'
+import { type LogRecord, decodeLogRecords, encodeLogRecords } from '~/logs/log-record-avro'
+import { compileRuleSet } from '~/logs/sampling/compile-rules'
+import { LogsSamplingService } from '~/logs/sampling/logs-sampling.service'
import { Hub } from '~/types'
import { closeHub, createHub } from '~/utils/db/hub'
-import { type LogRecord, decodeLogRecords, encodeLogRecords } from '../log-record-avro'
-import { compileRuleSet } from './compile-rules'
-import { LogsSamplingService } from './logs-sampling.service'
-
// Real-Redis integration test: drives the genuine token-bucket Lua with a mocked clock so we can
// simulate a sustained log stream at different volumes deterministically (no sleeps). This is the
// "save → impact" half of the rate-limit contract: it feeds the limiter the EXACT config shape the
diff --git a/nodejs/src/session-replay/recording-api/recording-api.integration.test.ts b/nodejs/tests/recording-api/recording-api.integration.test.ts
similarity index 98%
rename from nodejs/src/session-replay/recording-api/recording-api.integration.test.ts
rename to nodejs/tests/recording-api/recording-api.integration.test.ts
index c872ca9385f4..737c10b46ab1 100644
--- a/nodejs/src/session-replay/recording-api/recording-api.integration.test.ts
+++ b/nodejs/tests/recording-api/recording-api.integration.test.ts
@@ -44,16 +44,16 @@ import snappy from 'snappy'
import supertest from 'supertest'
import express from 'ultimate-express'
-import { IngestionOutputs } from '../../ingestion/outputs/ingestion-outputs'
-import { PostgresRouter } from '../../utils/db/postgres'
-import { parseJSON } from '../../utils/json-parse'
-import { SodiumRecordingDecryptor, SodiumRecordingEncryptor } from '../shared/crypto'
-import { DynamoDBKeyStore, MemoryKeyStore } from '../shared/keystore'
-import { MemoryCachedKeyStore } from '../shared/keystore/cache'
-import { ReplayEventsOutput, SessionFeaturesOutput } from '../shared/outputs'
-import { RecordingApi } from './recording-api'
-import { RecordingService } from './recording-service'
-import { KeyStore, RecordingApiConfig, SessionKey, SessionKeyDeletedError } from './types'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SodiumRecordingDecryptor, SodiumRecordingEncryptor } from '~/ingestion/pipelines/sessionreplay/shared/crypto'
+import { DynamoDBKeyStore, MemoryKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore'
+import { MemoryCachedKeyStore } from '~/ingestion/pipelines/sessionreplay/shared/keystore/cache'
+import { ReplayEventsOutput, SessionFeaturesOutput } from '~/ingestion/pipelines/sessionreplay/shared/outputs'
+import { RecordingApi } from '~/recording-api/recording-api'
+import { RecordingService } from '~/recording-api/recording-service'
+import { KeyStore, RecordingApiConfig, SessionKey, SessionKeyDeletedError } from '~/recording-api/types'
+import { PostgresRouter } from '~/utils/db/postgres'
+import { parseJSON } from '~/utils/json-parse'
const mockOutputs = {
queueMessages: jest.fn().mockResolvedValue(undefined),
diff --git a/nodejs/tests/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts b/nodejs/tests/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts
index 83c1f279cba8..8c0b673b47be 100644
--- a/nodejs/tests/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts
+++ b/nodejs/tests/worker/ingestion/event-pipeline/prefetchPersonsStep.test.ts
@@ -1,8 +1,8 @@
-import { PipelineResultType } from '~/ingestion/pipelines/results'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResultType } from '~/ingestion/framework/results'
+import { prefetchPersonsStep } from '~/ingestion/pipelines/analytics/steps/prefetchPersonsStep'
import { Team } from '~/types'
-import { prefetchPersonsStep } from '../../../../src/worker/ingestion/event-pipeline/prefetchPersonsStep'
-import { PersonsStoreForBatch } from '../../../../src/worker/ingestion/persons/persons-store-for-batch'
import { createTestPluginEvent } from '../../../helpers/plugin-event'
import { createTestTeam } from '../../../helpers/team'
diff --git a/nodejs/tests/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.test.ts b/nodejs/tests/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.test.ts
index 685f9e782cdb..e8b5ee764a21 100644
--- a/nodejs/tests/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.test.ts
+++ b/nodejs/tests/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.test.ts
@@ -1,22 +1,20 @@
-import { PipelineResultType } from '~/ingestion/pipelines/results'
+import { PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResultType } from '~/ingestion/framework/results'
import { PluginEvent } from '~/plugin-scaffold'
import { Team } from '~/types'
-import { PersonsStoreForBatch } from '../../../../src/worker/ingestion/persons/persons-store-for-batch'
import { createTestPluginEvent } from '../../../helpers/plugin-event'
import { createTestTeam } from '../../../helpers/team'
describe('processPersonlessDistinctIdsBatchStep', () => {
let mockPersonsStore: jest.Mocked<PersonsStoreForBatch>
let team: Team
- let processPersonlessDistinctIdsBatchStep: typeof import('../../../../src/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep').processPersonlessDistinctIdsBatchStep
+ let processPersonlessDistinctIdsBatchStep: typeof import('~/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep').processPersonlessDistinctIdsBatchStep
beforeEach(async () => {
// Reset modules to get a fresh LRU cache for each test
jest.resetModules()
- const module = await import(
- '../../../../src/worker/ingestion/event-pipeline/processPersonlessDistinctIdsBatchStep.js'
- )
+ const module = await import('~/ingestion/pipelines/analytics/steps/processPersonlessDistinctIdsBatchStep.js')
processPersonlessDistinctIdsBatchStep = module.processPersonlessDistinctIdsBatchStep
team = createTestTeam()
diff --git a/nodejs/tests/worker/ingestion/person-state-batch.test.ts b/nodejs/tests/worker/ingestion/person-state-batch.test.ts
index bb26c3131c8f..d6601de8d8e8 100644
--- a/nodejs/tests/worker/ingestion/person-state-batch.test.ts
+++ b/nodejs/tests/worker/ingestion/person-state-batch.test.ts
@@ -2,18 +2,33 @@ import { KafkaProducerObserver } from '~/tests/helpers/mocks/producer.spy'
import { DateTime } from 'luxon'
+import { INGESTION_WARNINGS_OUTPUT } from '~/common/outputs'
+import { ASYNC_OUTPUT, PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PersonMessage } from '~/common/persons/person-message'
+import { fromInternalPerson } from '~/common/persons/person-update-batch'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import { fetchDistinctIdValues } from '~/common/persons/repositories/test-helpers'
import { KAFKA_INGESTION_WARNINGS, KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '~/config/kafka-topics'
-import { ASYNC_OUTPUT, PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/ingestion/analytics/outputs'
-import { INGESTION_WARNINGS_OUTPUT } from '~/ingestion/common/outputs'
-import { IngestionOutputs } from '~/ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '~/ingestion/outputs/single-ingestion-output'
-import { PipelineResultType, isDlqResult, isOkResult, isRedirectResult } from '~/ingestion/pipelines/results'
+import { uuidFromDistinctId } from '~/ingestion/common/person-uuid'
+import { BatchWritingPersonsStore } from '~/ingestion/common/persons/batch-writing-person-store'
+import { PersonOutputs } from '~/ingestion/common/persons/person-context'
+import { PersonContext } from '~/ingestion/common/persons/person-context'
+import { PersonEventProcessor } from '~/ingestion/common/persons/person-event-processor'
+import { PersonMergeService } from '~/ingestion/common/persons/person-merge-service'
+import {
+ SourcePersonNotFoundError,
+ TargetPersonNotFoundError,
+ createDefaultSyncMergeMode,
+} from '~/ingestion/common/persons/person-merge-types'
+import { PersonPropertyService } from '~/ingestion/common/persons/person-property-service'
+import { BatchBoundPersonsStore, PersonsStoreForBatch } from '~/ingestion/common/persons/persons-store-for-batch'
+import { PipelineResultType, isDlqResult, isOkResult, isRedirectResult } from '~/ingestion/framework/results'
import { KafkaProducerWrapper } from '~/kafka/producer'
import { PluginEvent, Properties } from '~/plugin-scaffold'
import { Clickhouse } from '~/tests/helpers/clickhouse'
import { ensureKafkaTopics } from '~/tests/helpers/kafka'
-import { fromInternalPerson } from '~/worker/ingestion/persons/person-update-batch'
-import { BatchBoundPersonsStore, PersonsStoreForBatch } from '~/worker/ingestion/persons/persons-store-for-batch'
import {
ClickHousePerson,
@@ -29,21 +44,6 @@ import { closeHub, createHub } from '../../../src/utils/db/hub'
import { PostgresUse } from '../../../src/utils/db/postgres'
import { defaultRetryConfig } from '../../../src/utils/retries'
import { UUIDT } from '../../../src/utils/utils'
-import { uuidFromDistinctId } from '../../../src/worker/ingestion/person-uuid'
-import { BatchWritingPersonsStore } from '../../../src/worker/ingestion/persons/batch-writing-person-store'
-import { PersonOutputs } from '../../../src/worker/ingestion/persons/person-context'
-import { PersonContext } from '../../../src/worker/ingestion/persons/person-context'
-import { PersonEventProcessor } from '../../../src/worker/ingestion/persons/person-event-processor'
-import { PersonMergeService } from '../../../src/worker/ingestion/persons/person-merge-service'
-import {
- SourcePersonNotFoundError,
- TargetPersonNotFoundError,
- createDefaultSyncMergeMode,
-} from '../../../src/worker/ingestion/persons/person-merge-types'
-import { PersonMessage } from '../../../src/worker/ingestion/persons/person-message'
-import { PersonPropertyService } from '../../../src/worker/ingestion/persons/person-property-service'
-import { PostgresPersonRepository } from '../../../src/worker/ingestion/persons/repositories/postgres-person-repository'
-import { fetchDistinctIdValues } from '../../../src/worker/ingestion/persons/repositories/test-helpers'
import {
createOrganization,
createTeam,
@@ -4351,7 +4351,7 @@ describe('PersonState.processEvent()', () => {
// Mock the merge service to return a limit exceeded error
const mergeService = (processor as any).mergeService as PersonMergeService
const { PersonMergeLimitExceededError } = await import(
- '../../../src/worker/ingestion/persons/person-merge-types.js'
+ '~/ingestion/common/persons/person-merge-types.js'
)
jest.spyOn(mergeService, 'handleIdentifyOrAlias').mockResolvedValue({
success: false,
@@ -4375,7 +4375,7 @@ describe('PersonState.processEvent()', () => {
// Mock the merge service to return a limit exceeded error
const mergeService = (processor as any).mergeService as PersonMergeService
const { PersonMergeLimitExceededError } = await import(
- '../../../src/worker/ingestion/persons/person-merge-types.js'
+ '~/ingestion/common/persons/person-merge-types.js'
)
jest.spyOn(mergeService, 'handleIdentifyOrAlias').mockResolvedValue({
success: false,
@@ -4404,7 +4404,7 @@ describe('PersonState.processEvent()', () => {
// Mock the merge service to return a limit exceeded error
const mergeService = (processor as any).mergeService as PersonMergeService
const { PersonMergeLimitExceededError } = await import(
- '../../../src/worker/ingestion/persons/person-merge-types.js'
+ '~/ingestion/common/persons/person-merge-types.js'
)
jest.spyOn(mergeService, 'handleIdentifyOrAlias').mockResolvedValue({
success: false,
diff --git a/nodejs/tests/worker/ingestion/person-uuid.test.ts b/nodejs/tests/worker/ingestion/person-uuid.test.ts
index c27106dc4e1f..22ac04f4a07f 100644
--- a/nodejs/tests/worker/ingestion/person-uuid.test.ts
+++ b/nodejs/tests/worker/ingestion/person-uuid.test.ts
@@ -1,4 +1,4 @@
-import { uuidFromDistinctId } from '../../../src/worker/ingestion/person-uuid'
+import { uuidFromDistinctId } from '~/ingestion/common/person-uuid'
jest.setTimeout(5000) // 5 sec timeout
diff --git a/nodejs/tests/worker/ingestion/postgres-parity.test.ts b/nodejs/tests/worker/ingestion/postgres-parity.test.ts
index d372232c968d..eb050df4abff 100644
--- a/nodejs/tests/worker/ingestion/postgres-parity.test.ts
+++ b/nodejs/tests/worker/ingestion/postgres-parity.test.ts
@@ -1,22 +1,23 @@
import { DateTime } from 'luxon'
+import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '~/common/outputs'
+import { IngestionOutputs } from '~/common/outputs/ingestion-outputs'
+import { SingleIngestionOutput } from '~/common/outputs/single-ingestion-output'
+import { PostgresPersonRepository } from '~/common/persons/repositories/postgres-person-repository'
+import {
+ createPersonUpdateFields,
+ fetchDistinctIdValues,
+ fetchDistinctIds,
+ fetchPersons,
+} from '~/common/persons/repositories/test-helpers'
+
import { KAFKA_PERSON, KAFKA_PERSON_DISTINCT_ID } from '../../../src/config/kafka-topics'
-import { PERSONS_OUTPUT, PERSON_DISTINCT_IDS_OUTPUT } from '../../../src/ingestion/analytics/outputs'
-import { IngestionOutputs } from '../../../src/ingestion/outputs/ingestion-outputs'
-import { SingleIngestionOutput } from '../../../src/ingestion/outputs/single-ingestion-output'
import { KafkaProducerWrapper } from '../../../src/kafka/producer'
import { IngestionGeneralServer } from '../../../src/servers/ingestion-general-server'
import { PluginServerMode, PluginsServerConfig, PropertyUpdateOperation, TimestampFormat } from '../../../src/types'
import { PostgresRouter, PostgresUse } from '../../../src/utils/db/postgres'
import { parseJSON } from '../../../src/utils/json-parse'
import { UUIDT, castTimestampOrNow } from '../../../src/utils/utils'
-import { PostgresPersonRepository } from '../../../src/worker/ingestion/persons/repositories/postgres-person-repository'
-import {
- createPersonUpdateFields,
- fetchDistinctIdValues,
- fetchDistinctIds,
- fetchPersons,
-} from '../../../src/worker/ingestion/persons/repositories/test-helpers'
import { Clickhouse } from '../../helpers/clickhouse'
import { waitForExpect } from '../../helpers/expectations'
import { ensureKafkaTopics } from '../../helpers/kafka'
diff --git a/nodejs/tests/worker/ingestion/timestamps.test.ts b/nodejs/tests/worker/ingestion/timestamps.test.ts
index 5e13f62b18cd..bc583b1f36cd 100644
--- a/nodejs/tests/worker/ingestion/timestamps.test.ts
+++ b/nodejs/tests/worker/ingestion/timestamps.test.ts
@@ -1,12 +1,12 @@
-import { PluginEvent } from '~/plugin-scaffold'
-
-import { UUIDT } from '../../../src/utils/utils'
import {
parseDate,
parseEventTimestamp,
toStartOfDayInTimezone,
toYearMonthDayInTimezone,
-} from '../../../src/worker/ingestion/timestamps'
+} from '~/ingestion/common/timestamps'
+import { PluginEvent } from '~/plugin-scaffold'
+
+import { UUIDT } from '../../../src/utils/utils'
describe('parseDate()', () => {
// Get local timezone offset for Oct 29, 2021 at midnight
diff --git a/nodejs/tests/worker/ingestion/utils.test.ts b/nodejs/tests/worker/ingestion/utils.test.ts
index 255778181d64..ddd0282647cc 100644
--- a/nodejs/tests/worker/ingestion/utils.test.ts
+++ b/nodejs/tests/worker/ingestion/utils.test.ts
@@ -1,7 +1,8 @@
+import { captureIngestionWarning } from '~/ingestion/common/utils'
+
import { KafkaProducerWrapper } from '../../../src/kafka/producer'
import { Hub } from '../../../src/types'
import { closeHub, createHub } from '../../../src/utils/db/hub'
-import { captureIngestionWarning } from '../../../src/worker/ingestion/utils'
import { Clickhouse } from '../../helpers/clickhouse'
jest.setTimeout(60000) // 60 sec timeout