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(customer-analytics): seed account notes as markdown notebooks (#98352)

Sinan Kucukkoseler0d802ab61869
diff --git a/products/customer_analytics/backend/management/commands/seed_customer_analytics_accounts.py b/products/customer_analytics/backend/management/commands/seed_customer_analytics_accounts.py
index 59180602aae0..101341ffeb2a 100644
--- a/products/customer_analytics/backend/management/commands/seed_customer_analytics_accounts.py
+++ b/products/customer_analytics/backend/management/commands/seed_customer_analytics_accounts.py
@@ -34,6 +34,7 @@ from products.customer_analytics.backend.models.account import Account, AccountP
from products.customer_analytics.backend.models.relationship import AccountRelationshipDefinition
from products.customer_analytics.backend.models.team_customer_analytics_config import TeamCustomerAnalyticsConfig
from products.notebooks.backend.facade import api as notebooks
+from products.notebooks.backend.facade.content import build_markdown_notebook_content
ACCOUNT_GROUP_TYPE_INDEX = 0
@@ -233,14 +234,10 @@ class Command(BaseCommand):
team.id,
account.id,
title=f"{account.name} — {title}",
- content=_paragraph_doc(body),
+ content=build_markdown_notebook_content(body),
text_content=body,
created_by_id=author.id if author else None,
last_modified_by_id=author.id if author else None,
)
created += 1
self.stdout.write(f"Created {created} note(s) across up to {len(selected)} account(s).")
-
-
-def _paragraph_doc(text: str) -> dict[str, Any]:
- return {"type": "doc", "content": [{"type": "paragraph", "content": [{"type": "text", "text": text}]}]}
diff --git a/products/customer_analytics/backend/management/commands/test/test_seed_customer_analytics_accounts.py b/products/customer_analytics/backend/management/commands/test/test_seed_customer_analytics_accounts.py
index 8cbf8dc03b87..5c7892a1e347 100644
--- a/products/customer_analytics/backend/management/commands/test/test_seed_customer_analytics_accounts.py
+++ b/products/customer_analytics/backend/management/commands/test/test_seed_customer_analytics_accounts.py
@@ -13,6 +13,7 @@ from posthog.persons_seed import insert_seed_group
from products.customer_analytics.backend.models.account import Account
from products.customer_analytics.backend.models.relationship import AccountRelationship
from products.customer_analytics.backend.models.team_customer_analytics_config import TeamCustomerAnalyticsConfig
+from products.notebooks.backend.facade.content import is_markdown_notebook_content
from products.notebooks.backend.models import Notebook, ResourceNotebook
pytestmark = pytest.mark.persons_db_direct
@@ -79,6 +80,7 @@ class TestSeedCustomerAnalyticsAccounts(BaseTest):
notebooks = Notebook.objects.filter(resources__account__team_id=self.team.pk)
assert notebooks.count() == 4
assert all(notebook.visibility == Notebook.Visibility.INTERNAL for notebook in notebooks)
+ assert all(is_markdown_notebook_content(notebook.content) for notebook in notebooks)
accounts_with_notes = set(
ResourceNotebook.objects.filter(account__team_id=self.team.pk).values_list("account_id", flat=True)
)