: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(navigation): remove the user product list model (#117253)
Rafael Audiberte69767e70894
diff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.jsindex d3414de02a59..821962fe7536 100644--- a/.github/scripts/trunk-impacted-targets.js+++ b/.github/scripts/trunk-impacted-targets.js@@ -621,7 +621,7 @@ const TRIPWIRE_RULES = [// A manifest publishes its product's urls, routes, and tree items into// globals any other product's frontend can reference, and build-products.mjs// compiles every manifest into products.json, which posthog/products.py- // loads at runtime and user_product_list.py keys off the `path` values of.+ // loads at runtime and starred_products.py keys off the `path` values of.// So both sides of the fe/py split can hold a reference to what one manifest// renames, and both claim their full lane family here.//diff --git a/.semgrep/rules/security/idor-team-scoped-models.yaml b/.semgrep/rules/security/idor-team-scoped-models.yamlindex bbbf3e6de363..5349a622e2f6 100644--- a/.semgrep/rules/security/idor-team-scoped-models.yaml+++ b/.semgrep/rules/security/idor-team-scoped-models.yaml@@ -1233,7 +1233,6 @@ rules:|UserGroup|UserInterview|UserInterviewTopic- |UserProductList|UserRepoPreference|WarehouseSuggestionTeamConfig|WebAnalyticsFilterPreset@@ -1653,7 +1652,6 @@ rules:|SessionRecordingViewed|UserFacetSettings|UserHomeSettings- |UserProductList|UserScenePersonalisation|WebAnalyticsUserConfig)$@@ -1727,7 +1725,6 @@ rules:|SessionRecordingViewed|UserFacetSettings|UserHomeSettings- |UserProductList|UserScenePersonalisation|WebAnalyticsUserConfig)$diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.tsindex 3ddc1e8970db..2b0ec92951a1 100644--- a/frontend/src/generated/core/api.schemas.ts+++ b/frontend/src/generated/core/api.schemas.ts@@ -6023,7 +6023,7 @@ export interface UserApi {passkeys_enabled_for_2fa?: boolean | null/** When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions. */hide_mcp_hints?: boolean- /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true. */+ /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization. */ui_configuration?: unknown/** @nullable */readonly onboarding_skipped_at: string | null@@ -6139,7 +6139,7 @@ export interface PatchedUserApi {passkeys_enabled_for_2fa?: boolean | null/** When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions. */hide_mcp_hints?: boolean- /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true. */+ /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization. */ui_configuration?: unknown/** @nullable */readonly onboarding_skipped_at?: string | nulldiff --git a/frontend/src/generated/core/api.zod.ts b/frontend/src/generated/core/api.zod.tsindex b7a61bcce97b..b93d7c417645 100644--- a/frontend/src/generated/core/api.zod.ts+++ b/frontend/src/generated/core/api.zod.ts@@ -1398,7 +1398,7 @@ export const UsersUpdateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -1489,7 +1489,7 @@ export const UsersPartialUpdateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -1577,7 +1577,7 @@ export const UsersHedgehogConfigPartialUpdateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -1853,7 +1853,7 @@ export const UsersScenePersonalisationCreateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -1944,7 +1944,7 @@ export const UsersTwoFactorBackupCodesCreateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -2035,7 +2035,7 @@ export const UsersTwoFactorDisableCreateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -2123,7 +2123,7 @@ export const UsersTwoFactorValidateCreateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -2211,7 +2211,7 @@ export const UsersValidate2faCreateBody = /* @__PURE__ */ zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -2299,7 +2299,7 @@ export const UsersCancelEmailChangeRequestPartialUpdateBody = /* @__PURE__ */ zo.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})@@ -2387,7 +2387,7 @@ export const UsersRequestEmailVerificationCreateBody = /* @__PURE__ */ zod.objec.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})diff --git a/frontend/src/lib/api.mock.ts b/frontend/src/lib/api.mock.tsindex 30ca516950b5..1b0fed49b09e 100644--- a/frontend/src/lib/api.mock.ts+++ b/frontend/src/lib/api.mock.ts@@ -263,8 +263,7 @@ export const MOCK_DEFAULT_USER: UserType = {has_social_auth: false,has_sso_enforcement: false,shortcut_position: 'above',- // Most stories show a settled sidebar. Stories of the starred products setup override this.- ui_configuration: { version: 1, sidebar: { starred_products_setup_completed: true } },+ ui_configuration: null,sensitive_session_expires_at: dayjs().add(1, 'hour').toISOString(),theme_mode: null,team: MOCK_DEFAULT_TEAM,diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 1d3af17f2588..bd91912d68af 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -54029,90 +54029,6 @@},"type": "object"},- "SidebarConfiguration": {- "additionalProperties": {},- "description": "Customization of the main navigation sidebar. Extra keys are tolerated so older servers accept configs written by newer clients.",- "properties": {- "density": {- "$ref": "#/definitions/SidebarDensity",- "description": "Row density of the sidebar."- },- "items": {- "$ref": "#/definitions/SidebarItemsConfiguration"- },- "sections": {- "$ref": "#/definitions/SidebarSectionsConfiguration"- },- "starred_products_setup_completed": {- "description": "True once the user saved or dismissed the setup that moves their custom products to starred products in the simple sidebar.",- "type": "boolean"- }- },- "type": "object"- },- "SidebarDensity": {- "description": "How densely the sidebar renders its rows. An absent value means \"comfortable\".",- "enum": ["comfortable", "compact"],- "type": "string"- },- "SidebarItemsConfiguration": {- "additionalProperties": false,- "description": "Individual items of the main navigation sidebar. Items inside a hidden section are hidden regardless of their own config. Activity and Settings are deliberately absent: they always stay visible.",- "properties": {- "data": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Data\" panel trigger in the Project section."- },- "files": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Files\" panel trigger in the Project section."- },- "help": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Help\" entry in the sidebar footer."- },- "home": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Home\" link in the Project section."- },- "inbox": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Inbox\" link in the Project section. Only rendered when the inbox feature is available."- },- "notifications": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Notifications\" entry in the sidebar footer. Only rendered when real-time notifications are available."- },- "starred": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Starred\" panel trigger in the Project section."- },- "tools": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "\"Products\" panel trigger in the Project section."- }- },- "type": "object"- },- "SidebarSectionsConfiguration": {- "additionalProperties": false,- "description": "Collapsible sections of the main navigation sidebar. Hiding a section hides everything inside it, except always-visible items like Activity.",- "properties": {- "my_tools": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "The \"My products\" section, listing the user's selected products."- },- "project": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "The \"Project\" section (Home and the Data/Files/Products/Starred panel triggers). Activity stays visible even when this section is hidden."- },- "recents": {- "$ref": "#/definitions/UIVisibilityConfig",- "description": "The \"Recents\" section, listing recently viewed items."- }- },- "type": "object"- },"SimilarIssue": {"additionalProperties": false,"properties": {@@ -57491,16 +57407,6 @@"enum": ["twitter", "x", "twitter_ads", "x_ads"],"type": "string"},- "UIVisibilityConfig": {- "additionalProperties": false,- "description": "Visibility of a single customizable UI element. An absent config or an absent `visible` means the element is shown.",- "properties": {- "visible": {- "type": "boolean"- }- },- "type": "object"- },"UsageMetric": {"additionalProperties": false,"properties": {@@ -57699,11 +57605,8 @@},"UserUIConfiguration": {"additionalProperties": {},- "description": "Per-user UI customization, persisted on the User model as a single JSONB blob. A null configuration and any absent key mean \"default\", which for visibility is \"shown\", so newly added UI surfaces appear for everyone until explicitly hidden. Writers must send the complete object; the server validates and replaces it wholesale.",+ "description": "Per-user UI customization, persisted on the User model as a single JSONB blob. A null configuration and any absent key mean \"default\". Writers must send the complete object; the server validates and replaces it wholesale.","properties": {- "sidebar": {- "$ref": "#/definitions/SidebarConfiguration"- },"sql_editor": {"$ref": "#/definitions/SQLEditorConfiguration"},diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 5e311df905a5..78398ced8d54 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -9200,55 +9200,6 @@ export interface ProductsData {metadata: ProductItem[]}-/** Visibility of a single customizable UI element. An absent config or an absent `visible` means the element is shown. */-export interface UIVisibilityConfig {- visible?: boolean-}--/** Collapsible sections of the main navigation sidebar. Hiding a section hides everything inside it, except always-visible items like Activity. */-export interface SidebarSectionsConfiguration {- /** The "Project" section (Home and the Data/Files/Products/Starred panel triggers). Activity stays visible even when this section is hidden. */- project?: UIVisibilityConfig- /** The "Recents" section, listing recently viewed items. */- recents?: UIVisibilityConfig- /** The "My products" section, listing the user's selected products. */- my_tools?: UIVisibilityConfig-}--/** Individual items of the main navigation sidebar. Items inside a hidden section are hidden regardless of their own config. Activity and Settings are deliberately absent: they always stay visible. */-export interface SidebarItemsConfiguration {- /** "Home" link in the Project section. */- home?: UIVisibilityConfig- /** "Inbox" link in the Project section. Only rendered when the inbox feature is available. */- inbox?: UIVisibilityConfig- /** "Data" panel trigger in the Project section. */- data?: UIVisibilityConfig- /** "Files" panel trigger in the Project section. */- files?: UIVisibilityConfig- /** "Products" panel trigger in the Project section. */- tools?: UIVisibilityConfig- /** "Starred" panel trigger in the Project section. */- starred?: UIVisibilityConfig- /** "Notifications" entry in the sidebar footer. Only rendered when real-time notifications are available. */- notifications?: UIVisibilityConfig- /** "Help" entry in the sidebar footer. */- help?: UIVisibilityConfig-}--/** How densely the sidebar renders its rows. An absent value means "comfortable". */-export type SidebarDensity = 'comfortable' | 'compact'--/** Customization of the main navigation sidebar. Extra keys are tolerated so older servers accept configs written by newer clients. */-export interface SidebarConfiguration {- sections?: SidebarSectionsConfiguration- items?: SidebarItemsConfiguration- /** Row density of the sidebar. */- density?: SidebarDensity- /** True once the user saved or dismissed the setup that moves their custom products to starred products in the simple sidebar. */- starred_products_setup_completed?: boolean- [key: string]: unknown-}-/** Customization of the SQL editor. Extra keys are tolerated so older servers accept configs written by newer clients. */export interface SQLEditorConfiguration {/** Whether the SQL editor uses Vim keybindings. An absent value falls back to the legacy browser preference. */@@ -9263,8 +9214,7 @@ export interface SQLEditorConfiguration {/*** Per-user UI customization, persisted on the User model as a single JSONB blob.- * A null configuration and any absent key mean "default", which for visibility is "shown",- * so newly added UI surfaces appear for everyone until explicitly hidden.+ * A null configuration and any absent key mean "default".* Writers must send the complete object; the server validates and replaces it wholesale.*/export interface UserUIConfiguration {@@ -9273,7 +9223,6 @@ export interface UserUIConfiguration {* @asType integer*/version: number- sidebar?: SidebarConfigurationsql_editor?: SQLEditorConfiguration[key: string]: unknown}diff --git a/posthog/admin/admins/user_product_list_admin.py b/posthog/admin/admins/user_product_list_admin.pydeleted file mode 100644index 6f268ae1bd22..000000000000--- a/posthog/admin/admins/user_product_list_admin.py+++ /dev/null@@ -1,54 +0,0 @@-from django.contrib import admin--from posthog.models.file_system.user_product_list import UserProductList--[email protected](UserProductList)-class UserProductListAdmin(admin.ModelAdmin):- list_display = ("id", "user", "team", "product_path", "enabled", "updated_at")- list_display_links = ("id",)- list_filter = (- "product_path",- "enabled",- ("created_at", admin.DateFieldListFilter),- )- search_fields = ("product_path", "user__email", "team__name")- ordering = ("-created_at",)- list_select_related = ("user", "team")-- readonly_fields = [- "id",- "user",- "team",- "product_path",- "enabled",- "created_at",- "updated_at",- ]-- fieldsets = [- (- None,- {- "fields": ["id", "user", "team", "product_path"],- },- ),- (- "Status",- {- "fields": ["enabled"],- },- ),- (- "Timestamps",- {- "fields": ["created_at", "updated_at"],- },- ),- ]-- def has_add_permission(self, request):- return False-- def has_change_permission(self, request, obj=None):- return Falsediff --git a/posthog/api/test/test_user.py b/posthog/api/test/test_user.pyindex 2e548a488bef..1ceea5f32ad0 100644--- a/posthog/api/test/test_user.py+++ b/posthog/api/test/test_user.py@@ -39,7 +39,6 @@ from posthog.models.oauth import OAuthAccessToken, OAuthApplication, OAuthGrant,from posthog.models.organization import Organization, OrganizationMembershipfrom posthog.models.organization_domain import OrganizationDomainfrom posthog.models.personal_api_key import PersonalAPIKey-from posthog.models.user import default_ui_configuration_for_new_usersfrom posthog.models.utils import generate_random_token_personal, hash_key_valuefrom posthog.models.webauthn_credential import WebauthnCredentialfrom posthog.temporal.tests.delete_teams.inline import execute_deletion_workflows_inline@@ -278,16 +277,7 @@ class TestUserAPI(APIBaseTest):assert response.json() == {"a bag": "of data"}def test_can_update_ui_configuration(self):- # Joining marks the starred setup done, and updates keep that key, so start from nothing.- self.user.ui_configuration = None- self.user.save(update_fields=["ui_configuration"])- configuration = {- "version": 1,- "sidebar": {- "sections": {"recents": {"visible": False}},- "items": {"data": {"visible": False}},- },- }+ configuration = {"version": 1, "sql_editor": {"vim_mode_enabled": True, "vimrc": "imap jj <Esc>"}}response = self.client.patch("/api/users/@me/", {"ui_configuration": configuration})@@ -301,7 +291,7 @@ class TestUserAPI(APIBaseTest):response = self.client.patch("/api/users/@me/",- {"ui_configuration": {"version": 1, "sidebar": {"items": {"bogus": {"visible": False}}}}},+ {"ui_configuration": {"version": 1, "sql_editor": {"vim_mode_enabled": "nope"}}},)self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)@@ -2821,12 +2811,7 @@ class TestUserUIConfigurationValidation(SimpleTestCase):@parameterized.expand([("not_an_object", ["version"]),- ("missing_version", {"sidebar": {}}),- ("unknown_section", {"version": 1, "sidebar": {"sections": {"bogus": {"visible": False}}}}),- ("unknown_item", {"version": 1, "sidebar": {"items": {"bogus": {"visible": False}}}}),- ("activity_not_customizable", {"version": 1, "sidebar": {"items": {"activity": {"visible": False}}}}),- ("non_boolean_visible", {"version": 1, "sidebar": {"items": {"home": {"visible": "nope"}}}}),- ("unknown_node_key", {"version": 1, "sidebar": {"items": {"home": {"visible": False, "size": 1}}}}),+ ("missing_version", {"sql_editor": {}}),("non_boolean_vim_mode", {"version": 1, "sql_editor": {"vim_mode_enabled": "nope"}}),("non_string_vimrc", {"version": 1, "sql_editor": {"vimrc": ["imap jj <Esc>"]}}),("vimrc_too_long", {"version": 1, "sql_editor": {"vimrc": "x" * 10001}}),@@ -2843,9 +2828,9 @@ class TestUserUIConfigurationValidation(SimpleTestCase):("null", None),("minimal", {"version": 1}),("unknown_top_level_key", {"version": 1, "surprise": True}),- ("unknown_sidebar_key", {"version": 1, "sidebar": {"density": "compact", "surprise": True}}),(- "full",+ # Sidebar settings an older client stored. Rejecting them would block every later save.+ "stored_sidebar_settings",{"version": 1,"sidebar": {@@ -2863,7 +2848,6 @@ class TestUserUIConfigurationValidation(SimpleTestCase):},},),- ("new_user_default", default_ui_configuration_for_new_users()),("sql_editor",{@@ -2879,37 +2863,6 @@ class TestUserUIConfigurationValidation(SimpleTestCase):self.assertTrue(serializer.is_valid(), serializer.errors)self.assertEqual(serializer.validated_data["ui_configuration"], value)- @parameterized.expand(- [- (- "omitted_key_is_kept",- True,- {"version": 1, "sidebar": {"density": "compact"}},- {"version": 1, "sidebar": {"density": "compact", "starred_products_setup_completed": True}},- ),- (- "omitted_sidebar_is_kept",- True,- {"version": 1},- {"version": 1, "sidebar": {"starred_products_setup_completed": True}},- ),- ("reset_is_kept", True, None, {"version": 1, "sidebar": {"starred_products_setup_completed": True}}),- (- "explicit_false_wins",- True,- {"version": 1, "sidebar": {"starred_products_setup_completed": False}},- {"version": 1, "sidebar": {"starred_products_setup_completed": False}},- ),- ("not_completed_is_untouched", False, {"version": 1}, {"version": 1}),- ]- )- def test_update_keeps_completed_starred_products_setup(self, _name, completed, value, expected):- user = User(ui_configuration={"version": 1, "sidebar": {"starred_products_setup_completed": completed}})- serializer = UserSerializer(instance=user, data={"ui_configuration": value}, partial=True)-- self.assertTrue(serializer.is_valid(), serializer.errors)- self.assertEqual(serializer.validated_data["ui_configuration"], expected)-@pytest.mark.eeclass TestToolbarAccessControl(APIBaseTest):diff --git a/posthog/api/user.py b/posthog/api/user.pyindex 37cb0b30a3fc..ff5602a1864f 100644--- a/posthog/api/user.py+++ b/posthog/api/user.py@@ -117,13 +117,7 @@ from posthog.models.organization import Organization, OrganizationMembershipfrom posthog.models.organization_domain import OrganizationDomainfrom posthog.models.organization_notification_lock import notification_locks_for_usersfrom posthog.models.personal_api_key import PersonalAPIKey-from posthog.models.user import (- ROLE_CHOICES,- Notifications,- OnboardingSkippedReason,- ShortcutPosition,- preserve_starred_products_setup,-)+from posthog.models.user import ROLE_CHOICES, Notifications, OnboardingSkippedReason, ShortcutPositionfrom posthog.models.webauthn_credential import WebauthnCredentialfrom posthog.permissions import APIScopePermission, TimeSensitiveActionPermission, UserNoOrgMembershipDeletePermissionfrom posthog.rate_limit import (@@ -284,11 +278,9 @@ class UserSerializer(serializers.ModelSerializer):required=False,allow_null=True,help_text=(- "Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar "- "section and item visibility, and SQL editor settings such as Vim mode and the vimrc. "- "Send the complete object: it replaces the stored value "- "wholesale. Null means no customization; absent keys mean the element is shown. Once "- "`sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true."+ "Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL "+ "editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the "+ "stored value wholesale. Null means no customization."),)anonymize_data = ClassicBehaviorBooleanFieldSerializer(@@ -669,7 +661,6 @@ class UserSerializer(serializers.ModelSerializer):return validate_notification_settings(cast(User, self.instance), notification_settings)def validate_ui_configuration(self, value: Optional[dict[str, Any]]) -> Optional[dict[str, Any]]:- value = preserve_starred_products_setup(cast(Optional[User], self.instance), value)if value is None:return Nonetry:diff --git a/posthog/apps.py b/posthog/apps.pyindex 39f4eb5e1b78..b8f59e47356d 100644--- a/posthog/apps.py+++ b/posthog/apps.py@@ -49,6 +49,7 @@ class PostHogConfig(AppConfig):# shell) would lose them. They live in dedicated import-light modules — never wire# ready() through an API module, even one that looks light today.import posthog.storage.checks # noqa: F401, PLC0415+ import posthog.models.file_system.signal_handlers # noqa: F401, PLC0415import posthog.caching.organization_serializer_cache # noqa: F401, PLC0415import posthog.models.activity_logging.signal_handlers # noqa: F401, PLC0415diff --git a/posthog/dags/backfill_starred_products.py b/posthog/dags/backfill_starred_products.pydeleted file mode 100644index 3a1bac33a9df..000000000000--- a/posthog/dags/backfill_starred_products.py+++ /dev/null@@ -1,168 +0,0 @@-"""-One-off Dagster job that moves sidebar custom products (`UserProductList`) to starred products.--For every user who has not finished the starred products setup:- - In each project with at most `MAX_PRODUCTS_TO_STAR` enabled custom products, star them all.- - In a project with more, star nothing. A list that long is a catalog, not a choice.- - Mark the setup as completed, so a re-run skips the user and the setup card no longer shows.--Safe to re-run: users who finished the setup are skipped, and products the user already starred-are not starred twice. Run it manually from the Dagster UI. Set-ops.backfill_starred_products_op.config.dry_run=True to preview.-"""--from collections import defaultdict--from django.db.models.functions import Lower--import dagster--from posthog.dags.common import JobOwners-from posthog.dataclasses import frozen-from posthog.models.file_system.starred_products import (- mark_starred_products_setup_completed,- star_products,- starred_products_setup_completed,-)-from posthog.models.file_system.user_product_list import UserProductList-from posthog.models.team import Team-from posthog.models.user import User-from posthog.products import Products--MAX_PRODUCTS_TO_STAR = 6---@frozen-class StarredProductsBackfillOutcome:- projects_starred: int- projects_over_limit: int- stars_created: int---def backfill_starred_products_for_user(user: User, *, dry_run: bool) -> StarredProductsBackfillOutcome:- known_paths = set(Products.get_product_paths())- # Custom products belong to an environment, but the sidebar shows the stars of the whole project.- # So each project gets one deduplicated list, and the limit applies to that list.- paths_by_project_id: dict[int, list[str]] = defaultdict(list)- team_ids_by_project_id: dict[int, set[int]] = defaultdict(set)- for project_id, team_id, product_path in (- UserProductList.objects.filter(user=user, enabled=True)- .order_by("team__project_id", Lower("product_path"))- .values_list("team__project_id", "team_id", "product_path")- ):- team_ids_by_project_id[project_id].add(team_id)- # A product removed from the catalog can't be starred, so it doesn't count towards the limit.- if product_path in known_paths and product_path not in paths_by_project_id[project_id]:- paths_by_project_id[project_id].append(product_path)-- projects_starred = projects_over_limit = stars_created = 0- for project_id, paths in paths_by_project_id.items():- if not paths:- continue- if len(paths) > MAX_PRODUCTS_TO_STAR:- projects_over_limit += 1- continue- projects_starred += 1- if not dry_run:- # The main environment shares its id with the project. Fall back to the oldest one the user has.- team_ids = team_ids_by_project_id[project_id]- team_id = project_id if project_id in team_ids else min(team_ids)- stars_created += star_products(user, Team.objects.only("id", "project_id").get(id=team_id), paths)-- if not dry_run:- mark_starred_products_setup_completed(user)-- return StarredProductsBackfillOutcome(- projects_starred=projects_starred, projects_over_limit=projects_over_limit, stars_created=stars_created- )--- out=dagster.DynamicOut(list[int]),- config_schema={- "user_ids": dagster.Field(- dagster.Array(dagster.Int),- default_value=[],- is_required=False,- description="Specific user IDs to process. If empty, processes every user with custom products.",- ),- "batch_size": dagster.Field(dagster.Int, default_value=500, is_required=False),- },-)-def get_custom_products_user_ids_op(context: dagster.OpExecutionContext):- user_ids: list[int] = context.op_config["user_ids"] or list(- UserProductList.objects.filter(enabled=True).order_by("user_id").values_list("user_id", flat=True).distinct()- )- batch_size: int = context.op_config["batch_size"]- context.log.info(f"Processing {len(user_ids)} users in batches of {batch_size}")- for i in range(0, len(user_ids), batch_size):- yield dagster.DynamicOutput(user_ids[i : i + batch_size], mapping_key=f"batch_{i // batch_size}")--- config_schema={- "dry_run": dagster.Field(- dagster.Bool,- default_value=False,- description="If True, count what would change but don't write anything.",- ),- },-)-def backfill_starred_products_op(context: dagster.OpExecutionContext, user_ids: list[int]) -> dict[str, int]:- dry_run: bool = context.op_config["dry_run"]- totals = {- "users_migrated": 0,- "skipped_already_completed": 0,- "skipped_errored": 0,- "projects_starred": 0,- "projects_over_limit": 0,- "stars_created": 0,- }-- # is_active is read by User.from_db, so leaving it out costs a query per user.- for user in User.objects.filter(id__in=user_ids).only("id", "ui_configuration", "is_active"):- if starred_products_setup_completed(user):- totals["skipped_already_completed"] += 1- continue- try:- outcome = backfill_starred_products_for_user(user, dry_run=dry_run)- except Exception as e:- context.log.warning(f"user {user.id}: failed to backfill starred products ({e!r}); skipping")- totals["skipped_errored"] += 1- continue- totals["users_migrated"] += 1- totals["projects_starred"] += outcome.projects_starred- totals["projects_over_limit"] += outcome.projects_over_limit- totals["stars_created"] += outcome.stars_created-- context.log.info(f"Batch: dry_run={dry_run}, {totals}")- context.add_output_metadata(- {"dry_run": dagster.MetadataValue.bool(dry_run)}- | {key: dagster.MetadataValue.int(value) for key, value in totals.items()}- )- return totals---def aggregate_starred_products_backfill_op(context: dagster.OpExecutionContext, results: list[dict[str, int]]) -> None:- totals: dict[str, int] = defaultdict(int)- for result in results:- for key, value in result.items():- totals[key] += value- context.log.info(f"Job complete: {dict(totals)}")- context.add_output_metadata({key: dagster.MetadataValue.int(value) for key, value in totals.items()})--- description=(- "Move sidebar custom products to starred products for users who have not finished the starred "- f"products setup. Projects with more than {MAX_PRODUCTS_TO_STAR} custom products get no stars. "- "Every migrated user is marked as having finished the setup. "- "Set ops.backfill_starred_products_op.config.dry_run=True to preview."- ),- tags={"owner": JobOwners.TEAM_GROWTH.value},-)-def backfill_starred_products_job():- user_ids = get_custom_products_user_ids_op()- results = user_ids.map(backfill_starred_products_op)- aggregate_starred_products_backfill_op(results.collect())diff --git a/posthog/dags/locations/analytics_platform.py b/posthog/dags/locations/analytics_platform.pyindex 6c0c25273bad..db0f1e788a55 100644--- a/posthog/dags/locations/analytics_platform.py+++ b/posthog/dags/locations/analytics_platform.py@@ -3,7 +3,6 @@ import dagsterfrom posthog.dags import sessions, sessions_v1_cleanupfrom posthog.dags.backfill_internal_test_users_cohort import backfill_internal_test_users_cohort_jobfrom posthog.dags.backfill_persons_on_events_mode import backfill_persons_on_events_mode_job-from posthog.dags.backfill_starred_products import backfill_starred_products_jobfrom posthog.dags.sessions import (experimental_sessions_backfill_job,experimental_sessions_v3_backfill,@@ -20,7 +19,6 @@ defs = dagster.Definitions(experimental_sessions_backfill_job,backfill_internal_test_users_cohort_job,backfill_persons_on_events_mode_job,- backfill_starred_products_job,],loggers=loggers,resources=resources,diff --git a/posthog/dags/tests/test_backfill_starred_products.py b/posthog/dags/tests/test_backfill_starred_products.pydeleted file mode 100644index e7f3315a53e3..000000000000--- a/posthog/dags/tests/test_backfill_starred_products.py+++ /dev/null@@ -1,89 +0,0 @@-from posthog.test.base import BaseTest--from dagster import build_op_context-from parameterized import parameterized--from posthog.dags.backfill_starred_products import MAX_PRODUCTS_TO_STAR, backfill_starred_products_op-from posthog.models.file_system.file_system_shortcut import FileSystemShortcut-from posthog.models.file_system.starred_products import starred_products_setup_completed-from posthog.models.file_system.user_product_list import UserProductList-from posthog.models.team import Team-from posthog.models.user import User-from posthog.products import Products---class TestBackfillStarredProducts(BaseTest):- def _starred_paths(self, user: User, team: Team) -> list[str]:- return list(- FileSystemShortcut.objects.filter(user=user, team=team).order_by("order").values_list("path", flat=True)- )-- def _add_custom_products(self, user: User, team: Team, paths: list[str], *, enabled: bool = True) -> None:- UserProductList.objects.bulk_create(- [UserProductList(user=user, team=team, product_path=path, enabled=enabled) for path in paths]- )-- def test_stars_small_lists_skips_long_lists_and_completes_setup(self) -> None:- paths = sorted(Products.get_product_paths(), key=str.lower)[: MAX_PRODUCTS_TO_STAR + 1]- user = User.objects.create_user(email="[email protected]", password="password", first_name="User")- user.ui_configuration = {"version": 1, "sidebar": {"density": "compact"}}- user.save()- long_list_team = Team.objects.create(organization=self.organization, name="Long list")- self._add_custom_products(user, self.team, paths[:MAX_PRODUCTS_TO_STAR])- self._add_custom_products(user, self.team, [paths[MAX_PRODUCTS_TO_STAR]], enabled=False)- self._add_custom_products(user, long_list_team, paths)-- result = backfill_starred_products_op(build_op_context(), [user.id])-- assert self._starred_paths(user, self.team) == paths[:MAX_PRODUCTS_TO_STAR]- assert self._starred_paths(user, long_list_team) == []- user.refresh_from_db()- assert starred_products_setup_completed(user)- assert (user.ui_configuration or {})["sidebar"]["density"] == "compact"- assert result["users_migrated"] == 1- assert result["projects_starred"] == 1- assert result["projects_over_limit"] == 1-- @parameterized.expand([("dry_run", True), ("already_completed", False)])- def test_writes_nothing(self, _name: str, dry_run: bool) -> None:- user = User.objects.create_user(email="[email protected]", password="password", first_name="User")- if not dry_run:- user.ui_configuration = {"version": 1, "sidebar": {"starred_products_setup_completed": True}}- user.save()- self._add_custom_products(user, self.team, ["Session replay"])-- backfill_starred_products_op(build_op_context(op_config={"dry_run": dry_run}), [user.id])-- assert self._starred_paths(user, self.team) == []- user.refresh_from_db()- assert starred_products_setup_completed(user) is not dry_run-- def test_keeps_existing_stars_without_duplicating_them(self) -> None:- user = User.objects.create_user(email="[email protected]", password="password", first_name="User")- FileSystemShortcut.objects.create(team=self.team, user=user, path="Session replay", type="session_replay")- self._add_custom_products(user, self.team, ["Error tracking", "Session replay"])-- backfill_starred_products_op(build_op_context(), [user.id])-- assert self._starred_paths(user, self.team) == ["Session replay", "Error tracking"]-- @parameterized.expand([("at_the_limit", 2, 6), ("over_the_limit", 3, 0)])- def test_applies_the_limit_to_each_project_across_its_environments(- self, _name: str, extra_in_second_environment: int, expected_stars: int- ) -> None:- paths = sorted(Products.get_product_paths(), key=str.lower)- user = User.objects.create_user(email="[email protected]", password="password", first_name="User")- second_environment = Team.objects.create(organization=self.organization, project=self.project, name="Staging")- self._add_custom_products(user, self.team, paths[:4])- # Two products overlap, so they count once.- self._add_custom_products(user, second_environment, paths[2 : 4 + extra_in_second_environment])-- backfill_starred_products_op(build_op_context(), [user.id])-- starred = list(- FileSystemShortcut.objects.filter(user=user, team__project_id=self.project.id).values_list(- "path", flat=True- )- )- assert sorted(starred, key=str.lower) == paths[: 4 + extra_in_second_environment][:expected_stars]- assert len(starred) == len(set(starred))diff --git a/posthog/management/migration_analysis/atomic_false_acknowledged_migrations.txt b/posthog/management/migration_analysis/atomic_false_acknowledged_migrations.txtindex b706ed97df5a..1f33eb358afa 100644--- a/posthog/management/migration_analysis/atomic_false_acknowledged_migrations.txt+++ b/posthog/management/migration_analysis/atomic_false_acknowledged_migrations.txt@@ -54,3 +54,4 @@ signals.0177_backfill_scout_notebook_writeposthog.1383_taggeditem_untrack_legacy_keysee.0064_split_identity_provider_config_scopesconversations.0076_tag_legacy_conversation_attachments+posthog.1398_remove_userproductlist_statediff --git a/posthog/migrations/1398_remove_userproductlist_state.py b/posthog/migrations/1398_remove_userproductlist_state.pynew file mode 100644index 000000000000..c8126998bd50--- /dev/null+++ b/posthog/migrations/1398_remove_userproductlist_state.py@@ -0,0 +1,31 @@+from django.db import migrations++from posthog.migration_helpers import DropForeignKey+++class Migration(migrations.Migration):+ """Take UserProductList out of Django's state and drop its foreign keys.++ Starred products replaced custom products, and nothing reads or writes the table anymore.+ The table stays until a later migration drops it with SafeDropTable.++ The foreign keys go now. Once Django cannot see the model, deleting a team or a user stops+ cascading into this table, and the deferred constraints would fail that delete at COMMIT.+ Both keys point at hot tables, so each drop commits on its own to keep the parent locks short.+ """++ atomic = False++ dependencies = [+ ("posthog", "1397_uploaded_media_dimensions_and_archive"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[migrations.DeleteModel(name="UserProductList")],+ database_operations=[+ DropForeignKey("posthog_userproductlist", column="team_id"),+ DropForeignKey("posthog_userproductlist", column="user_id"),+ ],+ ),+ ]diff --git a/posthog/migrations/1399_alter_user_ui_configuration_help_text.py b/posthog/migrations/1399_alter_user_ui_configuration_help_text.pynew file mode 100644index 000000000000..0832be42dbe2--- /dev/null+++ b/posthog/migrations/1399_alter_user_ui_configuration_help_text.py@@ -0,0 +1,27 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ # help_text lives only in Django's state, so the database is left alone. A plain AlterField would+ # emit no SQL either, but it reads as a lock on posthog_user, which is read on every request.++ dependencies = [+ ("posthog", "1398_remove_userproductlist_state"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.AlterField(+ model_name="user",+ name="ui_configuration",+ field=models.JSONField(+ blank=True,+ help_text="Per-user UI customization, such as SQL editor settings, shaped like the UserUIConfiguration schema. NULL means the user has no customization.",+ null=True,+ ),+ ),+ ],+ database_operations=[],+ ),+ ]diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txtindex 57c831b47cbb..90ac8b1a295b 100644--- a/posthog/migrations/max_migration.txt+++ b/posthog/migrations/max_migration.txt@@ -1 +1 @@-1397_uploaded_media_dimensions_and_archive+1399_alter_user_ui_configuration_help_textdiff --git a/posthog/models/__init__.py b/posthog/models/__init__.pyindex 31304fdaad35..ae1fdb51545d 100644--- a/posthog/models/__init__.py+++ b/posthog/models/__init__.py@@ -29,7 +29,6 @@ from products.event_definitions.backend.models import EventPropertyfrom .file_system.file_system import FileSystemfrom .file_system.file_system_home_folder import FileSystemHomeFolderfrom .file_system.file_system_view_log import FileSystemViewLog-from .file_system.user_product_list import UserProductListfrom .group import Groupfrom .group_usage_metric import GroupUsageMetricfrom .group_type_mapping import GroupTypeMapping@@ -113,7 +112,6 @@ __all__ = ["FileSystem","FileSystemHomeFolder","FileSystemViewLog",- "UserProductList","Group","GroupUsageMetric","GroupTypeMapping",diff --git a/posthog/models/file_system/signal_handlers.py b/posthog/models/file_system/signal_handlers.pynew file mode 100644index 000000000000..aa13bd366895--- /dev/null+++ b/posthog/models/file_system/signal_handlers.py@@ -0,0 +1,19 @@+from django.conf import settings+from django.db import transaction+from django.db.models.signals import post_save+from django.dispatch import receiver++from posthog.models.file_system.starred_products import star_default_products+++@receiver(post_save, sender="ee.AccessControl")+def access_control_created(sender, instance, created, **kwargs):+ """Star the default products for a user who is granted access to a project."""+ if created and instance.organization_member and instance.resource == "project":+ user = instance.organization_member.user+ team = instance.team++ if settings.TEST:+ star_default_products(user, team)+ else:+ transaction.on_commit(lambda: star_default_products(user, team))diff --git a/posthog/models/file_system/starred_products.py b/posthog/models/file_system/starred_products.pyindex 4acf99972041..5b46464c912c 100644--- a/posthog/models/file_system/starred_products.py+++ b/posthog/models/file_system/starred_products.py@@ -1,4 +1,4 @@-from typing import TYPE_CHECKING, Any, cast+from typing import TYPE_CHECKING, castfrom django.db import transactionfrom django.db.models import QuerySet@@ -24,28 +24,6 @@ DEFAULT_PRODUCT_PATHS = []-def starred_products_setup_completed(user: User) -> bool:- configuration = user.ui_configuration- sidebar = configuration.get("sidebar") if isinstance(configuration, dict) else None- return isinstance(sidebar, dict) and bool(sidebar.get("starred_products_setup_completed"))---def mark_starred_products_setup_completed(user: User) -> None:- # Merge into the stored value under a short row lock, so a concurrent settings change is kept.- # NO KEY UPDATE is the lock the UPDATE takes anyway, and it does not block inserts of child rows.- with transaction.atomic():- # Not type(user): request.user is a SimpleLazyObject, which has no objects manager.- stored = User.objects.select_for_update(no_key=True).only("ui_configuration").get(pk=user.pk).ui_configuration- configuration: dict[str, Any] = stored if isinstance(stored, dict) else {}- sidebar = configuration.get("sidebar")- user.ui_configuration = {- "version": 1,- **configuration,- "sidebar": {**(sidebar if isinstance(sidebar, dict) else {}), "starred_products_setup_completed": True},- }- user.save(update_fields=["ui_configuration"])--def _project_shortcuts(user: User, team: "Team") -> QuerySet[FileSystemShortcut]:# The sidebar lists the shortcuts of every environment in the project, so checks span them all.# nosemgrep: environment-model-scoped-by-project -- the shortcut API lists a user's own stars project-widediff --git a/posthog/models/file_system/user_product_list.py b/posthog/models/file_system/user_product_list.pydeleted file mode 100644index 47f310733c0a..000000000000--- a/posthog/models/file_system/user_product_list.py+++ /dev/null@@ -1,63 +0,0 @@-from typing import ClassVar--from django.conf import settings-from django.db import models, transaction-from django.db.models.expressions import F-from django.db.models.signals import post_save-from django.dispatch.dispatcher import receiver--from posthog.models.file_system.starred_products import star_default_products-from posthog.models.utils import UpdatedMetaFields, UUIDModel, uuid7---class UserProductList(UUIDModel, UpdatedMetaFields):- """- A user's custom sidebar products from before starred products replaced them.-- Nothing writes it anymore. It stays until the starred products backfill has moved every user over.- """-- # django-stubs normally injects the default `objects` manager during mypy's semantic pass,- # but this module sits in an import cycle (it imports `user_access_control`/`organization`,- # which loop back through `posthog.models`). When the plugin analyzes the model mid-cycle it- # skips the injection, so every `UserProductList.objects` use trips `attr-defined`. Declaring- # the manager explicitly is order-independent and keeps the type stable regardless of the cycle.- objects: ClassVar[models.Manager["UserProductList"]]-- id = models.UUIDField(primary_key=True, default=uuid7, editable=False)- team = models.ForeignKey("Team", on_delete=models.CASCADE)- user = models.ForeignKey("User", on_delete=models.CASCADE)- product_path = models.CharField(max_length=200)-- # Not using `CreatedMetaFields` because of the clashing `user` reference with `created_by`- created_at = models.DateTimeField(auto_now_add=True)-- # There's a difference between the `UserProductList` not existing and it being disabled- # If it's not existing it just means the user hasn't decided whether they want that in- # the sidebar or not. In that case, we're free to add it to the sidebar as a suggestion- # when we detect they have been using a product.- #- # If the model does exist but this is set to false, we then know that we should not turn- # it on as a suggestion since it was an intentional change.- enabled = models.BooleanField(default=True)-- class Meta:- unique_together = (("team", "user", "product_path"),)- indexes = [- models.Index(F("team_id"), F("user_id"), name="posthog_upl_team_user"),- ]- verbose_name = "User Product List"- verbose_name_plural = "User Product Lists"---@receiver(post_save, sender="ee.AccessControl")-def access_control_created(sender, instance, created, **kwargs):- """Star the default products for a user who is granted access to a project."""- if created and instance.organization_member and instance.resource == "project":- user = instance.organization_member.user- team = instance.team-- if settings.TEST:- star_default_products(user, team)- else:- transaction.on_commit(lambda: star_default_products(user, team))diff --git a/posthog/models/scoping/baseline_unmigrated.txt b/posthog/models/scoping/baseline_unmigrated.txtindex be574225253b..fc12bcbf3572 100644--- a/posthog/models/scoping/baseline_unmigrated.txt+++ b/posthog/models/scoping/baseline_unmigrated.txt@@ -181,7 +181,6 @@ UploadedMediaUserHomeSettingsUserInterviewUserInterviewTopic-UserProductListUserRepoPreferenceUserScenePersonalisationWebAnalyticsFilterPresetdiff --git a/posthog/models/test/test_user_model.py b/posthog/models/test/test_user_model.pyindex 4f1754ee5977..c4a9f645b64f 100644--- a/posthog/models/test/test_user_model.py+++ b/posthog/models/test/test_user_model.py@@ -8,7 +8,6 @@ from django.core.management.base import CommandErrorfrom posthog.constants import AvailableFeaturefrom posthog.models import Team, Userfrom posthog.models.organization import Organization, OrganizationMembership-from posthog.models.user import default_ui_configuration_for_new_usersfrom products.access_control.backend.models.access_control import AccessControl@@ -20,10 +19,6 @@ class TestUser(BaseTest):self.assertNotEqual(user.distinct_id, "")self.assertNotEqual(user.distinct_id, None)- def test_create_user_sets_slim_ui_configuration_default(self):- user = User.objects.create_user(first_name="Tim", email="[email protected]", password=None)- self.assertEqual(user.ui_configuration, default_ui_configuration_for_new_users())-def test_create_superuser_raises_with_guidance(self):with self.assertRaises(CommandError) as ctx:User.objects.create_superuser(email="[email protected]", password="12345678")diff --git a/posthog/models/user.py b/posthog/models/user.pyindex 589a4ef595e8..4658830b0270 100644--- a/posthog/models/user.py+++ b/posthog/models/user.py@@ -141,7 +141,6 @@ class UserManager(BaseUserManager):raise ValueError("Email must be provided!")email = EmailNormalizer.normalize(email)extra_fields.setdefault("distinct_id", generate_random_token())- extra_fields.setdefault("ui_configuration", default_ui_configuration_for_new_users())user = cast("User", self.model(email=email, first_name=first_name, **extra_fields))if password is not None:# nosemgrep: python.django.security.audit.unvalidated-password.unvalidated-password (validation happens at serializer/view layer before reaching this method)@@ -217,47 +216,6 @@ def events_column_config_default() -> dict[str, Any]:return {"active": "DEFAULT"}-# New users start with a slimmer sidebar. Existing users keep ui_configuration NULL, which the-# frontend resolves as "everything shown" (their pre-customization experience). Absent keys also-# mean "shown", so this only lists the elements hidden by default for new accounts. The shape must-# stay valid against the UserUIConfiguration schema (see frontend/src/queries/schema/schema-general.ts).-def default_ui_configuration_for_new_users() -> dict[str, Any]:- return {- "version": 1,- "sidebar": {- "items": {- "files": {"visible": False},- "starred": {"visible": False},- },- },- }---def preserve_starred_products_setup(- user: Optional["User"], configuration: Optional[dict[str, Any]]-) -> Optional[dict[str, Any]]:- """Carry the completed starred products setup into a new configuration that omits it.-- Writers send the whole configuration, so a client that does not know this key (an API call,- the MCP tool, an older frontend) would otherwise drop it and show the setup again.- Sending the key explicitly, even as false, still wins.- """- stored = user.ui_configuration if user else None- if not isinstance(stored, dict):- return configuration- stored_sidebar = stored.get("sidebar")- if not (isinstance(stored_sidebar, dict) and stored_sidebar.get("starred_products_setup_completed")):- return configuration- if configuration is None:- return {"version": stored.get("version", 1), "sidebar": {"starred_products_setup_completed": True}}- sidebar = configuration.get("sidebar") if isinstance(configuration, dict) else None- if not isinstance(configuration, dict) or not isinstance(sidebar, dict | None):- return configuration- if sidebar is not None and "starred_products_setup_completed" in sidebar:- return configuration- return {**configuration, "sidebar": {**(sidebar or {}), "starred_products_setup_completed": True}}--class ThemeMode(models.TextChoices):LIGHT = "light", "Light"DARK = "dark", "Dark"@@ -333,13 +291,11 @@ class User(AbstractUser, UUIDTClassicModel, ModelActivityMixin): # type: ignoreblank=False,help_text="When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions.",)- # No field default on purpose: existing rows must stay NULL so long-time users keep seeing- # everything. New accounts get default_ui_configuration_for_new_users() via UserManager.create_user.ui_configuration = models.JSONField(null=True,blank=True,- help_text="Per-user UI customization (currently sidebar element visibility), shaped like the "- "UserUIConfiguration schema. NULL means the user has no customization and every element shows.",+ help_text="Per-user UI customization, such as SQL editor settings, shaped like the "+ "UserUIConfiguration schema. NULL means the user has no customization.",)# Onboarding exit tracking. Set when the user explicitly leaves the onboarding flow (skip or delegate).diff --git a/posthog/schema.py b/posthog/schema.pyindex 930b65e86024..f34397ccfbf8 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -286,7 +286,6 @@ from posthog.schema_enums import (SessionsV2JoinMode as SessionsV2JoinMode,SessionTableVersion as SessionTableVersion,Shelf as Shelf,- SidebarDensity as SidebarDensity,SlackIntegrationScope as SlackIntegrationScope,SlashCommandName as SlashCommandName,SliceContent as SliceContent,@@ -3507,13 +3506,6 @@ class TrendsFormulaNode(BaseModel):formula: str-class UIVisibilityConfig(BaseModel):- model_config = ConfigDict(- extra="forbid",- )- visible: bool | None = None--class UserBasicType(BaseModel):model_config = ConfigDict(extra="forbid",@@ -3529,6 +3521,14 @@ class UserBasicType(BaseModel):uuid: str+class UserUIConfiguration(BaseModel):+ sql_editor: SQLEditorConfiguration | None = None+ version: int = Field(+ ...,+ description=("Schema version of this configuration blob, for future format migrations."),+ )++class VectorSearchResponseItem(BaseModel):model_config = ConfigDict(extra="forbid",@@ -8184,53 +8184,6 @@ class SessionsTimelineQueryResponse(BaseModel):)-class SidebarItemsConfiguration(BaseModel):- model_config = ConfigDict(- extra="forbid",- )- data: UIVisibilityConfig | None = Field(default=None, description='"Data" panel trigger in the Project section.')- files: UIVisibilityConfig | None = Field(default=None, description='"Files" panel trigger in the Project section.')- help: UIVisibilityConfig | None = Field(default=None, description='"Help" entry in the sidebar footer.')- home: UIVisibilityConfig | None = Field(default=None, description='"Home" link in the Project section.')- inbox: UIVisibilityConfig | None = Field(- default=None,- description=('"Inbox" link in the Project section. Only rendered when the inbox feature is available.'),- )- notifications: UIVisibilityConfig | None = Field(- default=None,- description=(- '"Notifications" entry in the sidebar footer. Only rendered when real-time notifications are available.'- ),- )- starred: UIVisibilityConfig | None = Field(- default=None, description='"Starred" panel trigger in the Project section.'- )- tools: UIVisibilityConfig | None = Field(- default=None, description='"Products" panel trigger in the Project section.'- )---class SidebarSectionsConfiguration(BaseModel):- model_config = ConfigDict(- extra="forbid",- )- my_tools: UIVisibilityConfig | None = Field(- default=None,- description='The "My products" section, listing the user\'s selected products.',- )- project: UIVisibilityConfig | None = Field(- default=None,- description=(- 'The "Project" section (Home and the Data/Files/Products/Starred panel'- " triggers). Activity stays visible even when this section is hidden."- ),- )- recents: UIVisibilityConfig | None = Field(- default=None,- description='The "Recents" section, listing recently viewed items.',- )--class SourceSymbol(BaseModel):model_config = ConfigDict(extra="forbid",@@ -25997,19 +25950,6 @@ class SessionsTimelineQuery(BaseModel):version: float | None = Field(default=None, description="version of the node, used for schema migrations")-class SidebarConfiguration(BaseModel):- density: SidebarDensity | None = Field(default=None, description="Row density of the sidebar.")- items: SidebarItemsConfiguration | None = None- sections: SidebarSectionsConfiguration | None = None- starred_products_setup_completed: bool | None = Field(- default=None,- description=(- "True once the user saved or dismissed the setup that moves their custom"- " products to starred products in the simple sidebar."- ),- )--class SurveyCreationSchema(BaseModel):model_config = ConfigDict(extra="forbid",@@ -26136,15 +26076,6 @@ class UsageMetricsQuery(BaseModel):version: float | None = Field(default=None, description="version of the node, used for schema migrations")-class UserUIConfiguration(BaseModel):- sidebar: SidebarConfiguration | None = None- sql_editor: SQLEditorConfiguration | None = None- version: int = Field(- ...,- description=("Schema version of this configuration blob, for future format migrations."),- )--class VectorSearchQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 53918547ded3..ca9ae73c0e59 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -2936,11 +2936,6 @@ class Theme(StrEnum):SYSTEM = "system"-class SidebarDensity(StrEnum):- COMFORTABLE = "comfortable"- COMPACT = "compact"--class SlackIntegrationScope(StrEnum):APP_MENTIONS_READ = "app_mentions:read"ASSISTANT_WRITE = "assistant:write"diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 6c14454a83f3..51c9ceeee4af 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -1330,7 +1330,6 @@2 products/experiments/backend/experiment_summary_data_service.py2 products/experiments/stats/shared/cuped.py2 products/growth/backend/product_push/service.py-2 products/growth/dags/user_product_list.py2 products/managed_warehouse/backend/facade/contracts.py2 products/managed_warehouse/backend/temporal/types.py2 products/marketing_analytics/backend/demo/events.pydiff --git a/posthog/test/repo_invariants/setup_receivers_baseline.txt b/posthog/test/repo_invariants/setup_receivers_baseline.txtindex 934bef67c410..f871a09c880b 100644--- a/posthog/test/repo_invariants/setup_receivers_baseline.txt+++ b/posthog/test/repo_invariants/setup_receivers_baseline.txt@@ -137,7 +137,7 @@ post_save:posthog.models.comment.comment.log_comment_activitypost_save:posthog.models.comment.slack_thread.mirror_comment_reply_to_slack_on_createpost_save:posthog.models.event_ingestion_restriction_config.update_redis_cache_with_configpost_save:posthog.models.file_system.file_system_mixin.FileSystemSyncMixin.__init_subclass__.<locals>._file_system_post_save-post_save:posthog.models.file_system.user_product_list.access_control_created+post_save:posthog.models.file_system.signal_handlers.access_control_createdpost_save:posthog.models.global_rate_limit_threshold_config.update_redis_thresholds_on_savepost_save:posthog.models.organization.cache_organization_session_agepost_save:posthog.models.organization.invalidate_llm_gateway_quota_cache_on_active_state_changediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 1b7f96f87e26..693ee1f7bd48 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -76719,7 +76719,7 @@ export namespace Schemas {passkeys_enabled_for_2fa?: boolean | null;/** When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions. */hide_mcp_hints?: boolean;- /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true. */+ /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization. */ui_configuration?: unknown;/** @nullable */readonly onboarding_skipped_at: string | null;@@ -86986,7 +86986,7 @@ export namespace Schemas {passkeys_enabled_for_2fa?: boolean | null;/** When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions. */hide_mcp_hints?: boolean;- /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true. */+ /** Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization. */ui_configuration?: unknown;/** @nullable */readonly onboarding_skipped_at?: string | null;diff --git a/services/mcp/src/generated/core/api.ts b/services/mcp/src/generated/core/api.tsindex de003400d448..94a26441cf17 100644--- a/services/mcp/src/generated/core/api.ts+++ b/services/mcp/src/generated/core/api.ts@@ -5906,6 +5906,6 @@ export const UsersPartialUpdateBody = () => zod.object({.unknown().optional().describe(- 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true.'+ 'Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization.'),})diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/user-settings-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/user-settings-update.jsonindex 322268d8f775..9e69580aa45d 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/user-settings-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/user-settings-update.json@@ -150,7 +150,7 @@]},"ui_configuration": {- "description": "Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers sidebar section and item visibility, and SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization; absent keys mean the element is shown. Once `sidebar.starred_products_setup_completed` is true, an update that omits it keeps it true."+ "description": "Per-user UI customization, validated against the `UserUIConfiguration` schema. Covers SQL editor settings such as Vim mode and the vimrc. Send the complete object: it replaces the stored value wholesale. Null means no customization."},"uuid": {"description": "User UUID, or `@me` to target the authenticated user.",