: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(workflows): accept the conversion window as a duration string (#93258)
Daniel Marchukaa49b0d776c7
diff --git a/nodejs/src/cdp/schema/hogflow.test.ts b/nodejs/src/cdp/schema/hogflow.test.tsindex 374bafb93488..d4027fa8c6f2 100644--- a/nodejs/src/cdp/schema/hogflow.test.ts+++ b/nodejs/src/cdp/schema/hogflow.test.ts@@ -103,5 +103,17 @@ describe('hogflow schema', () => {})expect(parsed.conversion?.events).toBeUndefined()})++ it('accepts a conversion goal carrying only the duration-string window', () => {+ // A workflow migrated onto `window` has no `window_minutes` key at all. Requiring one+ // fails the whole flow to parse, which stops it running rather than just mis-reading the+ // window.+ const parsed = HogFlowSchema.parse({+ ...baseHogFlow,+ conversion: { window: '60d', filters: {}, bytecode: [] },+ })+ expect(parsed.conversion?.window).toBe('60d')+ expect(parsed.conversion?.window_minutes).toBeUndefined()+ })})})diff --git a/nodejs/src/cdp/schema/hogflow.ts b/nodejs/src/cdp/schema/hogflow.tsindex 433dab540ecc..a5f5a0bf4a6f 100644--- a/nodejs/src/cdp/schema/hogflow.ts+++ b/nodejs/src/cdp/schema/hogflow.ts@@ -294,6 +294,14 @@ const HogFlowEdgeSchema = z.object({index: z.number().optional(),})+// Optional masking config for the trigger, allows HogFlows to be rate limited per distinct ID or other property+const HogFlowTriggerMaskingSchema = z.object({+ ttl: z.number().nullable(),+ hash: z.string(),+ bytecode: z.array(z.union([z.string(), z.number()])),+ threshold: z.number().nullable(),+})+export const HogFlowSchema = z.object({id: z.string(),team_id: z.number(),@@ -301,19 +309,15 @@ export const HogFlowSchema = z.object({name: z.string(),status: z.enum(['active', 'draft', 'archived']),trigger: HogFlowTriggerSchema,- // Optional masking config for the trigger, allows HogFlows to be rate limited per distinct ID or other property- trigger_masking: z- .object({- ttl: z.number().nullable(),- hash: z.string(),- bytecode: z.array(z.union([z.string(), z.number()])),- threshold: z.number().nullable(),- })- .optional()- .nullable(),+ trigger_masking: HogFlowTriggerMaskingSchema.optional().nullable(),conversion: z.object({- window_minutes: z.number().nullable(),+ // Preferred form, matching how delay steps express a duration: `7d`, `12h`, `90d`.+ window: z.string().nullable().optional(),+ // Deprecated: a bare integer whose unit lives only in the field name. Optional because a+ // row migrated onto `window` carries no `window_minutes` key at all, and a required one+ // would fail the whole flow to parse and stop it running.+ window_minutes: z.number().nullable().optional(),filters: z.any(),bytecode: z.array(z.union([z.string(), z.number()])),events: zdiff --git a/nodejs/src/cdp/services/hogflows/actions/delay.ts b/nodejs/src/cdp/services/hogflows/actions/delay.tsindex 255761e0272b..443d5f57f737 100644--- a/nodejs/src/cdp/services/hogflows/actions/delay.ts+++ b/nodejs/src/cdp/services/hogflows/actions/delay.ts@@ -4,6 +4,7 @@ import { HogFlowAction } from '~/cdp/schema/hogflow'import { CyclotronJobInvocationHogFlow } from '~/cdp/types'import { execHog } from '~/cdp/utils/hog-exec'+import { ParsedDuration, SECONDS_PER_DURATION_UNIT, parseDuration } from '../duration'import { findContinueAction } from '../hogflow-utils'import { ActionHandler, ActionHandlerOptions, ActionHandlerResult } from './action.interface'import { resolveTimezone } from './timezone'@@ -33,21 +34,12 @@ export class DelayHandler implements ActionHandler {}}-// Value is expected to be like `10d` or `1.5h` or `10m`--const DURATION_REGEX = /^(\d*\.?\d+)([dhms])$/--// Same shape as a duration, with an optional leading sign so an offset can point before the instant.-const OFFSET_REGEX = /^(-?)(\d*\.?\d+)([dhms])$/-const DEFAULT_MAX_DELAY_UNTIL = '30d'// The last second luxon (and JS Date) can represent as a real date, end of year 9999. A numeric value larger// than this is a millisecond timestamp mislabelled as seconds, not a plausible date to wait for.const MAX_UNIX_SECONDS = 253402300799-const SECONDS_PER_DURATION_UNIT: Record<string, number> = { d: 86400, h: 3600, m: 60, s: 1 }-/*** Seconds for a signed offset, at its full magnitude.*@@ -57,22 +49,25 @@ const SECONDS_PER_DURATION_UNIT: Record<string, number> = { d: 86400, h: 3600, m* late rather than not at all.*/function offsetSeconds(value: string): number | null {- const match = OFFSET_REGEX.exec(value)- if (!match) {+ const parsed = parseDuration(value)+ if (!parsed) {return null}- const [, sign, amountString, unit] = match- return (sign === '-' ? -1 : 1) * parseFloat(amountString) * SECONDS_PER_DURATION_UNIT[unit]+ return (parsed.negative ? -1 : 1) * parsed.amount * SECONDS_PER_DURATION_UNIT[parsed.unit]}/** Seconds for the wait's ceiling, using the same units and per-unit ceilings as a fixed delay. */function maxDelaySeconds(value: string): number | null {- const match = DURATION_REGEX.exec(value)- if (!match) {+ const parsed = parseDuration(value)+ if (!parsed || parsed.negative) {return null}- const [, amountString, unit] = match- return Math.min(MAX_VALUE_FOR_DURATION_UNIT[unit], parseFloat(amountString)) * SECONDS_PER_DURATION_UNIT[unit]+ return clampedAmount(parsed) * SECONDS_PER_DURATION_UNIT[parsed.unit]+}++/** The amount a fixed delay is allowed to wait for, held to this unit's ceiling. */+function clampedAmount(parsed: ParsedDuration): number {+ return Math.min(MAX_VALUE_FOR_DURATION_UNIT[parsed.unit], parsed.amount)}/**@@ -193,6 +188,8 @@ async function scheduledAtFromInstant(return DateTime.utc() >= scheduledAt ? null : scheduledAt}+const LUXON_UNIT = { d: 'days', h: 'hours', m: 'minutes', s: 'seconds' } as const+const MAX_VALUE_FOR_DURATION_UNIT: Record<string, number> = {d: 30,h: 24,@@ -216,32 +213,13 @@ export function calculatedScheduledAt(throw new Error("'startedAtTimestamp' is not set or is invalid")}- const match = DURATION_REGEX.exec(value)+ const parsed = parseDuration(value)- if (!match) {+ if (!parsed || parsed.negative) {throw new Error(`Invalid duration: ${value}`)}- const [_, amountString, unit] = match-- let duration: DurationLike-- switch (unit) {- case 'd':- duration = { days: Math.min(MAX_VALUE_FOR_DURATION_UNIT[unit], parseFloat(amountString)) }- break- case 'h':- duration = { hours: Math.min(MAX_VALUE_FOR_DURATION_UNIT[unit], parseFloat(amountString)) }- break- case 'm':- duration = { minutes: Math.min(MAX_VALUE_FOR_DURATION_UNIT[unit], parseFloat(amountString)) }- break- case 's':- duration = { seconds: Math.min(MAX_VALUE_FOR_DURATION_UNIT[unit], parseFloat(amountString)) }- break- default:- throw new Error(`Invalid duration: ${value}`)- }+ const duration: DurationLike = { [LUXON_UNIT[parsed.unit]]: clampedAmount(parsed) }const waitUntilTime = actionStartedAt.plus(duration)diff --git a/nodejs/src/cdp/services/hogflows/conversion-watcher.ts b/nodejs/src/cdp/services/hogflows/conversion-watcher.tsindex 33d10dce8cf6..3489493f5d8e 100644--- a/nodejs/src/cdp/services/hogflows/conversion-watcher.ts+++ b/nodejs/src/cdp/services/hogflows/conversion-watcher.ts@@ -3,6 +3,7 @@ import { Counter } from 'prom-client'import { HogFlow } from '~/cdp/schema/hogflow'import { ConversionWatcherRow, CyclotronJobInvocationHogFlow, PinnedConversionGoal } from '../../types'+import { durationSeconds } from './duration'import { hasEventOrActionTarget } from './hogflow-utils'// A goal is configured if either detection path has something to evaluate. Gates the watcher: a@@ -67,11 +68,16 @@ export function buildConversionWatcher(invocation: CyclotronJobInvocationHogFlow// workflow whose own steps run past this can never measure the back half of its own runs.export const DEFAULT_CONVERSION_WINDOW_MINUTES = 90 * 24 * 60-// The ceiling on an explicitly configured window. It exists only to bound the table: a row that never-// expires is a row the sweep can never reclaim. It cannot sit below the default, or a workflow could-// ask for less than it gets by asking for nothing. Raising it further waits on an unambiguous way to-// express the window, since today's out-of-range values are minutes fields holding second counts.-export const MAX_CONVERSION_WINDOW_MINUTES = 90 * 24 * 60+// The ceiling on a window given as a duration string. It exists only to bound the table: a row that+// never expires is a row the sweep can never reclaim.+export const MAX_CONVERSION_WINDOW_MINUTES = 365 * 24 * 60++// The ceiling on the deprecated integer field. It stays where it is because a bare number cannot be+// trusted to be minutes: the values above it are second counts in a field that takes minutes, so+// `604800` means seven days rather than 420. Honoring those to the full ceiling would credit a+// week-long sequence with a conversion nearly a year later. A duration string cannot be misread, so+// only that form earns the higher ceiling.+export const MAX_LEGACY_WINDOW_MINUTES = 90 * 24 * 60// Substituting our window for the configured one changes what the workflow's conversion rate measures,// so it must not be silent: a clamped run reports over the cap, not over the window it asked for.@@ -80,14 +86,37 @@ const counterConversionWindowClamped = new Counter({help: 'Runs enrolled with a conversion window shortened to the cap because the workflow configured a longer one. Each one measures its conversion rate over a shorter period than the workflow asked for.',})+// A window we cannot parse is another silent substitution of the measured period, so it gets the same+// treatment as the clamp above: a counter, not a quiet fallback. It reads zero while the API and worker+// share one ASCII grammar, so a non-zero value flags a row that reached storage past validation.+const counterConversionWindowInvalid = new Counter({+ name: 'cdp_conversion_window_invalid',+ help: 'Runs whose stored conversion window string could not be parsed, so the run fell back to the default or legacy window instead of the one the workflow configured.',+})+function conversionWindowMinutes(hogFlow: HogFlow): number {- const configured = hogFlow.conversion?.window_minutes- if (!configured || configured <= 0) {+ const window = hogFlow.conversion?.window+ if (window) {+ const seconds = durationSeconds(window)+ if (seconds !== null && seconds > 0) {+ return clampWindow(seconds / 60, MAX_CONVERSION_WINDOW_MINUTES)+ }+ // A present window that will not parse means a write reached the row past the API's validation+ // (the two share one ASCII grammar), such as a direct database write. Record the substitution,+ // then fall back: measuring over the fallback window beats measuring over a window nobody can read.+ counterConversionWindowInvalid.inc()+ }+ const legacyMinutes = hogFlow.conversion?.window_minutes+ if (!legacyMinutes || legacyMinutes <= 0) {return DEFAULT_CONVERSION_WINDOW_MINUTES}- if (configured > MAX_CONVERSION_WINDOW_MINUTES) {+ return clampWindow(legacyMinutes, MAX_LEGACY_WINDOW_MINUTES)+}++function clampWindow(minutes: number, ceiling: number): number {+ if (minutes > ceiling) {counterConversionWindowClamped.inc()- return MAX_CONVERSION_WINDOW_MINUTES+ return ceiling}- return configured+ return minutes}diff --git a/nodejs/src/cdp/services/hogflows/duration.test.ts b/nodejs/src/cdp/services/hogflows/duration.test.tsnew file mode 100644index 000000000000..a1d453c9499a--- /dev/null+++ b/nodejs/src/cdp/services/hogflows/duration.test.ts@@ -0,0 +1,60 @@+import { durationSeconds, parseDuration } from './duration'++describe('duration', () => {+ // The grammar is shared by every duration a workflow expresses, so loosening it in one place+ // silently changes delays, wait ceilings and conversion windows together.+ it.each([+ ['7d', { amount: 7, unit: 'd', negative: false }],+ ['1.5h', { amount: 1.5, unit: 'h', negative: false }],+ ['.5m', { amount: 0.5, unit: 'm', negative: false }],+ ['45s', { amount: 45, unit: 's', negative: false }],+ ['0d', { amount: 0, unit: 'd', negative: false }],+ ['-45d', { amount: 45, unit: 'd', negative: true }],+ ])('parses %p', (value, expected) => {+ expect(parseDuration(value)).toEqual(expected)+ })++ it.each([+ [''],+ ['5'],+ ['d'],+ // Case and whitespace stay out: a delay reading `5 d` as five days would be a wait nobody wrote.+ ['5D'],+ ['5 d'],+ [' 5d'],+ ['5d '],+ ['5days'],+ ['1.2.3d'],+ ['1e3d'],+ ['--5d'],+ ['+5d'],+ ['1,5d'],+ ['5w'],+ // Non-ASCII digits parse under some number readers but not this one.+ ['٥d'],+ ])('rejects %p', (value) => {+ expect(parseDuration(value)).toBeNull()+ })++ it.each([+ ['7d', 604800],+ ['12h', 43200],+ ['90m', 5400],+ ['45s', 45],+ ])('converts %p to seconds', (value, expected) => {+ expect(durationSeconds(value)).toBe(expected)+ })++ it('refuses a signed duration', () => {+ // Only a `delay_until` offset may point backwards. A negative wait or conversion window is+ // meaningless, and reading one as positive would schedule work in the past.+ expect(durationSeconds('-7d')).toBeNull()+ expect(parseDuration('-7d')).toEqual({ amount: 7, unit: 'd', negative: true })+ })++ it('applies no ceiling of its own', () => {+ // The per-unit ceilings belong to delays. Applying `d: 30` here would cut a 365-day+ // conversion window to 30 days without saying so.+ expect(durationSeconds('365d')).toBe(365 * 86400)+ })+})diff --git a/nodejs/src/cdp/services/hogflows/duration.ts b/nodejs/src/cdp/services/hogflows/duration.tsnew file mode 100644index 000000000000..5e5d66a0e662--- /dev/null+++ b/nodejs/src/cdp/services/hogflows/duration.ts@@ -0,0 +1,43 @@+// One grammar for every duration a workflow expresses: `10d`, `1.5h`, `30m`, `45s`. The sign is parsed+// here because a `delay_until` offset may point before its instant, but nothing else may carry one, so+// unsigned callers reject it rather than quietly accepting `-5d`.+// The alternation keeps each digit run owned by one quantifier. The obvious `\d*\.?\d+` lets two+// quantifiers claim the same digits, so a long non-matching value backtracks quadratically. This form+// matches the same strings linearly. `[0-9]` is the same ASCII grammar the API enforces, spelled the+// same way so the two cannot drift (JS `\d` is already ASCII, but Python's also matches Unicode digits).+const DURATION_REGEX = /^(-?)([0-9]+(?:\.[0-9]+)?|\.[0-9]+)([dhms])$/++export type DurationUnit = 'd' | 'h' | 'm' | 's'++export type ParsedDuration = { amount: number; unit: DurationUnit; negative: boolean }++export const SECONDS_PER_DURATION_UNIT: Record<DurationUnit, number> = { d: 86400, h: 3600, m: 60, s: 1 }++/**+ * The parts of a duration string, or null when it is not one.+ *+ * Returns the parts rather than a total because each caller bounds them differently: a fixed delay+ * clamps the amount per unit, an offset keeps its sign, and a conversion window takes the value whole.+ */+export function parseDuration(value: string): ParsedDuration | null {+ const match = DURATION_REGEX.exec(value)+ if (!match) {+ return null+ }+ const [, sign, amountString, unit] = match+ return { amount: parseFloat(amountString), unit: unit as DurationUnit, negative: sign === '-' }+}++/**+ * Seconds for an unsigned duration, at its full magnitude.+ *+ * Unclamped on purpose. A delay applies per-unit ceilings to bound how long one step waits, and those+ * must not reach a conversion window: `d: 30` there would silently turn a 365-day window into 30 days.+ */+export function durationSeconds(value: string): number | null {+ const parsed = parseDuration(value)+ if (!parsed || parsed.negative) {+ return null+ }+ return parsed.amount * SECONDS_PER_DURATION_UNIT[parsed.unit]+}diff --git a/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.tsindex 09aa53f7cd83..061dc029dd19 100644--- a/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts+++ b/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts@@ -7,6 +7,7 @@ import { CyclotronJobInvocationHogFlow } from '../../types'import {DEFAULT_CONVERSION_WINDOW_MINUTES,MAX_CONVERSION_WINDOW_MINUTES,+ MAX_LEGACY_WINDOW_MINUTES,buildConversionWatcher,} from './conversion-watcher'@@ -77,8 +78,8 @@ describe('buildConversionWatcher', () => {it.each([['no configured window', null, DEFAULT_CONVERSION_WINDOW_MINUTES],- ['a window longer than the cap', 60 * 24 * 400, MAX_CONVERSION_WINDOW_MINUTES],- ['a window inside the cap', 60, 60],+ ['a legacy window longer than its cap', 604800, MAX_LEGACY_WINDOW_MINUTES],+ ['a legacy window inside its cap', 60, 60],])('expires after %s', (_name, windowMinutes, expectedMinutes) => {// Treating null as "forever" would leave rows the expiry sweep can never reach.const before = Date.now()@@ -91,6 +92,22 @@ describe('buildConversionWatcher', () => {expect(minutes).toBeLessThan(expectedMinutes + 1)})+ it.each([+ ['a duration string', { window: '7d' }, 7 * 24 * 60],+ ['hours', { window: '12h' }, 12 * 60],+ ['a duration string past the cap', { window: '400d' }, MAX_CONVERSION_WINDOW_MINUTES],+ // The duration string is the trustworthy form, so it wins over a bare number that may hold+ // any unit at all.+ ['both forms set', { window: '7d', window_minutes: 604800 }, 7 * 24 * 60],+ ])('expires after %s', (_name, conversionWindow, expectedMinutes) => {+ const before = Date.now()+ const watcher = buildConversionWatcher(invocationFor({ ...propertyGoal, ...conversionWindow }))++ const minutes = (watcher!.expires_at.getTime() - before) / 60_000+ expect(minutes).toBeGreaterThanOrEqual(expectedMinutes)+ expect(minutes).toBeLessThan(expectedMinutes + 1)+ })+it('counts a run whose window was shortened to the cap, and only then', async () => {// The clamp changes what the workflow's conversion rate measures. Without this counter the// substitution leaves no trace anywhere, which is how it went unnoticed in the first place.@@ -99,13 +116,37 @@ describe('buildConversionWatcher', () => {const before = await clamped()- buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_CONVERSION_WINDOW_MINUTES + 1 }))+ buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_LEGACY_WINDOW_MINUTES + 1 }))expect(await clamped()).toBe(before + 1)- buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_CONVERSION_WINDOW_MINUTES }))+ buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_LEGACY_WINDOW_MINUTES }))expect(await clamped()).toBe(before + 1)})+ it('counts a run whose stored window string could not be parsed, and only then', async () => {+ // A stored window the worker cannot parse falls back to the default, changing what the run+ // measures. The counter is the only signal that happened, so it must fire on the fallback path.+ const invalidCount = async (): Promise<number> =>+ ((await register.getSingleMetric('cdp_conversion_window_invalid')?.get())?.values[0]?.value as number) ?? 0++ const before = await invalidCount()++ // An unparseable window (e.g. a non-ASCII digit reaching storage past validation) falls back to+ // the default window and increments the counter.+ // Read the clock before building, not after: expires_at is stamped inside the call, so a+ // millisecond spent there makes the measured window fall a hair short of the expected one.+ const start = Date.now()+ const fallback = buildConversionWatcher(invocationFor({ ...propertyGoal, window: '٧d' }))+ const minutes = (fallback!.expires_at.getTime() - start) / 60_000+ expect(minutes).toBeGreaterThanOrEqual(DEFAULT_CONVERSION_WINDOW_MINUTES)+ expect(minutes).toBeLessThan(DEFAULT_CONVERSION_WINDOW_MINUTES + 1)+ expect(await invalidCount()).toBe(before + 1)++ // A parseable window does not touch the counter.+ buildConversionWatcher(invocationFor({ ...propertyGoal, window: '7d' }))+ expect(await invalidCount()).toBe(before + 1)+ })+it('does not build a watcher for a run that has already started', () => {// A run with several delays would otherwise enroll once per wake, inflating the denominator// and the row count together.diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.pyindex 9b07d06146fc..6eeb2d87ace7 100644--- a/products/workflows/backend/api/hog_flow.py+++ b/products/workflows/backend/api/hog_flow.py@@ -1941,6 +1941,26 @@ class HogFlowConversionEventSerializer(serializers.Serializer):)+# Duration strings as the workflow's delay steps already express them, so one convention covers both.+# The alternation keeps each digit run owned by one quantifier. The obvious `\d*\.?\d+` lets `\d*` and+# `\d+` both claim the same digits, so a long non-matching value backtracks quadratically, which lets an+# authenticated caller burn a web process with one request. This form matches the same strings linearly.+# Use `[0-9]`, not `\d`: Python's `\d` also matches Unicode digits (e.g. '٧', '7') and `float()` parses+# them, so `\d` would store a window the Node worker's ASCII regex cannot parse, and the worker would+# then fall back to its default window with no error. `[0-9]` holds the API to the same ASCII grammar the+# worker and the generated clients enforce.+CONVERSION_WINDOW_REGEX = r"^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)[dhms]$"++_MINUTES_PER_DURATION_UNIT = {"d": 1440, "h": 60, "m": 1, "s": 1 / 60}++MAX_CONVERSION_WINDOW_MINUTES = 365 * 24 * 60+MAX_LEGACY_WINDOW_MINUTES = 90 * 24 * 60+++def _duration_minutes(value: str) -> float:+ return float(value[:-1]) * _MINUTES_PER_DURATION_UNIT[value[-1]]++class HogFlowConversionSerializer(serializers.Serializer):filters = serializers.ListField(child=serializers.DictField(),@@ -1956,10 +1976,27 @@ class HogFlowConversionSerializer(serializers.Serializer):required=False,help_text="Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}].",)+ window = serializers.RegexField(+ regex=CONVERSION_WINDOW_REGEX,+ # A real window is a handful of characters ('365d', '31536000s'); the cap keeps the regex and the+ # float parse off arbitrarily long input and flows a bound into the generated client schemas.+ max_length=32,+ required=False,+ allow_null=True,+ help_text=(+ "How long after entering the workflow a conversion still counts, as a duration string: "+ "'7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. "+ "Omit it to use the default window. Set this or 'window_minutes', not both."+ ),+ )window_minutes = serializers.IntegerField(required=False,allow_null=True,- help_text="Conversion window in minutes after a person enters the workflow. null = no explicit window.",+ help_text=(+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a "+ "person enters the workflow. Maximum 129600 (90 days). null = use the default window. "+ "Set this or 'window', not both."+ ),)# Not DRF read_only: drf-spectacular puts readOnly fields in the component's `required` list# (shared by request and response schemas), which would make generated write schemas demand a@@ -1969,6 +2006,48 @@ class HogFlowConversionSerializer(serializers.Serializer):required=False, allow_null=True, help_text="Compiled server-side from 'filters'. Do not set; ignored if sent.")+ def validate_window(self, value: str | None) -> str | None:+ if value is None:+ return value+ minutes = _duration_minutes(value)+ # A zero window measures nothing. The worker cannot honor it either, so it would fall back to+ # the default and give the workflow a 90-day window nobody asked for.+ if minutes <= 0:+ raise serializers.ValidationError("The conversion window must be longer than zero.")+ if minutes > MAX_CONVERSION_WINDOW_MINUTES:+ raise serializers.ValidationError("The conversion window cannot be longer than 365d.")+ return value++ def _stored_window_minutes(self) -> int | None:+ # The value this workflow already holds, or None on create. `conversion` is nested only under+ # HogFlowSerializer, so self.root.instance is the HogFlow being updated.+ stored = getattr(self.root.instance, "conversion", None)+ if isinstance(stored, dict):+ return stored.get("window_minutes")+ return None++ def validate_window_minutes(self, value: int | None) -> int | None:+ if value is None:+ return value+ # Grandfather an over-ceiling value the row already holds. The builder resends the whole+ # conversion on every save, so a plain value ceiling would 400 an unrelated edit (a rename or a+ # step change) on a workflow that predates the ceiling, naming a field the builder cannot show.+ # Reject the value only when this write introduces or changes it.+ if value > MAX_LEGACY_WINDOW_MINUTES and value != self._stored_window_minutes():+ # Almost every value this large is a second count in a field that takes minutes, so name the+ # unit and show what the number means rather than silently shortening it.+ raise serializers.ValidationError(+ f"window_minutes is in minutes, so {value} means {value // 1440} days. "+ f"The maximum is {MAX_LEGACY_WINDOW_MINUTES}. Use 'window' with a duration string "+ f"such as '7d' instead."+ )+ return value++ def validate(self, data: dict) -> dict:+ if data.get("window") is not None and data.get("window_minutes") is not None:+ raise serializers.ValidationError("Set either 'window' or the deprecated 'window_minutes', not both.")+ return data+def to_internal_value(self, data):# bytecode is server-computed; never trust a client-supplied value (the matcher executes it).if isinstance(data, dict) and "bytecode" in data:@@ -2819,7 +2898,9 @@ class HogFlowSerializer(HogFlowMinimalSerializer):allow_null=True,help_text=("Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; "- "events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. "+ "events: event-based goals [{filters: {events: [...]}}]; "+ "window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', "+ "maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. ""Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. ""bytecode compiled server-side."),diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.pyindex 940a387ceadb..e06a4469139c 100644--- a/products/workflows/backend/api/test/test_hog_flow.py+++ b/products/workflows/backend/api/test/test_hog_flow.py@@ -1081,6 +1081,78 @@ class TestHogFlowAPI(APIBaseTest):conversion = response.json()["conversion"]assert conversion["bytecode"] == [], conversion+ @parameterized.expand(+ [+ ("duration string", {"window": "7d"}, 201),+ ("hours", {"window": "12h"}, 201),+ ("over the ceiling", {"window": "400d"}, 400),+ ("zero", {"window": "0d"}, 400),+ ("zero seconds", {"window": "0s"}, 400),+ ("not a duration", {"window": "7 days"}, 400),+ ("legacy minutes", {"window_minutes": 60}, 201),+ # 604800 is seven days in seconds, in a field that takes minutes. Rejecting it turns a+ # silently shortened window into an error that names the unit.+ ("legacy seconds mistaken for minutes", {"window_minutes": 604800}, 400),+ ("both forms", {"window": "7d", "window_minutes": 60}, 400),+ # A valid 7-day window padded past the length cap. Without max_length the regex accepts it and+ # it stores as 7 days; the cap rejects it, which is what keeps arbitrarily long input off the+ # regex and the float parse.+ ("over the length cap", {"window": "0" * 40 + "7d"}, 400),+ # Non-ASCII digits: Python's \d and float() accept these, but the Node worker's ASCII regex+ # rejects them, so storing one would silently fall back to the default window. The [0-9] grammar+ # rejects them here, at the API, the same way the worker does.+ ("arabic-indic digits", {"window": "٧d"}, 400),+ ("full-width digits", {"window": "7d"}, 400),+ ]+ )+ def test_hog_flow_conversion_window(self, _name, conversion_window, expected_status):+ hog_flow, _ = self._create_hog_flow_with_action(+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}+ )+ hog_flow["conversion"] = {"filters": [], **conversion_window}++ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)+ assert response.status_code == expected_status, response.json()++ def test_hog_flow_conversion_window_minutes_error_names_the_unit(self):+ hog_flow, _ = self._create_hog_flow_with_action(+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}+ )+ hog_flow["conversion"] = {"filters": [], "window_minutes": 604800}++ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)+ assert response.status_code == 400, response.json()+ assert "minutes" in response.json()["detail"]+ assert "420 days" in response.json()["detail"]++ def test_hog_flow_conversion_window_minutes_grandfathers_stored_over_ceiling_value(self):+ hog_flow, _ = self._create_hog_flow_with_action(+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}+ )+ create_response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)+ assert create_response.status_code == 201, create_response.json()+ flow_id = create_response.json()["id"]++ # Seed a row from before the ceiling existed, bypassing the serializer that now refuses this value.+ flow = HogFlow.objects.get(id=flow_id)+ flow.conversion = {"filters": [], "window_minutes": 604800}+ flow.save()++ # An unrelated edit that resends the unchanged over-ceiling value must still succeed.+ unrelated_edit = self.client.patch(+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",+ {"name": "Renamed", "conversion": {"filters": [], "window_minutes": 604800}},+ )+ assert unrelated_edit.status_code == 200, unrelated_edit.json()+ assert unrelated_edit.json()["conversion"]["window_minutes"] == 604800++ # Changing the stored value to a different over-ceiling value is still refused.+ changed = self.client.patch(+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",+ {"conversion": {"filters": [], "window_minutes": 700000}},+ )+ assert changed.status_code == 400, changed.json()+def test_hog_flow_conversion_filters_compiles_bytecode_on_update(self):expected_conversion_bytecode = ["_H",diff --git a/products/workflows/backend/management/commands/migrate_conversion_window_to_duration.py b/products/workflows/backend/management/commands/migrate_conversion_window_to_duration.pynew file mode 100644index 000000000000..920d9f3e4e3e--- /dev/null+++ b/products/workflows/backend/management/commands/migrate_conversion_window_to_duration.py@@ -0,0 +1,252 @@+import uuid+from typing import Any++from django.core.management.base import BaseCommand+from django.db import transaction++from posthog.dataclasses import frozen++from products.workflows.backend.api.hog_flow import MAX_LEGACY_WINDOW_MINUTES+from products.workflows.backend.models.hog_flow.hog_flow import HogFlow+from products.workflows.backend.models.hog_flow_revision import HogFlowRevision+from products.workflows.backend.services.timing_reschedule import parse_delay_duration_seconds++MINUTES_PER_DAY = 1440+++@frozen+class RewrittenWindow:+ """A conversion whose window_minutes has been respelled as a duration string."""++ conversion: dict+ window: str+ minutes: int+++@frozen+class ConvertedFlow:+ """What one locked row's conversion turned into, and whether its draft moved with it."""++ window: str+ minutes: int+ draft_converted: bool+++class Command(BaseCommand):+ help = (+ "Move conversion.window_minutes onto conversion.window, the duration-string form. "+ "Only converts values the matcher already honors in full (at or under the legacy ceiling of "+ f"{MAX_LEGACY_WINDOW_MINUTES} minutes), which is a representation change with no effect on any "+ "conversion rate. A larger value is reported and left alone: it can be a real minute count or a "+ "seconds count in a minutes field, and either reading changes what the workflow measures, so "+ "which one is right needs a person. Default dry-run; pass --live-run to apply."+ )++ def add_arguments(self, parser: Any) -> None:+ parser.add_argument("--team-id", default=None, type=int, help="Limit to a specific team ID")+ parser.add_argument("--live-run", action="store_true", help="Apply changes (default is dry-run)")++ def handle(self, *args: Any, **options: Any) -> None:+ live_run = options.get("live_run", False)+ team_id = options.get("team_id")+ mode = "LIVE RUN" if live_run else "DRY RUN"+ self.stdout.write(f"Starting migrate_conversion_window_to_duration ({mode})")++ flows = HogFlow.objects.filter(conversion__isnull=False)+ if team_id:+ flows = flows.filter(team_id=team_id)+ self.stdout.write(f"Filtering to team_id={team_id}")++ converted = 0+ drafts_with_rows = 0+ needs_review = []+ for flow in flows.iterator():+ conversion = flow.conversion or {}+ minutes = conversion.get("window_minutes")+ # A row that already carries a window was written by a client that knows the new field.+ if conversion.get("window") or not isinstance(minutes, int) or isinstance(minutes, bool) or minutes <= 0:+ continue++ if minutes > MAX_LEGACY_WINDOW_MINUTES:+ needs_review.append((flow, minutes))+ continue++ if not live_run:+ self.stdout.write(+ f" Would convert flow id={flow.id} team_id={flow.team_id} status={flow.status}: "+ f"window_minutes={minutes} -> window={duration_string(minutes)}"+ )+ converted += 1+ continue++ result = self.convert_locked(flow.pk)+ if result is None:+ self.stdout.write(+ f" Skipped flow id={flow.id} team_id={flow.team_id}: conversion changed since the "+ "scan, leaving it for a rerun"+ )+ continue++ drafts_with_rows += 1 if result.draft_converted else 0+ self.stdout.write(+ f" Converting flow id={flow.id} team_id={flow.team_id} status={flow.status}: "+ f"window_minutes={result.minutes} -> window={result.window}"+ )+ converted += 1++ drafts = drafts_with_rows + self.convert_drafts(live_run, team_id)+ revisions = self.convert_revisions(live_run, team_id)++ self.report_needs_review(needs_review)++ verb = "converted" if live_run else "to convert"+ self.stdout.write(self.style.SUCCESS(f"Completed ({mode}): {converted} flow(s) {verb}"))+ self.stdout.write(self.style.SUCCESS(f" plus {drafts} draft(s) and {revisions} revision snapshot(s)"))++ def convert_drafts(self, live_run: bool, team_id: int | None) -> int:+ """Drafts whose live conversion needed no change of its own. The pass above already rewrote a+ draft alongside its row; this catches the rest, where only the draft carries the old field."""+ flows = HogFlow.objects.filter(draft__isnull=False)+ if team_id:+ flows = flows.filter(team_id=team_id)++ count = 0+ for flow in flows.iterator():+ draft = flow.draft+ if not isinstance(draft, dict):+ continue+ rewritten = converted_conversion(draft.get("conversion"))+ if rewritten is None:+ continue+ self.stdout.write(+ f" {'Converting' if live_run else 'Would convert'} draft on flow id={flow.id} "+ f"team_id={flow.team_id}: window={rewritten.window}"+ )+ if live_run:+ with transaction.atomic():+ locked = HogFlow.objects.select_for_update().get(pk=flow.pk)+ locked_draft = locked.draft+ if not isinstance(locked_draft, dict):+ continue+ fresh = converted_conversion(locked_draft.get("conversion"))+ if fresh is None:+ continue+ HogFlow.objects.filter(pk=flow.pk).update(draft={**locked_draft, "conversion": fresh.conversion})+ count += 1+ return count++ def convert_revisions(self, live_run: bool, team_id: int | None) -> int:+ """Snapshots a rollback copies back into the draft. Rewriting one keeps a restore from putting+ the deprecated field back. The value is unchanged, only how it is spelled, so the snapshot still+ records the same window it always did."""+ # Fail-closed manager: one team goes through for_team, and a whole-instance backfill is the+ # cross-team access unscoped() exists for.+ revisions = HogFlowRevision.objects.for_team(team_id) if team_id else HogFlowRevision.objects.unscoped().all()++ count = 0+ for revision in revisions.iterator():+ content = revision.content+ if not isinstance(content, dict):+ continue+ rewritten = converted_conversion(content.get("conversion"))+ if rewritten is None:+ continue+ self.stdout.write(+ f" {'Converting' if live_run else 'Would convert'} revision id={revision.id} "+ f"flow={revision.hog_flow_id} v{revision.version}: window={rewritten.window}"+ )+ if live_run:+ # Append-only in practice — nothing edits a published snapshot — so no lock is needed.+ HogFlowRevision.objects.for_team(revision.team_id).filter(pk=revision.pk).update(+ content={**content, "conversion": rewritten.conversion}+ )+ count += 1+ return count++ def convert_locked(self, pk: uuid.UUID) -> ConvertedFlow | None:+ # Re-read the row under a lock and convert the value it holds now, not the one the scan read.+ # A customer saving the workflow between the scan and this write would otherwise lose that edit+ # to the stale conversion this command is holding, the lost write the API save path and the+ # sibling backfills guard against. A locked row that no longer qualifies (a save added a window+ # or pushed the value above the ceiling) is left for a rerun. .update() keeps updated_at+ # untouched: this is a representation change, not a user edit, so it must not fail an open+ # editor's next save or re-sort untouched flows to the top. The cost is that an editor which loaded+ # the workflow before the run and saves after it writes its stale conversion back, returning that+ # one row to window_minutes. The value it restores is under the ceiling and still honored, and a+ # rerun converts it again, so this is the cheaper side of the trade.+ with transaction.atomic():+ locked = HogFlow.objects.select_for_update().get(pk=pk)+ rewritten = converted_conversion(locked.conversion or {})+ if rewritten is None:+ return None+ fields: dict[str, object] = {"conversion": rewritten.conversion}+ draft_converted = False+ # The draft holds its own copy of conversion, so leaving it behind would put the+ # deprecated field back on the live row the moment the draft is published.+ draft = locked.draft+ if isinstance(draft, dict):+ draft_conversion = converted_conversion(draft.get("conversion"))+ if draft_conversion is not None:+ fields["draft"] = {**draft, "conversion": draft_conversion.conversion}+ draft_converted = True+ HogFlow.objects.filter(pk=pk).update(**fields)+ return ConvertedFlow(window=rewritten.window, minutes=rewritten.minutes, draft_converted=draft_converted)++ def report_needs_review(self, needs_review: list[tuple[HogFlow, int]]) -> None:+ if not needs_review:+ return+ self.stdout.write("")+ self.stdout.write(self.style.WARNING(f"{len(needs_review)} flow(s) left alone, each needs a person:"))+ self.stdout.write(f" {'id':<36} team_id window_minutes as minutes as seconds own delay steps name")+ for flow, minutes in sorted(needs_review, key=lambda pair: pair[0].team_id):+ span = flow_span_days(flow)+ span_label = f"{span:.1f}d" if span else "none"+ self.stdout.write(+ f" {str(flow.id):<36} {flow.team_id:<7} {minutes:<14} {minutes / MINUTES_PER_DAY:>7.1f}d "+ f"{minutes / (MINUTES_PER_DAY * 60):>8.1f}d {span_label:>15} {flow.name}"+ )+ self.stdout.write(+ " Read it as whichever column sits closest to the workflow's own delay steps. A value that "+ "only makes sense as seconds was written by someone who meant that many days."+ )+++def converted_conversion(conversion: object) -> RewrittenWindow | None:+ """The same conversion with window_minutes spelled as a duration string, or None when it must not+ be touched: already migrated, no usable value, or above the ceiling where the reading is in doubt."""+ if not isinstance(conversion, dict):+ return None+ minutes = conversion.get("window_minutes")+ if conversion.get("window") or not isinstance(minutes, int) or isinstance(minutes, bool) or minutes <= 0:+ return None+ if minutes > MAX_LEGACY_WINDOW_MINUTES:+ return None+ window = duration_string(minutes)+ rewritten = {k: v for k, v in conversion.items() if k != "window_minutes"}+ rewritten["window"] = window+ return RewrittenWindow(conversion=rewritten, window=window, minutes=minutes)+++def duration_string(minutes: int) -> str:+ """The shortest exact duration string for a whole number of minutes."""+ if minutes % MINUTES_PER_DAY == 0:+ return f"{minutes // MINUTES_PER_DAY}d"+ if minutes % 60 == 0:+ return f"{minutes // 60}h"+ return f"{minutes}m"+++def flow_span_days(flow: HogFlow) -> float:+ """Rough timescale of the workflow's fixed delay steps, each clamped per unit the way the worker+ clamps a delay before it waits, so a step written 90d counts the 30 days it actually waits. This+ is only a sanity signal for the review table. It sums fixed delays without following branches, so+ mutually exclusive delays are added together, and it counts neither date-based delays nor+ condition-wait deadlines. Treat it as approximate, not the exact span any one run follows."""+ total_seconds = 0.0+ for action in flow.actions or []:+ if not isinstance(action, dict):+ continue+ seconds = parse_delay_duration_seconds((action.get("config") or {}).get("delay_duration"))+ if seconds is not None:+ total_seconds += seconds+ return total_seconds / (MINUTES_PER_DAY * 60)diff --git a/products/workflows/backend/test/test_migrate_conversion_window_to_duration.py b/products/workflows/backend/test/test_migrate_conversion_window_to_duration.pynew file mode 100644index 000000000000..7f89e1cf7c02--- /dev/null+++ b/products/workflows/backend/test/test_migrate_conversion_window_to_duration.py@@ -0,0 +1,114 @@+from posthog.test.base import BaseTest++from django.core.management import call_command++from parameterized import parameterized++from posthog.models import Team+from posthog.models.scoping import team_scope++from products.workflows.backend.models.hog_flow.hog_flow import HogFlow+from products.workflows.backend.models.hog_flow_revision import HogFlowRevision+++def _flow(team: Team, name: str, conversion: dict) -> HogFlow:+ return HogFlow.objects.create(+ team=team,+ name=name,+ status="active",+ trigger={"type": "event", "filters": {}},+ exit_condition="exit_only_at_end",+ conversion=conversion,+ actions=[],+ edges=[],+ )+++class TestMigrateConversionWindowToDuration(BaseTest):+ @parameterized.expand(+ [+ ("a whole number of days", 129600, "90d"),+ ("a whole number of hours", 60, "1h"),+ ("neither", 90, "90m"),+ ]+ )+ def test_converts_a_window_the_matcher_already_honors(self, _name, minutes, expected):+ flow = _flow(self.team, "convertible", {"filters": [], "window_minutes": minutes})++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ flow.refresh_from_db()+ assert flow.conversion == {"filters": [], "window": expected}++ @parameterized.expand([("seven days in seconds", 604800), ("thirty days in seconds", 2592000)])+ def test_leaves_a_window_above_the_legacy_ceiling_alone(self, _name, minutes):+ # Converting one of these either way changes what the workflow measures, and which reading is+ # right needs a person. Touching it silently is the failure this guards.+ flow = _flow(self.team, "ambiguous", {"filters": [], "window_minutes": minutes})++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ flow.refresh_from_db()+ assert flow.conversion == {"filters": [], "window_minutes": minutes}++ def test_dry_run_writes_nothing(self):+ flow = _flow(self.team, "untouched", {"filters": [], "window_minutes": 60})++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk)++ flow.refresh_from_db()+ assert flow.conversion == {"filters": [], "window_minutes": 60}++ def test_leaves_a_flow_that_already_has_a_window_alone(self):+ flow = _flow(self.team, "already migrated", {"filters": [], "window": "7d"})++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ flow.refresh_from_db()+ assert flow.conversion == {"filters": [], "window": "7d"}++ def test_converts_the_draft_copy_of_a_conversion(self):+ # A draft carries its own conversion, so leaving it behind puts the deprecated field back on+ # the live row the moment someone publishes.+ flow = _flow(self.team, "with draft", {"filters": [], "window_minutes": 60})+ flow.draft = {"conversion": {"filters": [], "window_minutes": 1440}}+ flow.save()++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ flow.refresh_from_db()+ assert flow.conversion == {"filters": [], "window": "1h"}+ assert flow.draft == {"conversion": {"filters": [], "window": "1d"}}++ def test_converts_a_revision_snapshot(self):+ # Restoring a snapshot copies it back into the draft, so an unmigrated one reintroduces the field.+ flow = _flow(self.team, "with revision", {"filters": [], "window": "7d"})+ with team_scope(self.team.id):+ revision = HogFlowRevision.objects.create(+ team=self.team,+ hog_flow=flow,+ version=1,+ content={"conversion": {"filters": [], "window_minutes": 1440}},+ )++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ with team_scope(self.team.id):+ revision.refresh_from_db()+ assert revision.content == {"conversion": {"filters": [], "window": "1d"}}++ def test_leaves_an_ambiguous_revision_snapshot_alone(self):+ flow = _flow(self.team, "ambiguous revision", {"filters": [], "window": "7d"})+ with team_scope(self.team.id):+ revision = HogFlowRevision.objects.create(+ team=self.team,+ hog_flow=flow,+ version=1,+ content={"conversion": {"filters": [], "window_minutes": 604800}},+ )++ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)++ with team_scope(self.team.id):+ revision.refresh_from_db()+ assert revision.content == {"conversion": {"filters": [], "window_minutes": 604800}}diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.tsindex bc715db821d9..8bc813d53394 100644--- a/products/workflows/frontend/generated/api.schemas.ts+++ b/products/workflows/frontend/generated/api.schemas.ts@@ -367,7 +367,14 @@ export interface HogFlowConversionApi {/** Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]. */events?: HogFlowConversionEventApi[]/**- * Conversion window in minutes after a person enters the workflow. null = no explicit window.+ * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both.+ * @maxLength 32+ * @nullable+ * @pattern ^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)[dhms]$+ */+ window?: string | null+ /**+ * DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both.* @nullable*/window_minutes?: number | null@@ -594,7 +601,7 @@ export interface HogFlowApi {readonly trigger: unknown/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMaskingApi | null- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversionApi | null/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*@@ -692,7 +699,7 @@ export interface HogFlowUpdateApi {readonly trigger: unknown/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMaskingApi | null- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversionApi | null/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*@@ -790,7 +797,7 @@ export interface PatchedHogFlowUpdateApi {readonly trigger?: unknown/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMaskingApi | null- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversionApi | null/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.tsindex 78b30b451169..00bfdd83373e 100644--- a/products/workflows/frontend/generated/api.zod.ts+++ b/products/workflows/frontend/generated/api.zod.ts@@ -407,6 +407,9 @@ export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsCreateBodyConversionOneWindowMax = 32++export const hogFlowsCreateBodyConversionOneWindowRegExp = new RegExp('^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$')export const hogFlowsCreateBodyEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsCreateBodyActionsItemIdMax = 200@@ -507,11 +510,19 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsCreateBodyConversionOneWindowMax)+ .regex(hogFlowsCreateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -522,7 +533,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([@@ -800,6 +811,9 @@ export const hogFlowsUpdateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsUpdateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsUpdateBodyConversionOneWindowMax = 32++export const hogFlowsUpdateBodyConversionOneWindowRegExp = new RegExp('^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$')export const hogFlowsUpdateBodyEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsUpdateBodyActionsItemIdMax = 200@@ -894,11 +908,19 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsUpdateBodyConversionOneWindowMax)+ .regex(hogFlowsUpdateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -909,7 +931,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([@@ -1187,6 +1209,11 @@ export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsPartialUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsPartialUpdateBodyConversionOneWindowMax = 32++export const hogFlowsPartialUpdateBodyConversionOneWindowRegExp = new RegExp(+ '^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$'+)export const hogFlowsPartialUpdateBodyEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsPartialUpdateBodyActionsItemIdMax = 200@@ -1286,11 +1313,19 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsPartialUpdateBodyConversionOneWindowMax)+ .regex(hogFlowsPartialUpdateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -1301,7 +1336,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([@@ -1767,6 +1802,11 @@ export const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMiexport const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMax = 94608000export const hogFlowsInvocationsCreateBodyConfigurationOneConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsInvocationsCreateBodyConfigurationOneConversionOneWindowMax = 32++export const hogFlowsInvocationsCreateBodyConfigurationOneConversionOneWindowRegExp = new RegExp(+ '^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$'+)export const hogFlowsInvocationsCreateBodyConfigurationOneEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemIdMax = 200@@ -1928,11 +1968,19 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsInvocationsCreateBodyConfigurationOneConversionOneWindowMax)+ .regex(hogFlowsInvocationsCreateBodyConfigurationOneConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -1943,7 +1991,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([@@ -2543,6 +2591,11 @@ export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsBulkDeleteCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsBulkDeleteCreateBodyConversionOneWindowMax = 32++export const hogFlowsBulkDeleteCreateBodyConversionOneWindowRegExp = new RegExp(+ '^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$'+)export const hogFlowsBulkDeleteCreateBodyEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsBulkDeleteCreateBodyActionsItemIdMax = 200@@ -2648,11 +2701,19 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsBulkDeleteCreateBodyConversionOneWindowMax)+ .regex(hogFlowsBulkDeleteCreateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -2663,7 +2724,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([diff --git a/products/workflows/skills/building-workflows/references/graph-schema.md b/products/workflows/skills/building-workflows/references/graph-schema.mdindex 96aaaec93a8e..a27c0abc6a6e 100644--- a/products/workflows/skills/building-workflows/references/graph-schema.md+++ b/products/workflows/skills/building-workflows/references/graph-schema.md@@ -199,7 +199,8 @@ A `delay` waits either a fixed span or until a date carried by the person or the- The `…conversion` variants require a `conversion` goal with two slots plus a window:- `filters` — **property conditions only**, an array `[{key, value, operator, type}, ...]` (empty array = any event in the window converts).- `events` — **event-based goals**, `[{ "filters": { "events": [{ "id": "<event>", "name": "<event>", "type": "events" }] } }]`.- - `window_minutes` — minutes after entry (`null` = no window).+ - `window` — how long after entry a conversion still counts, as a duration string (`"7d"`, `"12h"`, `"30m"`, `"45s"`), max `"365d"`. The preferred form.+ - `window_minutes` — deprecated: the same window in minutes, not seconds, max `129600` (90 days). Set `window` or `window_minutes`, not both. Omit both (or `null`) for the default 90-day window.- **An event goal goes in `events`, never in `filters`.** An event object stuffed into `filters` is invisible to the conversion matcher and breaks the conversion picker. Without a goal the `…conversion` exit is a silent no-op. Server compiles the bytecode.## Pre-submit checklistdiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex b151bc6c1901..6226f53622dd 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -43857,7 +43857,14 @@ export namespace Schemas {/** Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]. */events?: HogFlowConversionEvent[];/**- * Conversion window in minutes after a person enters the workflow. null = no explicit window.+ * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both.+ * @maxLength 32+ * @nullable+ * @pattern ^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)[dhms]$+ */+ window?: string | null;+ /**+ * DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both.* @nullable*/window_minutes?: number | null;@@ -44097,7 +44104,7 @@ export namespace Schemas {readonly trigger: unknown;/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMasking | null;- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversion | null;/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*@@ -44563,7 +44570,7 @@ export namespace Schemas {readonly trigger: unknown;/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMasking | null;- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversion | null;/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*@@ -66427,7 +66434,7 @@ export namespace Schemas {readonly trigger?: unknown;/** Optional dedup/throttle on an already-matched trigger: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Without threshold: fire once per hash, then suppress repeats within ttl (hash '{person.id}' = once per person per ttl). With threshold N: fire once per N matches of the same hash — a sampler, the 1st then every Nth. Throttles an already-qualifying trigger; it doesn't decide who enters. Server compiles bytecode from hash; omit to disable. */trigger_masking?: HogFlowMasking | null;- /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */+ /** Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */conversion?: HogFlowConversion | null;/** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').*diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.tsindex 85e40290293a..05ef94567e97 100644--- a/services/mcp/src/generated/workflows/api.ts+++ b/services/mcp/src/generated/workflows/api.ts@@ -61,6 +61,9 @@ export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsCreateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsCreateBodyConversionOneWindowMax = 32++export const hogFlowsCreateBodyConversionOneWindowRegExp = new RegExp('^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$')export const hogFlowsCreateBodyEmailSendingRateLimitOneCountMax = 1000000export const hogFlowsCreateBodyActionsItemIdMax = 200@@ -161,11 +164,19 @@ export const HogFlowsCreateBody = () => zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsCreateBodyConversionOneWindowMax)+ .regex(hogFlowsCreateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -176,7 +187,7 @@ export const HogFlowsCreateBody = () => zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([@@ -471,6 +482,11 @@ export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000export const hogFlowsPartialUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`+export const hogFlowsPartialUpdateBodyConversionOneWindowMax = 32++export const hogFlowsPartialUpdateBodyConversionOneWindowRegExp = new RegExp(+ '^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$'+)export const hogFlowsPartialUpdateBodyEmailSendingRateLimitOneCountMax = 1000000export const HogFlowsPartialUpdateBody = () => zod@@ -551,11 +567,19 @@ export const HogFlowsPartialUpdateBody = () => zod.describe("Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]."),+ window: zod+ .string()+ .max(hogFlowsPartialUpdateBodyConversionOneWindowMax)+ .regex(hogFlowsPartialUpdateBodyConversionOneWindowRegExp)+ .nullish()+ .describe(+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ ),window_minutes: zod.number().nullish().describe(- 'Conversion window in minutes after a person enters the workflow. null = no explicit window.'+ "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."),bytecode: zod.unknown()@@ -566,7 +590,7 @@ export const HogFlowsPartialUpdateBody = () => zod]).optional().describe(- 'Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'+ "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."),exit_condition: zod.enum([diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.jsonindex 9a402f0d468d..76759421171c 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json@@ -428,6 +428,19 @@},"type": "array"},+ "window": {+ "anyOf": [+ {+ "maxLength": 32,+ "pattern": "^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$",+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ },"window_minutes": {"anyOf": [{@@ -437,7 +450,7 @@"type": "null"}],- "description": "Conversion window in minutes after a person enters the workflow. null = no explicit window."+ "description": "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."}},"type": "object"@@ -446,7 +459,7 @@"type": "null"}],- "description": "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."+ "description": "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."},"description": {"default": "",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.jsonindex 651871157ba4..6337706fe44e 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json@@ -95,6 +95,19 @@},"type": "array"},+ "window": {+ "anyOf": [+ {+ "maxLength": 32,+ "pattern": "^(?:[0-9]+(?:\\.[0-9]+)?|\\.[0-9]+)[dhms]$",+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Maximum '365d'. Omit it to use the default window. Set this or 'window_minutes', not both."+ },"window_minutes": {"anyOf": [{@@ -104,7 +117,7 @@"type": "null"}],- "description": "Conversion window in minutes after a person enters the workflow. null = no explicit window."+ "description": "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default window. Set this or 'window', not both."}},"type": "object"@@ -113,7 +126,7 @@"type": "null"}],- "description": "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window_minutes: minutes after entry. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."+ "description": "Conversion goal. filters: ARRAY of property conditions [{key, value, operator, type: event|person|group}]; events: event-based goals [{filters: {events: [...]}}]; window: how long after entry a conversion counts, as a duration string such as '7d' or '12h', maximum '365d' (window_minutes is the deprecated integer form, in MINUTES not seconds); set one, not both. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."},"description": {"description": "Optional description.",