: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(oauth): group consent permissions by product area (#102105)
Alex Liderfc4d8bc5f09d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex c07a38ddae68..5eaf54075286 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -10842,6 +10842,10 @@ snapshots:hash: v1.k794b7964.6e3f3f52d27e324920f358daaeadb32da366ff50210050c19f8de58d130fc1c1.sDKTyirwbr3u9MmHkz6rng_Hs_eKZHs-SBz0PbCtgTkscenes-app-oauth-authorize--identity-only-scopes--light:hash: v1.k794b7964.247a8dd0c0990f5be55cd872c28380228cebbab4aaf3fc7278452d920da1b723.-v0kuh_uR_IXDf7TZJ-zp-BBuwH1MC84DjGhsgkta0w+ scenes-app-oauth-authorize--many-optional-scopes-narrow--narrow--dark:+ hash: v1.k794b7964.b8bfc1eb9ff13d0748975f9706cb537a62ad94096c9dd71053a24412a6303aab.Kp38f4_qTzLt13-NxA0h49dh3lp_TQtyPFsP456DMKM+ scenes-app-oauth-authorize--many-optional-scopes-narrow--narrow--light:+ hash: v1.k794b7964.69b488ed05f7fc22dc4d687380eed713044d08de75471709c74f16fbe2da6906.dU_XPp75Xj24HNmLvV8OMttgxLKJ8oYuDz2DcV-rq-Escenes-app-oauth-authorize--wildcard-scope--dark:hash: v1.k794b7964.9b96958067dc05edc0e8fcbe6192e5bd4b01a3c4b8a346a4e69e7ec6008397d8.gu62zWdVnryoqleY_jEV76T8ym5U7kyZvMovNElPAmsscenes-app-oauth-authorize--wildcard-scope--light:diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessControlsLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessControlsLogic.tsindex 5af269d97bfb..af6d99b3eb07 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessControlsLogic.ts+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessControlsLogic.ts@@ -459,6 +459,7 @@ export interface accessControlsLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -504,6 +505,7 @@ export interface accessControlsLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',AccessControlLevel | null>@@ -635,6 +637,7 @@ export interface accessControlsLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -680,6 +683,7 @@ export interface accessControlsLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session')[],featureFlags: FeatureFlagsSet@@ -788,6 +792,7 @@ export interface accessControlsLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -833,6 +838,7 @@ export interface accessControlsLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'>) => AccessControlRoleEntry[]@@ -913,6 +919,7 @@ export interface accessControlsLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -958,6 +965,7 @@ export interface accessControlsLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'>) => AccessControlMemberEntry[]diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessDetailLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessDetailLogic.tsindex 704af55c1347..3128a86713f3 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessDetailLogic.ts+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/accessDetailLogic.ts@@ -284,6 +284,7 @@ export interface accessDetailLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -329,6 +330,7 @@ export interface accessDetailLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'resourceId: string}diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/addObjectOverrideModalLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/addObjectOverrideModalLogic.tsindex be66a3fcf324..2b690738143f 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/addObjectOverrideModalLogic.ts+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/addObjectOverrideModalLogic.ts@@ -130,6 +130,7 @@ export interface addObjectOverrideModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -175,6 +176,7 @@ export interface addObjectOverrideModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',resourceId: string,level: AccessControlLevel | null@@ -253,6 +255,7 @@ export interface addObjectOverrideModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -298,6 +301,7 @@ export interface addObjectOverrideModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'resourceId: string} // accessDetailLogic@@ -397,6 +401,7 @@ export interface addObjectOverrideModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -442,6 +447,7 @@ export interface addObjectOverrideModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'}openModal: () => {@@ -525,6 +531,7 @@ export interface addObjectOverrideModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -570,6 +577,7 @@ export interface addObjectOverrideModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'}setLevel: (level: AccessControlLevel) => {@@ -652,6 +660,7 @@ export interface addObjectOverrideModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -697,6 +706,7 @@ export interface addObjectOverrideModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'}setSearch: (search: string) => {@@ -800,6 +810,7 @@ export interface addObjectOverrideModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -845,6 +856,7 @@ export interface addObjectOverrideModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',objectId: string | null) => AccessObjectRule | nulldiff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/groupedAccessControlRuleModalLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/groupedAccessControlRuleModalLogic.tsindex 31ab8bf120a7..9de1e1ca3f47 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/groupedAccessControlRuleModalLogic.ts+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/ResourceAccessControlsV2/groupedAccessControlRuleModalLogic.ts@@ -93,6 +93,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -138,6 +139,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => booleanmodalTitle: 'Update default access' | 'Update member access' | 'Update role access'@@ -227,6 +229,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -272,6 +275,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => string | undefinedresourceLevelOptions: (@@ -348,6 +352,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -393,6 +398,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',resourceLabel: string) => (@@ -482,6 +488,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -527,6 +534,7 @@ export interface groupedAccessControlRuleModalLogicValues {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => boolean}@@ -616,6 +624,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -661,6 +670,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',AccessControlLevel | null>@@ -757,6 +767,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -802,6 +813,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session'}setResourceLevels: (levels: Record<APIScopeObject, FormAccessLevel>) => {@@ -878,6 +890,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -923,6 +936,7 @@ export interface groupedAccessControlRuleModalLogicActions {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',FormAccessLevel>@@ -1038,6 +1052,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1083,6 +1098,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',FormAccessLevel>,@@ -1161,6 +1177,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1206,6 +1223,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => booleanresourceInheritedReasonTooltip: (@@ -1283,6 +1301,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1328,6 +1347,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => boolean,entry: AccessControlSettingsEntry@@ -1405,6 +1425,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1450,6 +1471,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => string | undefinedresourceLevelOptions: (@@ -1528,6 +1550,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1573,6 +1596,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',FormAccessLevel>@@ -1650,6 +1674,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1695,6 +1720,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',resourceLabel: string) => (@@ -1783,6 +1809,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1828,6 +1855,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',FormAccessLevel>@@ -1905,6 +1933,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -1950,6 +1979,7 @@ export interface groupedAccessControlRuleModalLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => boolean}diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/accessControlLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/accessControlLogic.tsindex 55f48f7524e9..19b669a43aa2 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/accessControlLogic.ts+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/access_control/accessControlLogic.ts@@ -385,6 +385,7 @@ export interface accessControlLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -430,6 +431,7 @@ export interface accessControlLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') =>| 'access_control'@@ -611,6 +613,7 @@ export interface accessControlLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -656,6 +659,7 @@ export interface accessControlLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session',resource_id: string) => string@@ -733,6 +737,7 @@ export interface accessControlLogicMeta {| 'marketing_analytics'| 'mcp_analytics'| 'mcp_builtin_agent'+ | 'mcp_registry'| 'metrics'| 'notebook'| 'offline_evaluation_ingestion'@@ -778,6 +783,7 @@ export interface accessControlLogicMeta {| 'warehouse_view'| 'web_analytics'| 'webhook'+ | 'wizard_run'| 'wizard_session') => stringminimumAccessLevel: (accessControls: AccessControlResponseType | null) => AccessControlLevel | nulldiff --git a/frontend/src/lib/scopes.test.ts b/frontend/src/lib/scopes.test.tsindex 79b71208b1b0..62067a97e9cb 100644--- a/frontend/src/lib/scopes.test.ts+++ b/frontend/src/lib/scopes.test.ts@@ -2,6 +2,7 @@ import { AGENT_USE_CASE_SCOPES } from 'lib/agentScopes.generated'import {AGENT_CLI_API_KEY_SCOPES,API_KEY_SCOPE_PRESETS,+ API_SCOPE_GROUPS,API_SCOPES,API_SCOPES_OMITTED_FROM_MODAL,getScopeDescription,@@ -61,6 +62,21 @@ describe('API_SCOPES modal coverage', () => {})})+describe('API_SCOPE_GROUPS', () => {+ it('files every scope object in exactly one group', () => {+ // A new scope object fails here until someone picks the product area it belongs to.+ const filed = API_SCOPE_GROUPS.flatMap(({ objects }) => objects)+ const duplicates = [...new Set(filed.filter((obj, index) => filed.indexOf(obj) !== index))]+ const missing = API_SCOPE_OBJECTS.filter((obj) => !filed.includes(obj))+ expect({ duplicates, missing }).toEqual({ duplicates: [], missing: [] })+ })++ it('uses each group label once', () => {+ const labels = API_SCOPE_GROUPS.map(({ label }) => label)+ expect(labels).toEqual([...new Set(labels)])+ })+})+describe('scopeMatchesSearch', () => {const featureFlag = { key: 'feature_flag', objectName: 'Feature flag', objectPlural: 'feature flags' }diff --git a/frontend/src/lib/scopes.tsx b/frontend/src/lib/scopes.tsxindex a9c493bcf0d7..acc663f5f19f 100644--- a/frontend/src/lib/scopes.tsx+++ b/frontend/src/lib/scopes.tsx@@ -282,12 +282,14 @@ export const API_SCOPES_OMITTED_FROM_MODAL: Partial<Record<APIScopeObject, strinbatch_import_support: 'OAuth-hidden: staff-only, pasteable into a PAT but not advertised.',query_performance: 'OAuth-hidden: staff-only, pasteable into a PAT but not advertised.',wizard_session: 'OAuth-hidden: pasteable into a PAT but not advertised.',+ wizard_run: 'OAuth-hidden: pasteable into a PAT but not advertised.',// Umbrella access-control resource that `warehouse_view`/`warehouse_table` inherit from —// the granular scopes are offered instead, so keep the umbrella out of the modal.warehouse_objects: 'Umbrella resource: grant warehouse_view/warehouse_table instead.',// Pending removal — no endpoint enforces these, so they do nothing when granted.// Remove from posthog/scopes.py once no PAK/OAuth grant references them.batch_import: 'Pending removal: no endpoint enforces it (its viewset is INTERNAL).',+ mcp_registry: 'Behind a feature flag.',external_data_schema: 'Pending removal: covered by external_data_source; no viewset uses it.',}@@ -398,6 +400,197 @@ export const PROJECT_SECRET_API_KEY_SCOPE_PRESETS: ProjectSecretAPIKeyScopePrese{ value: 'llm_gateway', label: 'AI gateway access', scopes: ['llm_gateway:read'] },]+// The product areas that the scope pickers use to group objects, in display order. Each object in+// API_SCOPE_OBJECTS is in exactly one group, and scopes.test.ts fails until a new object has a group.+// Internal and OAuth-hidden objects go in the last group, "Internal tools". The pickers do not show+// those objects, so a person never sees that group.+export type APIScopeGroup = {+ label: string+ objects: APIScopeObject[]+}++export const API_SCOPE_GROUPS: APIScopeGroup[] = [+ {+ label: 'Product analytics',+ objects: [+ 'insight',+ 'insight_variable',+ 'dashboard',+ 'dashboard_template',+ 'query',+ 'notebook',+ 'canvas',+ 'subscription',+ 'alert',+ 'annotation',+ 'export',+ 'sharing_configuration',+ ],+ },+ {+ label: 'Web, marketing & revenue analytics',+ objects: ['web_analytics', 'marketing_analytics', 'revenue_analytics', 'heatmap', 'link'],+ },+ {+ label: 'Events, people & data model',+ objects: [+ 'person',+ 'group',+ 'cohort',+ 'action',+ 'event_definition',+ 'property_definition',+ 'event_filter',+ 'element',+ ],+ },+ {+ label: 'Session replay',+ objects: ['session_recording', 'session_recording_playlist', 'replay_scanner', 'vision_action', 'vision_alert'],+ },+ {+ label: 'Feature flags, experiments & surveys',+ objects: [+ 'feature_flag',+ 'experiment',+ 'experiment_holdout',+ 'experiment_saved_metric',+ 'early_access_feature',+ 'survey',+ 'user_interview',+ 'product_tour',+ ],+ },+ {+ label: 'Error tracking, logs & tracing',+ objects: ['error_tracking', 'logs', 'tracing', 'metrics'],+ },+ {+ label: 'Developer experience',+ objects: ['engineering_analytics', 'stamphog', 'visual_review'],+ },+ {+ label: 'LLM & MCP analytics',+ objects: [+ 'llm_analytics',+ 'llm_prompt',+ 'llm_provider_key',+ 'llm_skill',+ 'llm_playground',+ 'dataset',+ 'evaluation',+ 'offline_evaluation_ingestion',+ 'tagger',+ 'ai_observability_clusters',+ 'mcp_analytics',+ 'llm_gateway',+ ],+ },+ {+ label: 'Data warehouse & pipelines',+ objects: [+ 'external_data_source',+ 'external_data_schema',+ 'warehouse_objects',+ 'warehouse_table',+ 'warehouse_view',+ 'batch_export',+ 'batch_import',+ 'hog_function',+ 'hog_flow',+ 'endpoint',+ 'streamlit_app',+ 'webhook',+ 'plugin',+ ],+ },+ {+ label: 'AI & context management tools',+ objects: [+ 'conversation',+ 'business_knowledge',+ 'data_catalog',+ 'data_catalog_approval',+ 'mcp_registry',+ 'task',+ 'loop',+ 'signal_scout',+ 'review_hog',+ 'approvals',+ 'autoresearch',+ 'field_note',+ ],+ },+ {+ label: 'Customers & support',+ objects: [+ 'customer_analytics',+ 'account',+ 'customer_journey',+ 'customer_task',+ 'customer_profile_config',+ 'usage_metric',+ 'ticket',+ ],+ },+ {+ label: 'Setup & data management',+ objects: [+ 'toolbar',+ 'live_debugger',+ 'ingestion_warning',+ 'health_issue',+ 'data_deletion',+ 'product_enablement',+ 'integration',+ 'organization_integration',+ ],+ },+ {+ label: 'Organization & account',+ objects: [+ 'organization',+ 'organization_member',+ 'project',+ 'user',+ 'billing',+ 'access_control',+ 'activity_log',+ 'comment',+ 'legal_document',+ 'uploaded_media',+ 'file_system',+ 'file_system_shortcut',+ ],+ },+ {+ label: 'Internal tools',+ objects: [+ 'batch_import_support',+ 'clickhouse_test_cluster_perf',+ 'context_layer_internal',+ 'internal_run',+ 'mcp_builtin_agent',+ 'query_performance',+ 'signal_scout_internal',+ 'signal_scout_report',+ 'signal_scratchpad_internal',+ 'wizard_session',+ 'wizard_run',+ ],+ },+]++export const OTHER_SCOPE_GROUP_LABEL = 'Other'++// An object that is in no group gets OTHER_SCOPE_GROUP_LABEL, so it still renders.+const SCOPE_GROUP_LABEL_BY_OBJECT: Record<string, string> = Object.fromEntries(+ API_SCOPE_GROUPS.flatMap(({ label, objects }) => objects.map((object) => [object, label]))+)++export const getScopeGroupLabel = (scopeObject: string): string =>+ SCOPE_GROUP_LABEL_BY_OBJECT[scopeObject] ?? OTHER_SCOPE_GROUP_LABEL+export const DEFAULT_OAUTH_SCOPES = ['openid', 'email', 'profile']export const getScopeDescription = (scope: string): string | undefined => {diff --git a/frontend/src/scenes/oauth/OAuthAuthorize.stories.tsx b/frontend/src/scenes/oauth/OAuthAuthorize.stories.tsxindex 768bbd75ad7f..3e20f69fbaa1 100644--- a/frontend/src/scenes/oauth/OAuthAuthorize.stories.tsx+++ b/frontend/src/scenes/oauth/OAuthAuthorize.stories.tsx@@ -217,6 +217,25 @@ export const AccessControlsApply: Story = {},}+// The consent page has no sidebar, so it only gets narrow in a narrow browser window, such as+// an OAuth popup. There the group labels truncate and the counts hide, so the controls keep+// their place. This story snapshots the runner's narrow viewport to show that.+export const ManyOptionalScopesNarrow: Story = {+ parameters: { testOptions: { viewportWidths: ['narrow'] } },+ decorators: [withOAuthApplication({ required_scopes: [] })],+ render: () => {+ useDelayedOnMountEffect(() =>+ pushAuthorize(+ 'openid profile email user:read user:write organization:read project:read project:write ' ++ 'feature_flag:read feature_flag:write experiment:read experiment:write insight:read ' ++ 'insight:write dashboard:read dashboard:write query:read survey:read survey:write ' ++ 'event_definition:read event_definition:write error_tracking:read logs:read tracing:read'+ )+ )+ return <App />+ },+}+const everyScopeRequest = ['openid', 'profile', 'email', ...API_SCOPES.map(({ key }) => `${key}:write`)].join(' ')// The worst case for the layout: a client that asks for every scope PostHog has, which is onediff --git a/frontend/src/scenes/oauth/OAuthAuthorize.tsx b/frontend/src/scenes/oauth/OAuthAuthorize.tsxindex 54929a50f574..c8884c4e7320 100644--- a/frontend/src/scenes/oauth/OAuthAuthorize.tsx+++ b/frontend/src/scenes/oauth/OAuthAuthorize.tsx@@ -4,7 +4,6 @@ import { useMemo, useState } from 'react'import { IconCheck, IconCheckCircle, IconLock, IconPlus, IconWarning } from '@posthog/icons'-import { ScopeAccessRow } from 'lib/components/ScopeAccessRow/ScopeAccessRow'import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'import { LemonBanner } from 'lib/lemon-ui/LemonBanner'import { LemonButton } from 'lib/lemon-ui/LemonButton'@@ -25,7 +24,9 @@ import { AvailableFeature } from '~/types'import { SceneExport } from '../sceneTypes'import { OAuthAuthorizeLayout } from './OAuthAuthorizeLayout'-import { ScopeAccessLevel, oauthAuthorizeLogic } from './oauthAuthorizeLogic'+import { oauthAuthorizeLogic } from './oauthAuthorizeLogic'+import { OAuthScopeGroupControl } from './OAuthScopeGroupControl'+import { OAuthScopeRowControl } from './OAuthScopeRowControl'export const OAuthAuthorizeError = ({ title, description }: { title: string; description: string }): JSX.Element => {return (@@ -131,6 +132,8 @@ export const OAuthAuthorize = (): JSX.Element => {const {requiredScopeRows,adjustableScopeRows,+ scopeGroups,+ scopeRowsGrouped,allScopesRequired,identityScopeDescriptions,showReadOnlyBulkAction,@@ -163,6 +166,7 @@ export const OAuthAuthorize = (): JSX.Element => {setSelectedOrganization,setOauthAuthorizationValue,setScopeAccess,+ setScopeGroupAccess,setAllScopeAccess,} = useActions(oauthAuthorizeLogic)@@ -285,7 +289,12 @@ export const OAuthAuthorize = (): JSX.Element => {{/* Everything the person reads and adjusts scrolls in here. The action rowbelow sits outside, so Authorize stays reachable however manypermissions the application asks for. */}- <div className="flex flex-col min-h-0 overflow-y-auto" data-attr="oauth-permissions-scroll">+ {/* The scrollbar gutter is always reserved. When a group opens and the scrollbar+ appears, the column does not move. */}+ <div+ className="flex flex-col min-h-0 overflow-y-auto [scrollbar-gutter:stable]"+ data-attr="oauth-permissions-scroll"+ ><div className="flex flex-col gap-4 sm:gap-6 p-4 sm:p-6">{isImpersonated && (<div className="flex items-center gap-2 p-3 bg-danger-highlight border border-danger rounded text-sm">@@ -454,28 +463,32 @@ export const OAuthAuthorize = (): JSX.Element => {))}</ul>)}- {adjustableScopeRows.length > 0 && (+ {scopeRowsGrouped ? (<div className="flex flex-col">- {adjustableScopeRows.map((row) => (- <ScopeAccessRow- key={row.key}- label={row.label}- info={row.info}- muted={row.value === 'none'}- value={row.value}- onChange={(value) => setScopeAccess(row.key, value as ScopeAccessLevel)}- noneDisabledReason={- row.minLevel !== 'none'- ? `${appName} requires at least ${row.minLevel} access`- : undefined- }- writeDisabledReason={- row.maxLevel !== 'write' ? `Not requested by ${appName}` : undefined- }- warning={row.warning}+ {scopeGroups.map((group) => (+ <OAuthScopeGroupControl+ key={group.label}+ label={group.label}+ rows={group.rows}+ appName={appName}+ onChangeRow={setScopeAccess}+ onChangeGroup={setScopeGroupAccess}/>))}</div>+ ) : (+ adjustableScopeRows.length > 0 && (+ <div className="flex flex-col">+ {adjustableScopeRows.map((row) => (+ <OAuthScopeRowControl+ key={row.key}+ row={row}+ appName={appName}+ onChange={setScopeAccess}+ />+ ))}+ </div>+ ))}{accessControlsApply && (<LemonBanner type="info" icon={<IconLock className="LemonBanner__icon" />}>diff --git a/frontend/src/scenes/oauth/OAuthScopeGroupControl.tsx b/frontend/src/scenes/oauth/OAuthScopeGroupControl.tsxnew file mode 100644index 000000000000..d5c7fa93d9cd--- /dev/null+++ b/frontend/src/scenes/oauth/OAuthScopeGroupControl.tsx@@ -0,0 +1,126 @@+import clsx from 'clsx'+import { useId, useState } from 'react'++import { IconChevronRight } from '@posthog/icons'+import { LemonSegmentedButton, LemonTag } from '@posthog/lemon-ui'++import {+ type OAuthScopeRow,+ type ScopeAccessLevel,+ scopeGroupAccessLevel,+ scopeGroupLevelTooltip,+} from './oauthAuthorizeLogic'+import { OAuthScopeRowControl } from './OAuthScopeRowControl'++interface OAuthScopeGroupControlProps {+ label: string+ rows: OAuthScopeRow[]+ appName: string+ onChangeRow: (scopeObject: string, level: ScopeAccessLevel) => void+ onChangeGroup: (scopeObjects: string[], level: ScopeAccessLevel) => void+}++const countByLevel = (rows: OAuthScopeRow[]): Record<ScopeAccessLevel, number> => {+ const counts: Record<ScopeAccessLevel, number> = { none: 0, read: 0, write: 0 }+ for (const row of rows) {+ counts[row.value] += 1+ }+ return counts+}++export function OAuthScopeGroupControl({+ label,+ rows,+ appName,+ onChangeRow,+ onChangeGroup,+}: OAuthScopeGroupControlProps): JSX.Element {+ const [open, setOpen] = useState(false)+ const panelId = useId()+ const counts = countByLevel(rows)+ const groupLevel = scopeGroupAccessLevel(rows)+ const groupLevelTooltip = scopeGroupLevelTooltip(rows, groupLevel, appName)+ const keys = rows.map((row) => row.key)+ const anyWritable = rows.some((row) => row.maxLevel === 'write')+ const allRequired = rows.every((row) => row.minLevel !== 'none')+ const groupSlug = label.toLowerCase().replace(/[^a-z0-9]+/g, '-')++ return (+ <div className="border-t border-border first:border-t-0 @container/scope-group">+ {/* The header stays on one line. In a narrow container, such as an OAuth popup window,+ the label truncates and the counts hide, so the control keeps its place. */}+ <div className="flex items-center gap-2 py-2 min-h-10">+ <button+ type="button"+ className="flex items-center gap-2 flex-1 min-w-0 text-left font-semibold cursor-pointer bg-transparent border-0 p-0 text-inherit"+ onClick={() => setOpen(!open)}+ aria-expanded={open}+ aria-controls={panelId}+ data-attr={`oauth-scope-group-toggle-${groupSlug}`}+ >+ <IconChevronRight+ className={clsx(+ 'shrink-0 text-muted transition-transform motion-reduce:transition-none',+ open && 'rotate-90'+ )}+ />+ <span className="truncate">{label}</span>+ </button>+ <div className="flex items-center gap-2 ml-auto shrink-0">+ <span className="hidden @min-[36rem]/scope-group:flex items-center gap-2">+ <span className="text-xs text-muted whitespace-nowrap">+ <span translate="no">{rows.length}</span> {rows.length === 1 ? 'permission' : 'permissions'}+ </span>+ <span className="flex items-center gap-1">+ {/* Same order as the segmented control: no access, read, write. */}+ {counts.none > 0 && (+ <LemonTag size="small" type="muted">+ <span translate="no">{counts.none}</span> none+ </LemonTag>+ )}+ {counts.read > 0 && (+ <LemonTag size="small" type="success">+ <span translate="no">{counts.read}</span> read+ </LemonTag>+ )}+ {counts.write > 0 && (+ <LemonTag size="small" type="warning">+ <span translate="no">{counts.write}</span> write+ </LemonTag>+ )}+ </span>+ </span>+ <div role="group" aria-label={`${label} access`}>+ <LemonSegmentedButton+ size="xsmall"+ value={groupLevel}+ onChange={(level) => onChangeGroup(keys, level as ScopeAccessLevel)}+ options={[+ {+ label: 'No access',+ value: 'none',+ disabledReason: allRequired ? `${appName} requires these permissions` : undefined,+ },+ { label: 'Read', value: 'read' },+ {+ label: 'Write',+ value: 'write',+ disabledReason: anyWritable ? undefined : `Not requested by ${appName}`,+ },+ ].map((option) =>+ option.value === groupLevel ? { ...option, tooltip: groupLevelTooltip } : option+ )}+ />+ </div>+ </div>+ </div>+ {open && (+ <div id={panelId} className="flex flex-col pb-2 pl-7">+ {rows.map((row) => (+ <OAuthScopeRowControl key={row.key} row={row} appName={appName} onChange={onChangeRow} />+ ))}+ </div>+ )}+ </div>+ )+}diff --git a/frontend/src/scenes/oauth/OAuthScopeRowControl.tsx b/frontend/src/scenes/oauth/OAuthScopeRowControl.tsxnew file mode 100644index 000000000000..5bad57815430--- /dev/null+++ b/frontend/src/scenes/oauth/OAuthScopeRowControl.tsx@@ -0,0 +1,26 @@+import { ScopeAccessRow } from 'lib/components/ScopeAccessRow/ScopeAccessRow'++import type { OAuthScopeRow, ScopeAccessLevel } from './oauthAuthorizeLogic'++interface OAuthScopeRowControlProps {+ row: OAuthScopeRow+ appName: string+ onChange: (scopeObject: string, level: ScopeAccessLevel) => void+}++export function OAuthScopeRowControl({ row, appName, onChange }: OAuthScopeRowControlProps): JSX.Element {+ return (+ <ScopeAccessRow+ label={row.label}+ info={row.info}+ muted={row.value === 'none'}+ value={row.value}+ onChange={(value) => onChange(row.key, value as ScopeAccessLevel)}+ noneDisabledReason={+ row.minLevel !== 'none' ? `${appName} requires at least ${row.minLevel} access` : undefined+ }+ writeDisabledReason={row.maxLevel !== 'write' ? `Not requested by ${appName}` : undefined}+ warning={row.warning}+ />+ )+}diff --git a/frontend/src/scenes/oauth/oauthAuthorizeLogic.test.ts b/frontend/src/scenes/oauth/oauthAuthorizeLogic.test.tsindex 12d9402d9947..2b22491fe38f 100644--- a/frontend/src/scenes/oauth/oauthAuthorizeLogic.test.ts+++ b/frontend/src/scenes/oauth/oauthAuthorizeLogic.test.ts@@ -2,14 +2,19 @@ import { MOCK_DEFAULT_USER } from 'lib/api.mock'import { decodeParams, router } from 'kea-router'-import { DEFAULT_OAUTH_SCOPES } from 'lib/scopes'+import { DEFAULT_OAUTH_SCOPES, getScopeGroupLabel } from 'lib/scopes'import { userLogic } from 'scenes/userLogic'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { AppContext } from '~/types'-import { describeOAuthError, oauthAuthorizeLogic } from './oauthAuthorizeLogic'+import {+ describeOAuthError,+ oauthAuthorizeLogic,+ scopeGroupAccessLevel,+ scopeGroupLevelTooltip,+} from './oauthAuthorizeLogic'describe('oauthAuthorizeLogic', () => {let logic: ReturnType<typeof oauthAuthorizeLogic.build>@@ -482,4 +487,61 @@ describe('oauthAuthorizeLogic', () => {expect(describeOAuthError(data)).toBeNull()})})+ describe('grouping', () => {+ it('keeps a short request flat and groups only past the threshold', () => {+ logic.actions.setScopes(['openid', 'feature_flag:write', 'session_recording:write', 'insight:write'])+ expect(logic.values.scopeRowsGrouped).toBe(false)+ logic.actions.setScopes([+ 'openid',+ ...[+ 'insight',+ 'dashboard',+ 'query',+ 'cohort',+ 'action',+ 'person',+ 'survey',+ 'experiment',+ 'notebook',+ 'logs',+ 'error_tracking',+ ].map((object) => `${object}:read`),+ ])+ expect(logic.values.scopeRowsGrouped).toBe(true)+ const groups = logic.values.scopeGroups+ expect(groups.flatMap((group) => group.rows)).toHaveLength(logic.values.adjustableScopeRows.length)+ for (const group of groups) {+ expect(group.rows.length).toBeGreaterThan(0)+ expect(group.rows.map((row) => getScopeGroupLabel(row.key))).toEqual(group.rows.map(() => group.label))+ }+ })++ it('sets every row of a group with one group action, clamped to each ceiling', () => {+ logic.actions.setScopes(['openid', 'session_recording:write', 'session_recording_playlist:read'])+ logic.actions.setScopeGroupAccess(['session_recording', 'session_recording_playlist'], 'none')+ expect(logic.values.effectiveScopes).toEqual(['openid'])+ expect(scopeGroupAccessLevel(logic.values.adjustableScopeRows)).toBe('none')+ expect(scopeGroupLevelTooltip(logic.values.adjustableScopeRows, 'none', 'Test app')).toBeUndefined()+ const [recordingRow, playlistRow] = logic.values.adjustableScopeRows+ const requiredRows = [{ ...recordingRow, minLevel: 'read' as const, value: 'read' as const }, playlistRow]+ expect(scopeGroupAccessLevel(requiredRows)).toBe('none')+ expect(scopeGroupLevelTooltip(requiredRows, 'none', 'Test app')).toBe(+ '1 of these permissions stays on. Test app requires it.'+ )+ logic.actions.setScopeGroupAccess(['session_recording', 'session_recording_playlist'], 'write')+ expect(logic.values.effectiveScopes).toEqual([+ 'openid',+ 'session_recording:write',+ 'session_recording_playlist:read',+ ])+ expect(scopeGroupAccessLevel(logic.values.adjustableScopeRows)).toBe('write')+ expect(scopeGroupLevelTooltip(logic.values.adjustableScopeRows, 'write', 'Test app')).toBe(+ '1 of these permissions stays at read. Test app did not request write access.'+ )+ logic.actions.setScopeAccess('session_recording', 'read')+ expect(scopeGroupAccessLevel(logic.values.adjustableScopeRows)).toBe('read')+ logic.actions.setScopeAccess('session_recording_playlist', 'none')+ expect(scopeGroupAccessLevel(logic.values.adjustableScopeRows)).toBeUndefined()+ })+ })})diff --git a/frontend/src/scenes/oauth/oauthAuthorizeLogic.ts b/frontend/src/scenes/oauth/oauthAuthorizeLogic.tsindex 3d48d698cc47..24d68ec3e38c 100644--- a/frontend/src/scenes/oauth/oauthAuthorizeLogic.ts+++ b/frontend/src/scenes/oauth/oauthAuthorizeLogic.ts@@ -7,7 +7,15 @@ import { router, urlToAction } from 'kea-router'import api from 'lib/api'import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'-import { API_SCOPES, DEFAULT_OAUTH_SCOPES, getMinimumEquivalentScopes, getScopeDescription } from 'lib/scopes'+import {+ API_SCOPE_GROUPS,+ API_SCOPES,+ DEFAULT_OAUTH_SCOPES,+ getMinimumEquivalentScopes,+ getScopeDescription,+ getScopeGroupLabel,+ OTHER_SCOPE_GROUP_LABEL,+} from 'lib/scopes'import { getAppContext } from 'lib/utils/getAppContext'import { userLogic } from 'scenes/userLogic'@@ -58,8 +66,57 @@ export type OAuthScopeRow = {locked: boolean}+export type OAuthScopeGroup = {+ label: string+ rows: OAuthScopeRow[]+}++// A group action clamps each row to its own floor and ceiling, so a group set to write can hold+// read-only rows at read. The group shows a level as selected when each row is at that level+// after the clamp. A disabled level is never selected, which removes the tie between write and+// read in a group with no writable row, and between none and read in a group of required rows.+export const scopeGroupAccessLevel = (rows: OAuthScopeRow[]): ScopeAccessLevel | undefined => {+ const anyWritable = rows.some((row) => row.maxLevel === 'write')+ const allRequired = rows.every((row) => row.minLevel !== 'none')+ const levels: ScopeAccessLevel[] = ['write', 'read', 'none']+ return levels.find(+ (level) =>+ !(level === 'write' && !anyWritable) &&+ !(level === 'none' && allRequired) &&+ rows.every((row) => row.value === clampAccessLevel(level, row.minLevel, row.maxLevel))+ )+}++// Tooltip for the selected group level when some rows sit at another level after the clamp.+// A row sits lower when the app did not request the level, and higher when the app requires more.+export const scopeGroupLevelTooltip = (+ rows: OAuthScopeRow[],+ level: ScopeAccessLevel | undefined,+ appName: string+): string | undefined => {+ if (!level) {+ return undefined+ }+ const lower = rows.filter((row) => ACCESS_LEVEL_ORDER[row.value] < ACCESS_LEVEL_ORDER[level]).length+ const higher = rows.filter((row) => ACCESS_LEVEL_ORDER[row.value] > ACCESS_LEVEL_ORDER[level]).length+ const stays = (count: number): string => `${count} of these permissions ${count === 1 ? 'stays' : 'stay'}`+ const notes: string[] = []+ if (lower > 0) {+ notes.push(`${stays(lower)} at read. ${appName} did not request write access.`)+ }+ if (higher > 0) {+ const where = level === 'none' ? 'on' : 'at write'+ notes.push(`${stays(higher)} ${where}. ${appName} requires ${higher === 1 ? 'it' : 'them'}.`)+ }+ return notes.length > 0 ? notes.join(' ') : undefined+}+const WILDCARD_LABEL = 'All PostHog data'+// A request with this many adjustable rows or fewer shows a flat alphabetical list. Group+// headers only help when the list is long.+export const SCOPE_GROUPING_MIN_ROWS = 10+// Fallback for scopes absent from API_SCOPES (e.g. server-side scopes the local list lags// behind) — derive a readable label from the raw key.const humanizeScopeKey = (key: string): string => {@@ -230,7 +287,9 @@ export interface oauthAuthorizeLogicValues {bulk: ScopeAccessLevel | nulloverrides: Record<string, ScopeAccessLevel>}+ scopeGroups: OAuthScopeGroup[]scopeRows: OAuthScopeRow[]+ scopeRowsGrouped: booleanscopes: string[]scopesWereDefaulted: booleanselectedOrganization: string | null@@ -321,6 +380,13 @@ export interface oauthAuthorizeLogicActions {level: ScopeAccessLevelscopeObject: string}+ setScopeGroupAccess: (+ scopeObjects: string[],+ level: ScopeAccessLevel+ ) => {+ level: ScopeAccessLevel+ scopeObjects: string[]+ }setScopes: (scopes: string[]) => {scopes: string[]}@@ -388,6 +454,8 @@ export interface oauthAuthorizeLogicMeta {) => OAuthScopeRow[]requiredScopeRows: (scopeRows: OAuthScopeRow[]) => OAuthScopeRow[]adjustableScopeRows: (scopeRows: OAuthScopeRow[]) => OAuthScopeRow[]+ scopeRowsGrouped: (adjustableScopeRows: OAuthScopeRow[]) => boolean+ scopeGroups: (adjustableScopeRows: OAuthScopeRow[]) => OAuthScopeGroup[]allScopesRequired: (scopeRows: OAuthScopeRow[]) => booleanshowReadOnlyBulkAction: (adjustableScopeRows: OAuthScopeRow[]) => booleaneffectiveScopes: (@@ -414,6 +482,7 @@ export const oauthAuthorizeLogic = kea<oauthAuthorizeLogicType>([actions({setScopes: (scopes: string[]) => ({ scopes }),setScopeAccess: (scopeObject: string, level: ScopeAccessLevel) => ({ scopeObject, level }),+ setScopeGroupAccess: (scopeObjects: string[], level: ScopeAccessLevel) => ({ scopeObjects, level }),setAllScopeAccess: (level: ScopeAccessLevel) => ({ level }),setRequiredAccessLevel: (requiredAccessLevel: 'organization' | 'team' | null) => ({ requiredAccessLevel }),setTeamHint: (teamId: number | null) => ({ teamId }),@@ -529,6 +598,13 @@ export const oauthAuthorizeLogic = kea<oauthAuthorizeLogicType>([...state,overrides: { ...state.overrides, [scopeObject]: level },}),+ setScopeGroupAccess: (state, { scopeObjects, level }) => ({+ ...state,+ overrides: {+ ...state.overrides,+ ...Object.fromEntries(scopeObjects.map((scopeObject) => [scopeObject, level])),+ },+ }),setAllScopeAccess: (_, { level }) => ({ bulk: level, overrides: {} }),setScopes: () => ({ bulk: null, overrides: {} }),},@@ -847,6 +923,25 @@ export const oauthAuthorizeLogic = kea<oauthAuthorizeLogicType>([(s) => [s.scopeRows],(scopeRows: OAuthScopeRow[]): OAuthScopeRow[] => scopeRows.filter((row) => !row.locked),],+ scopeRowsGrouped: [+ (s) => [s.adjustableScopeRows],+ (adjustableScopeRows: OAuthScopeRow[]): boolean => adjustableScopeRows.length > SCOPE_GROUPING_MIN_ROWS,+ ],+ // The adjustable rows, grouped by product area in API_SCOPE_GROUPS order. An object that is+ // not in the map goes in the "Other" group at the end, so it still shows.+ scopeGroups: [+ (s) => [s.adjustableScopeRows],+ (adjustableScopeRows: OAuthScopeRow[]): OAuthScopeGroup[] => {+ const rowsByLabel = new Map<string, OAuthScopeRow[]>()+ for (const row of adjustableScopeRows) {+ const label = getScopeGroupLabel(row.key)+ rowsByLabel.set(label, [...(rowsByLabel.get(label) ?? []), row])+ }+ return [...API_SCOPE_GROUPS.map(({ label }) => label), OTHER_SCOPE_GROUP_LABEL]+ .filter((label) => rowsByLabel.has(label))+ .map((label) => ({ label, rows: rowsByLabel.get(label) ?? [] }))+ },+ ],allScopesRequired: [(s) => [s.scopeRows],(scopeRows: OAuthScopeRow[]): boolean => scopeRows.length > 0 && scopeRows.every((row) => row.locked),diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 64e578bfd218..bf25fa9d3778 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -5938,6 +5938,7 @@ export const API_SCOPE_OBJECTS = ['marketing_analytics','mcp_builtin_agent','mcp_analytics',+ 'mcp_registry','metrics','notebook','offline_evaluation_ingestion',@@ -5985,6 +5986,7 @@ export const API_SCOPE_OBJECTS = ['web_analytics','webhook','wizard_session',+ 'wizard_run',] as constexport type APIScopeObject = (typeof API_SCOPE_OBJECTS)[number]diff --git a/playwright/e2e/oauth-mcp-consent.spec.ts b/playwright/e2e/oauth-mcp-consent.spec.tsindex 2100e013372b..506314514c4f 100644--- a/playwright/e2e/oauth-mcp-consent.spec.ts+++ b/playwright/e2e/oauth-mcp-consent.spec.ts@@ -31,7 +31,9 @@ testWithWorkspace.describe('OAuth MCP consent', () => {await test.step('assert server-preloaded MCP scopes', async () => {await expect(page.getByText('Showing all permissions the PostHog MCP server supports')).toBeVisible()// notebook scopes are absent from the old static fallback, so their- // presence proves the server derived the full catalog.+ // presence proves the server derived the full catalog. A long request groups+ // the rows by product area, so open the group the notebook row is in first.+ await page.getByTestId('oauth-scope-group-toggle-product-analytics').click()await expect(page.getByText('Notebook', { exact: true })).toBeVisible()})}diff --git a/posthog/scopes.py b/posthog/scopes.pyindex 6d3848486f03..7ccd0bc6b712 100644--- a/posthog/scopes.py+++ b/posthog/scopes.py@@ -7,7 +7,7 @@ from typing import Literal, get_args# Typically each object should have `read` and `write` scopes, but some objects may have more specific scopes# WARNING: Make sure to keep in sync with the frontend!-# - frontend/src/lib/scopes.tsx+# - frontend/src/lib/scopes.tsx (an `API_SCOPES` row and a group in `API_SCOPE_GROUPS`)# - frontend/src/types.ts (`export type APIScopeObject`)## The MCP `OAUTH_SCOPES_SUPPORTED` list at