:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cdp): label poll-only advance counter with team and flow (#74022)
Daniel Marchukd8f9e5e1f133
diff --git a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.tsindex 7df7d65b49e6..dd9522de3587 100644--- a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts+++ b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts@@ -18,6 +18,9 @@ import {const pollOnlyAdvanceCount = async (): Promise<number> =>(await counterHogflowWaitPollOnlyAdvance.get()).values[0]?.value ?? 0+const pollOnlyAdvanceLabels = async (): Promise<Record<string, string | number> | undefined> =>+ (await counterHogflowWaitPollOnlyAdvance.get()).values[0]?.labels+const rekeyWakeCount = async (outcome: 'advanced' | 'reparked'): Promise<number> =>(await counterHogflowRekeyWake.get()).values.find((v) => v.labels.outcome === outcome)?.value ?? 0@@ -311,6 +314,11 @@ describe('action.conditional_branch', () => {expect(result.nextAction).toEqual(findActionById(waitInvocation.hogFlow, 'matched_target'))expect(await pollOnlyAdvanceCount()).toBe(1)+ // Must name the flow, not the run: attributing the residual is the counter's whole job.+ expect(await pollOnlyAdvanceLabels()).toEqual({+ team_id: waitInvocation.hogFlow.team_id,+ hog_flow_id: waitInvocation.hogFlow.id,+ })})it('does not count an evaluate-on-entry match (the wait never re-parked)', async () => {diff --git a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.tsindex 1016a2e89a66..3b5cb9f9b005 100644--- a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts+++ b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts@@ -15,9 +15,12 @@ const DEFAULT_WAIT_DURATION_SECONDS = 10 * 60// subscription matcher did NOT wake (and not an evaluate-on-entry match). This is the decisive// signal for removing the poll: while it sits at ~0 across teams for a sustained window, the// person/event/internal streams cover every wake and polling is provably redundant.+// Labelled by team and flow so a non-zero reading names the workflow still leaning on the poll; a+// series only exists for flows that actually poll-advance, so cardinality tracks incidence.export const counterHogflowWaitPollOnlyAdvance = new Counter({name: 'cdp_hogflow_wait_poll_only_advance',help: 'wait_until_condition advanced via the polling re-check, not the subscription matcher — a wake the streams missed.',+ labelNames: ['team_id', 'hog_flow_id'],})// Outcome of a wait_until_condition re-check that ran because a person merge re-keyed the parked job@@ -91,7 +94,9 @@ export class ConditionalBranchHandler implements ActionHandler {// Poll-only advance: a wait whose condition matched on a re-check (not via the matcher's// eventMatched short-circuit above, and not on entry). This is the wake the streams missed.if (isWait && invocation.state.currentAction?.pollReparked === true) {- counterHogflowWaitPollOnlyAdvance.inc()+ counterHogflowWaitPollOnlyAdvance+ .labels({ team_id: invocation.hogFlow.team_id, hog_flow_id: invocation.hogFlow.id })+ .inc()}if (rekeyWoken) {counterHogflowRekeyWake.labels('advanced').inc()