: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
feat(admin): audit and display who tops up an AI gateway wallet (#68756)
Brandon63004cf58868
diff --git a/posthog/admin/admins/team_admin.py b/posthog/admin/admins/team_admin.pyindex ee3f941ed092..1198e6d7281a 100644--- a/posthog/admin/admins/team_admin.py+++ b/posthog/admin/admins/team_admin.py@@ -21,7 +21,7 @@ from django.shortcuts import redirect, renderfrom django.template.loader import render_to_stringfrom django.urls import NoReverseMatch, path, reversefrom django.utils import timezone-from django.utils.html import escapejs, format_html+from django.utils.html import escapejs, format_html, format_html_joinfrom django.utils.safestring import mark_safefrom structlog import get_logger@@ -33,9 +33,10 @@ from posthog.admin.inlines.organization_member_for_related_inline import Organizfrom posthog.admin.inlines.team_experiments_config_inline import TeamExperimentsConfigInlinefrom posthog.admin.inlines.team_marketing_analytics_config_inline import TeamMarketingAnalyticsConfigInlinefrom posthog.admin.inlines.user_product_list_inline import UserProductListInline+from posthog.helpers.impersonation import is_impersonatedfrom posthog.llm.gateway_internal_client import AIGatewayInternalError, AIGatewayNotConfigured, add_credit, get_walletfrom posthog.models import Team-from posthog.models.activity_logging.activity_log import ActivityContextBase, Detail, log_activity+from posthog.models.activity_logging.activity_log import ActivityContextBase, ActivityLog, Detail, log_activityfrom posthog.models.group_type_mapping import invalidate_group_types_cachefrom posthog.models.remote_config import RemoteConfigfrom posthog.models.team.team import DEPRECATED_ATTRS@@ -69,6 +70,13 @@ class ReplayActivityContext(ActivityContextBase):reason: str[email protected](frozen=True)+class AIGatewayCreditActivityContext(ActivityContextBase):+ amount_usd: str+ reason: str+ balance_usd: str++class TeamAdminForm(ModelForm):def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)@@ -141,6 +149,7 @@ class TeamAdmin(admin.ModelAdmin):"admit_state","ai_gateway_actions","ai_gateway_wallet",+ "ai_gateway_credit_history","policy_cache_blob","group_type_mappings_display",]@@ -278,6 +287,7 @@ class TeamAdmin(admin.ModelAdmin):"admit_state","ai_gateway_actions","ai_gateway_wallet",+ "ai_gateway_credit_history","policy_cache_blob",],"description": mark_safe(@@ -687,6 +697,41 @@ class TeamAdmin(admin.ModelAdmin):duplicate=result.duplicate,triggered_by=request.user.email,)+ # Audit is keyed by the ledger entry_id, so write it whenever one is missing;+ # a replay backfills the audit if an earlier attempt's write was lost after the+ # money moved (the credit and this record can't share a transaction). The credit+ # has already succeeded, so an audit-side failure is logged and swallowed rather+ # than surfaced as an error to the admin. The existence check dedupes best-effort.+ try:+ if not ActivityLog.objects.filter(+ scope="AIGatewayCredit", team_id=team.id, item_id=result.entry_id+ ).exists():+ log_activity(+ organization_id=team.organization_id,+ team_id=team.id,+ user=request.user,+ was_impersonated=is_impersonated(request),+ item_id=result.entry_id,+ scope="AIGatewayCredit",+ activity="credit_added",+ detail=Detail(+ name=f"AI gateway credit — ${result.amount_usd}",+ type="admin_add_credit",+ context=AIGatewayCreditActivityContext(+ amount_usd=result.amount_usd,+ reason=reason,+ balance_usd=result.balance_usd,+ ),+ ),+ )+ except Exception:+ logger.warning(+ "admin_add_ai_gateway_credit_audit_failed",+ team_id=team.id,+ entry_id=result.entry_id,+ triggered_by=request.user.email,+ exc_info=True,+ )if result.duplicate:messages.info(request,@@ -753,6 +798,40 @@ class TeamAdmin(admin.ModelAdmin):))+ @admin.display(description="Recent top-ups (who topped up)")+ def ai_gateway_credit_history(self, team: Team):+ if not team.pk:+ return "-"+ # Local ActivityLog read (no gateway call), so render inline. The ledger+ # records the movement; the actor lives here, joined by item_id == entry_id.+ entries = (+ ActivityLog.objects.filter(scope="AIGatewayCredit", team_id=team.pk, activity="credit_added")+ .select_related("user")+ .order_by("-created_at")[:20]+ )+ if not entries:+ return format_html("<em>(no top-ups recorded)</em>")+ rows = format_html_join(+ "",+ "<tr><td>{}</td><td>{}</td><td>${}</td><td>{}</td></tr>",+ (+ (+ e.created_at.strftime("%Y-%m-%d %H:%M UTC"),+ format_html(+ "{}{}", e.user.email if e.user else "—", " (impersonated)" if e.was_impersonated else ""+ ),+ (e.detail or {}).get("context", {}).get("amount_usd", ""),+ (e.detail or {}).get("context", {}).get("reason", ""),+ )+ for e in entries+ ),+ )+ return format_html(+ "<table><thead><tr><th>When</th><th>Who</th><th>Amount</th><th>Reason</th></tr></thead>"+ "<tbody>{}</tbody></table>",+ rows,+ )+def ai_gateway_wallet_view(self, request, object_id):team = Team.objects.get(pk=object_id)if not self.has_view_permission(request, team):diff --git a/posthog/admin/inlines/team_inline.py b/posthog/admin/inlines/team_inline.pyindex 49974e2707ac..35f5a97f416e 100644--- a/posthog/admin/inlines/team_inline.py+++ b/posthog/admin/inlines/team_inline.py@@ -48,6 +48,7 @@ class TeamInline(TabularInlinePaginated):"admit_state","ai_gateway_actions","ai_gateway_wallet",+ "ai_gateway_credit_history","policy_cache_blob","group_type_mappings_display",)diff --git a/posthog/admin/test_team_admin.py b/posthog/admin/test_team_admin.pyindex 1139f6d6fcc4..3b83be30c15e 100644--- a/posthog/admin/test_team_admin.py+++ b/posthog/admin/test_team_admin.py@@ -21,6 +21,7 @@ from posthog.llm.gateway_internal_client import (LedgerEntry,Wallet,)+from posthog.models.activity_logging.activity_log import ActivityLogfrom posthog.models.team.team import Team@@ -481,6 +482,115 @@ class TestTeamAdminAIGatewayWallet(BaseTest):with self.assertRaises(PermissionDenied):self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))+ def test_add_credit_records_activity_log_with_actor(self) -> None:+ request = self._post({"amount_usd": "25.00", "reason": "goodwill", "form_nonce": "n1"})+ result = CreditResult(+ team_id=self.team.id, entry_id="entry-42", amount_usd="25.000000", balance_usd="35.000000", duplicate=False+ )+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))++ entry = ActivityLog.objects.get(scope="AIGatewayCredit", team_id=self.team.id)+ assert entry.activity == "credit_added"+ assert entry.item_id == "entry-42"+ assert entry.user == self.user+ assert entry.was_impersonated is False+ context = (entry.detail or {}).get("context", {})+ assert context.get("amount_usd") == "25.000000"+ assert context.get("reason") == "goodwill"+ assert context.get("balance_usd") == "35.000000"++ def test_add_credit_impersonated_session_is_captured_and_displayed(self) -> None:+ request = self._post({"amount_usd": "5", "reason": "x", "form_nonce": "n1"})+ result = CreditResult(team_id=self.team.id, entry_id="e1", amount_usd="5", balance_usd="5", duplicate=False)+ with patch("posthog.admin.admins.team_admin.is_impersonated", return_value=True):+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))++ entry = ActivityLog.objects.get(scope="AIGatewayCredit", team_id=self.team.id)+ assert entry.was_impersonated is True+ rendered = str(self.admin.ai_gateway_credit_history(self.team))+ assert "(impersonated)" in rendered++ def test_add_credit_duplicate_backfills_missing_audit(self) -> None:+ # A replay whose original audit was lost after the money moved backfills it.+ request = self._post({"amount_usd": "5", "reason": "x"})+ result = CreditResult(team_id=self.team.id, entry_id="e1", amount_usd="5", balance_usd="5", duplicate=True)+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))+ entry = ActivityLog.objects.get(scope="AIGatewayCredit", team_id=self.team.id)+ assert entry.item_id == "e1"+ # The backfill path is where actor capture matters most, so pin it here too.+ assert entry.user == self.user+ assert entry.was_impersonated is False+ assert (entry.detail or {}).get("context", {}).get("reason") == "x"++ def test_add_credit_audit_is_idempotent_per_entry(self) -> None:+ # Two submits resolving to the same ledger entry record exactly one audit row.+ result_first = CreditResult(+ team_id=self.team.id, entry_id="e1", amount_usd="5", balance_usd="5", duplicate=False+ )+ result_replay = CreditResult(+ team_id=self.team.id, entry_id="e1", amount_usd="5", balance_usd="5", duplicate=True+ )+ for result in (result_first, result_replay):+ request = self._post({"amount_usd": "5", "reason": "x", "form_nonce": "n1"})+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))+ assert ActivityLog.objects.filter(scope="AIGatewayCredit", team_id=self.team.id, item_id="e1").count() == 1++ def test_add_credit_dedup_check_is_team_scoped(self) -> None:+ # A shared entry_id across teams must not make one team's credit skip the audit write.+ other_team = Team.objects.create(organization=self.organization, name="Other team")+ for team in (self.team, other_team):+ request = self._post({"amount_usd": "5", "reason": "x", "form_nonce": "n1"})+ result = CreditResult(team_id=team.id, entry_id="shared", amount_usd="5", balance_usd="5", duplicate=False)+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(team.pk))+ assert ActivityLog.objects.filter(scope="AIGatewayCredit", item_id="shared").count() == 2++ def test_add_credit_survives_audit_write_failure(self) -> None:+ # The credit already moved money, so an audit-write failure must not error the request.+ request = self._post({"amount_usd": "5", "reason": "x", "form_nonce": "n1"})+ result = CreditResult(team_id=self.team.id, entry_id="e1", amount_usd="5", balance_usd="5", duplicate=False)+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ with patch("posthog.admin.admins.team_admin.log_activity", side_effect=Exception("boom")):+ response = self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))+ assert response.status_code == 302+ assert response["Location"] == self.team_change_url++ def test_credit_history_renders_recorded_top_ups(self) -> None:+ request = self._post({"amount_usd": "25.00", "reason": "goodwill", "form_nonce": "n1"})+ result = CreditResult(+ team_id=self.team.id, entry_id="e1", amount_usd="25.000000", balance_usd="35.000000", duplicate=False+ )+ with patch("posthog.admin.admins.team_admin.add_credit", return_value=result):+ self.admin.add_ai_gateway_credit_view(request, str(self.team.pk))++ rendered = str(self.admin.ai_gateway_credit_history(self.team))+ assert self.user.email in rendered+ assert "25.000000" in rendered+ assert "goodwill" in rendered++ def test_credit_history_empty_state(self) -> None:+ rendered = str(self.admin.ai_gateway_credit_history(self.team))+ assert "no top-ups recorded" in rendered++ def test_credit_history_scoped_to_team(self) -> None:+ # Another team's top-ups must not render on this team's page.+ other_team = Team.objects.create(organization=self.organization, name="Other team")+ ActivityLog.objects.create(+ organization_id=other_team.organization_id,+ team_id=other_team.id,+ scope="AIGatewayCredit",+ activity="credit_added",+ item_id="other-1",+ detail={"context": {"amount_usd": "99", "reason": "other-team-secret", "balance_usd": "99"}},+ )+ rendered = str(self.admin.ai_gateway_credit_history(self.team))+ assert "other-team-secret" not in rendered+ assert "no top-ups recorded" in rendered+class TestTeamAdminFormOverspendAllowance(BaseTest):def _form(self, value, instance=None):diff --git a/posthog/llm/gateway_internal_client.py b/posthog/llm/gateway_internal_client.pyindex 55cd49de13b3..a0590192b022 100644--- a/posthog/llm/gateway_internal_client.py+++ b/posthog/llm/gateway_internal_client.py@@ -7,6 +7,10 @@ import httpxINTERNAL_API_TIMEOUT_SECONDS = 5.0IDEMPOTENCY_KEY_HEADER = "Idempotency-Key"+INTERNAL_ACTOR_HEADER = "X-Internal-Actor"+# Ledger provenance tag (meta.source): admin-originated vs the billing path's+# "billing". The acting human is audited in ActivityLog, not here.+ADMIN_ACTOR = "posthog-admin"class AIGatewayInternalError(Exception):@@ -109,7 +113,7 @@ def add_credit(team_id: int, amount_usd: str, reason: str, idempotency_key: str)try:response = httpx.post(f"{url}/internal/teams/{team_id}/credits",- headers=_auth_headers(token, {IDEMPOTENCY_KEY_HEADER: idempotency_key}),+ headers=_auth_headers(token, {IDEMPOTENCY_KEY_HEADER: idempotency_key, INTERNAL_ACTOR_HEADER: ADMIN_ACTOR}),json={"amount_usd": amount_usd, "reason": reason},timeout=INTERNAL_API_TIMEOUT_SECONDS,trust_env=False,diff --git a/posthog/llm/test_gateway_internal_client.py b/posthog/llm/test_gateway_internal_client.pyindex 71faa4d48305..b76a15f10ce1 100644--- a/posthog/llm/test_gateway_internal_client.py+++ b/posthog/llm/test_gateway_internal_client.py@@ -4,7 +4,9 @@ from unittest.mock import patchimport httpxfrom posthog.llm.gateway_internal_client import (+ ADMIN_ACTOR,IDEMPOTENCY_KEY_HEADER,+ INTERNAL_ACTOR_HEADER,AIGatewayInternalError,AIGatewayNotConfigured,add_credit,@@ -108,6 +110,7 @@ class TestAddCredit:assert url == "http://gw/internal/teams/42/credits"assert mock_post.call_args.kwargs["json"] == {"amount_usd": "25.00", "reason": "topping up"}assert mock_post.call_args.kwargs["headers"][IDEMPOTENCY_KEY_HEADER] == "key-123"+ assert mock_post.call_args.kwargs["headers"][INTERNAL_ACTOR_HEADER] == ADMIN_ACTORassert mock_post.call_args.kwargs["headers"]["Authorization"] == "Bearer tok"assert result.entry_id == "entry-1"assert result.balance_usd == "35.000000"diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.pyindex b6999ebdabac..0101bf9725aa 100644--- a/posthog/models/activity_logging/activity_log.py+++ b/posthog/models/activity_logging/activity_log.py@@ -80,6 +80,7 @@ ActivityScope = Literal["ExternalDataSchema","Evaluation","LLMTrace",+ "AIGatewayCredit","WebAnalyticsFilterPreset","CustomerProfileConfig","Log",@@ -383,6 +384,14 @@ activity_visibility_restrictions: list[dict[str, Any]] = ["exclude_when": {},"allow_staff": True,},+ {+ # Admin AI-gateway top-ups are staff-only; keep the staff email, credit reason,+ # and wallet balance out of the org-scoped activity log endpoints.+ "scope": "AIGatewayCredit",+ "activities": ["credit_added"],+ "exclude_when": {},+ "allow_staff": True,+ },]field_exclusions: dict[AuditableScope, list[str]] = {diff --git a/posthog/test/activity_logging/test_activity_logging.py b/posthog/test/activity_logging/test_activity_logging.pyindex d1a23c4e7d42..db834bff467a 100644--- a/posthog/test/activity_logging/test_activity_logging.py+++ b/posthog/test/activity_logging/test_activity_logging.py@@ -235,6 +235,8 @@ class TestActivityLogVisibilityManager(BaseTest):("user_changed_password", "User", "changed_password", False, False),# InstanceSetting updates are staff-only and must be hidden from non-staff viewers("instance_setting_updated", "InstanceSetting", "updated", False, True),+ # AI-gateway top-ups are staff-only and must be hidden from non-staff viewers+ ("ai_gateway_credit_added", "AIGatewayCredit", "credit_added", False, True),# Non-User scopes are unaffected("feature_flag_created", "FeatureFlag", "created", False, False),("feature_flag_updated", "FeatureFlag", "updated", True, False),@@ -264,6 +266,8 @@ class TestActivityLogVisibilityManager(BaseTest):("user_created_staff_bypass", "User", "created", False, False),# Staff can also see InstanceSetting updates (allow_staff=True)("instance_setting_updated_staff_bypass", "InstanceSetting", "updated", False, False),+ # Staff can also see AI-gateway top-ups (allow_staff=True)+ ("ai_gateway_credit_added_staff_bypass", "AIGatewayCredit", "credit_added", False, False),# Non-User activities still not restricted for anyone("feature_flag_created", "FeatureFlag", "created", False, False),]@@ -300,6 +304,20 @@ class TestActivityLogVisibilityManager(BaseTest):self.assertFalse(filtered.filter(scope="User", activity="updated").exists())self.assertTrue(filtered.filter(scope="FeatureFlag", activity="created").exists())+ def test_queryset_excludes_ai_gateway_credit_for_non_staff(self) -> None:+ # Pin the actual API-facing exclusion path (apply_to_queryset), not just is_restricted:+ # the staff email, credit reason, and balance must stay out of org-scoped endpoints.+ ActivityLog.objects.create(team_id=self.team.id, scope="AIGatewayCredit", activity="credit_added")+ ActivityLog.objects.create(team_id=self.team.id, scope="FeatureFlag", activity="created")+ queryset = ActivityLog.objects.filter(team_id=self.team.id)++ non_staff = activity_visibility_manager.apply_to_queryset(queryset, is_staff=False)+ assert not non_staff.filter(scope="AIGatewayCredit").exists()+ assert non_staff.filter(scope="FeatureFlag").exists()++ staff = activity_visibility_manager.apply_to_queryset(queryset, is_staff=True)+ assert staff.filter(scope="AIGatewayCredit").exists()+def test_queryset_includes_all_logs_for_staff(self) -> None:ActivityLog.objects.create(team_id=self.team.id, scope="User", activity="logged_in", was_impersonated=True)ActivityLog.objects.create(team_id=self.team.id, scope="User", activity="logged_out", was_impersonated=True)diff --git a/products/platform_features/frontend/generated/api.schemas.ts b/products/platform_features/frontend/generated/api.schemas.tsindex 5f2d7dfc4aa7..53a064f8dd35 100644--- a/products/platform_features/frontend/generated/api.schemas.ts+++ b/products/platform_features/frontend/generated/api.schemas.ts@@ -984,6 +984,7 @@ export type ActivityLogListParams = {* * `ExternalDataSchema` - ExternalDataSchema* * `Evaluation` - Evaluation* * `LLMTrace` - LLMTrace+ * * `AIGatewayCredit` - AIGatewayCredit* * `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset* * `CustomerProfileConfig` - CustomerProfileConfig* * `Log` - Log@@ -1065,6 +1066,7 @@ export const ActivityLogListScope = {ExternalDataSchema: 'ExternalDataSchema',Evaluation: 'Evaluation',LLMTrace: 'LLMTrace',+ AIGatewayCredit: 'AIGatewayCredit',WebAnalyticsFilterPreset: 'WebAnalyticsFilterPreset',CustomerProfileConfig: 'CustomerProfileConfig',Log: 'Log',@@ -1133,6 +1135,7 @@ export const ActivityLogListScope = {* * `ExternalDataSchema` - ExternalDataSchema* * `Evaluation` - Evaluation* * `LLMTrace` - LLMTrace+ * * `AIGatewayCredit` - AIGatewayCredit* * `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset* * `CustomerProfileConfig` - CustomerProfileConfig* * `Log` - Log@@ -1202,6 +1205,7 @@ export const ActivityLogListScopesItem = {ExternalDataSchema: 'ExternalDataSchema',Evaluation: 'Evaluation',LLMTrace: 'LLMTrace',+ AIGatewayCredit: 'AIGatewayCredit',WebAnalyticsFilterPreset: 'WebAnalyticsFilterPreset',CustomerProfileConfig: 'CustomerProfileConfig',Log: 'Log',diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 832019e1a772..80e7460a6384 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -62329,6 +62329,7 @@ export namespace Schemas {* * `ExternalDataSchema` - ExternalDataSchema* * `Evaluation` - Evaluation* * `LLMTrace` - LLMTrace+ * * `AIGatewayCredit` - AIGatewayCredit* * `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset* * `CustomerProfileConfig` - CustomerProfileConfig* * `Log` - Log@@ -62411,6 +62412,7 @@ export namespace Schemas {ExternalDataSchema: 'ExternalDataSchema',Evaluation: 'Evaluation',LLMTrace: 'LLMTrace',+ AIGatewayCredit: 'AIGatewayCredit',WebAnalyticsFilterPreset: 'WebAnalyticsFilterPreset',CustomerProfileConfig: 'CustomerProfileConfig',Log: 'Log',@@ -62479,6 +62481,7 @@ export namespace Schemas {* * `ExternalDataSchema` - ExternalDataSchema* * `Evaluation` - Evaluation* * `LLMTrace` - LLMTrace+ * * `AIGatewayCredit` - AIGatewayCredit* * `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset* * `CustomerProfileConfig` - CustomerProfileConfig* * `Log` - Log@@ -62549,6 +62552,7 @@ export namespace Schemas {ExternalDataSchema: 'ExternalDataSchema',Evaluation: 'Evaluation',LLMTrace: 'LLMTrace',+ AIGatewayCredit: 'AIGatewayCredit',WebAnalyticsFilterPreset: 'WebAnalyticsFilterPreset',CustomerProfileConfig: 'CustomerProfileConfig',Log: 'Log',diff --git a/services/mcp/src/generated/platform_features/api.ts b/services/mcp/src/generated/platform_features/api.tsindex c13747a863ca..35672815652b 100644--- a/services/mcp/src/generated/platform_features/api.ts+++ b/services/mcp/src/generated/platform_features/api.ts@@ -164,6 +164,7 @@ export const ActivityLogListQueryParams = /* @__PURE__ */ zod.object({'ExternalDataSchema','Evaluation','LLMTrace',+ 'AIGatewayCredit','WebAnalyticsFilterPreset','CustomerProfileConfig','Log',@@ -178,7 +179,7 @@ export const ActivityLogListQueryParams = /* @__PURE__ */ zod.object({]).optional().describe(- 'Filter by a single activity scope, e.g. "FeatureFlag", "Insight", "Dashboard", "Experiment".\n\n* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig'+ 'Filter by a single activity scope, e.g. "FeatureFlag", "Insight", "Dashboard", "Experiment".\n\n* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `AIGatewayCredit` - AIGatewayCredit\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig'),scopes: zod.array(@@ -238,6 +239,7 @@ export const ActivityLogListQueryParams = /* @__PURE__ */ zod.object({'ExternalDataSchema','Evaluation','LLMTrace',+ 'AIGatewayCredit','WebAnalyticsFilterPreset','CustomerProfileConfig','Log',@@ -251,7 +253,7 @@ export const ActivityLogListQueryParams = /* @__PURE__ */ zod.object({'SignalScoutConfig',]).describe(- '* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig'+ '* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `AIGatewayCredit` - AIGatewayCredit\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig')).optional()diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/activity-log-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/activity-log-list.jsonindex 76bef56fbfab..59403e3d6311 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/activity-log-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/activity-log-list.json@@ -19,7 +19,7 @@"type": "number"},"scope": {- "description": "Filter by a single activity scope, e.g. \"FeatureFlag\", \"Insight\", \"Dashboard\", \"Experiment\".\n\n* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig",+ "description": "Filter by a single activity scope, e.g. \"FeatureFlag\", \"Insight\", \"Dashboard\", \"Experiment\".\n\n* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `AIGatewayCredit` - AIGatewayCredit\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig","enum": ["Cohort","FeatureFlag",@@ -75,6 +75,7 @@"ExternalDataSchema","Evaluation","LLMTrace",+ "AIGatewayCredit","WebAnalyticsFilterPreset","CustomerProfileConfig","Log",@@ -92,7 +93,7 @@"scopes": {"description": "Filter by multiple activity scopes, comma-separated. Values must be valid ActivityScope enum values. E.g. \"FeatureFlag,Insight\".","items": {- "description": "* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig",+ "description": "* `Cohort` - Cohort\n* `FeatureFlag` - FeatureFlag\n* `Person` - Person\n* `Group` - Group\n* `Insight` - Insight\n* `Plugin` - Plugin\n* `PluginConfig` - PluginConfig\n* `HogFunction` - HogFunction\n* `HogFlow` - HogFlow\n* `DataManagement` - DataManagement\n* `EventDefinition` - EventDefinition\n* `PropertyDefinition` - PropertyDefinition\n* `Notebook` - Notebook\n* `Endpoint` - Endpoint\n* `EndpointVersion` - EndpointVersion\n* `Dashboard` - Dashboard\n* `Replay` - Replay\n* `Experiment` - Experiment\n* `ExperimentHoldout` - ExperimentHoldout\n* `ExperimentSavedMetric` - ExperimentSavedMetric\n* `Survey` - Survey\n* `EarlyAccessFeature` - EarlyAccessFeature\n* `SessionRecordingPlaylist` - SessionRecordingPlaylist\n* `Comment` - Comment\n* `Team` - Team\n* `Project` - Project\n* `ErrorTrackingIssue` - ErrorTrackingIssue\n* `DataWarehouseSavedQuery` - DataWarehouseSavedQuery\n* `LegalDocument` - LegalDocument\n* `Organization` - Organization\n* `OrganizationDomain` - OrganizationDomain\n* `OrganizationMembership` - OrganizationMembership\n* `Role` - Role\n* `UserGroup` - UserGroup\n* `BatchExport` - BatchExport\n* `BatchImport` - BatchImport\n* `ExportedAsset` - ExportedAsset\n* `Integration` - Integration\n* `Annotation` - Annotation\n* `Tag` - Tag\n* `TaggedItem` - TaggedItem\n* `Subscription` - Subscription\n* `PersonalAPIKey` - PersonalAPIKey\n* `ProjectSecretAPIKey` - ProjectSecretAPIKey\n* `OAuthApplication` - OAuthApplication\n* `User` - User\n* `Action` - Action\n* `AlertConfiguration` - AlertConfiguration\n* `Threshold` - Threshold\n* `AlertSubscription` - AlertSubscription\n* `ExternalDataSource` - ExternalDataSource\n* `ExternalDataSchema` - ExternalDataSchema\n* `Evaluation` - Evaluation\n* `LLMTrace` - LLMTrace\n* `AIGatewayCredit` - AIGatewayCredit\n* `WebAnalyticsFilterPreset` - WebAnalyticsFilterPreset\n* `CustomerProfileConfig` - CustomerProfileConfig\n* `Log` - Log\n* `LogsAlertConfiguration` - LogsAlertConfiguration\n* `LogsExclusionRule` - LogsExclusionRule\n* `DashboardWidget` - DashboardWidget\n* `ProductTour` - ProductTour\n* `Ticket` - Ticket\n* `InstanceSetting` - InstanceSetting\n* `SignalReport` - SignalReport\n* `SignalScoutConfig` - SignalScoutConfig","enum": ["Cohort","FeatureFlag",@@ -148,6 +149,7 @@"ExternalDataSchema","Evaluation","LLMTrace",+ "AIGatewayCredit","WebAnalyticsFilterPreset","CustomerProfileConfig","Log",