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(workflows): remove the deprecated conversion window_minutes field (#104871)

Daniel Marchuk2e1d8e1ccac2
diff --git a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
index b92b50186a82..79030d0b0468 100644
--- a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
@@ -546,7 +546,6 @@ describe('CdpHogflowSubscriptionMatcherConsumer', () => {
id: 'flow-1',
exit_condition: 'exit_on_conversion',
conversion: {
- window_minutes: null,
filters: {},
bytecode: [],
events: [
diff --git a/nodejs/src/cdp/schema/hogflow.test.ts b/nodejs/src/cdp/schema/hogflow.test.ts
index d4027fa8c6f2..409af74b6dac 100644
--- a/nodejs/src/cdp/schema/hogflow.test.ts
+++ b/nodejs/src/cdp/schema/hogflow.test.ts
@@ -87,7 +87,7 @@ describe('hogflow schema', () => {
const parsed = HogFlowSchema.parse({
...baseHogFlow,
conversion: {
- window_minutes: 60,
+ window: '1h',
filters: {},
bytecode: [],
events: [{ filters: { bytecode: ['_H', 1] }, name: 'subscribed' }],
@@ -99,21 +99,20 @@ describe('hogflow schema', () => {
it('accepts a conversion goal without an events list (optional)', () => {
const parsed = HogFlowSchema.parse({
...baseHogFlow,
- conversion: { window_minutes: 60, filters: {}, bytecode: [] },
+ conversion: { window: '1h', filters: {}, bytecode: [] },
})
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.
+ it('still parses a row that carries the removed legacy field', () => {
+ // Rows keep window_minutes until the backfill strips it. Zod drops an unknown key, so the
+ // flow must still parse; failing here would stop those workflows running altogether.
const parsed = HogFlowSchema.parse({
...baseHogFlow,
- conversion: { window: '60d', filters: {}, bytecode: [] },
+ conversion: { window: '60d', window_minutes: 604800, filters: {}, bytecode: [] },
})
expect(parsed.conversion?.window).toBe('60d')
- expect(parsed.conversion?.window_minutes).toBeUndefined()
+ expect(parsed.conversion).not.toHaveProperty('window_minutes')
})
})
})
diff --git a/nodejs/src/cdp/schema/hogflow.ts b/nodejs/src/cdp/schema/hogflow.ts
index 70ffd386a734..083201c94e96 100644
--- a/nodejs/src/cdp/schema/hogflow.ts
+++ b/nodejs/src/cdp/schema/hogflow.ts
@@ -313,10 +313,6 @@ export const HogFlowSchema = z.object({
.object({
// 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: z
diff --git a/nodejs/src/cdp/services/hogflows/conversion-watcher.ts b/nodejs/src/cdp/services/hogflows/conversion-watcher.ts
index 3489493f5d8e..ccdf1b4b4988 100644
--- a/nodejs/src/cdp/services/hogflows/conversion-watcher.ts
+++ b/nodejs/src/cdp/services/hogflows/conversion-watcher.ts
@@ -72,13 +72,6 @@ export const DEFAULT_CONVERSION_WINDOW_MINUTES = 90 * 24 * 60
// 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.
const counterConversionWindowClamped = new Counter({
@@ -106,11 +99,7 @@ function conversionWindowMinutes(hogFlow: HogFlow): number {
// 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
- }
- return clampWindow(legacyMinutes, MAX_LEGACY_WINDOW_MINUTES)
+ return DEFAULT_CONVERSION_WINDOW_MINUTES
}
function clampWindow(minutes: number, ceiling: number): number {
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts
index 061dc029dd19..630a31516d3a 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-conversion-watcher.test.ts
@@ -7,7 +7,6 @@ import { CyclotronJobInvocationHogFlow } from '../../types'
import {
DEFAULT_CONVERSION_WINDOW_MINUTES,
MAX_CONVERSION_WINDOW_MINUTES,
- MAX_LEGACY_WINDOW_MINUTES,
buildConversionWatcher,
} from './conversion-watcher'
@@ -18,15 +17,13 @@ describe('buildConversionWatcher', () => {
const propertyGoal = {
filters: [{ key: '$browser', type: 'person', value: ['Chrome'], operator: 'exact' }],
bytecode: propertyBytecode,
- window_minutes: null,
}
const eventGoal = {
filters: [],
bytecode: [],
- window_minutes: null,
events: [{ filters: { events: [{ id: 'signed_up' }], bytecode: eventBytecode } }],
}
- const noGoal = { filters: [], bytecode: [], window_minutes: null }
+ const noGoal = { filters: [], bytecode: [] }
const invocationFor = (conversion: any, flowOverrides: Partial<HogFlow> = {}): CyclotronJobInvocationHogFlow => {
const hogFlow = { id: 'flow-1', team_id: 1, version: 3, conversion, ...flowOverrides } as unknown as HogFlow
@@ -69,36 +66,40 @@ describe('buildConversionWatcher', () => {
const emptyTarget = {
filters: [],
bytecode: [],
- window_minutes: null,
events: [{ filters: { bytecode: [1] } }],
}
expect(buildConversionWatcher(invocationFor(emptyTarget))).toBeNull()
})
- it.each([
- ['no configured window', null, DEFAULT_CONVERSION_WINDOW_MINUTES],
- ['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.
+ it('expires after the default when no window is configured', () => {
+ // Treating an absent window as "forever" would leave rows the expiry sweep can never reach.
const before = Date.now()
- const watcher = buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: windowMinutes }))
+ const watcher = buildConversionWatcher(invocationFor(propertyGoal))
// Measured from `before`, so the window is at least the expected value and at most a
// fraction of a minute more.
const minutes = (watcher!.expires_at.getTime() - before) / 60_000
- expect(minutes).toBeGreaterThanOrEqual(expectedMinutes)
- expect(minutes).toBeLessThan(expectedMinutes + 1)
+ expect(minutes).toBeGreaterThanOrEqual(DEFAULT_CONVERSION_WINDOW_MINUTES)
+ expect(minutes).toBeLessThan(DEFAULT_CONVERSION_WINDOW_MINUTES + 1)
+ })
+
+ it('ignores a row still carrying the removed legacy field', () => {
+ // Rows keep window_minutes until the backfill strips it. It must read as no window at all,
+ // not as a window of its own, or those flows would measure something different again.
+ const before = Date.now()
+ const watcher = buildConversionWatcher(
+ invocationFor({ ...propertyGoal, window_minutes: 60 } as unknown as typeof propertyGoal)
+ )
+
+ const minutes = (watcher!.expires_at.getTime() - before) / 60_000
+ expect(minutes).toBeGreaterThanOrEqual(DEFAULT_CONVERSION_WINDOW_MINUTES)
})
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 }))
@@ -116,10 +117,10 @@ describe('buildConversionWatcher', () => {
const before = await clamped()
- buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_LEGACY_WINDOW_MINUTES + 1 }))
+ buildConversionWatcher(invocationFor({ ...propertyGoal, window: '400d' }))
expect(await clamped()).toBe(before + 1)
- buildConversionWatcher(invocationFor({ ...propertyGoal, window_minutes: MAX_LEGACY_WINDOW_MINUTES }))
+ buildConversionWatcher(invocationFor({ ...propertyGoal, window: '365d' }))
expect(await clamped()).toBe(before + 1)
})
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
index 0c469e29e279..7ef5817d7ef0 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
@@ -1436,7 +1436,6 @@ describe('Hogflow Executor', () => {
},
],
bytecode: ['_H', 1, 32, 'Chrome', 32, '$browser', 32, 'properties', 32, 'person', 1, 3, 11],
- window_minutes: null,
}
// Person does not match conversion filters yet
@@ -1551,7 +1550,6 @@ describe('Hogflow Executor', () => {
},
],
bytecode: ['_H', 1, 32, 'Chrome', 32, '$browser', 32, 'properties', 32, 'person', 1, 3, 11],
- window_minutes: null,
}
// Person does not match conversion filters yet
@@ -1621,7 +1619,6 @@ describe('Hogflow Executor', () => {
hogFlow.conversion = {
filters: [{ key: '$browser', type: 'person', value: ['Chrome'], operator: 'exact' }],
bytecode: ['_H', 1, 32, 'Chrome', 32, '$browser', 32, 'properties', 32, 'person', 1, 3, 11],
- window_minutes: null,
} as any
const invocation = createExampleHogFlowInvocation(
@@ -1645,7 +1642,6 @@ describe('Hogflow Executor', () => {
hogFlow.conversion = {
filters: [],
bytecode: [],
- window_minutes: null,
events: [{ filters: { bytecode: ['_H', 1, 29] } }],
}
diff --git a/nodejs/src/cdp/workflows-e2e.serial.test.ts b/nodejs/src/cdp/workflows-e2e.serial.test.ts
index 85ddce2ebe21..e85c445dbeb6 100644
--- a/nodejs/src/cdp/workflows-e2e.serial.test.ts
+++ b/nodejs/src/cdp/workflows-e2e.serial.test.ts
@@ -1345,7 +1345,6 @@ describe('Workflows E2E (postgres-v2)', () => {
{
exitCondition: 'exit_only_at_end',
conversion: {
- window_minutes: 60,
filters: [],
bytecode: [],
events: [eventNameFilter('conversion_event')],
@@ -1383,7 +1382,6 @@ describe('Workflows E2E (postgres-v2)', () => {
{
exitCondition: 'exit_on_conversion',
conversion: {
- window_minutes: 60,
filters: [],
bytecode: [],
events: [eventNameFilter('conversion_event')],
@@ -1857,7 +1855,6 @@ describe('Workflows E2E (postgres-v2)', () => {
{
exitCondition: 'exit_only_at_end',
conversion: {
- window_minutes: 60,
filters: [],
bytecode: [],
events: [eventNameFilter('conversion_event')],
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 777109d2eb5c..0b6cb8011d87 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -2013,7 +2013,6 @@ class HogFlowConversionEventSerializer(serializers.Serializer):
MAX_CONVERSION_WINDOW_MINUTES = 365 * 24 * 60
-MAX_LEGACY_WINDOW_MINUTES = 90 * 24 * 60
class HogFlowConversionSerializer(serializers.Serializer):
@@ -2041,17 +2040,7 @@ class HogFlowConversionSerializer(serializers.Serializer):
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. Must be longer than zero, "
- "and at most '365d'. Omit it to use the default of 90 days. "
- "Set this or 'window_minutes', not both."
- ),
- )
- window_minutes = serializers.IntegerField(
- required=False,
- allow_null=True,
- 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 of 90 days. "
- "Set this or 'window', not both."
+ "and at most '365d'. Omit it to use the default of 90 days."
),
)
# Not DRF read_only: drf-spectacular puts readOnly fields in the component's `required` list
@@ -2074,36 +2063,6 @@ class HogFlowConversionSerializer(serializers.Serializer):
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:
@@ -2958,7 +2917,7 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
"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. "
+ "maximum '365d'. "
"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.py
index 2a87c7e33e1c..cb430e23cc30 100644
--- a/products/workflows/backend/api/test/test_hog_flow.py
+++ b/products/workflows/backend/api/test/test_hog_flow.py
@@ -1381,7 +1381,6 @@ class TestHogFlowAPI(APIBaseTest):
"operator": "exact",
}
],
- "window_minutes": None,
}
response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
@@ -1399,7 +1398,7 @@ class TestHogFlowAPI(APIBaseTest):
flow = HogFlow.objects.get(pk=response.json()["id"])
flow_conversion = flow.conversion
assert flow_conversion is not None
- assert flow_conversion["window_minutes"] is None
+ assert "window_minutes" not in flow_conversion
assert flow_conversion["filters"][0] == {
"key": "$browser",
"type": "person",
@@ -1422,7 +1421,7 @@ class TestHogFlowAPI(APIBaseTest):
{"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
)
hog_flow["status"] = "active"
- hog_flow["conversion"] = {"filters": event_obj, "window_minutes": None}
+ hog_flow["conversion"] = {"filters": event_obj}
response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
assert response.status_code == 201, response.json()
@@ -1442,7 +1441,7 @@ class TestHogFlowAPI(APIBaseTest):
{"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
)
hog_flow["status"] = "active"
- hog_flow["conversion"] = {"filters": [], "window_minutes": 60, "bytecode": ["_H", 1, 32, "injected"]}
+ hog_flow["conversion"] = {"filters": [], "bytecode": ["_H", 1, 32, "injected"]}
response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
assert response.status_code == 201, response.json()
@@ -1458,11 +1457,9 @@ class TestHogFlowAPI(APIBaseTest):
("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),
+ # The field is gone, so DRF drops it like any unknown key rather than rejecting the write.
+ ("removed legacy field", {"window_minutes": 60}, 201),
+ ("removed legacy field alongside a window", {"window": "7d", "window_minutes": 60}, 201),
# 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.
@@ -1483,18 +1480,9 @@ class TestHogFlowAPI(APIBaseTest):
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):
+ def test_hog_flow_conversion_reads_back_a_row_that_still_carries_the_removed_field(self):
+ # Rows written before the field was removed keep the key until the backfill strips it. Reading
+ # one must not fail, or every such workflow breaks between the deploy and that run.
hog_flow, _ = self._create_hog_flow_with_action(
{"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
)
@@ -1502,25 +1490,21 @@ class TestHogFlowAPI(APIBaseTest):
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
+ read_back = self.client.get(f"/api/projects/{self.team.id}/hog_flows/{flow_id}")
+ assert read_back.status_code == 200, read_back.json()
+ assert read_back.json()["conversion"]["window_minutes"] == 604800
- # Changing the stored value to a different over-ceiling value is still refused.
- changed = self.client.patch(
+ # And an unrelated edit still succeeds; the key is simply not carried forward.
+ renamed = self.client.patch(
f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- {"conversion": {"filters": [], "window_minutes": 700000}},
+ {"name": "Renamed", "conversion": {"filters": [], "window": "7d"}},
)
- assert changed.status_code == 400, changed.json()
+ assert renamed.status_code == 200, renamed.json()
+ assert "window_minutes" not in renamed.json()["conversion"]
def test_hog_flow_conversion_filters_compiles_bytecode_on_update(self):
expected_conversion_bytecode = [
@@ -1563,7 +1547,6 @@ class TestHogFlowAPI(APIBaseTest):
"operator": "exact",
}
],
- "window_minutes": None,
}
},
)
@@ -1581,7 +1564,7 @@ class TestHogFlowAPI(APIBaseTest):
flow = HogFlow.objects.get(pk=flow_id)
flow_conversion = flow.conversion
assert flow_conversion is not None
- assert flow_conversion["window_minutes"] is None
+ assert "window_minutes" not in flow_conversion
assert flow_conversion["filters"][0] == {
"key": "$browser",
"type": "person",
@@ -2074,7 +2057,6 @@ class TestHogFlowAPI(APIBaseTest):
"status": "active",
"actions": [trigger_action],
"conversion": {
- "window_minutes": 60,
"events": [
{
"filters": {
@@ -2130,7 +2112,6 @@ class TestHogFlowAPI(APIBaseTest):
"status": "active",
"actions": [trigger_action],
"conversion": {
- "window_minutes": 60,
"events": [
{"filters": {"events": []}},
{"filters": {"actions": [{"id": str(action.id), "type": "actions", "order": 0}], "events": []}},
@@ -2167,7 +2148,6 @@ class TestHogFlowAPI(APIBaseTest):
# No status => draft, so invalid filters are tolerated rather than rejected.
"actions": [trigger_action],
"conversion": {
- "window_minutes": 60,
"events": [
{
"filters": {
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.py
index 920d9f3e4e3e..e3d4ed9a5793 100644
--- a/products/workflows/backend/management/commands/migrate_conversion_window_to_duration.py
+++ b/products/workflows/backend/management/commands/migrate_conversion_window_to_duration.py
@@ -6,19 +6,22 @@ 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.hog_flow_template import HogFlowTemplate
from products.workflows.backend.models.hog_flow_revision import HogFlowRevision
from products.workflows.backend.services.timing_reschedule import parse_delay_duration_seconds
+from products.workflows.backend.utils.durations import duration_minutes
MINUTES_PER_DAY = 1440
+# The ceiling the matcher clamped a legacy value to, kept here because nothing else needs it now.
+MAX_LEGACY_WINDOW_MINUTES = 90 * 24 * 60
@frozen
class RewrittenWindow:
"""A conversion whose window_minutes has been respelled as a duration string."""
- conversion: dict
+ conversion: dict[str, Any]
window: str
minutes: int
@@ -45,13 +48,28 @@ class Command(BaseCommand):
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)")
+ parser.add_argument(
+ "--strip-inert",
+ action="store_true",
+ help=(
+ "Delete window_minutes wherever it cannot change what a workflow measures: null, zero, a "
+ "row that already carries window, or a value above the legacy ceiling the matcher clamped "
+ "anyway. Refuses to touch a row the convert pass would still convert, so run without this "
+ "flag first."
+ ),
+ )
def handle(self, *args: Any, **options: Any) -> None:
live_run = options.get("live_run", False)
team_id = options.get("team_id")
+ strip_inert = options.get("strip_inert", False)
mode = "LIVE RUN" if live_run else "DRY RUN"
self.stdout.write(f"Starting migrate_conversion_window_to_duration ({mode})")
+ if strip_inert:
+ self.strip_inert(live_run, team_id, mode)
+ return
+
flows = HogFlow.objects.filter(conversion__isnull=False)
if team_id:
flows = flows.filter(team_id=team_id)
@@ -63,8 +81,11 @@ class Command(BaseCommand):
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:
+ # A row that already carries a usable window was written by a client that knows the new
+ # field. Anything the worker cannot read leaves the legacy value as what it measures.
+ if has_usable_window(conversion):
+ continue
+ if not isinstance(minutes, int) or isinstance(minutes, bool) or minutes <= 0:
continue
if minutes > MAX_LEGACY_WINDOW_MINUTES:
@@ -96,12 +117,128 @@ class Command(BaseCommand):
drafts = drafts_with_rows + self.convert_drafts(live_run, team_id)
revisions = self.convert_revisions(live_run, team_id)
+ templates = self.convert_templates(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)"))
+ self.stdout.write(
+ self.style.SUCCESS(
+ f" plus {drafts} draft(s), {revisions} revision snapshot(s) and {templates} template(s)"
+ )
+ )
+
+ def strip_inert(self, live_run: bool, team_id: int | None, mode: str) -> None:
+ """Delete the key everywhere it is dead weight, so nothing is left to read or restore."""
+ flows = HogFlow.objects.filter(conversion__isnull=False)
+ drafted = HogFlow.objects.filter(draft__isnull=False)
+ if team_id:
+ flows = flows.filter(team_id=team_id)
+ drafted = drafted.filter(team_id=team_id)
+ self.stdout.write(f"Filtering to team_id={team_id}")
+
+ verb = "Stripping" if live_run else "Would strip"
+ still_convertible = 0
+ flows_stripped = 0
+ for flow in flows.iterator():
+ if converted_conversion(flow.conversion) is not None:
+ still_convertible += 1
+ continue
+ if stripped_conversion(flow.conversion) is None:
+ continue
+ value = (flow.conversion or {}).get("window_minutes")
+ self.stdout.write(f" {verb} flow id={flow.id} team_id={flow.team_id}: window_minutes={value!r}")
+ if live_run:
+ with transaction.atomic():
+ locked = HogFlow.objects.select_for_update().get(pk=flow.pk)
+ fresh = stripped_conversion(locked.conversion)
+ if fresh is None:
+ continue
+ HogFlow.objects.filter(pk=flow.pk).update(conversion=fresh)
+ flows_stripped += 1
+
+ drafts_stripped = 0
+ for flow in drafted.iterator():
+ draft = flow.draft
+ if not isinstance(draft, dict):
+ continue
+ if converted_conversion(draft.get("conversion")) is not None:
+ # Publishing this draft later would drop a window the convert pass could still save.
+ still_convertible += 1
+ continue
+ if stripped_conversion(draft.get("conversion")) is None:
+ continue
+ self.stdout.write(f" {verb} draft on flow id={flow.id} team_id={flow.team_id}")
+ 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 = stripped_conversion(locked_draft.get("conversion"))
+ if fresh is None:
+ continue
+ HogFlow.objects.filter(pk=flow.pk).update(draft={**locked_draft, "conversion": fresh})
+ drafts_stripped += 1
+
+ revisions = HogFlowRevision.objects.for_team(team_id) if team_id else HogFlowRevision.objects.unscoped().all()
+ revisions_stripped = 0
+ for revision in revisions.iterator():
+ content = revision.content
+ if not isinstance(content, dict):
+ continue
+ if converted_conversion(content.get("conversion")) is not None:
+ # Restoring this snapshot later would drop a window the convert pass could still save.
+ still_convertible += 1
+ continue
+ fresh = stripped_conversion(content.get("conversion"))
+ if fresh is None:
+ continue
+ self.stdout.write(f" {verb} revision id={revision.id} flow={revision.hog_flow_id} v{revision.version}")
+ if live_run:
+ HogFlowRevision.objects.for_team(revision.team_id).filter(pk=revision.pk).update(
+ content={**content, "conversion": fresh}
+ )
+ revisions_stripped += 1
+
+ templates = HogFlowTemplate.objects.filter(conversion__isnull=False)
+ if team_id:
+ templates = templates.filter(team_id=team_id)
+ templates_stripped = 0
+ for template in templates.iterator():
+ if converted_conversion(template.conversion) is not None:
+ # A workflow created from this template would get the default window instead of its own.
+ still_convertible += 1
+ continue
+ if stripped_conversion(template.conversion) is None:
+ continue
+ self.stdout.write(f" {verb} template id={template.id} team_id={template.team_id}")
+ if live_run:
+ with transaction.atomic():
+ locked_template = HogFlowTemplate.objects.select_for_update().get(pk=template.pk)
+ fresh = stripped_conversion(locked_template.conversion)
+ if fresh is None:
+ continue
+ HogFlowTemplate.objects.filter(pk=template.pk).update(conversion=fresh)
+ templates_stripped += 1
+
+ if still_convertible:
+ self.stdout.write(
+ self.style.WARNING(
+ f" {still_convertible} flow(s), draft(s), snapshot(s) or template(s) still carry a "
+ "convertible value and were left alone. Run the command without --strip-inert first, "
+ "then repeat this pass."
+ )
+ )
+ done = "stripped" if live_run else "to strip"
+ self.stdout.write(self.style.SUCCESS(f"Completed ({mode}): {flows_stripped} flow(s) {done}"))
+ self.stdout.write(
+ self.style.SUCCESS(
+ f" plus {drafts_stripped} draft(s), {revisions_stripped} revision snapshot(s) and "
+ f"{templates_stripped} template(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
@@ -163,6 +300,32 @@ class Command(BaseCommand):
count += 1
return count
+ def convert_templates(self, live_run: bool, team_id: int | None) -> int:
+ """Templates a new workflow copies its conversion from. The flow API drops window_minutes, so a
+ template left on the old field gives every workflow created from it the default window instead."""
+ templates = HogFlowTemplate.objects.filter(conversion__isnull=False)
+ if team_id:
+ templates = templates.filter(team_id=team_id)
+
+ count = 0
+ for template in templates.iterator():
+ rewritten = converted_conversion(template.conversion)
+ if rewritten is None:
+ continue
+ self.stdout.write(
+ f" {'Converting' if live_run else 'Would convert'} template id={template.id} "
+ f"team_id={template.team_id}: window={rewritten.window}"
+ )
+ if live_run:
+ with transaction.atomic():
+ locked = HogFlowTemplate.objects.select_for_update().get(pk=template.pk)
+ fresh = converted_conversion(locked.conversion)
+ if fresh is None:
+ continue
+ HogFlowTemplate.objects.filter(pk=template.pk).update(conversion=fresh.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
@@ -211,13 +374,42 @@ class Command(BaseCommand):
)
+def stripped_conversion(conversion: object) -> dict[str, Any] | None:
+ """The same conversion without window_minutes, or None when the key must stay or is already gone.
+
+ A row the convert pass would still rewrite is left alone: dropping its value there would move the
+ window it measures, which is the one thing this whole change must not do."""
+ if not isinstance(conversion, dict) or "window_minutes" not in conversion:
+ return None
+ if converted_conversion(conversion) is not None:
+ return None
+ return {k: v for k, v in conversion.items() if k != "window_minutes"}
+
+
+def has_usable_window(conversion: dict[str, Any]) -> bool:
+ """True when conversion.window holds a window the matcher can actually read.
+
+ One rule for both passes, and the matcher's own: it honors `window` only when the shared duration
+ grammar parses it to a positive value (nodejs/src/cdp/services/hogflows/conversion-watcher.ts), so
+ a missing, non-string, unparseable or non-positive one leaves the legacy value as what the row
+ measures. Treating any of those as migrated would let the strip pass delete the only readable
+ window, which is the one outcome this change must not produce."""
+ window = conversion.get("window")
+ if not isinstance(window, str):
+ return False
+ minutes = duration_minutes(window)
+ return minutes is not None and minutes > 0
+
+
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:
+ if has_usable_window(conversion):
+ return None
+ if not isinstance(minutes, int) or isinstance(minutes, bool) or minutes <= 0:
return None
if minutes > MAX_LEGACY_WINDOW_MINUTES:
return None
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.py
index 7f89e1cf7c02..342da82304f4 100644
--- a/products/workflows/backend/test/test_migrate_conversion_window_to_duration.py
+++ b/products/workflows/backend/test/test_migrate_conversion_window_to_duration.py
@@ -1,3 +1,6 @@
+from io import StringIO
+from typing import Any
+
from posthog.test.base import BaseTest
from django.core.management import call_command
@@ -8,10 +11,11 @@ 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.hog_flow_template import HogFlowTemplate
from products.workflows.backend.models.hog_flow_revision import HogFlowRevision
-def _flow(team: Team, name: str, conversion: dict) -> HogFlow:
+def _flow(team: Team, name: str, conversion: dict[str, Any]) -> HogFlow:
return HogFlow.objects.create(
team=team,
name=name,
@@ -24,6 +28,10 @@ def _flow(team: Team, name: str, conversion: dict) -> HogFlow:
)
+def _template(team: Team, conversion: dict[str, Any]) -> HogFlowTemplate:
+ return HogFlowTemplate.objects.create(team=team, name="template", scope="team", conversion=conversion)
+
+
class TestMigrateConversionWindowToDuration(BaseTest):
@parameterized.expand(
[
@@ -32,7 +40,7 @@ class TestMigrateConversionWindowToDuration(BaseTest):
("neither", 90, "90m"),
]
)
- def test_converts_a_window_the_matcher_already_honors(self, _name, minutes, expected):
+ def test_converts_a_window_the_matcher_already_honors(self, _name: str, minutes: int, expected: str) -> None:
flow = _flow(self.team, "convertible", {"filters": [], "window_minutes": minutes})
call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)
@@ -41,7 +49,7 @@ class TestMigrateConversionWindowToDuration(BaseTest):
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):
+ def test_leaves_a_window_above_the_legacy_ceiling_alone(self, _name: str, minutes: int) -> None:
# 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})
@@ -51,7 +59,28 @@ class TestMigrateConversionWindowToDuration(BaseTest):
flow.refresh_from_db()
assert flow.conversion == {"filters": [], "window_minutes": minutes}
- def test_dry_run_writes_nothing(self):
+ @parameterized.expand(
+ [
+ ("a number", 7),
+ ("null", None),
+ ("an empty string", ""),
+ ("a string the duration grammar rejects", "1 week"),
+ ("an ISO-8601 duration", "P7D"),
+ ("a duration of zero", "0d"),
+ ]
+ )
+ def test_converts_over_a_window_that_is_not_a_usable_duration(self, _name: str, window: object) -> None:
+ # The matcher honors `window` only when the shared grammar parses it to a positive value, so
+ # each of these already falls through to the legacy value. Skipping the row here would let the
+ # strip pass delete the only readable window.
+ flow = _flow(self.team, "junk window", {"filters": [], "window": window, "window_minutes": 60})
+
+ 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"}
+
+ def test_dry_run_writes_nothing(self) -> None:
flow = _flow(self.team, "untouched", {"filters": [], "window_minutes": 60})
call_command("migrate_conversion_window_to_duration", team_id=self.team.pk)
@@ -59,7 +88,7 @@ class TestMigrateConversionWindowToDuration(BaseTest):
flow.refresh_from_db()
assert flow.conversion == {"filters": [], "window_minutes": 60}
- def test_leaves_a_flow_that_already_has_a_window_alone(self):
+ def test_leaves_a_flow_that_already_has_a_window_alone(self) -> None:
flow = _flow(self.team, "already migrated", {"filters": [], "window": "7d"})
call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)
@@ -67,7 +96,7 @@ class TestMigrateConversionWindowToDuration(BaseTest):
flow.refresh_from_db()
assert flow.conversion == {"filters": [], "window": "7d"}
- def test_converts_the_draft_copy_of_a_conversion(self):
+ def test_converts_the_draft_copy_of_a_conversion(self) -> None:
# 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})
@@ -80,7 +109,7 @@ class TestMigrateConversionWindowToDuration(BaseTest):
assert flow.conversion == {"filters": [], "window": "1h"}
assert flow.draft == {"conversion": {"filters": [], "window": "1d"}}
- def test_converts_a_revision_snapshot(self):
+ def test_converts_a_revision_snapshot(self) -> None:
# 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):
@@ -97,7 +126,17 @@ class TestMigrateConversionWindowToDuration(BaseTest):
revision.refresh_from_db()
assert revision.content == {"conversion": {"filters": [], "window": "1d"}}
- def test_leaves_an_ambiguous_revision_snapshot_alone(self):
+ def test_converts_a_template(self) -> None:
+ # A new workflow copies the template's conversion, and the flow API drops window_minutes, so an
+ # unmigrated template hands every workflow built from it the default window instead of its own.
+ template = _template(self.team, {"filters": [], "window_minutes": 2880})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True)
+
+ template.refresh_from_db()
+ assert template.conversion == {"filters": [], "window": "2d"}
+
+ def test_leaves_an_ambiguous_revision_snapshot_alone(self) -> None:
flow = _flow(self.team, "ambiguous revision", {"filters": [], "window": "7d"})
with team_scope(self.team.id):
revision = HogFlowRevision.objects.create(
@@ -112,3 +151,117 @@ class TestMigrateConversionWindowToDuration(BaseTest):
with team_scope(self.team.id):
revision.refresh_from_db()
assert revision.content == {"conversion": {"filters": [], "window_minutes": 604800}}
+
+
+class TestStripInert(BaseTest):
+ @parameterized.expand(
+ [
+ ("null", None),
+ ("zero", 0),
+ ("above the legacy ceiling, which the matcher clamped anyway", 604800),
+ ]
+ )
+ def test_strips_a_value_that_cannot_change_what_the_workflow_measures(
+ self, _name: str, minutes: int | None
+ ) -> None:
+ flow = _flow(self.team, "inert", {"filters": [], "window_minutes": minutes})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True, strip_inert=True)
+
+ flow.refresh_from_db()
+ assert flow.conversion == {"filters": []}
+
+ def test_refuses_a_row_the_convert_pass_would_still_convert(self) -> None:
+ # Stripping here would move the window from two days to the default, which is the one outcome
+ # this whole change must not produce. The operator is told to run the convert pass first.
+ flow = _flow(self.team, "convertible", {"filters": [], "window_minutes": 2880})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True, strip_inert=True)
+
+ flow.refresh_from_db()
+ assert flow.conversion == {"filters": [], "window_minutes": 2880}
+
+ def test_strips_alongside_an_existing_window_without_touching_it(self) -> None:
+ flow = _flow(self.team, "both", {"filters": [], "window": "7d", "window_minutes": 60})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True, strip_inert=True)
+
+ flow.refresh_from_db()
+ assert flow.conversion == {"filters": [], "window": "7d"}
+
+ @parameterized.expand([("a string the grammar rejects", "1 week"), ("a duration of zero", "0d")])
+ def test_refuses_a_row_whose_window_the_matcher_cannot_read(self, _name: str, window: str) -> None:
+ # A window the shared grammar cannot parse to a positive value is not a window: the legacy
+ # value is what the row measures today, so the convert pass still owns this row.
+ flow = _flow(self.team, "unreadable window", {"filters": [], "window": window, "window_minutes": 2880})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True, strip_inert=True)
+
+ flow.refresh_from_db()
+ assert flow.conversion == {"filters": [], "window": window, "window_minutes": 2880}
+
+ def test_refuses_a_convertible_draft_snapshot_or_template_and_says_so(self) -> None:
+ # A convertible value hiding in a draft, a snapshot or a template is not inert: publishing,
+ # restoring or building from it after the field is gone drops the window. Skipping it silently
+ # would report a clean sweep.
+ flow = _flow(self.team, "clean live row", {"filters": []})
+ flow.draft = {"conversion": {"filters": [], "window_minutes": 2880}}
+ flow.save()
+ with team_scope(self.team.pk):
+ revision = HogFlowRevision.objects.create(
+ team=self.team,
+ hog_flow=flow,
+ version=1,
+ content={"conversion": {"filters": [], "window_minutes": 1440}},
+ )
+ template = _template(self.team, {"filters": [], "window_minutes": 60})
+
+ out = StringIO()
+ call_command(
+ "migrate_conversion_window_to_duration",
+ team_id=self.team.pk,
+ live_run=True,
+ strip_inert=True,
+ stdout=out,
+ )
+
+ flow.refresh_from_db()
+ revision.refresh_from_db()
+ template.refresh_from_db()
+ assert flow.draft == {"conversion": {"filters": [], "window_minutes": 2880}}
+ assert revision.content == {"conversion": {"filters": [], "window_minutes": 1440}}
+ assert template.conversion == {"filters": [], "window_minutes": 60}
+ assert "3 flow(s), draft(s), snapshot(s) or template(s) still carry a convertible value" in out.getvalue()
+
+ def test_strips_drafts_revision_snapshots_and_templates(self) -> None:
+ # A snapshot or a template that keeps the key puts it back the moment someone restores that
+ # version or builds a workflow from it.
+ flow = _flow(self.team, "with draft", {"filters": [], "window_minutes": 0})
+ flow.draft = {"conversion": {"filters": [], "window_minutes": None}}
+ flow.save()
+ with team_scope(self.team.pk):
+ revision = HogFlowRevision.objects.create(
+ team=self.team,
+ hog_flow=flow,
+ version=1,
+ content={"conversion": {"filters": [], "window_minutes": 0}},
+ )
+ template = _template(self.team, {"filters": [], "window_minutes": None})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, live_run=True, strip_inert=True)
+
+ flow.refresh_from_db()
+ revision.refresh_from_db()
+ template.refresh_from_db()
+ assert flow.conversion == {"filters": []}
+ assert flow.draft == {"conversion": {"filters": []}}
+ assert revision.content == {"conversion": {"filters": []}}
+ assert template.conversion == {"filters": []}
+
+ def test_dry_run_writes_nothing(self) -> None:
+ flow = _flow(self.team, "inert", {"filters": [], "window_minutes": 0})
+
+ call_command("migrate_conversion_window_to_duration", team_id=self.team.pk, strip_inert=True)
+
+ flow.refresh_from_db()
+ assert flow.conversion == {"filters": [], "window_minutes": 0}
diff --git a/products/workflows/frontend/Workflows/WorkflowSceneHeader.test.tsx b/products/workflows/frontend/Workflows/WorkflowSceneHeader.test.tsx
index 1b6242fc0f36..1c06d4312cd6 100644
--- a/products/workflows/frontend/Workflows/WorkflowSceneHeader.test.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowSceneHeader.test.tsx
@@ -36,7 +36,7 @@ const ACTIVE_WITH_DRAFT: HogFlow = {
},
],
edges: [{ from: 'trigger_node', to: 'exit_node', type: 'continue' }],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'active',
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
index 480010451840..0f2928d41011 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
@@ -20,7 +20,7 @@ export const CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW: HogFlow = {
actions: [],
},
},
- conversion: { window_minutes: 10080, filters: [] },
+ conversion: { window: '7d', filters: [] },
exit_condition: 'exit_only_at_end',
variables: [
{ key: 'account_stage', type: 'string', label: 'Account stage', default: 'new' },
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index 4b2b1dbd4f0b..2f0b20877b29 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -901,7 +901,6 @@ export interface hogFlowEditorLogicActions {
| undefined
filters: any
window?: string | undefined
- window_minutes?: number | null | undefined
}
| undefined
created_at: string
@@ -1758,7 +1757,6 @@ export interface hogFlowEditorLogicActions {
| undefined
filters: any
window?: string | undefined
- window_minutes?: number | null | undefined
}
| undefined
created_at: string
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
index 8a938a4be67d..5a3c4b3eb290 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
@@ -52,7 +52,7 @@ const WORKFLOW_FIXTURE = {
},
],
edges: [{ from: 'trigger_node', to: 'exit_node', type: 'continue' }],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'draft',
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/ConversionGoalEditor.tsx b/products/workflows/frontend/Workflows/hogflows/steps/components/ConversionGoalEditor.tsx
index c5c3e4937c8f..b831e6a67fbd 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/ConversionGoalEditor.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/components/ConversionGoalEditor.tsx
@@ -11,7 +11,6 @@ import { HogFlowDuration, MAX_CONVERSION_WINDOW_FOR_DURATION_UNIT } from './HogF
// type and the generated HogFlowConversionApi type.
export interface ConversionGoalValue {
window?: string | null
- window_minutes?: number | null
filters?: any
events?: { filters?: any; name?: string }[]
bytecode?: unknown
@@ -25,27 +24,10 @@ export interface ConversionGoalEditorProps {
}
const DEFAULT_CONVERSION_WINDOW = '90d'
-// The worker measures a legacy window_minutes at most this long, so a longer stored value is shown
-// as what it actually measures rather than as a number the API would now reject.
-const LEGACY_CONVERSION_WINDOW_CEILING_MINUTES = 90 * 24 * 60
-
-function conversionWindowFromMinutes(minutes: number): string {
- const capped = Math.min(minutes, LEGACY_CONVERSION_WINDOW_CEILING_MINUTES)
- if (capped % (24 * 60) === 0) {
- return `${capped / (24 * 60)}d`
- }
- if (capped % 60 === 0) {
- return `${capped / 60}h`
- }
- return `${capped}m`
-}
export function ConversionGoalEditor({ conversion, onChange, pageKey }: ConversionGoalEditorProps): JSX.Element {
const conversionEventFilters = conversion?.events?.[0]?.filters ?? {}
- const legacyWindowMinutes = conversion?.window_minutes
- const conversionWindow =
- conversion?.window ??
- (legacyWindowMinutes ? conversionWindowFromMinutes(legacyWindowMinutes) : DEFAULT_CONVERSION_WINDOW)
+ const conversionWindow = conversion?.window ?? DEFAULT_CONVERSION_WINDOW
return (
<div className="flex flex-col gap-4">
@@ -94,10 +76,9 @@ export function ConversionGoalEditor({ conversion, onChange, pageKey }: Conversi
<HogFlowDuration
value={conversionWindow}
onChange={(next) => {
- // Dropping window_minutes keeps the two forms from arriving together, which
- // the API rejects. A cleared amount arrives as a bare unit such as "d", so
- // omitting window restores the default instead of failing the save.
- const { window_minutes, window, ...rest } = conversion ?? {}
+ // A cleared amount arrives as a bare unit such as "d", so omitting window
+ // restores the default instead of failing the save.
+ const { window, ...rest } = conversion ?? {}
onChange(/\d/.test(next) ? { ...rest, window: next } : rest)
}}
maxValueForUnit={MAX_CONVERSION_WINDOW_FOR_DURATION_UNIT}
diff --git a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx
index efb63a9a1bc2..3a506077fbca 100644
--- a/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/tree/HogFlowTreeEditor.stories.tsx
@@ -41,7 +41,7 @@ const COMPLEX_WORKFLOW: HogFlow = {
actions: [],
},
},
- conversion: { window_minutes: 10080, filters: [] },
+ conversion: { window: '7d', filters: [] },
exit_condition: 'exit_only_at_end',
variables: [
{ key: 'account_stage', type: 'string', label: 'Account stage', default: 'new' },
diff --git a/products/workflows/frontend/Workflows/hogflows/types.ts b/products/workflows/frontend/Workflows/hogflows/types.ts
index 53e62ee6ff93..601ff314e582 100644
--- a/products/workflows/frontend/Workflows/hogflows/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/types.ts
@@ -37,7 +37,6 @@ export const HogFlowSchema = z.object({
conversion: z
.object({
window: z.string().optional(),
- window_minutes: z.number().nullable().optional(),
filters: z.any(),
events: z
.array(
diff --git a/products/workflows/frontend/Workflows/templates/workflowTemplateLogic.test.ts b/products/workflows/frontend/Workflows/templates/workflowTemplateLogic.test.ts
index 19b895316ffe..f2f5c078625a 100644
--- a/products/workflows/frontend/Workflows/templates/workflowTemplateLogic.test.ts
+++ b/products/workflows/frontend/Workflows/templates/workflowTemplateLogic.test.ts
@@ -102,7 +102,7 @@ describe('workflowTemplateLogic', () => {
updated_at: '2024-01-02T00:00:00Z',
actions: [],
edges: [],
- conversion: { window_minutes: 0, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
}
@@ -147,7 +147,7 @@ describe('workflowTemplateLogic', () => {
updated_at: '2024-01-02T00:00:00Z',
actions: [],
edges: [],
- conversion: { window_minutes: 0, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
}
@@ -234,7 +234,7 @@ describe('workflowTemplateLogic', () => {
},
],
edges: [{ from: 'trigger_node', to: 'function-action-1', type: 'continue' }],
- conversion: { window_minutes: 0, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
}
}
@@ -426,7 +426,7 @@ describe('workflowTemplateLogic', () => {
},
],
edges: [],
- conversion: { window_minutes: 0, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
})
diff --git a/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts b/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts
index ff4cfed76676..7603d2d2d024 100644
--- a/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts
+++ b/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts
@@ -34,7 +34,7 @@ const makeWorkflow = (overrides: Partial<HogFlow> = {}): HogFlow => ({
},
],
edges: [{ from: 'trigger_node', to: 'exit_node', type: 'continue' }],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'draft',
diff --git a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts
index 9b4472329f01..fc6604078f0a 100644
--- a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts
+++ b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts
@@ -62,7 +62,7 @@ const makeWorkflow = (fromValue: any): HogFlow => ({
{ from: 'trigger_node', to: EMAIL_NODE_ID, type: 'continue' },
{ from: EMAIL_NODE_ID, to: 'exit_node', type: 'continue' },
],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'draft',
diff --git a/products/workflows/frontend/Workflows/workflowLogic.externalEdits.test.ts b/products/workflows/frontend/Workflows/workflowLogic.externalEdits.test.ts
index a2e5a3f977c7..1bfde53c2801 100644
--- a/products/workflows/frontend/Workflows/workflowLogic.externalEdits.test.ts
+++ b/products/workflows/frontend/Workflows/workflowLogic.externalEdits.test.ts
@@ -39,7 +39,7 @@ const makeWorkflow = (overrides: Partial<HogFlow> = {}): HogFlow => ({
},
],
edges: [{ from: 'trigger_node', to: 'exit_node', type: 'continue' }],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'draft',
diff --git a/products/workflows/frontend/Workflows/workflowLogic.ts b/products/workflows/frontend/Workflows/workflowLogic.ts
index f6c8813eee67..1d649273f306 100644
--- a/products/workflows/frontend/Workflows/workflowLogic.ts
+++ b/products/workflows/frontend/Workflows/workflowLogic.ts
@@ -103,7 +103,7 @@ export const NEW_WORKFLOW: HogFlow = {
type: 'continue',
},
],
- conversion: { window_minutes: null, filters: [] },
+ conversion: { filters: [] },
exit_condition: 'exit_only_at_end',
version: 1,
status: 'draft',
@@ -1006,7 +1006,6 @@ export interface workflowLogicActions {
| undefined
filters: any
window?: string | undefined
- window_minutes?: number | null | undefined
}
| undefined
created_at: string
@@ -1863,7 +1862,6 @@ export interface workflowLogicActions {
| undefined
filters: any
window?: string | undefined
- window_minutes?: number | null | undefined
}
| undefined
created_at: string
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 24854d225c4d..239539bc8893 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -372,17 +372,12 @@ export interface HogFlowConversionApi {
/** Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]. */
events?: HogFlowConversionEventApi[]
/**
- * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both.
+ * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days.
* @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 of 90 days. Set this or 'window', not both.
- * @nullable
- */
- window_minutes?: number | null
/** Compiled server-side from 'filters'. Do not set; ignored if sent. */
bytecode?: unknown
}
@@ -608,7 +603,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: 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 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'. 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').
*
@@ -707,7 +702,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: 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 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'. 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').
*
@@ -806,7 +801,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: 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 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'. 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.ts
index dcd7c8b774d0..0765512bfde8 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -523,13 +523,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -540,7 +534,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: 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 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'. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
),
exit_condition: zod
.enum([
@@ -925,13 +919,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -942,7 +930,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: 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 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'. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
),
exit_condition: zod
.enum([
@@ -1334,13 +1322,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -1351,7 +1333,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: 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 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'. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
),
exit_condition: zod
.enum([
@@ -1996,13 +1978,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -2013,7 +1989,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: 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 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'. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
),
exit_condition: zod
.enum([
@@ -2736,13 +2712,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -2753,7 +2723,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: 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 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'. 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.md
index a27c0abc6a6e..3bda790e8a44 100644
--- a/products/workflows/skills/building-workflows/references/graph-schema.md
+++ b/products/workflows/skills/building-workflows/references/graph-schema.md
@@ -199,8 +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` — 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.
+ - `window` — how long after entry a conversion still counts, as a duration string (`"7d"`, `"12h"`, `"30m"`, `"45s"`), max `"365d"`. Omit it (or `null`) for the default 90-day window.
+ - There is no minutes form. The server drops a `window_minutes` key without an error, so a window sent that way silently becomes the 90-day default.
- **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 checklist
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b6a721391fbe..708e7211d0a0 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -49399,17 +49399,12 @@ export namespace Schemas {
/** Event-based conversion goals: [{filters: {events: [{id, name, type: 'events'}], ...}}]. */
events?: HogFlowConversionEvent[];
/**
- * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both.
+ * How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days.
* @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 of 90 days. Set this or 'window', not both.
- * @nullable
- */
- window_minutes?: number | null;
/** Compiled server-side from 'filters'. Do not set; ignored if sent. */
bytecode?: unknown;
}
@@ -49647,7 +49642,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: 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 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'. 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').
*
@@ -50116,7 +50111,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: 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 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'. 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').
*
@@ -73482,7 +73477,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: 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 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'. 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.ts
index ac57499642e6..af14460ede3e 100644
--- a/services/mcp/src/generated/workflows/api.ts
+++ b/services/mcp/src/generated/workflows/api.ts
@@ -185,13 +185,7 @@ export const HogFlowsCreateBody = () => zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -202,7 +196,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: 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 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'. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
),
exit_condition: zod
.enum([
@@ -592,13 +586,7 @@ export const HogFlowsPartialUpdateBody = () => zod
.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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- ),
- window_minutes: zod
- .number()
- .nullish()
- .describe(
- "DEPRECATED, use 'window' instead. Conversion window in MINUTES (not seconds) after a person enters the workflow. Maximum 129600 (90 days). null = use the default of 90 days. Set this or 'window', not both."
+ "How long after entering the workflow a conversion still counts, as a duration string: '7d', '12h', '30m', '45s'. Same form the delay steps use. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
),
bytecode: zod
.unknown()
@@ -609,7 +597,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: 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 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'. 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.json
index 55b90c68a7db..e6f682ac2fd9 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json
@@ -451,18 +451,7 @@
"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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- },
- "window_minutes": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "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 of 90 days. Set this or 'window', not both."
+ "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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
}
},
"type": "object"
@@ -471,7 +460,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: 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": "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'. 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.json
index dd9f89818f7e..3b586e05d7da 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
@@ -109,18 +109,7 @@
"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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days. Set this or 'window_minutes', not both."
- },
- "window_minutes": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "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 of 90 days. Set this or 'window', not both."
+ "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. Must be longer than zero, and at most '365d'. Omit it to use the default of 90 days."
}
},
"type": "object"
@@ -129,7 +118,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: 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": "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'. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
},
"description": {
"description": "Optional description.",