: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-direct-persons-db-orm
message: >-
Do not query persons DB models via the Django ORM — all calls must
route through the personhog gRPC service. Use the client helpers in
`posthog/models/person/util.py` (e.g. `get_person_by_uuid`,
`get_persons_by_distinct_ids`) and `posthog/models/group_type_mapping.py`
(`get_group_types_for_project`). When adding new access patterns, follow
the `_personhog_routed()` pattern in `posthog/models/person/util.py`.
See `posthog/personhog_client/README.md` for client details
or reach out to #team-ingestion for more information.
severity: WARNING
languages: [python]
patterns:
- pattern: $MODEL.objects.$METHOD(...)
- pattern-not: $MODEL.objects.none()
- metavariable-regex:
metavariable: $MODEL
regex: >-
^(Person|PersonDistinctId|PersonOverrideMapping|PersonOverride|PendingPersonOverride|FlatPersonOverride|FeatureFlagHashKeyOverride|CohortPeople|Group|GroupTypeMapping)$
paths:
exclude:
# personhog client implementation
- '**/posthog/personhog_client/**'
# personhog routing helpers (reference the models internally)
- '**/posthog/models/person/util.py'
- '**/posthog/models/group_type_mapping.py'
# semgrep test cases
- '**/.semgrep/**'
# Migrations
- '**/migrations/**'
# Test files
- '**/test/**'
- '**/tests/**'
- '**/*_test.py'
- '**/test_*.py'
- '**/conftest*.py'