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(admin): add managed proxy records to django admin (#91981)

Tom Piccirelloc0d4b958603f
diff --git a/posthog/admin/admins/organization_admin.py b/posthog/admin/admins/organization_admin.py
index 7d7d27779507..f1755ef7a3a2 100644
--- a/posthog/admin/admins/organization_admin.py
+++ b/posthog/admin/admins/organization_admin.py
@@ -26,6 +26,7 @@ from posthog.admin.inlines.organization_domain_inline import OrganizationDomainI
from posthog.admin.inlines.organization_invite_inline import OrganizationInviteInline
from posthog.admin.inlines.organization_member_inline import OrganizationMemberInline
from posthog.admin.inlines.project_inline import ProjectInline
+from posthog.admin.inlines.proxy_record_inline import ProxyRecordInline
from posthog.admin.inlines.team_inline import TeamInline
from posthog.admin.paginators.no_count_paginator import NoCountPaginator
from posthog.models.organization import Organization
@@ -265,6 +266,7 @@ class OrganizationAdmin(admin.ModelAdmin):
OrganizationMemberInline,
OrganizationInviteInline,
OrganizationDomainInline,
+ ProxyRecordInline,
]
readonly_fields = [
"id",
diff --git a/posthog/admin/admins/proxy_record_admin.py b/posthog/admin/admins/proxy_record_admin.py
new file mode 100644
index 000000000000..9a3c7e38df5e
--- /dev/null
+++ b/posthog/admin/admins/proxy_record_admin.py
@@ -0,0 +1,55 @@
+from django.contrib import admin
+from django.http import HttpRequest
+from django.urls import reverse
+from django.utils.html import format_html
+
+from posthog.models import ProxyRecord
+
+
[email protected](ProxyRecord)
+class ProxyRecordAdmin(admin.ModelAdmin):
+ list_display = ("domain", "organization_link", "status", "target_cname", "created_at")
+ list_filter = ("status",)
+ search_fields = ("domain", "organization__name")
+ list_select_related = ("organization", "created_by")
+ readonly_fields = (
+ "id",
+ "domain",
+ "organization_link",
+ "status",
+ "target_cname",
+ "message",
+ "created_by_link",
+ "created_at",
+ "updated_at",
+ )
+ fields = (
+ "id",
+ "domain",
+ "organization_link",
+ "status",
+ "target_cname",
+ "message",
+ "created_by_link",
+ "created_at",
+ "updated_at",
+ )
+ ordering = ("-created_at",)
+
+ def has_add_permission(self, request: HttpRequest) -> bool:
+ return False
+
+ def has_delete_permission(self, request: HttpRequest, obj: ProxyRecord | None = None) -> bool:
+ return False
+
+ @admin.display(description="Organization", ordering="organization__name")
+ def organization_link(self, obj: ProxyRecord) -> str:
+ url = reverse("admin:posthog_organization_change", args=[obj.organization_id])
+ return format_html('<a href="{}">{}</a>', url, obj.organization.name)
+
+ @admin.display(description="Created by", ordering="created_by__email")
+ def created_by_link(self, obj: ProxyRecord) -> str:
+ if not obj.created_by:
+ return "-"
+ url = reverse("admin:posthog_user_change", args=[obj.created_by_id])
+ return format_html('<a href="{}">{}</a>', url, obj.created_by.email)
diff --git a/posthog/admin/inlines/proxy_record_inline.py b/posthog/admin/inlines/proxy_record_inline.py
new file mode 100644
index 000000000000..3730d940e2a8
--- /dev/null
+++ b/posthog/admin/inlines/proxy_record_inline.py
@@ -0,0 +1,35 @@
+from django.http import HttpRequest
+
+from django_admin_inline_paginator.admin import TabularInlinePaginated
+
+from posthog.models.organization import Organization
+from posthog.models.proxy_record import ProxyRecord
+
+
+class ProxyRecordInline(TabularInlinePaginated):
+ extra = 0
+ model = ProxyRecord
+ per_page = 20
+ pagination_key = "page-proxy-record"
+ show_change_link = True
+ verbose_name = "reverse proxy"
+ verbose_name_plural = "Reverse proxies"
+
+ fields = (
+ "domain",
+ "status",
+ "target_cname",
+ "message",
+ "created_at",
+ )
+
+ readonly_fields = fields
+
+ ordering = ("-created_at",)
+
+ def has_add_permission(self, request: HttpRequest, obj: Organization | None = None) -> bool:
+ # Proxy records are created via the app, not the admin
+ return False
+
+ def has_delete_permission(self, request: HttpRequest, obj: Organization | None = None) -> bool:
+ return False