: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(early-access-features): allow assigning features to a person or role (#73523)
Joe Martin8454d7375f46
diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex d5f2ebdd624d..2bdcd1ac4071 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -4433,6 +4433,14 @@ export enum EarlyAccessFeatureTabs {OptedOut = 'opted-out',}+export type EarlyAccessFeatureAssigneeType = 'user' | 'role'++/** Person or role an early access feature is assigned to. Defaults to the creator. */+export interface EarlyAccessFeatureAssignee {+ type: EarlyAccessFeatureAssigneeType+ id: number | string+}+export interface EarlyAccessFeatureType {/** UUID */id: string@@ -4447,6 +4455,7 @@ export interface EarlyAccessFeatureType {created_at: string/** The user who created this feature. Null for features created before creator tracking was added. */created_by?: UserBasicType | null+ assignee?: EarlyAccessFeatureAssignee | null_create_in_folder?: string | null/** The effective access level the user has for this early access feature. */user_access_level?: AccessControlLeveldiff --git a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambrindex 28966ae9f717..273e74e505ee 100644--- a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr+++ b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr@@ -368,6 +368,8 @@# ---# name: TestVisitorFieldSnapshots.test_relation_fields_EarlyAccessFeaturelist([+ 'assigned_role',+ 'assigned_user','created_by','feature_flag','team',@@ -662,6 +664,8 @@'__static_attributes__','__str__','_meta',+ 'assigned_role_id',+ 'assigned_user_id','created_at','created_by_id','feature_flag_id',diff --git a/products/early_access_features/backend/api.py b/products/early_access_features/backend/api.pyindex 31a49452d00b..89a75c05b928 100644--- a/products/early_access_features/backend/api.py+++ b/products/early_access_features/backend/api.py@@ -1,5 +1,6 @@from typing import Any+from django.core.exceptions import ValidationError as DjangoValidationErrorfrom django.http import JsonResponsefrom django.utils.text import slugifyfrom django.views.decorators.csrf import csrf_exempt@@ -16,6 +17,7 @@ from posthog.api.shared import UserBasicSerializerfrom posthog.api.utils import get_tokenfrom posthog.cdp.internal_events import InternalEventEvent, InternalEventPerson, produce_internal_eventfrom posthog.exceptions import generate_exception_response+from posthog.models.organization import OrganizationMembershipfrom posthog.models.team.team import Teamfrom posthog.models.utils import uuid7from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin@@ -30,6 +32,8 @@ from products.feature_flags.backend.api.feature_flag import ()from products.feature_flags.backend.models.feature_flag import FeatureFlag+from ee.models.rbac.role import Role+from .models import EarlyAccessFeaturelogger = structlog.get_logger(__name__)@@ -67,11 +71,16 @@ class MinimalEarlyAccessFeatureSerializer(serializers.ModelSerializer):"""A more minimal serializer, intended specificaly for non-generally-available features to be providedto posthog-js via the /early_access_features/ endpoint. Sync with posthog-js's FeaturePreview interface!++ The assignee only carries a display name (no user ID or email): the endpoint is public+ (project-token auth), so consumers like posthog.com's roadmap can attribute a feature to+ its owner without exposing anything else about the person or role."""documentationUrl = serializers.URLField(source="documentation_url")flagKey = serializers.CharField(source="feature_flag.key", allow_null=True)payload = serializers.SerializerMethodField()+ assignee = serializers.SerializerMethodField()class Meta:model = EarlyAccessFeature@@ -83,6 +92,7 @@ class MinimalEarlyAccessFeatureSerializer(serializers.ModelSerializer):"documentationUrl","flagKey","payload",+ "assignee",]read_only_fields = fields@@ -90,6 +100,33 @@ class MinimalEarlyAccessFeatureSerializer(serializers.ModelSerializer):def get_payload(self, obj):return obj.payload if obj.payload else {}+ @extend_schema_field(+ {+ "type": "object",+ "nullable": True,+ "description": "Display name of the person or role this feature is assigned to, e.g. "+ '{"type": "user", "name": "Ada Lovelace"} or {"type": "role", "name": "Data Modeling"}.',+ "properties": {+ "type": {"type": "string", "enum": ["user", "role"]},+ "name": {"type": "string"},+ },+ }+ )+ def get_assignee(self, obj):+ # Callers serializing many features should select_related assigned_user/assigned_role;+ # for unassigned features the *_id checks avoid touching the relations entirely.+ if obj.assigned_user_id and obj.assigned_user:+ name = f"{obj.assigned_user.first_name} {obj.assigned_user.last_name}".strip()+ # Users without a set name (common for SSO/invited accounts) would otherwise+ # surface an "assigned but nameless" payload, which is worse than no assignee;+ # treat them as unassigned rather than exposing a blank name.+ if name:+ return {"type": "user", "name": name}+ return None+ if obj.assigned_role_id and obj.assigned_role:+ return {"type": "role", "name": obj.assigned_role.name}+ return None+class EarlyAccessFeatureSerializer(UserAccessControlSerializerMixin, serializers.ModelSerializer):feature_flag = MinimalFeatureFlagSerializer(read_only=True)@@ -118,6 +155,7 @@ class EarlyAccessFeatureSerializer(UserAccessControlSerializerMixin, serializersallow_null=True,help_text="The user who created this early access feature. Null for features created before creator tracking was added.",)+ assignee = serializers.SerializerMethodField()class Meta:model = EarlyAccessFeature@@ -131,6 +169,7 @@ class EarlyAccessFeatureSerializer(UserAccessControlSerializerMixin, serializers"payload","created_at","created_by",+ "assignee","user_access_level",]read_only_fields = ["id", "feature_flag", "created_at", "created_by"]@@ -139,11 +178,62 @@ class EarlyAccessFeatureSerializer(UserAccessControlSerializerMixin, serializersdef get_payload(self, obj):return obj.payload if obj.payload else {}+ @extend_schema_field(+ {+ "type": "object",+ "nullable": True,+ "description": 'The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or '+ '{"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.',+ "properties": {+ "type": {"type": "string", "enum": ["user", "role"]},+ "id": {"oneOf": [{"type": "integer"}, {"type": "string"}]},+ },+ }+ )+ def get_assignee(self, obj):+ if obj.assigned_user_id:+ return {"type": "user", "id": obj.assigned_user_id}+ if obj.assigned_role_id:+ return {"type": "role", "id": str(obj.assigned_role_id)}+ return None++ def _validated_assignee_fields(self, assignee: Any) -> dict:+ """Convert an assignee payload ({"type": "user"|"role", "id": ...} or None) into model field values,+ validating that the referenced user/role belongs to this team's organization."""+ if assignee is None:+ return {"assigned_user_id": None, "assigned_role_id": None}+ if (+ not isinstance(assignee, dict)+ or assignee.get("type") not in ("user", "role")+ or assignee.get("id") in (None, "")+ ):+ raise serializers.ValidationError(+ {"assignee": 'Expected null or an object of shape {"type": "user" | "role", "id": ...}.'}+ )+ organization = self.context["get_organization"]()+ try:+ if assignee["type"] == "user":+ if not OrganizationMembership.objects.filter(+ user_id=assignee["id"], organization=organization+ ).exists():+ raise serializers.ValidationError(+ {"assignee": "Assignee user does not belong to this organization."}+ )+ return {"assigned_user_id": assignee["id"], "assigned_role_id": None}+ if not Role.objects.filter(id=assignee["id"], organization=organization).exists():+ raise serializers.ValidationError({"assignee": "Assignee role does not belong to this organization."})+ return {"assigned_user_id": None, "assigned_role_id": assignee["id"]}+ except (ValueError, TypeError, DjangoValidationError):+ raise serializers.ValidationError({"assignee": "Assignee ID is invalid."})+def update(self, instance: EarlyAccessFeature, validated_data: Any) -> EarlyAccessFeature:# Handle payload separately since SerializerMethodField is read-onlyif "payload" in self.initial_data:payload_value = self.initial_data.get("payload")validated_data["payload"] = payload_value if payload_value else {}+ # Same for assignee, which also diverges from the model fields (assigned_user/assigned_role)+ if "assignee" in self.initial_data:+ validated_data.update(self._validated_assignee_fields(self.initial_data.get("assignee")))stage = validated_data.get("stage", None)rollout_to_all = self.initial_data.get("rollout_to_all", False)@@ -269,6 +359,7 @@ class EarlyAccessFeatureSerializerCreateOnly(EarlyAccessFeatureSerializer):"payload","created_at","created_by",+ "assignee","feature_flag_id","feature_flag","_create_in_folder",@@ -308,6 +399,11 @@ class EarlyAccessFeatureSerializerCreateOnly(EarlyAccessFeatureSerializer):request = self.context["request"]validated_data["created_by"] = request.user if request.user.is_authenticated else None+ if "assignee" in self.initial_data:+ validated_data.update(self._validated_assignee_fields(self.initial_data.get("assignee")))+ elif validated_data["created_by"] is not None:+ # By default, the feature is assigned to whoever created it+ validated_data["assigned_user_id"] = validated_data["created_by"].idfeature_flag_id = validated_data.get("feature_flag_id", None)@@ -377,7 +473,9 @@ class EarlyAccessFeatureSerializerCreateOnly(EarlyAccessFeatureSerializer):class EarlyAccessFeatureViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets.ModelViewSet):scope_object = "early_access_feature"- queryset = EarlyAccessFeature.objects.select_related("feature_flag", "created_by").all()+ queryset = EarlyAccessFeature.objects.select_related(+ "feature_flag", "created_by", "assigned_user", "assigned_role"+ ).all()def get_serializer_class(self) -> type[serializers.Serializer]:if self.request.method == "POST":@@ -436,7 +534,7 @@ def early_access_features(request: Request):early_access_features = MinimalEarlyAccessFeatureSerializer(EarlyAccessFeature.objects.filter(team__project_id=team.project_id, stage__in=stages).select_related(- "feature_flag"+ "feature_flag", "assigned_user", "assigned_role"),many=True,).datadiff --git a/products/early_access_features/backend/migrations/0009_earlyaccessfeature_assignee.py b/products/early_access_features/backend/migrations/0009_earlyaccessfeature_assignee.pynew file mode 100644index 000000000000..f2505d9e8081--- /dev/null+++ b/products/early_access_features/backend/migrations/0009_earlyaccessfeature_assignee.py@@ -0,0 +1,40 @@+# Generated manually++import django.db.models.deletion+from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),+ ("early_access_features", "0008_backfill_earlyaccessfeature_created_by"),+ ("ee", "0028_alter_conversation_type"),+ ]++ operations = [+ migrations.AddField(+ model_name="earlyaccessfeature",+ name="assigned_user",+ field=models.ForeignKey(+ blank=True,+ # db_constraint disabled to avoid locking the hot posthog_user table when adding this FK.+ db_constraint=False,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to=settings.AUTH_USER_MODEL,+ ),+ ),+ migrations.AddField(+ model_name="earlyaccessfeature",+ name="assigned_role",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="ee.role",+ ),+ ),+ ]diff --git a/products/early_access_features/backend/migrations/max_migration.txt b/products/early_access_features/backend/migrations/max_migration.txtindex 932308544374..79d5d9f448d1 100644--- a/products/early_access_features/backend/migrations/max_migration.txt+++ b/products/early_access_features/backend/migrations/max_migration.txt@@ -1 +1 @@-0008_backfill_earlyaccessfeature_created_by+0009_earlyaccessfeature_assigneediff --git a/products/early_access_features/backend/models.py b/products/early_access_features/backend/models.pyindex 2c432c7667c3..5b4b77dc7ad2 100644--- a/products/early_access_features/backend/models.py+++ b/products/early_access_features/backend/models.py@@ -58,6 +58,18 @@ class EarlyAccessFeature(FileSystemSyncMixin, RootTeamMixin, UUIDTModel):documentation_url = models.URLField(max_length=800, blank=True)payload = models.JSONField(default=dict, blank=True)created_at = models.DateTimeField(auto_now_add=True)+ # Exactly one of assigned_user/assigned_role may be set (same convention as ErrorTrackingIssueAssignment).+ # Defaults to the creator on creation.+ assigned_user = models.ForeignKey(+ "posthog.User",+ null=True,+ blank=True,+ on_delete=models.SET_NULL,+ related_name="+",+ # db_constraint disabled to avoid locking the hot posthog_user table when adding this FK.+ db_constraint=False,+ )+ assigned_role = models.ForeignKey("ee.Role", null=True, blank=True, on_delete=models.SET_NULL, related_name="+")def __str__(self) -> str:return self.namediff --git a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambrindex 20daa692bccf..83f81aae5bba 100644--- a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr+++ b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr@@ -157,6 +157,8 @@"posthog_earlyaccessfeature"."documentation_url","posthog_earlyaccessfeature"."payload","posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id","posthog_featureflag"."id","posthog_featureflag"."key","posthog_featureflag"."name",@@ -177,10 +179,57 @@"posthog_featureflag"."has_encrypted_payloads","posthog_featureflag"."evaluation_runtime","posthog_featureflag"."bucketing_identifier",- "posthog_featureflag"."last_called_at"+ "posthog_featureflag"."last_called_at",+ "posthog_user"."id",+ "posthog_user"."password",+ "posthog_user"."last_login",+ "posthog_user"."first_name",+ "posthog_user"."last_name",+ "posthog_user"."is_staff",+ "posthog_user"."date_joined",+ "posthog_user"."uuid",+ "posthog_user"."current_organization_id",+ "posthog_user"."current_team_id",+ "posthog_user"."email",+ "posthog_user"."pending_email",+ "posthog_user"."distinct_id",+ "posthog_user"."is_email_verified",+ "posthog_user"."credentials_reviewed_at",+ "posthog_user"."requested_password_reset_at",+ "posthog_user"."requested_2fa_reset_at",+ "posthog_user"."has_seen_product_intro_for",+ "posthog_user"."strapi_id",+ "posthog_user"."is_active",+ "posthog_user"."role_at_organization",+ "posthog_user"."theme_mode",+ "posthog_user"."partial_notification_settings",+ "posthog_user"."anonymize_data",+ "posthog_user"."allow_impersonation",+ "posthog_user"."toolbar_mode",+ "posthog_user"."hedgehog_config",+ "posthog_user"."allow_sidebar_suggestions",+ "posthog_user"."shortcut_position",+ "posthog_user"."passkeys_enabled_for_2fa",+ "posthog_user"."hide_mcp_hints",+ "posthog_user"."onboarding_skipped_at",+ "posthog_user"."onboarding_skipped_reason",+ "posthog_user"."onboarding_skipped_organization_id",+ "posthog_user"."onboarding_delegated_to_invite_id",+ "posthog_user"."onboarding_delegated_to_organization_id",+ "posthog_user"."onboarding_delegation_accepted_at",+ "posthog_user"."events_column_config",+ "posthog_user"."email_opt_in",+ "ee_role"."id",+ "ee_role"."name",+ "ee_role"."organization_id",+ "ee_role"."created_at",+ "ee_role"."created_by_id",+ "ee_role"."feature_flags_access_level"FROM "posthog_earlyaccessfeature"INNER JOIN "posthog_team" ON ("posthog_earlyaccessfeature"."team_id" = "posthog_team"."id")LEFT OUTER JOIN "posthog_featureflag" ON ("posthog_earlyaccessfeature"."feature_flag_id" = "posthog_featureflag"."id")+ LEFT OUTER JOIN "posthog_user" ON ("posthog_earlyaccessfeature"."assigned_user_id" = "posthog_user"."id")+ LEFT OUTER JOIN "ee_role" ON ("posthog_earlyaccessfeature"."assigned_role_id" = "ee_role"."id")WHERE ("posthog_earlyaccessfeature"."stage" IN ('beta')AND "posthog_team"."project_id" = 99999)'''@@ -619,6 +668,8 @@"posthog_earlyaccessfeature"."documentation_url","posthog_earlyaccessfeature"."payload","posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id","posthog_featureflag"."id","posthog_featureflag"."key","posthog_featureflag"."name",@@ -639,10 +690,57 @@"posthog_featureflag"."has_encrypted_payloads","posthog_featureflag"."evaluation_runtime","posthog_featureflag"."bucketing_identifier",- "posthog_featureflag"."last_called_at"+ "posthog_featureflag"."last_called_at",+ "posthog_user"."id",+ "posthog_user"."password",+ "posthog_user"."last_login",+ "posthog_user"."first_name",+ "posthog_user"."last_name",+ "posthog_user"."is_staff",+ "posthog_user"."date_joined",+ "posthog_user"."uuid",+ "posthog_user"."current_organization_id",+ "posthog_user"."current_team_id",+ "posthog_user"."email",+ "posthog_user"."pending_email",+ "posthog_user"."distinct_id",+ "posthog_user"."is_email_verified",+ "posthog_user"."credentials_reviewed_at",+ "posthog_user"."requested_password_reset_at",+ "posthog_user"."requested_2fa_reset_at",+ "posthog_user"."has_seen_product_intro_for",+ "posthog_user"."strapi_id",+ "posthog_user"."is_active",+ "posthog_user"."role_at_organization",+ "posthog_user"."theme_mode",+ "posthog_user"."partial_notification_settings",+ "posthog_user"."anonymize_data",+ "posthog_user"."allow_impersonation",+ "posthog_user"."toolbar_mode",+ "posthog_user"."hedgehog_config",+ "posthog_user"."allow_sidebar_suggestions",+ "posthog_user"."shortcut_position",+ "posthog_user"."passkeys_enabled_for_2fa",+ "posthog_user"."hide_mcp_hints",+ "posthog_user"."onboarding_skipped_at",+ "posthog_user"."onboarding_skipped_reason",+ "posthog_user"."onboarding_skipped_organization_id",+ "posthog_user"."onboarding_delegated_to_invite_id",+ "posthog_user"."onboarding_delegated_to_organization_id",+ "posthog_user"."onboarding_delegation_accepted_at",+ "posthog_user"."events_column_config",+ "posthog_user"."email_opt_in",+ "ee_role"."id",+ "ee_role"."name",+ "ee_role"."organization_id",+ "ee_role"."created_at",+ "ee_role"."created_by_id",+ "ee_role"."feature_flags_access_level"FROM "posthog_earlyaccessfeature"INNER JOIN "posthog_team" ON ("posthog_earlyaccessfeature"."team_id" = "posthog_team"."id")LEFT OUTER JOIN "posthog_featureflag" ON ("posthog_earlyaccessfeature"."feature_flag_id" = "posthog_featureflag"."id")+ LEFT OUTER JOIN "posthog_user" ON ("posthog_earlyaccessfeature"."assigned_user_id" = "posthog_user"."id")+ LEFT OUTER JOIN "ee_role" ON ("posthog_earlyaccessfeature"."assigned_role_id" = "ee_role"."id")WHERE ("posthog_earlyaccessfeature"."stage" IN ('beta')AND "posthog_team"."project_id" = 99999)'''@@ -900,6 +998,8 @@"posthog_earlyaccessfeature"."documentation_url","posthog_earlyaccessfeature"."payload","posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id","posthog_featureflag"."id","posthog_featureflag"."key","posthog_featureflag"."name",@@ -920,10 +1020,57 @@"posthog_featureflag"."has_encrypted_payloads","posthog_featureflag"."evaluation_runtime","posthog_featureflag"."bucketing_identifier",- "posthog_featureflag"."last_called_at"+ "posthog_featureflag"."last_called_at",+ "posthog_user"."id",+ "posthog_user"."password",+ "posthog_user"."last_login",+ "posthog_user"."first_name",+ "posthog_user"."last_name",+ "posthog_user"."is_staff",+ "posthog_user"."date_joined",+ "posthog_user"."uuid",+ "posthog_user"."current_organization_id",+ "posthog_user"."current_team_id",+ "posthog_user"."email",+ "posthog_user"."pending_email",+ "posthog_user"."distinct_id",+ "posthog_user"."is_email_verified",+ "posthog_user"."credentials_reviewed_at",+ "posthog_user"."requested_password_reset_at",+ "posthog_user"."requested_2fa_reset_at",+ "posthog_user"."has_seen_product_intro_for",+ "posthog_user"."strapi_id",+ "posthog_user"."is_active",+ "posthog_user"."role_at_organization",+ "posthog_user"."theme_mode",+ "posthog_user"."partial_notification_settings",+ "posthog_user"."anonymize_data",+ "posthog_user"."allow_impersonation",+ "posthog_user"."toolbar_mode",+ "posthog_user"."hedgehog_config",+ "posthog_user"."allow_sidebar_suggestions",+ "posthog_user"."shortcut_position",+ "posthog_user"."passkeys_enabled_for_2fa",+ "posthog_user"."hide_mcp_hints",+ "posthog_user"."onboarding_skipped_at",+ "posthog_user"."onboarding_skipped_reason",+ "posthog_user"."onboarding_skipped_organization_id",+ "posthog_user"."onboarding_delegated_to_invite_id",+ "posthog_user"."onboarding_delegated_to_organization_id",+ "posthog_user"."onboarding_delegation_accepted_at",+ "posthog_user"."events_column_config",+ "posthog_user"."email_opt_in",+ "ee_role"."id",+ "ee_role"."name",+ "ee_role"."organization_id",+ "ee_role"."created_at",+ "ee_role"."created_by_id",+ "ee_role"."feature_flags_access_level"FROM "posthog_earlyaccessfeature"INNER JOIN "posthog_team" ON ("posthog_earlyaccessfeature"."team_id" = "posthog_team"."id")LEFT OUTER JOIN "posthog_featureflag" ON ("posthog_earlyaccessfeature"."feature_flag_id" = "posthog_featureflag"."id")+ LEFT OUTER JOIN "posthog_user" ON ("posthog_earlyaccessfeature"."assigned_user_id" = "posthog_user"."id")+ LEFT OUTER JOIN "ee_role" ON ("posthog_earlyaccessfeature"."assigned_role_id" = "ee_role"."id")WHERE ("posthog_earlyaccessfeature"."stage" IN ('beta')AND "posthog_team"."project_id" = 99999)'''@@ -1079,6 +1226,8 @@"posthog_earlyaccessfeature"."documentation_url","posthog_earlyaccessfeature"."payload","posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id","posthog_featureflag"."id","posthog_featureflag"."key","posthog_featureflag"."name",@@ -1099,10 +1248,57 @@"posthog_featureflag"."has_encrypted_payloads","posthog_featureflag"."evaluation_runtime","posthog_featureflag"."bucketing_identifier",- "posthog_featureflag"."last_called_at"+ "posthog_featureflag"."last_called_at",+ "posthog_user"."id",+ "posthog_user"."password",+ "posthog_user"."last_login",+ "posthog_user"."first_name",+ "posthog_user"."last_name",+ "posthog_user"."is_staff",+ "posthog_user"."date_joined",+ "posthog_user"."uuid",+ "posthog_user"."current_organization_id",+ "posthog_user"."current_team_id",+ "posthog_user"."email",+ "posthog_user"."pending_email",+ "posthog_user"."distinct_id",+ "posthog_user"."is_email_verified",+ "posthog_user"."credentials_reviewed_at",+ "posthog_user"."requested_password_reset_at",+ "posthog_user"."requested_2fa_reset_at",+ "posthog_user"."has_seen_product_intro_for",+ "posthog_user"."strapi_id",+ "posthog_user"."is_active",+ "posthog_user"."role_at_organization",+ "posthog_user"."theme_mode",+ "posthog_user"."partial_notification_settings",+ "posthog_user"."anonymize_data",+ "posthog_user"."allow_impersonation",+ "posthog_user"."toolbar_mode",+ "posthog_user"."hedgehog_config",+ "posthog_user"."allow_sidebar_suggestions",+ "posthog_user"."shortcut_position",+ "posthog_user"."passkeys_enabled_for_2fa",+ "posthog_user"."hide_mcp_hints",+ "posthog_user"."onboarding_skipped_at",+ "posthog_user"."onboarding_skipped_reason",+ "posthog_user"."onboarding_skipped_organization_id",+ "posthog_user"."onboarding_delegated_to_invite_id",+ "posthog_user"."onboarding_delegated_to_organization_id",+ "posthog_user"."onboarding_delegation_accepted_at",+ "posthog_user"."events_column_config",+ "posthog_user"."email_opt_in",+ "ee_role"."id",+ "ee_role"."name",+ "ee_role"."organization_id",+ "ee_role"."created_at",+ "ee_role"."created_by_id",+ "ee_role"."feature_flags_access_level"FROM "posthog_earlyaccessfeature"INNER JOIN "posthog_team" ON ("posthog_earlyaccessfeature"."team_id" = "posthog_team"."id")LEFT OUTER JOIN "posthog_featureflag" ON ("posthog_earlyaccessfeature"."feature_flag_id" = "posthog_featureflag"."id")+ LEFT OUTER JOIN "posthog_user" ON ("posthog_earlyaccessfeature"."assigned_user_id" = "posthog_user"."id")+ LEFT OUTER JOIN "ee_role" ON ("posthog_earlyaccessfeature"."assigned_role_id" = "ee_role"."id")WHERE ("posthog_earlyaccessfeature"."stage" IN ('beta')AND "posthog_team"."project_id" = 99999)'''diff --git a/products/early_access_features/backend/test/test_early_access_feature.py b/products/early_access_features/backend/test/test_early_access_feature.pyindex ab77b141f150..b4c55fe9fe19 100644--- a/products/early_access_features/backend/test/test_early_access_feature.py+++ b/products/early_access_features/backend/test/test_early_access_feature.py@@ -21,6 +21,7 @@ from products.early_access_features.backend.models import EarlyAccessFeaturefrom products.feature_flags.backend.models.feature_flag import FeatureFlagfrom ee.models.rbac.access_control import AccessControl+from ee.models.rbac.role import Roleif TYPE_CHECKING:from products.surveys.backend.models import Survey as SurveyModel@@ -642,6 +643,174 @@ class TestEarlyAccessFeature(APIBaseTest):assert response_data["stage"] == "beta"assert feature.name == "Mouse-up counter"+ def test_create_sets_created_by_and_defaults_assignee_to_creator(self):+ response = self.client.post(+ f"/api/projects/{self.team.id}/early_access_feature/",+ data={+ "name": "Assignable feature",+ "description": "A feature with an owner.",+ "stage": "concept",+ },+ format="json",+ )+ response_data = response.json()++ assert response.status_code == status.HTTP_201_CREATED, response_data+ assert response_data["created_by"]["id"] == self.user.id+ assert response_data["assignee"] == {"type": "user", "id": self.user.id}++ feature = EarlyAccessFeature.objects.get(id=response_data["id"])+ assert feature.created_by == self.user+ assert feature.assigned_user == self.user+ assert feature.assigned_role is None++ def test_can_create_feature_with_explicit_role_assignee(self):+ role = Role.objects.create(name="Data Modeling", organization=self.organization)++ response = self.client.post(+ f"/api/projects/{self.team.id}/early_access_feature/",+ data={+ "name": "Assignable feature",+ "stage": "concept",+ "assignee": {"type": "role", "id": str(role.id)},+ },+ format="json",+ )+ response_data = response.json()++ assert response.status_code == status.HTTP_201_CREATED, response_data+ assert response_data["assignee"] == {"type": "role", "id": str(role.id)}++ feature = EarlyAccessFeature.objects.get(id=response_data["id"])+ assert feature.assigned_user is None+ assert feature.assigned_role == role++ def test_can_create_feature_with_explicit_null_assignee(self):+ response = self.client.post(+ f"/api/projects/{self.team.id}/early_access_feature/",+ data={+ "name": "Assignable feature",+ "stage": "concept",+ "assignee": None,+ },+ format="json",+ )+ response_data = response.json()++ assert response.status_code == status.HTTP_201_CREATED, response_data+ assert response_data["assignee"] is None+ assert response_data["created_by"]["id"] == self.user.id++ feature = EarlyAccessFeature.objects.get(id=response_data["id"])+ assert feature.assigned_user is None+ assert feature.assigned_role is None++ def test_can_update_assignee(self):+ feature = EarlyAccessFeature.objects.create(+ team=self.team,+ name="Click counter",+ description="A revolution in usability research: now you can count clicks!",+ stage="beta",+ assigned_user=self.user,+ )+ other_user = User.objects.create_and_join(self.organization, "[email protected]", None)+ role = Role.objects.create(name="AI Research", organization=self.organization)++ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": {"type": "user", "id": other_user.id}},+ format="json",+ )+ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["assignee"] == {"type": "user", "id": other_user.id}+ # Re-fetch instead of refresh_from_db: mypy's narrowing of the assigned_* attributes+ # would otherwise persist across the refresh and flag later assertions as unreachable+ feature = EarlyAccessFeature.objects.get(id=feature.id)+ assert feature.assigned_user == other_user+ assert feature.assigned_role is None++ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": {"type": "role", "id": str(role.id)}},+ format="json",+ )+ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["assignee"] == {"type": "role", "id": str(role.id)}+ feature = EarlyAccessFeature.objects.get(id=feature.id)+ assert feature.assigned_user is None+ assert feature.assigned_role == role++ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": None},+ format="json",+ )+ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["assignee"] is None+ feature = EarlyAccessFeature.objects.get(id=feature.id)+ assert feature.assigned_user is None+ assert feature.assigned_role is None++ def test_cannot_assign_user_outside_organization(self):+ feature = EarlyAccessFeature.objects.create(+ team=self.team,+ name="Click counter",+ stage="beta",+ )+ stranger = User.objects.create_user("[email protected]", None, "Stranger")++ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": {"type": "user", "id": stranger.id}},+ format="json",+ )+ response_data = response.json()+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response_data+ assert "does not belong to this organization" in str(response_data)+ feature.refresh_from_db()+ assert feature.assigned_user is None++ def test_cannot_assign_role_outside_organization(self):+ from posthog.models.organization import Organization++ feature = EarlyAccessFeature.objects.create(+ team=self.team,+ name="Click counter",+ stage="beta",+ )+ other_organization = Organization.objects.create(name="Other org")+ other_role = Role.objects.create(name="Other role", organization=other_organization)++ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": {"type": "role", "id": str(other_role.id)}},+ format="json",+ )+ response_data = response.json()+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response_data+ assert "does not belong to this organization" in str(response_data)++ def test_rejects_malformed_assignee(self):+ feature = EarlyAccessFeature.objects.create(+ team=self.team,+ name="Click counter",+ stage="beta",+ )++ for bad_assignee in [+ {"type": "group", "id": 1},+ {"type": "user"},+ "someone",+ 42,+ {"type": "role", "id": "not-a-uuid"},+ ]:+ response = self.client.patch(+ f"/api/projects/{self.team.id}/early_access_feature/{feature.id}",+ data={"assignee": bad_assignee},+ format="json",+ )+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+def test_can_list_features(self):EarlyAccessFeature.objects.create(team=self.team,@@ -660,6 +829,7 @@ class TestEarlyAccessFeature(APIBaseTest):"previous": None,"results": [{+ "assignee": None,"created_at": ANY,"created_by": None,"description": "A revolution in usability research: now you can count clicks!",@@ -941,6 +1111,7 @@ class TestPreviewList(BaseTest, QueryMatchingTest):"documentationUrl": "","payload": {},"flagKey": "sprocket",+ "assignee": None,}],)@@ -998,6 +1169,7 @@ class TestPreviewList(BaseTest, QueryMatchingTest):"documentationUrl": "","payload": {},"flagKey": "sprocket",+ "assignee": None,}],)@@ -1044,6 +1216,7 @@ class TestPreviewList(BaseTest, QueryMatchingTest):"documentationUrl": "","payload": {},"flagKey": "sprocket",+ "assignee": None,}],)@@ -1113,6 +1286,7 @@ class TestPreviewList(BaseTest, QueryMatchingTest):"documentationUrl": "","payload": {},"flagKey": "sprocket",+ "assignee": None,}],)@@ -1208,10 +1382,76 @@ class TestPreviewList(BaseTest, QueryMatchingTest):"documentationUrl": "","payload": payload,"flagKey": "sprocket",+ "assignee": None,}],)+ def test_early_access_features_includes_assignee_display_name_in_preview(self):+ feature_flag = FeatureFlag.objects.create(+ team=self.team,+ name="Feature Flag for Feature Sprocket",+ key="sprocket",+ created_by=self.user,+ )+ feature_flag2 = FeatureFlag.objects.create(+ team=self.team,+ name="Feature Flag for Feature Sprocket 2",+ key="sprocket2",+ created_by=self.user,+ )+ feature_flag3 = FeatureFlag.objects.create(+ team=self.team,+ name="Feature Flag for Feature Sprocket 3",+ key="sprocket3",+ created_by=self.user,+ )+ role = Role.objects.create(name="Data Modeling", organization=self.organization)+ named_user = User.objects.create_and_join(self.organization, "[email protected]", None, first_name="Ada")+ nameless_user = User.objects.create_and_join(self.organization, "[email protected]", None, first_name="")+ EarlyAccessFeature.objects.create(+ team=self.team,+ name="Sprocket",+ description="A fancy new sprocket.",+ stage="beta",+ feature_flag=feature_flag,+ assigned_user=named_user,+ )+ EarlyAccessFeature.objects.create(+ team=self.team,+ name="Sprocket 2",+ description="An even fancier sprocket.",+ stage="beta",+ feature_flag=feature_flag2,+ assigned_role=role,+ )+ EarlyAccessFeature.objects.create(+ team=self.team,+ name="Sprocket 3",+ description="A nameless sprocket.",+ stage="beta",+ feature_flag=feature_flag3,+ assigned_user=nameless_user,+ )++ self.client.logout()++ # The assignee join must not introduce per-feature queries+ with self.assertNumQueries(2):+ response = self._get_features()+ self.assertEqual(response.status_code, 200)++ assignees = {f["flagKey"]: f["assignee"] for f in response.json()["earlyAccessFeatures"]}+ self.assertEqual(+ assignees,+ {+ "sprocket": {"type": "user", "name": "Ada"},+ "sprocket2": {"type": "role", "name": "Data Modeling"},+ # A user with no name serializes as unassigned rather than a blank name.+ "sprocket3": None,+ },+ )+class TestEarlyAccessFeatureScopeWarning(PersonalAPIKeysBaseTest, APIBaseTest):CREATE_PAYLOAD = {diff --git a/products/early_access_features/frontend/EarlyAccessFeature.tsx b/products/early_access_features/frontend/EarlyAccessFeature.tsxindex 0c0ea7535060..f54b75d30c34 100644--- a/products/early_access_features/frontend/EarlyAccessFeature.tsx+++ b/products/early_access_features/frontend/EarlyAccessFeature.tsx@@ -30,6 +30,7 @@ import { LemonField } from 'lib/lemon-ui/LemonField'import { LemonTabs } from 'lib/lemon-ui/LemonTabs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'+import { MenuOpenIndicator } from 'lib/ui/Menus/Menus'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'import { JSONEditorInput } from 'scenes/feature-flags/JSONEditorInput'import { LinkedHogFunctions } from 'scenes/hog-functions/list/LinkedHogFunctions'@@ -54,6 +55,7 @@ import {ScenePanelActionsSection,ScenePanelDivider,ScenePanelInfoSection,+ ScenePanelLabel,} from '~/layout/scenes/SceneLayout'import { defaultDataTableColumns } from '~/queries/nodes/DataTable/utils'import { Query } from '~/queries/Query/Query'@@ -74,6 +76,12 @@ import {ReplayTabs,} from '~/types'+import {+ AssigneeIconDisplay,+ AssigneeLabelDisplay,+} from 'products/error_tracking/frontend/components/Assignee/AssigneeDisplay'+import { AssigneeSelect } from 'products/error_tracking/frontend/components/Assignee/AssigneeSelect'+import { EarlyAccessFeatureLogicProps, earlyAccessFeatureLogic } from './earlyAccessFeatureLogic'import { InstructionsModal } from './InstructionsModal'@@ -453,6 +461,36 @@ export function EarlyAccessFeature({ id }: EarlyAccessFeatureLogicProps): JSX.El},]}/>+ {!isNewEarlyAccessFeature && (+ <ScenePanelLabel title="Assignee">+ <AssigneeSelect+ assignee={earlyAccessFeature.assignee ?? null}+ onChange={(assignee) => {+ if (isEditingFeature) {+ setEarlyAccessFeatureValue('assignee', assignee)+ } else {+ saveEarlyAccessFeature({ ...earlyAccessFeature, assignee })+ }+ }}+ fullWidth+ >+ {(displayAssignee, isOpen) => (+ <ButtonPrimitive+ fullWidth+ variant="panel"+ disabled={!!accessControlDisabledReason}+ tooltip={accessControlDisabledReason ?? undefined}+ data-state={isOpen ? 'open' : 'closed'}+ data-attr={`${RESOURCE_TYPE}-assignee`}+ >+ <AssigneeIconDisplay assignee={displayAssignee} size="small" />+ <AssigneeLabelDisplay assignee={displayAssignee} size="small" />+ <MenuOpenIndicator className="ml-auto" />+ </ButtonPrimitive>+ )}+ </AssigneeSelect>+ </ScenePanelLabel>+ )}<SceneFile dataAttrKey={RESOURCE_TYPE} /><Linkto="https://posthog.com/docs/feature-flags/early-access-feature-management"diff --git a/products/early_access_features/frontend/EarlyAccessFeatures.tsx b/products/early_access_features/frontend/EarlyAccessFeatures.tsxindex 11ad93ebdca8..250664e6eaca 100644--- a/products/early_access_features/frontend/EarlyAccessFeatures.tsx+++ b/products/early_access_features/frontend/EarlyAccessFeatures.tsx@@ -6,7 +6,7 @@ import { LemonButton, LemonInput, LemonTable, LemonTag } from '@posthog/lemon-uiimport { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'import { Shortcut } from 'lib/components/Shortcuts/Shortcut'import { keyBinds } from 'lib/components/Shortcuts/shortcuts'-import { createdAtColumn, createdByColumn } from 'lib/lemon-ui/LemonTable/columnUtils'+import { createdAtColumn } from 'lib/lemon-ui/LemonTable/columnUtils'import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'import { LemonTableColumn } from 'lib/lemon-ui/LemonTable/types'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'@@ -19,6 +19,8 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType, EarlyAccessFeatureType } from '~/types'+import { AssigneeDisplay, AssigneeResolver } from 'products/error_tracking/frontend/components/Assignee/AssigneeDisplay'+import { earlyAccessFeaturesLogic } from './earlyAccessFeaturesLogic'export const scene: SceneExport = {@@ -138,10 +140,19 @@ export function EarlyAccessFeatures(): JSX.Element {},sorter: (a, b) => STAGES_IN_ORDER[a.stage] - STAGES_IN_ORDER[b.stage],},- createdByColumn<EarlyAccessFeatureType>() as LemonTableColumn<- EarlyAccessFeatureType,- keyof EarlyAccessFeatureType | undefined- >,+ {+ title: 'Assignee',+ key: 'assignee',+ render(_, { assignee }) {+ return (+ <AssigneeResolver assignee={assignee ?? null}>+ {({ assignee: resolvedAssignee }) => (+ <AssigneeDisplay assignee={resolvedAssignee} size="small" />+ )}+ </AssigneeResolver>+ )+ },+ },createdAtColumn<EarlyAccessFeatureType>() as LemonTableColumn<EarlyAccessFeatureType,keyof EarlyAccessFeatureType | undefineddiff --git a/products/early_access_features/frontend/earlyAccessFeatureLogic.ts b/products/early_access_features/frontend/earlyAccessFeatureLogic.tsindex 1552dc13ec06..624938b87288 100644--- a/products/early_access_features/frontend/earlyAccessFeatureLogic.ts+++ b/products/early_access_features/frontend/earlyAccessFeatureLogic.ts@@ -42,6 +42,7 @@ export const NEW_EARLY_ACCESS_FEATURE: NewEarlyAccessFeatureType = {documentation_url: '',feature_flag_id: undefined,payload: {},+ // assignee is intentionally left unset: the backend defaults it to the creator}export interface EarlyAccessFeatureLogicProps {diff --git a/products/early_access_features/frontend/generated/api.schemas.ts b/products/early_access_features/frontend/generated/api.schemas.tsindex 20a4428d5bc3..9553311661a1 100644--- a/products/early_access_features/frontend/generated/api.schemas.ts+++ b/products/early_access_features/frontend/generated/api.schemas.ts@@ -143,6 +143,15 @@ export interface UserBasicApi {*/export type EarlyAccessFeatureApiPayload = { [key: string]: unknown }+/**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+export type EarlyAccessFeatureApiAssignee = {+ readonly type?: 'user' | 'role'+ readonly id?: number | string+} | null+/*** Mixin for serializers to add user access control fields*/@@ -175,6 +184,11 @@ export interface EarlyAccessFeatureApi {readonly created_at: string/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by: UserBasicApi | null+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee: EarlyAccessFeatureApiAssignee/*** The effective access level the user has for this object* @nullable@@ -191,6 +205,15 @@ export interface PaginatedEarlyAccessFeatureListApi {results: EarlyAccessFeatureApi[]}+/**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+export type EarlyAccessFeatureSerializerCreateOnlyApiAssignee = {+ readonly type?: 'user' | 'role'+ readonly id?: number | string+} | null+/*** Mixin for serializers to add user access control fields*/@@ -222,6 +245,11 @@ export interface EarlyAccessFeatureSerializerCreateOnlyApi {readonly created_at: string/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by: UserBasicApi | null+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee: EarlyAccessFeatureSerializerCreateOnlyApiAssignee/** Optional ID of an existing feature flag to link. If omitted, a new flag is auto-created from the feature name. The flag must not already be linked to another feature, must not be group-based, and must not be multivariate. */feature_flag_id?: numberreadonly feature_flag: MinimalFeatureFlagApi@@ -238,6 +266,15 @@ export interface EarlyAccessFeatureSerializerCreateOnlyApi {*/export type PatchedEarlyAccessFeatureApiPayload = { [key: string]: unknown }+/**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+export type PatchedEarlyAccessFeatureApiAssignee = {+ readonly type?: 'user' | 'role'+ readonly id?: number | string+} | null+/*** Mixin for serializers to add user access control fields*/@@ -270,6 +307,11 @@ export interface PatchedEarlyAccessFeatureApi {readonly created_at?: string/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by?: UserBasicApi | null+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee?: PatchedEarlyAccessFeatureApiAssignee/*** The effective access level the user has for this object* @nullablediff --git a/products/feature_flags/backend/api/feature_flag.py b/products/feature_flags/backend/api/feature_flag.pyindex 31de18b098f4..bf82105150cb 100644--- a/products/feature_flags/backend/api/feature_flag.py+++ b/products/feature_flags/backend/api/feature_flag.py@@ -2849,6 +2849,7 @@ class FeatureFlagViewSet(def safely_get_queryset(self, queryset) -> QuerySet:from django.db.models import Exists, OuterRef+ from products.early_access_features.backend.models import EarlyAccessFeaturefrom products.feature_flags.backend.models.evaluation_context import FeatureFlagEvaluationContext# Always prefetch experiment_set since it's used in both list and retrieve@@ -2860,6 +2861,16 @@ class FeatureFlagViewSet())+ # `features` is serialized on every action (list/retrieve/create/update), and+ # MinimalEarlyAccessFeatureSerializer resolves the assignee's name, so join the+ # assignee relations here rather than only in the list branch.+ queryset = queryset.prefetch_related(+ Prefetch(+ "features",+ queryset=EarlyAccessFeature.objects.select_related("assigned_user", "assigned_role"),+ )+ )+# Prefetch evaluation contexts to avoid N+1 queries when serializing.queryset = queryset.prefetch_related(Prefetch(@@ -2887,7 +2898,6 @@ class FeatureFlagViewSet(if self.action == "list":queryset = (queryset.filter(deleted=False)- .prefetch_related("features").prefetch_related("analytics_dashboards").prefetch_related(Prefetch(diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambrindex 3ef3303cdcfa..666e99f7182c 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr@@ -536,6 +536,26 @@'''# ---# name: TestFeatureFlag.test_creating_static_cohort.10+ '''+ SELECT "posthog_featureflagevaluationcontext"."id",+ "posthog_featureflagevaluationcontext"."feature_flag_id",+ "posthog_featureflagevaluationcontext"."evaluation_context_id",+ "posthog_featureflagevaluationcontext"."created_at",+ "posthog_evaluationcontext"."id",+ "posthog_evaluationcontext"."name",+ "posthog_evaluationcontext"."team_id",+ "posthog_evaluationcontext"."created_at",+ "posthog_evaluationcontext"."hidden_from_suggestions"+ FROM "posthog_featureflagevaluationcontext"+ INNER JOIN "posthog_evaluationcontext" ON ("posthog_featureflagevaluationcontext"."evaluation_context_id" = "posthog_evaluationcontext"."id")+ WHERE "posthog_featureflagevaluationcontext"."feature_flag_id" IN (1,+ 2,+ 3,+ 4,+ 5 /* ... */)+ '''+# ---+# name: TestFeatureFlag.test_creating_static_cohort.11'''SELECT "posthog_taggeditem"."id","posthog_taggeditem"."tag_id",@@ -561,7 +581,7 @@5 /* ... */)'''# ----# name: TestFeatureFlag.test_creating_static_cohort.11+# name: TestFeatureFlag.test_creating_static_cohort.12'''SELECT "posthog_team"."id","posthog_team"."uuid",@@ -663,7 +683,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.12+# name: TestFeatureFlag.test_creating_static_cohort.13'''SELECT "posthog_filesystem"."team_id","posthog_filesystem"."id",@@ -688,7 +708,7 @@AND "posthog_filesystem"."shortcut" IS NOT NULL))'''# ----# name: TestFeatureFlag.test_creating_static_cohort.13+# name: TestFeatureFlag.test_creating_static_cohort.14'''SELECT "posthog_filesystem"."team_id","posthog_filesystem"."id",@@ -713,7 +733,7 @@AND "posthog_filesystem"."shortcut" IS NOT NULL))'''# ----# name: TestFeatureFlag.test_creating_static_cohort.14+# name: TestFeatureFlag.test_creating_static_cohort.15'''SELECT "posthog_filesystemshortcut"."id","posthog_filesystemshortcut"."team_id",@@ -736,7 +756,7 @@AND "posthog_filesystemshortcut"."href" IS NOT NULL))'''# ----# name: TestFeatureFlag.test_creating_static_cohort.15+# name: TestFeatureFlag.test_creating_static_cohort.16'''SELECT "posthog_team"."id","posthog_team"."project_id"@@ -745,7 +765,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.16+# name: TestFeatureFlag.test_creating_static_cohort.17'''SELECT "posthog_cohort"."id","posthog_cohort"."name",@@ -781,7 +801,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.17+# name: TestFeatureFlag.test_creating_static_cohort.18'''SELECT "posthog_featureflag"."id","posthog_featureflag"."key",@@ -812,7 +832,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.18+# name: TestFeatureFlag.test_creating_static_cohort.19'''SELECT 1 AS "a"FROM "posthog_cohort"@@ -828,7 +848,7 @@LIMIT 1'''# ----# name: TestFeatureFlag.test_creating_static_cohort.19+# name: TestFeatureFlag.test_creating_static_cohort.2'''SELECT "posthog_team"."id","posthog_team"."uuid",@@ -924,13 +944,50 @@"posthog_team"."experiment_recalculation_time","posthog_team"."default_experiment_confidence_level","posthog_team"."default_experiment_stats_method",- "posthog_team"."business_model"+ "posthog_team"."business_model",+ "posthog_organization"."id",+ "posthog_organization"."name",+ "posthog_organization"."slug",+ "posthog_organization"."logo_media_id",+ "posthog_organization"."created_at",+ "posthog_organization"."updated_at",+ "posthog_organization"."is_active",+ "posthog_organization"."is_not_active_reason",+ "posthog_organization"."session_cookie_age",+ "posthog_organization"."is_member_join_email_enabled",+ "posthog_organization"."is_ai_data_processing_approved",+ "posthog_organization"."is_ai_training_opted_in",+ "posthog_organization"."is_ai_training_locked",+ "posthog_organization"."is_ai_training_cta_shown",+ "posthog_organization"."enforce_2fa",+ "posthog_organization"."members_can_invite",+ "posthog_organization"."members_can_create_projects",+ "posthog_organization"."members_can_use_personal_api_keys",+ "posthog_organization"."members_can_see_org_members",+ "posthog_organization"."allow_publicly_shared_resources",+ "posthog_organization"."default_role_id",+ "posthog_organization"."plugins_access_level",+ "posthog_organization"."for_internal_metrics",+ "posthog_organization"."default_experiment_stats_method",+ "posthog_organization"."default_anonymize_ips",+ "posthog_organization"."is_hipaa",+ "posthog_organization"."is_pending_deletion",+ "posthog_organization"."customer_id",+ "posthog_organization"."available_product_features",+ "posthog_organization"."usage",+ "posthog_organization"."never_drop_data",+ "posthog_organization"."customer_trust_scores",+ "posthog_organization"."setup_section_2_completed",+ "posthog_organization"."personalization",+ "posthog_organization"."domain_whitelist",+ "posthog_organization"."is_platform"FROM "posthog_team"+ INNER JOIN "posthog_organization" ON ("posthog_team"."organization_id" = "posthog_organization"."id")WHERE "posthog_team"."id" = 99999LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.2+# name: TestFeatureFlag.test_creating_static_cohort.20'''SELECT "posthog_team"."id","posthog_team"."uuid",@@ -1026,50 +1083,13 @@"posthog_team"."experiment_recalculation_time","posthog_team"."default_experiment_confidence_level","posthog_team"."default_experiment_stats_method",- "posthog_team"."business_model",- "posthog_organization"."id",- "posthog_organization"."name",- "posthog_organization"."slug",- "posthog_organization"."logo_media_id",- "posthog_organization"."created_at",- "posthog_organization"."updated_at",- "posthog_organization"."is_active",- "posthog_organization"."is_not_active_reason",- "posthog_organization"."session_cookie_age",- "posthog_organization"."is_member_join_email_enabled",- "posthog_organization"."is_ai_data_processing_approved",- "posthog_organization"."is_ai_training_opted_in",- "posthog_organization"."is_ai_training_locked",- "posthog_organization"."is_ai_training_cta_shown",- "posthog_organization"."enforce_2fa",- "posthog_organization"."members_can_invite",- "posthog_organization"."members_can_create_projects",- "posthog_organization"."members_can_use_personal_api_keys",- "posthog_organization"."members_can_see_org_members",- "posthog_organization"."allow_publicly_shared_resources",- "posthog_organization"."default_role_id",- "posthog_organization"."plugins_access_level",- "posthog_organization"."for_internal_metrics",- "posthog_organization"."default_experiment_stats_method",- "posthog_organization"."default_anonymize_ips",- "posthog_organization"."is_hipaa",- "posthog_organization"."is_pending_deletion",- "posthog_organization"."customer_id",- "posthog_organization"."available_product_features",- "posthog_organization"."usage",- "posthog_organization"."never_drop_data",- "posthog_organization"."customer_trust_scores",- "posthog_organization"."setup_section_2_completed",- "posthog_organization"."personalization",- "posthog_organization"."domain_whitelist",- "posthog_organization"."is_platform"+ "posthog_team"."business_model"FROM "posthog_team"- INNER JOIN "posthog_organization" ON ("posthog_team"."organization_id" = "posthog_organization"."id")WHERE "posthog_team"."id" = 99999LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.20+# name: TestFeatureFlag.test_creating_static_cohort.21'''SELECT "posthog_filesystem"."team_id","posthog_filesystem"."id",@@ -1094,7 +1114,7 @@AND "posthog_filesystem"."shortcut" IS NOT NULL))'''# ----# name: TestFeatureFlag.test_creating_static_cohort.21+# name: TestFeatureFlag.test_creating_static_cohort.22'''SELECT "posthog_filesystemshortcut"."id","posthog_filesystemshortcut"."team_id",@@ -1117,7 +1137,7 @@AND "posthog_filesystemshortcut"."href" IS NOT NULL))'''# ----# name: TestFeatureFlag.test_creating_static_cohort.22+# name: TestFeatureFlag.test_creating_static_cohort.23'''SELECT "posthog_cohort"."id","posthog_cohort"."name",@@ -1151,7 +1171,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.23+# name: TestFeatureFlag.test_creating_static_cohort.24'''SELECT "posthog_team"."id","posthog_team"."uuid",@@ -1253,7 +1273,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.24+# name: TestFeatureFlag.test_creating_static_cohort.25'''SELECT "posthog_user"."id","posthog_user"."password",@@ -1299,7 +1319,7 @@LIMIT 21'''# ----# name: TestFeatureFlag.test_creating_static_cohort.25+# name: TestFeatureFlag.test_creating_static_cohort.26'''SELECT "posthog_cohortcalculationhistory"."id","posthog_cohortcalculationhistory"."team_id",@@ -1320,7 +1340,7 @@LIMIT 1'''# ----# name: TestFeatureFlag.test_creating_static_cohort.26+# name: TestFeatureFlag.test_creating_static_cohort.27'''SELECT "posthog_experiment"."id","posthog_experiment"."name",@@ -1361,7 +1381,7 @@WHERE "posthog_experiment"."exposure_cohort_id" = 99999'''# ----# name: TestFeatureFlag.test_creating_static_cohort.27+# name: TestFeatureFlag.test_creating_static_cohort.28'''/* user_id:0 celery:posthog.tasks.calculate_cohort.insert_cohort_from_feature_flag */SELECT person_id@@ -1372,7 +1392,7 @@GROUP BY person_id'''# ----# name: TestFeatureFlag.test_creating_static_cohort.28+# name: TestFeatureFlag.test_creating_static_cohort.29'''/* user_id:0 request:_snapshot_ */SELECT persons.id AS id@@ -1716,21 +1736,70 @@# ---# name: TestFeatureFlag.test_creating_static_cohort.9'''- SELECT "posthog_featureflagevaluationcontext"."id",- "posthog_featureflagevaluationcontext"."feature_flag_id",- "posthog_featureflagevaluationcontext"."evaluation_context_id",- "posthog_featureflagevaluationcontext"."created_at",- "posthog_evaluationcontext"."id",- "posthog_evaluationcontext"."name",- "posthog_evaluationcontext"."team_id",- "posthog_evaluationcontext"."created_at",- "posthog_evaluationcontext"."hidden_from_suggestions"- FROM "posthog_featureflagevaluationcontext"- INNER JOIN "posthog_evaluationcontext" ON ("posthog_featureflagevaluationcontext"."evaluation_context_id" = "posthog_evaluationcontext"."id")- WHERE "posthog_featureflagevaluationcontext"."feature_flag_id" IN (1,- 2,- 3,- 4,- 5 /* ... */)+ SELECT "posthog_earlyaccessfeature"."id",+ "posthog_earlyaccessfeature"."team_id",+ "posthog_earlyaccessfeature"."feature_flag_id",+ "posthog_earlyaccessfeature"."created_by_id",+ "posthog_earlyaccessfeature"."name",+ "posthog_earlyaccessfeature"."description",+ "posthog_earlyaccessfeature"."stage",+ "posthog_earlyaccessfeature"."documentation_url",+ "posthog_earlyaccessfeature"."payload",+ "posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id",+ "posthog_user"."id",+ "posthog_user"."password",+ "posthog_user"."last_login",+ "posthog_user"."first_name",+ "posthog_user"."last_name",+ "posthog_user"."is_staff",+ "posthog_user"."date_joined",+ "posthog_user"."uuid",+ "posthog_user"."current_organization_id",+ "posthog_user"."current_team_id",+ "posthog_user"."email",+ "posthog_user"."pending_email",+ "posthog_user"."distinct_id",+ "posthog_user"."is_email_verified",+ "posthog_user"."credentials_reviewed_at",+ "posthog_user"."requested_password_reset_at",+ "posthog_user"."requested_2fa_reset_at",+ "posthog_user"."has_seen_product_intro_for",+ "posthog_user"."strapi_id",+ "posthog_user"."is_active",+ "posthog_user"."role_at_organization",+ "posthog_user"."theme_mode",+ "posthog_user"."partial_notification_settings",+ "posthog_user"."anonymize_data",+ "posthog_user"."allow_impersonation",+ "posthog_user"."toolbar_mode",+ "posthog_user"."hedgehog_config",+ "posthog_user"."allow_sidebar_suggestions",+ "posthog_user"."shortcut_position",+ "posthog_user"."passkeys_enabled_for_2fa",+ "posthog_user"."hide_mcp_hints",+ "posthog_user"."onboarding_skipped_at",+ "posthog_user"."onboarding_skipped_reason",+ "posthog_user"."onboarding_skipped_organization_id",+ "posthog_user"."onboarding_delegated_to_invite_id",+ "posthog_user"."onboarding_delegated_to_organization_id",+ "posthog_user"."onboarding_delegation_accepted_at",+ "posthog_user"."events_column_config",+ "posthog_user"."email_opt_in",+ "ee_role"."id",+ "ee_role"."name",+ "ee_role"."organization_id",+ "ee_role"."created_at",+ "ee_role"."created_by_id",+ "ee_role"."feature_flags_access_level"+ FROM "posthog_earlyaccessfeature"+ LEFT OUTER JOIN "posthog_user" ON ("posthog_earlyaccessfeature"."assigned_user_id" = "posthog_user"."id")+ LEFT OUTER JOIN "ee_role" ON ("posthog_earlyaccessfeature"."assigned_role_id" = "ee_role"."id")+ WHERE "posthog_earlyaccessfeature"."feature_flag_id" IN (1,+ 2,+ 3,+ 4,+ 5 /* ... */)'''# ---diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambrindex f960f57ddd8a..fa1a76ac7d7b 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr@@ -2038,7 +2038,9 @@"posthog_earlyaccessfeature"."stage","posthog_earlyaccessfeature"."documentation_url","posthog_earlyaccessfeature"."payload",- "posthog_earlyaccessfeature"."created_at"+ "posthog_earlyaccessfeature"."created_at",+ "posthog_earlyaccessfeature"."assigned_user_id",+ "posthog_earlyaccessfeature"."assigned_role_id"FROM "posthog_earlyaccessfeature"WHERE "posthog_earlyaccessfeature"."feature_flag_id" = 99999'''diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 3b0a9bfaeca5..55ae22c857c5 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -22275,6 +22275,15 @@ export namespace Schemas {*/export type EarlyAccessFeaturePayload = { [key: string]: unknown };+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ export type EarlyAccessFeatureAssignee = {+ readonly type?: 'user' | 'role';+ readonly id?: number | string;+ } | null;+export type MinimalFeatureFlagFilters = { [key: string]: unknown };export interface MinimalFeatureFlag {@@ -22360,6 +22369,11 @@ export namespace Schemas {readonly created_at: string;/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by: UserBasic | null;+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee: EarlyAccessFeatureAssignee;/*** The effective access level the user has for this object* @nullable@@ -22367,6 +22381,15 @@ export namespace Schemas {readonly user_access_level: string | null;}+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ export type EarlyAccessFeatureSerializerCreateOnlyAssignee = {+ readonly type?: 'user' | 'role';+ readonly id?: number | string;+ } | null;+/*** Mixin for serializers to add user access control fields*/@@ -22398,6 +22421,11 @@ export namespace Schemas {readonly created_at: string;/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by: UserBasic | null;+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee: EarlyAccessFeatureSerializerCreateOnlyAssignee;/** Optional ID of an existing feature flag to link. If omitted, a new flag is auto-created from the feature name. The flag must not already be linked to another feature, must not be group-based, and must not be multivariate. */feature_flag_id?: number;readonly feature_flag: MinimalFeatureFlag;@@ -47449,6 +47477,15 @@ export namespace Schemas {*/export type PatchedEarlyAccessFeaturePayload = { [key: string]: unknown };+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ export type PatchedEarlyAccessFeatureAssignee = {+ readonly type?: 'user' | 'role';+ readonly id?: number | string;+ } | null;+/*** Mixin for serializers to add user access control fields*/@@ -47481,6 +47518,11 @@ export namespace Schemas {readonly created_at?: string;/** The user who created this early access feature. Null for features created before creator tracking was added. */readonly created_by?: UserBasic | null;+ /**+ * The person or role responsible for this feature, e.g. {"type": "user", "id": 123} or {"type": "role", "id": "<role uuid>"}. Defaults to the creator. Send null to unassign.+ * @nullable+ */+ readonly assignee?: PatchedEarlyAccessFeatureAssignee;/*** The effective access level the user has for this object* @nullable