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.

feat(cdp): add cdp-cyclotron-worker-email-legacy-pg server mode (#65806)

Harley Alexander887c31e85b8e
diff --git a/nodejs/src/capabilities.ts b/nodejs/src/capabilities.ts
index 03300490b4c2..f80e63133970 100644
--- a/nodejs/src/capabilities.ts
+++ b/nodejs/src/capabilities.ts
@@ -136,6 +136,10 @@ export function getPluginServerCapabilities(
return {
cdpCyclotronWorkerEmail: true,
}
+ case PluginServerMode.cdp_cyclotron_worker_email_legacy_pg:
+ return {
+ cdpCyclotronWorkerEmailLegacyPg: true,
+ }
case PluginServerMode.cdp_precalculated_filters:
return {
cdpPrecalculatedFilters: true,
diff --git a/nodejs/src/common/config.ts b/nodejs/src/common/config.ts
index 4017805f23dc..c5e4f1b9cd3c 100644
--- a/nodejs/src/common/config.ts
+++ b/nodejs/src/common/config.ts
@@ -33,6 +33,7 @@ export enum PluginServerMode {
cdp_cyclotron_worker_hogflow = 'cdp-cyclotron-worker-hogflow',
cdp_cyclotron_worker_hogflow_legacy_pg = 'cdp-cyclotron-worker-hogflow-legacy-pg',
cdp_cyclotron_worker_email = 'cdp-cyclotron-worker-email',
+ cdp_cyclotron_worker_email_legacy_pg = 'cdp-cyclotron-worker-email-legacy-pg',
cdp_api = 'cdp-api',
cdp_legacy_on_event = 'cdp-legacy-on-event',
evaluation_scheduler = 'evaluation-scheduler',
diff --git a/nodejs/src/server.ts b/nodejs/src/server.ts
index d552ede26714..2c027ca151a8 100644
--- a/nodejs/src/server.ts
+++ b/nodejs/src/server.ts
@@ -96,6 +96,7 @@ export class PluginServer implements NodeServer {
capabilities.cdpCyclotronWorkerHogFlow ||
capabilities.cdpCyclotronWorkerHogFlowLegacyPg ||
capabilities.cdpCyclotronWorkerEmail ||
+ capabilities.cdpCyclotronWorkerEmailLegacyPg ||
capabilities.cdpPrecalculatedFilters ||
capabilities.cdpCohortMembership ||
capabilities.cdpBatchHogFlow ||
@@ -278,6 +279,17 @@ export class PluginServer implements NodeServer {
})
}
+ // Transitional drain for email jobs stranded on the legacy V1 queue — the email worker
+ // run against V1, sending inline. Delete once V1 'email' throughput is ~0.
+ if (capabilities.cdpCyclotronWorkerEmailLegacyPg) {
+ serviceLoaders.push(async () => {
+ const legacyQueue = new CyclotronJobQueuePostgres(this.config.CONSUMER_BATCH_SIZE, this.config)
+ const worker = new CdpCyclotronWorkerEmail(this.config, cdpDeps!, legacyQueue)
+ await worker.start()
+ return worker.service
+ })
+ }
+
if (capabilities.cdpCyclotronWorkerEmail) {
serviceLoaders.push(async () => {
// Dedicated queue instance — see note on cdpCyclotronWorkerHogFlow above.
diff --git a/nodejs/src/types.ts b/nodejs/src/types.ts
index 04df0024a5b3..0fbb0171fe02 100644
--- a/nodejs/src/types.ts
+++ b/nodejs/src/types.ts
@@ -147,6 +147,7 @@ export interface PluginServerCapabilities {
cdpCyclotronWorkerHogFlow?: boolean
cdpCyclotronWorkerHogFlowLegacyPg?: boolean
cdpCyclotronWorkerEmail?: boolean
+ cdpCyclotronWorkerEmailLegacyPg?: boolean
cdpPrecalculatedFilters?: boolean
cdpCohortMembership?: boolean
cdpApi?: boolean