: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(hogbox-preview): sync feature flags so a pr's new flags are on (#111935)
Frank Hamand238d03ff397b
diff --git a/tools/hogbox-preview/README.md b/tools/hogbox-preview/README.mdindex d65f1aaf2902..b6ac48bdea25 100644--- a/tools/hogbox-preview/README.md+++ b/tools/hogbox-preview/README.md@@ -49,7 +49,8 @@ print(url) # https://pen-….boxes.hogland.prod-us.posthog.dev/ (stable acrossDB (`--reset-db` if the PR's migrations are incompatible with the baseline).5. **Sync HogFunction templates** - start the CDP service and load destinationtemplates into the restored database before the preview becomes available.-6. **Serve + report** — the box is HTTP-exposed; the URL is posted to the PR.+6. **Sync feature flags** - run `sync_feature_flags` so each flag in the PR's `constants.tsx` that the golden lacks exists and is on.+7. **Serve + report** — the box is HTTP-exposed; the URL is posted to the PR.Driven entirely by the **`posthog-hogland` Python SDK** over hogplane's HTTP API— **keyless** (GitHub OIDC → hogplane token over the tailnet), no `hogland` CLIdiff --git a/tools/hogbox-preview/hogbox_preview/stack.py b/tools/hogbox-preview/hogbox_preview/stack.pyindex e0eb8a6c9267..a41834f10fbe 100644--- a/tools/hogbox-preview/hogbox_preview/stack.py+++ b/tools/hogbox-preview/hogbox_preview/stack.py@@ -180,6 +180,10 @@ class PostHogPreviewStack:self.migrate()self.start_cdp_service()self.sync_hog_function_templates()+ try:+ self.sync_feature_flags()+ except Exception as e: # noqa: BLE001+ sys.stderr.write(f"[hogbox-preview] feature flag sync skipped (preview still usable): {e}\n")if self.seed_demo_data:# Best-effort: a transient build/model issue shouldn't sink an# otherwise-good preview — it just opens empty.@@ -659,6 +663,14 @@ class PostHogPreviewStack:timeout=900,)+ def sync_feature_flags(self) -> None:+ timing.stage("sync feature flags")+ self.backend.run_long(+ self._compose("run --rm -T web python manage.py sync_feature_flags"),+ name="sync-flags",+ timeout=600,+ )+def generate_demo_data(self) -> None:# Same command hobby-ci uses (bin/hobby-ci.py). Seeds a demo org + the# [email protected] / 12345678 login so the preview opens populated.diff --git a/tools/hogbox-preview/tests/test_deep_health.py b/tools/hogbox-preview/tests/test_deep_health.pyindex 6643af26da88..e52151b2eac0 100644--- a/tools/hogbox-preview/tests/test_deep_health.py+++ b/tools/hogbox-preview/tests/test_deep_health.py@@ -254,6 +254,7 @@ class TemplateSyncTest(unittest.TestCase):"migrate","start_cdp_service","sync_hog_function_templates",+ "sync_feature_flags","up_web","wait_for_health","deep_health",@@ -269,6 +270,7 @@ class TemplateSyncTest(unittest.TestCase):self.assertLess(events.index("migrate"), events.index("start_cdp_service"))self.assertLess(events.index("start_cdp_service"), events.index("sync_hog_function_templates"))self.assertLess(events.index("sync_hog_function_templates"), events.index("up_web"))+ self.assertLess(events.index("sync_feature_flags"), events.index("up_web"))def test_cdp_service_uses_the_published_image_configuration(self):backend = _RecordingBackend()