: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
rules:
- id: no-new-custom-admin-views
message: |
New staff workflows go in the PostHog Admin console, not in custom Django admin views,
URLs or template overrides. The console sits under /admin/console/, so the same staff
check and OAuth step-up apply, and its pages do not break when Django changes admin
internals. Add a Panel in products/<product>/backend/console.py; see
posthog/admin/console/AGENTS.md. Django admin stays for plain CRUD: list_display,
search_fields, readonly_fields, inlines and simple actions are fine.
Pre-existing findings are grandfathered; only newly introduced findings block CI.
languages: [python]
severity: WARNING
pattern-either:
# Report the name, not the whole function, so a PR that drains URLs from a grandfathered
# get_urls keeps the same finding instead of looking like a new one to the baseline scan.
- patterns:
- pattern: |
def $FUNC(self, ...):
...
- metavariable-regex:
metavariable: $FUNC
regex: ^get_urls$
- focus-metavariable: $FUNC
# Each URL entry is its own finding, so a URL added to a grandfathered get_urls is still new.
- patterns:
- pattern-inside: |
def get_urls(self, ...):
...
- pattern-either:
- pattern: path(...)
- pattern: re_path(...)
- patterns:
- pattern: $TEMPLATE = $VALUE
- metavariable-regex:
metavariable: $TEMPLATE
regex: ^(change_form_template|change_list_template|add_form_template|delete_confirmation_template|delete_selected_confirmation_template|object_history_template|popup_response_template)$
- pattern: $SITE.admin_view(...)
paths:
include:
- '**/admin.py'
- '**/admin/**/*.py'
- ee/urls.py
exclude:
- posthog/admin/console/**
- '**/test/**'
- '**/tests/**'
- '**/test_*.py'
metadata:
category: maintainability
subcategory: audit
confidence: HIGH
- id: no-new-admin-workflow-hooks
message: |
Django admin stays for plain CRUD: a ModelAdmin declares fields, filters, inlines and
permissions, and saving writes the row and nothing else. Overriding a save or delete hook,
a page view or a response turns the admin page into a workflow, for example resetting a
status, notifying staff or starting a job. Put that workflow in a PostHog Admin console
operation instead; see posthog/admin/console/AGENTS.md.
Pre-existing findings are grandfathered; only newly introduced findings block CI.
languages: [python]
severity: WARNING
patterns:
- pattern-inside: |
class $CLASS(...):
...
# Report the name, not the whole method, so editing a grandfathered method keeps the same finding.
- pattern: |
def $FUNC(self, ...):
...
- metavariable-regex:
metavariable: $FUNC
regex: ^(save_form|save_model|delete_model|save_related|save_formset|delete_queryset|add_view|change_view|changeform_view|changelist_view|delete_view|history_view|response_add|response_change|response_delete)$
- focus-metavariable: $FUNC
paths:
include:
- '**/admin.py'
- '**/admin/**/*.py'
exclude:
- posthog/admin/console/**
- '**/test/**'
- '**/tests/**'
- '**/test_*.py'
metadata:
category: maintainability
subcategory: audit
confidence: HIGH
- id: no-new-custom-admin-templates
message: |
Django admin picks up a template under templates/admin/ by its path alone, so this file
overrides or extends an admin page without any Python change. New staff pages go in the
PostHog Admin console; see posthog/admin/console/AGENTS.md.
Pre-existing findings are grandfathered; only newly introduced findings block CI.
languages: [generic]
severity: WARNING
pattern-regex: \{%\s*extends\s+["']admin/
paths:
include:
- '**/templates/admin/**/*.html'
metadata:
category: maintainability
subcategory: audit
confidence: HIGH