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(flags): fork flag calls up to 91 days old into flag_evaluations (#124561)

Phil Haack853d93e77ca4
diff --git a/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.test.ts
index 2e5e4341762f..5c62b315a4c6 100644
--- a/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.test.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.test.ts
@@ -186,9 +186,9 @@ describe('createForkFlagEvaluationsStep', () => {
})
it.each([
- // 2026-07-05 is the oldest UTC day a 90-day TTL keeps on 2026-10-02.
- { timestamp: '2026-07-04T23:59:59.999Z', forked: false, outcome: 'continued_past_retention' },
- { timestamp: '2026-07-05T00:00:00.000Z', forked: true, outcome: 'dual_written' },
+ // 2026-07-03 is the oldest UTC day a 92-day TTL keeps on 2026-10-02.
+ { timestamp: '2026-07-02T23:59:59.999Z', forked: false, outcome: 'continued_past_retention' },
+ { timestamp: '2026-07-03T00:00:00.000Z', forked: true, outcome: 'dual_written' },
])('forks a call dated $timestamp -> $forked', async ({ timestamp, forked, outcome }) => {
jest.useFakeTimers({ now: new Date('2026-10-02T15:00:00.000Z') })
const { step, outputs } = createStep(enabledService())
@@ -415,7 +415,7 @@ describe('createForkFlagEvaluationsStep', () => {
name: 'the call is past the flag_evaluations retention',
mode: FlagEvaluationsMode.FlagEvaluationsOnly,
buildService: () => enabledService(),
- flagCalledOverrides: { timestamp: DateTime.utc().minus({ days: 91 }).toISO() as ISOTimestamp },
+ flagCalledOverrides: { timestamp: DateTime.utc().minus({ days: 93 }).toISO() as ISOTimestamp },
},
{
name: 'queueing the row throws',
diff --git a/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.ts b/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.ts
index 2c2590241cf0..d1fa0316b1bc 100644
--- a/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.ts
+++ b/nodejs/src/ingestion/common/steps/event-processing/fork-flag-evaluations-step.ts
@@ -58,7 +58,7 @@ const hasFlagKey = ({ event }: EventToEmit<string>): boolean => {
}
// Mirrors FLAG_EVALUATIONS_TTL_DAYS in posthog/models/flag_evaluations/sql.py. Change both together.
-const FLAG_EVALUATIONS_TTL_DAYS = 90
+const FLAG_EVALUATIONS_TTL_DAYS = 92
const DAY_MS = 24 * 60 * 60 * 1000
// The table's TTL expires a row dated D at the start of day D + FLAG_EVALUATIONS_TTL_DAYS.