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.

chore(product-analytics): write down where product frontend code goes (#120256)

Thomas Obermüller2f1f1e9a8a6e
diff --git a/.agents/skills/placing-product-frontend-code/scripts/scene_product_split.py b/.agents/skills/placing-product-frontend-code/scripts/scene_product_split.py
index 7596c9bc061d..2cc35c82c32f 100644
--- a/.agents/skills/placing-product-frontend-code/scripts/scene_product_split.py
+++ b/.agents/skills/placing-product-frontend-code/scripts/scene_product_split.py
@@ -25,6 +25,14 @@ PRODUCTS_ROOT = REPO_ROOT / "products"
SOURCE_SUFFIXES = (".ts", ".tsx")
+# Scene directories whose product directory has a different name. Name matching finds the rest.
+SCENE_PRODUCT_ALIASES = {
+ "insights": "product_analytics",
+ "persons-management": "persons",
+ "saved-insights": "product_analytics",
+ "trends": "product_analytics",
+}
+
@dataclass(frozen=True)
class SceneDir:
@@ -64,6 +72,13 @@ def product_directories() -> dict[str, str]:
return {entry.name.replace("_", ""): entry.name for entry in sorted(PRODUCTS_ROOT.iterdir()) if entry.is_dir()}
+def product_for(scene_name: str, products: dict[str, str]) -> str | None:
+ alias = SCENE_PRODUCT_ALIASES.get(scene_name)
+ if alias in products.values():
+ return alias
+ return products.get(scene_name.replace("-", "").replace("_", ""))
+
+
def scan() -> dict[str, SceneDir]:
if not SCENES_ROOT.is_dir():
return {}
@@ -75,7 +90,7 @@ def scan() -> dict[str, SceneDir]:
scene_files = count_sources(entry)
if scene_files == 0:
continue
- product = products.get(entry.name.replace("-", "").replace("_", ""))
+ product = product_for(entry.name, products)
found[entry.name] = SceneDir(
name=entry.name,
scene_files=scene_files,
@@ -102,7 +117,7 @@ def main() -> int:
d = found.get(args.directory)
if not d:
products = product_directories()
- product = products.get(args.directory.replace("-", "").replace("_", ""))
+ product = product_for(args.directory, products)
if product:
print(f"No frontend/src/scenes/{args.directory}/ — put the UI in products/{product}/frontend/.")
else:
diff --git a/products/product_analytics/AGENTS.md b/products/product_analytics/AGENTS.md
index 878b36354efc..94eb1c43ed7d 100644
--- a/products/product_analytics/AGENTS.md
+++ b/products/product_analytics/AGENTS.md
@@ -65,3 +65,19 @@ Do not revive independently deleted related resources when adding or changing re
New deletion entry points, including background cleanup, must honor this contract.
Setting `deleted=True` through a model save or queryset update does not run the API's cleanup automatically.
When adding another related resource, define its deletion and restore behavior explicitly and apply it to both single and bulk operations.
+
+## Frontend placement
+
+These rules apply when you add or move a frontend file for this product.
+
+New frontend code that only this product imports goes in `products/product_analytics/frontend/`.
+Do not put it in `frontend/src/scenes/insights/` or in another scene tree that the placement report maps to this product.
+`resultSeriesName` landed in `scenes/insights/utils/` although only product files import it, so the default still points at core.
+
+A file in those scene trees stays in core while core or another product imports it.
+Moving it would make core import the product.
+Merge-queue lanes come from paths only, so the moved file would report only this product's lane while core still uses it.
+The lazy scene loaders in `frontend/src/scenes/appScenes.ts` do not count: repoint the loader when its scene moves.
+
+Read [the placement skill](../../.agents/skills/placing-product-frontend-code/SKILL.md) when you decide where a file goes.
+Its `scripts/scene_product_split.py` is the placement report: it maps each scene tree to its product and shows how far the tree has moved.