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.

feat(self-driving): Allow to enable products proactively through new safe `product_enablement` scope (#67131)

Alex Lebedev4d926857945a
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 04160d2eac7d..5fe39b79c80e 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -3066,6 +3066,37 @@ export interface PaginatedExportedAssetListApi {
results: ExportedAssetApi[]
}
+/**
+ * * `conversations` - conversations
+ * * `error_tracking` - error_tracking
+ * * `session_replay` - session_replay
+ */
+export type ProductsEnumApi = (typeof ProductsEnumApi)[keyof typeof ProductsEnumApi]
+
+export const ProductsEnumApi = {
+ Conversations: 'conversations',
+ ErrorTracking: 'error_tracking',
+ SessionReplay: 'session_replay',
+} as const
+
+export interface ProductEnablementApi {
+ /**
+ * Products to turn on for this project, each enabled with server-owned conservative defaults.
+ * @minItems 1
+ */
+ products: ProductsEnumApi[]
+}
+
+/**
+ * Per requested product: "enabled" (just turned on) or "already_enabled".
+ */
+export type ProductEnablementResultApiResults = { [key: string]: string }
+
+export interface ProductEnablementResultApi {
+ /** Per requested product: "enabled" (just turned on) or "already_enabled". */
+ results: ProductEnablementResultApiResults
+}
+
export interface ProjectSecretAPIKeyApi {
readonly id: string
/** @maxLength 40 */
diff --git a/frontend/src/generated/core/api.ts b/frontend/src/generated/core/api.ts
index faf84d73a073..e08d55708cc1 100644
--- a/frontend/src/generated/core/api.ts
+++ b/frontend/src/generated/core/api.ts
@@ -66,6 +66,8 @@ import type {
PatchedProjectBackwardCompatApi,
PatchedProjectSecretAPIKeyApi,
PatchedUserApi,
+ ProductEnablementApi,
+ ProductEnablementResultApi,
ProjectBackwardCompatApi,
ProjectSecretAPIKeyApi,
ProjectSecretApiKeysListParams,
@@ -2544,6 +2546,23 @@ export const notebooksSharingRefreshCreate = async (
})
}
+export const getProductEnablementCreateUrl = (projectId: string) => {
+ return `/api/projects/${projectId}/product_enablement/`
+}
+
+export const productEnablementCreate = async (
+ projectId: string,
+ productEnablementApi: ProductEnablementApi,
+ options?: RequestInit
+): Promise<ProductEnablementResultApi> => {
+ return apiMutator<ProductEnablementResultApi>(getProductEnablementCreateUrl(projectId), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(productEnablementApi),
+ })
+}
+
export const getProjectSecretApiKeysListUrl = (projectId: string, params?: ProjectSecretApiKeysListParams) => {
const normalizedParams = new URLSearchParams()
diff --git a/frontend/src/generated/core/api.zod.ts b/frontend/src/generated/core/api.zod.ts
index 151bbac810aa..2864753dc262 100644
--- a/frontend/src/generated/core/api.zod.ts
+++ b/frontend/src/generated/core/api.zod.ts
@@ -9730,6 +9730,19 @@ export const NotebooksSharingRefreshCreateBody = /* @__PURE__ */ zod.object({
password_required: zod.boolean().optional(),
})
+export const ProductEnablementCreateBody = /* @__PURE__ */ zod.object({
+ products: zod
+ .array(
+ zod
+ .enum(['conversations', 'error_tracking', 'session_replay'])
+ .describe(
+ '\* `conversations` - conversations\n\* `error_tracking` - error_tracking\n\* `session_replay` - session_replay'
+ )
+ )
+ .min(1)
+ .describe('Products to turn on for this project, each enabled with server-owned conservative defaults.'),
+})
+
export const projectSecretApiKeysCreateBodyLabelMax = 40
export const ProjectSecretApiKeysCreateBody = /* @__PURE__ */ zod.object({
diff --git a/frontend/src/lib/scopes.tsx b/frontend/src/lib/scopes.tsx
index d197854ab696..c4726d6ea20b 100644
--- a/frontend/src/lib/scopes.tsx
+++ b/frontend/src/lib/scopes.tsx
@@ -109,6 +109,12 @@ export const API_SCOPES: APIScope[] = [
{ key: 'person', objectName: 'Person', objectPlural: 'persons' },
{ key: 'customer_profile_config', objectName: 'Customer profile config', objectPlural: 'customer profile configs' },
{ key: 'plugin', objectName: 'Plugin', objectPlural: 'plugins' },
+ {
+ key: 'product_enablement',
+ objectName: 'Product enablement',
+ objectPlural: 'product enablement',
+ disabledActions: ['read'],
+ },
{ key: 'product_tour', objectName: 'Product tour', objectPlural: 'product tours' },
{
key: 'project',
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 5b775d1fa467..569357e71764 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5661,6 +5661,7 @@ export type APIScopeObject =
| 'organization_member'
| 'person'
| 'plugin'
+ | 'product_enablement'
| 'product_tour'
| 'project'
| 'property_definition'
diff --git a/posthog/api/product_enablement.py b/posthog/api/product_enablement.py
new file mode 100644
index 000000000000..bcab9a6b6891
--- /dev/null
+++ b/posthog/api/product_enablement.py
@@ -0,0 +1,148 @@
+"""Proactive product enablement for self-driving Signals setup.
+
+Turns PostHog products ON so their signal sources have data to read. The wizard
+calls this (via the `products-enable` MCP tool) before it enables sources, so a
+freshly-instrumented project isn't left with empty inboxes.
+
+Exposed under a narrow `product_enablement:write` scope rather than `project:write`:
+the caller only names which products; the server owns each recipe (the primary
+toggle plus conservative companion defaults), so a caller can never weaken masking
+or delete the project. Adding a product later = one entry in `RECIPES`.
+"""
+
+import secrets
+from collections.abc import Callable
+from typing import cast
+
+from drf_spectacular.utils import extend_schema
+from rest_framework import serializers, status, viewsets
+from rest_framework.exceptions import PermissionDenied
+from rest_framework.response import Response
+
+from posthog.api.routing import TeamAndOrgViewSetMixin
+from posthog.api.team import TEAM_CONFIG_ADMIN_FIELDS_SET
+from posthog.helpers.impersonation import is_impersonated
+from posthog.models import OrganizationMembership, User
+from posthog.models.activity_logging.activity_log import Detail, dict_changes_between, log_activity
+from posthog.models.team import Team
+
+# Written only when the team has none set. posthog-js already masks inputs + passwords
+# by default, so this just pins that floor — page text stays visible for Signals to read.
+REPLAY_MASKING_FLOOR = {"maskAllInputs": True}
+
+# Sets the primary toggle (always) + companion defaults (only if unset, never clobbering
+# user config). Adds touched field names to `touched`; returns "enabled" or "already_enabled".
+Recipe = Callable[[Team, set[str]], str]
+
+
+def _enable_session_replay(team: Team, touched: set[str]) -> str:
+ if team.session_recording_masking_config is None:
+ team.session_recording_masking_config = dict(REPLAY_MASKING_FLOOR)
+ touched.add("session_recording_masking_config")
+ if team.session_recording_opt_in:
+ return "already_enabled"
+ team.session_recording_opt_in = True
+ touched.add("session_recording_opt_in")
+ return "enabled"
+
+
+def _enable_error_tracking(team: Team, touched: set[str]) -> str:
+ if team.autocapture_exceptions_opt_in:
+ return "already_enabled"
+ team.autocapture_exceptions_opt_in = True
+ touched.add("autocapture_exceptions_opt_in")
+ return "enabled"
+
+
+def _enable_conversations(team: Team, touched: set[str]) -> str:
+ if team.conversations_enabled:
+ return "already_enabled"
+ team.conversations_enabled = True
+ touched.add("conversations_enabled")
+ # Mirror handle_conversations_token_on_update (posthog/api/team.py): mint a widget
+ # token but leave the widget off — tickets need a connected channel (the report CTA).
+ settings = dict(team.conversations_settings or {})
+ if not settings.get("widget_public_token"):
+ settings["widget_public_token"] = secrets.token_urlsafe(32)
+ team.conversations_settings = settings
+ touched.add("conversations_settings")
+ return "enabled"
+
+
+RECIPES: dict[str, Recipe] = {
+ "session_replay": _enable_session_replay,
+ "error_tracking": _enable_error_tracking,
+ "conversations": _enable_conversations,
+}
+
+
+class ProductEnablementSerializer(serializers.Serializer):
+ products = serializers.ListField(
+ child=serializers.ChoiceField(choices=sorted(RECIPES.keys())),
+ allow_empty=False,
+ min_length=1,
+ help_text="Products to turn on for this project, each enabled with server-owned conservative defaults.",
+ )
+
+
+class ProductEnablementResultSerializer(serializers.Serializer):
+ results = serializers.DictField(
+ child=serializers.CharField(),
+ help_text='Per requested product: "enabled" (just turned on) or "already_enabled".',
+ )
+
+
+class ProductEnablementViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
+ scope_object = "product_enablement"
+
+ @extend_schema(
+ request=ProductEnablementSerializer,
+ responses={200: ProductEnablementResultSerializer},
+ # Route the generated client to frontend/src/generated/core/ — this is a core
+ # endpoint, not part of any product folder.
+ extensions={"x-product": "core"},
+ )
+ def create(self, request, *args, **kwargs):
+ serializer = ProductEnablementSerializer(data=request.data)
+ serializer.is_valid(raise_exception=True)
+
+ team = self.team
+ before = team.__dict__.copy()
+ touched: set[str] = set()
+ # dict.fromkeys dedupes while preserving the caller's order.
+ results = {
+ product: RECIPES[product](team, touched) for product in dict.fromkeys(serializer.validated_data["products"])
+ }
+
+ # conversations + replay masking are admin-only on the normal Team-update API; replicate that
+ # gate so this endpoint can't be a bypass (error_tracking + the replay opt-in stay member-safe).
+ admin_fields = touched & TEAM_CONFIG_ADMIN_FIELDS_SET
+ if admin_fields:
+ level = self.user_permissions.team(team).effective_membership_level
+ if level is None or level < OrganizationMembership.Level.ADMIN:
+ raise PermissionDenied(
+ "Only project admins can enable products that change these settings: "
+ + ", ".join(sorted(admin_fields))
+ )
+
+ if touched:
+ team.save(update_fields=sorted(touched))
+ # Audit the enable like the Team-update API does; drop conversations_settings so the
+ # minted widget token never lands in the activity log.
+ changes = [
+ change
+ for change in dict_changes_between("Team", before, team.__dict__, use_field_exclusions=True)
+ if change.field != "conversations_settings"
+ ]
+ log_activity(
+ organization_id=team.organization_id,
+ team_id=team.pk,
+ user=cast(User, request.user),
+ was_impersonated=is_impersonated(request),
+ scope="Team",
+ item_id=team.pk,
+ activity="updated",
+ detail=Detail(name=str(team.name), changes=changes),
+ )
+
+ return Response({"results": results}, status=status.HTTP_200_OK)
diff --git a/posthog/api/rest_router.py b/posthog/api/rest_router.py
index b7f6a7708bdf..7743bac685e5 100644
--- a/posthog/api/rest_router.py
+++ b/posthog/api/rest_router.py
@@ -11,6 +11,7 @@ import posthog.temporal.ai # noqa: F401
from posthog.api import data_color_theme, metalytics, my_notifications, project, user_integration, user_push_token
from posthog.api.csp_reporting import CSPReportingViewSet
from posthog.api.js_snippet import JsSnippetViewSet
+from posthog.api.product_enablement import ProductEnablementViewSet
from posthog.api.query_performance_proxy import QueryPerformanceProxyViewSet
from posthog.api.routing import DefaultRouterPlusPlus, RouterRegistry
from posthog.api.sdk_health import SdkHealthViewSet
@@ -172,6 +173,14 @@ projects_router.register(
"project_quota_limits",
["team_id"],
)
+# Self-driving turns products ON (via the `products-enable` MCP tool) before enabling their
+# signal sources. Gated by the narrow `product_enablement` scope, never `project:write`.
+projects_router.register(
+ r"product_enablement",
+ ProductEnablementViewSet,
+ "project_product_enablement",
+ ["team_id"],
+)
register_legacy_dual_route_team_nested_viewset(
r"column_configurations",
diff --git a/posthog/api/test/test_product_enablement.py b/posthog/api/test/test_product_enablement.py
new file mode 100644
index 000000000000..356e8beb9545
--- /dev/null
+++ b/posthog/api/test/test_product_enablement.py
@@ -0,0 +1,125 @@
+from posthog.test.base import APIBaseTest
+
+from rest_framework import status
+
+from posthog.models import OrganizationMembership
+from posthog.models.activity_logging.activity_log import ActivityLog
+
+
+class TestProductEnablementAPI(APIBaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ # The endpoint's admin-gated recipes (conversations, replay masking) need an admin caller;
+ # the member-denial path is covered by test_admin_gated_products_require_project_admin.
+ self.organization_membership.level = OrganizationMembership.Level.ADMIN
+ self.organization_membership.save()
+
+ def _url(self) -> str:
+ return f"/api/projects/{self.team.id}/product_enablement/"
+
+ def _enable(self, products: list[str], **kwargs):
+ return self.client.post(self._url(), {"products": products}, format="json", **kwargs)
+
+ def test_enables_session_replay_with_masking_floor(self):
+ response = self._enable(["session_replay"])
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual(response.json(), {"results": {"session_replay": "enabled"}})
+
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.session_recording_opt_in)
+ self.assertEqual(self.team.session_recording_masking_config, {"maskAllInputs": True})
+
+ def test_does_not_clobber_existing_masking_config(self):
+ self.team.session_recording_masking_config = {"maskAllInputs": False, "maskTextSelector": "*"}
+ self.team.save()
+
+ self._enable(["session_replay"])
+
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.session_recording_opt_in)
+ # The user's deliberate config is left untouched.
+ self.assertEqual(
+ self.team.session_recording_masking_config,
+ {"maskAllInputs": False, "maskTextSelector": "*"},
+ )
+
+ def test_enables_error_tracking(self):
+ response = self._enable(["error_tracking"])
+ self.assertEqual(response.json(), {"results": {"error_tracking": "enabled"}})
+
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.autocapture_exceptions_opt_in)
+
+ def test_enables_conversations_mints_token_but_leaves_widget_off(self):
+ response = self._enable(["conversations"])
+ self.assertEqual(response.json(), {"results": {"conversations": "enabled"}})
+
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.conversations_enabled)
+ self.assertTrue((self.team.conversations_settings or {}).get("widget_public_token"))
+ # The embeddable widget stays off until a channel is connected (a report CTA).
+ self.assertFalse((self.team.conversations_settings or {}).get("widget_enabled"))
+
+ def test_already_enabled_is_idempotent(self):
+ self.team.session_recording_opt_in = True
+ self.team.session_recording_masking_config = {"maskAllInputs": True}
+ self.team.save()
+
+ response = self._enable(["session_replay"])
+ self.assertEqual(response.json(), {"results": {"session_replay": "already_enabled"}})
+
+ def test_multiple_products_deduped(self):
+ response = self._enable(["session_replay", "error_tracking", "session_replay"])
+ self.assertEqual(
+ response.json(),
+ {"results": {"session_replay": "enabled", "error_tracking": "enabled"}},
+ )
+
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.session_recording_opt_in)
+ self.assertTrue(self.team.autocapture_exceptions_opt_in)
+
+ def test_rejects_unknown_product(self):
+ response = self._enable(["heatmaps"])
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+
+ def test_rejects_empty_products(self):
+ response = self._enable([])
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+
+ def test_admin_gated_products_require_project_admin(self):
+ # A non-admin member can enable member-safe products but not the admin-gated ones
+ # (conversations / replay masking), matching the team-update API's gate.
+ self.organization_membership.level = OrganizationMembership.Level.MEMBER
+ self.organization_membership.save()
+
+ self.assertEqual(self._enable(["error_tracking"]).status_code, status.HTTP_200_OK)
+ self.team.refresh_from_db()
+ self.assertTrue(self.team.autocapture_exceptions_opt_in)
+
+ response = self._enable(["conversations"])
+ self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
+ self.team.refresh_from_db()
+ self.assertFalse(self.team.conversations_enabled)
+
+ def test_requires_product_enablement_write_scope(self):
+ self.client.logout()
+
+ ok_key = self.create_personal_api_key_with_scopes(["product_enablement:write"])
+ response = self._enable(["error_tracking"], HTTP_AUTHORIZATION=f"Bearer {ok_key}")
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+
+ wrong_key = self.create_personal_api_key_with_scopes(["session_recording:read"])
+ response = self._enable(["error_tracking"], HTTP_AUTHORIZATION=f"Bearer {wrong_key}")
+ self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
+
+ def test_enable_writes_activity_log_without_conversations_token(self):
+ self._enable(["error_tracking", "conversations"])
+
+ log = ActivityLog.objects.filter(scope="Team", team_id=self.team.id, activity="updated").latest("created_at")
+ assert log.detail is not None
+ changed_fields = {change["field"] for change in log.detail["changes"]}
+ self.assertIn("autocapture_exceptions_opt_in", changed_fields)
+ self.assertIn("conversations_enabled", changed_fields)
+ # The minted widget token must never land in the audit log.
+ self.assertNotIn("conversations_settings", changed_fields)
diff --git a/posthog/scopes.py b/posthog/scopes.py
index a7c647aa4e42..6cf916c1a777 100644
--- a/posthog/scopes.py
+++ b/posthog/scopes.py
@@ -80,6 +80,7 @@ APIScopeObject = Literal[
"organization_member",
"person",
"plugin",
+ "product_enablement",
"product_tour",
"project",
"property_definition",
diff --git a/products/signals/backend/management/commands/reset_signals_self_driving.py b/products/signals/backend/management/commands/reset_signals_self_driving.py
index b26e08b4afa2..b9a895ea3efc 100644
--- a/products/signals/backend/management/commands/reset_signals_self_driving.py
+++ b/products/signals/backend/management/commands/reset_signals_self_driving.py
@@ -29,14 +29,24 @@ SEEDED_BY_HARNESS = "signals_scout_harness"
# Basename the wizard's agent writes into its `--install-dir` after a self-driving run.
SELF_DRIVING_REPORT_FILE = "posthog-self-driving-report.md"
+# The products the wizard's "Enable products" step turns ON, as (label, Team attr). Reading
+# them before the reset doubles as a check: an OFF one right after a run is a missed enable.
+SELF_DRIVING_PRODUCT_TOGGLES = [
+ ("Session Replay", "session_recording_opt_in"),
+ ("Error Tracking", "autocapture_exceptions_opt_in"),
+ ("Support / Conversations", "conversations_enabled"),
+]
+
class Command(BaseCommand):
help = (
"Reset a team to its pre-self-driving state so the self-driving wizard can be "
- "re-tested from scratch. Deletes signal sources, the scout fleet config, custom "
- "scouts, scout run-state (and, unless --keep-findings, emitted findings via "
- "cleanup_signals); optionally removes the wizard's report file and cycles its log. "
- "DEBUG only."
+ "re-tested from scratch. Deletes signal sources, the scout fleet config, custom scouts, "
+ "scout run-state (and, unless --keep-findings, emitted findings via cleanup_signals); "
+ "optionally removes the wizard's report file and cycles its log. With --reset-products it "
+ "also reports the product-enablement toggles (replay / error tracking / conversations) — "
+ "after a run they should all be ON, so an OFF one is highlighted as a missed enable — and "
+ "then turns them back off. DEBUG only."
)
def add_arguments(self, parser):
@@ -76,6 +86,16 @@ class Command(BaseCommand):
action="store_true",
help="Do not clear emitted findings/reports (skips the cleanup_signals delegation).",
)
+ parser.add_argument(
+ "--reset-products",
+ action="store_true",
+ help=(
+ "Also report and then turn OFF the wizard's product-enablement toggles (replay / error "
+ "tracking / conversations). Off by default — the plain reset leaves product settings "
+ "untouched. Use this for the enable-products smoke test: the pre-reset report flags any "
+ "product a self-driving run should have enabled but didn't."
+ ),
+ )
def handle(self, *args, **options):
if not settings.DEBUG:
@@ -86,11 +106,16 @@ class Command(BaseCommand):
except Team.DoesNotExist:
raise CommandError(f"Team {options['team_id']} not found")
+ # Reported before the reset so it reflects what the wizard left behind.
+ if options["reset_products"]:
+ self._report_product_state(team)
+
if not options["yes"]:
+ products_clause = "turn OFF the product toggles above and " if options["reset_products"] else ""
self.stdout.write(
self.style.WARNING(
- f"This will DELETE all Signals self-driving state for team {team.id} "
- f"(sources, scout fleet config, custom scouts, scout run-state"
+ f"This will {products_clause}DELETE all Signals self-driving state for team "
+ f"{team.id} (sources, scout fleet config, custom scouts, scout run-state"
f"{'' if options['keep_findings'] else ', emitted findings'}). "
f"Canonical scouts are preserved."
)
@@ -140,6 +165,24 @@ class Command(BaseCommand):
# Signal sources. A fresh team has none.
source_configs_deleted, _ = SignalSourceConfig.objects.filter(team=team).delete()
+ # Product toggles + companion settings back to fresh-team shape so the next run re-enables.
+ # save(update_fields=...) fires the Team post_save that re-syncs remote config.
+ if options["reset_products"]:
+ team.session_recording_opt_in = False
+ team.session_recording_masking_config = None
+ team.autocapture_exceptions_opt_in = None
+ team.conversations_enabled = None
+ team.conversations_settings = None
+ team.save(
+ update_fields=[
+ "session_recording_opt_in",
+ "session_recording_masking_config",
+ "autocapture_exceptions_opt_in",
+ "conversations_enabled",
+ "conversations_settings",
+ ]
+ )
+
# Scout run-state, so the fleet cold-starts with no learned memory or stale runs.
runs_deleted, _ = SignalScoutRun.all_teams.filter(team=team).delete()
scratchpads_deleted, _ = SignalScratchpad.all_teams.filter(team=team).delete()
@@ -149,6 +192,8 @@ class Command(BaseCommand):
self.stdout.write(f" ✓ custom scouts: {len(custom_scout_names)} ({skills_deleted} LLMSkill rows + files)")
self.stdout.write(f" ✓ scout configs: {scout_configs_deleted}")
self.stdout.write(f" ✓ source configs: {source_configs_deleted}")
+ if options["reset_products"]:
+ self.stdout.write(" ✓ product toggles: replay / error tracking / conversations turned OFF")
self.stdout.write(
f" ✓ run-state: {runs_deleted} runs, {scratchpads_deleted} scratchpads, "
f"{profiles_deleted} profiles, {emission_deleted} emission records"
@@ -170,6 +215,22 @@ class Command(BaseCommand):
)
)
+ def _report_product_state(self, team):
+ """Print the product toggles before resetting them. Right after a run all three should be
+ ON, so an OFF one is a missed enable."""
+ self.stdout.write("Product enablement (should all be ON right after a self-driving run):")
+ off = []
+ for label, attr in SELF_DRIVING_PRODUCT_TOGGLES:
+ if getattr(team, attr):
+ self.stdout.write(self.style.SUCCESS(f" ✓ {label}: ON"))
+ else:
+ self.stdout.write(self.style.WARNING(f" ✗ {label}: OFF"))
+ off.append(label)
+ if off:
+ self.stdout.write(
+ self.style.WARNING(f" ⚠ a self-driving run should have enabled, but didn't: {', '.join(off)}")
+ )
+
def _soft_delete_dwh_sources(self, team):
"""Soft-delete the self-driving-created data-warehouse pipelines (the Github / Linear /
Zendesk / PgAnalyze issue/ticket sources) so a re-run starts clean.
diff --git a/products/signals/backend/test/test_reset_signals_self_driving.py b/products/signals/backend/test/test_reset_signals_self_driving.py
index c363d2343026..1cbf65d7fc1f 100644
--- a/products/signals/backend/test/test_reset_signals_self_driving.py
+++ b/products/signals/backend/test/test_reset_signals_self_driving.py
@@ -1,3 +1,5 @@
+from io import StringIO
+
from posthog.test.base import BaseTest
from unittest import mock
@@ -92,3 +94,62 @@ class TestResetSignalsSelfDrivingDWHTeardown(BaseTest):
stripe.refresh_from_db()
assert stripe.deleted is False
mock_delete_schedule.assert_not_called()
+
+
+@override_settings(DEBUG=True)
+class TestResetSignalsSelfDrivingProductToggles(BaseTest):
+ """The wizard's step-4 product toggles are reset only with --reset-products; before doing so the
+ command reports their state, flagging any a run should have enabled but didn't. The plain reset
+ leaves product settings untouched."""
+
+ def _run_reset(self, *, reset_products: bool = False) -> str:
+ out = StringIO()
+ call_command(
+ "reset_signals_self_driving",
+ team_id=self.team.id,
+ yes=True,
+ keep_findings=True,
+ keep_log=True,
+ reset_products=reset_products,
+ stdout=out,
+ )
+ return out.getvalue()
+
+ def _enable_all_products(self) -> None:
+ self.team.session_recording_opt_in = True
+ self.team.session_recording_masking_config = {"maskAllInputs": True}
+ self.team.autocapture_exceptions_opt_in = True
+ self.team.conversations_enabled = True
+ self.team.conversations_settings = {"widget_public_token": "tok"}
+ self.team.save()
+
+ def test_reset_products_turns_toggles_to_fresh_shape(self) -> None:
+ self._enable_all_products()
+
+ self._run_reset(reset_products=True)
+
+ self.team.refresh_from_db()
+ assert self.team.session_recording_opt_in is False
+ assert self.team.session_recording_masking_config is None
+ assert self.team.autocapture_exceptions_opt_in is None
+ assert self.team.conversations_enabled is None
+ assert self.team.conversations_settings is None
+
+ def test_without_flag_leaves_product_toggles_untouched(self) -> None:
+ self._enable_all_products()
+
+ output = self._run_reset()
+
+ self.team.refresh_from_db()
+ assert self.team.session_recording_opt_in is True
+ assert self.team.autocapture_exceptions_opt_in is True
+ assert self.team.conversations_enabled is True
+ # No product report either — the plain reset says nothing about products.
+ assert "Product enablement" not in output
+
+ def test_reset_products_highlights_products_a_run_should_have_enabled(self) -> None:
+ # A fresh team has all three OFF — exactly the "wizard didn't enable it" signal.
+ output = self._run_reset(reset_products=True)
+ assert "should have enabled, but didn't" in output
+ for label in ("Session Replay", "Error Tracking", "Support / Conversations"):
+ assert label in output
diff --git a/services/mcp/definitions/core.yaml b/services/mcp/definitions/core.yaml
index d95dd4a691ee..48447f390819 100644
--- a/services/mcp/definitions/core.yaml
+++ b/services/mcp/definitions/core.yaml
@@ -442,6 +442,9 @@ tools:
organizations-projects-settings-as-of-retrieve:
operation: organizations_projects_settings_as_of_retrieve
enabled: false
+ product-enablement-create:
+ operation: product_enablement_create
+ enabled: false
project-get:
operation: organizations_projects_retrieve
enabled: true
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cb42c9afeae5..ffb971ab2d10 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -42580,6 +42580,38 @@ export namespace Schemas {
primary_properties: PrimaryPropertiesResponsePrimaryProperties;
}
+ /**
+ * * `conversations` - conversations
+ * * `error_tracking` - error_tracking
+ * * `session_replay` - session_replay
+ */
+ export type ProductsEnum = typeof ProductsEnum[keyof typeof ProductsEnum];
+
+
+ export const ProductsEnum = {
+ Conversations: 'conversations',
+ ErrorTracking: 'error_tracking',
+ SessionReplay: 'session_replay',
+ } as const;
+
+ export interface ProductEnablement {
+ /**
+ * Products to turn on for this project, each enabled with server-owned conservative defaults.
+ * @minItems 1
+ */
+ products: ProductsEnum[];
+ }
+
+ /**
+ * Per requested product: "enabled" (just turned on) or "already_enabled".
+ */
+ export type ProductEnablementResultResults = {[key: string]: string};
+
+ export interface ProductEnablementResult {
+ /** Per requested product: "enabled" (just turned on) or "already_enabled". */
+ results: ProductEnablementResultResults;
+ }
+
/**
* One row in `inventory.product_intents`.
*/
diff --git a/services/mcp/src/lib/oauth-scopes.generated.ts b/services/mcp/src/lib/oauth-scopes.generated.ts
index 93feb84cbf0a..bd046d606717 100644
--- a/services/mcp/src/lib/oauth-scopes.generated.ts
+++ b/services/mcp/src/lib/oauth-scopes.generated.ts
@@ -137,6 +137,8 @@ export const OAUTH_SCOPES_SUPPORTED = [
'person:write',
'plugin:read',
'plugin:write',
+ 'product_enablement:read',
+ 'product_enablement:write',
'product_tour:read',
'product_tour:write',
'project:read',