: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(notifications): gate member notifications on member governance (#104944)
Yasenc26185ec8e98
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 02af2142731d..d3de0ccc3954 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -11361,9 +11361,9 @@ snapshots:scenes-app-settings-organization--settings-organization-details--light:hash: v1.k794b7964.cc797b5816e079594c687cec240e13d5d3411403e247720f6fcaf5f0f5d72318.FMc09Ob0_HMh5d-SMZEDeOX4on05IH5IMBt7Acnp1_oscenes-app-settings-organization--settings-organization-members--dark:- hash: v1.k794b7964.17d9e75f67b7f65a243351e1618b706cecf0d5e9e25cef98be5d4adc103ade93.X6xN010pLxuaK-OVBJDma36lKEQYa6UvGFa9nFhomgc+ hash: v1.k794b7964.7728118a93e6616d1a7635d948f2e90a69430386f652f369540bdfe64d9861fb.4j1qbfUUSFXvBSP9MJLHJk2XX7uSiv6HuLnXMlztSugscenes-app-settings-organization--settings-organization-members--light:- hash: v1.k794b7964.3d1eea8017ed5f29f426c24d92475bd45601e0c62441a1ce6a76fc479add83ab.634xz8ZpbuDzYSbYB353yluG9F8lj_TNyZd8VFfJW8A+ hash: v1.k794b7964.912f9a1af222d321b17ef4824cccf7ca1b8824766f27725b82d8d64bd256f5f8.QUSx4VxLoA9v96T8UxtoP3b2_Oo7zzT8y-IBd_c87zgscenes-app-settings-organization--settings-organization-proxy--dark:hash: v1.k794b7964.8d224fe300274548438d00f38a72825c5e8425c42da637eb010efbc6791e6294.ZwYt5atQBiMtka55zyETWNWXpZhyoO2-FGb_nxzZcwEscenes-app-settings-organization--settings-organization-proxy--light:@@ -12481,17 +12481,17 @@ snapshots:scenes-other-onboarding-shared-wizard-sync-card--stalled--light:hash: v1.k794b7964.b52a107e85cd22687e6bc1dcf23a4067f185915e7aaa4518b39ef1bbfefe87ac.TU0cv3huC_bueumE3zh9JXnBoRGtM6FKvdbtqCcUL4cscenes-other-org-member-invites--current-user-is-admin--dark:- hash: v1.k794b7964.0f4584049163a792877d9d5fb25efb8f188acef5695b45d05ee77008a94a9991.wMCuvK27mejBo-SjJVCDa_xYXqUQiTgYYS4tq7UpZU4+ hash: v1.k794b7964.ec53183f80d7e83191a0e4dd75d07e2e8711744e44e6e0f8c0f0e418a34f7f06.NfjMFHuMD7wEXsV3BYObaYf4ZGHBFrYafbQOA7bh0O8scenes-other-org-member-invites--current-user-is-admin--light:- hash: v1.k794b7964.fdd9cd835d1826ac61a70e03aa12302c7b3a814cb38b15602ba3858ea6fef45c.C4nSqKk7VieuJ1HBR5brVi00V_Rt3UwxcQ5JcnHL19Q+ hash: v1.k794b7964.b2d0b70d2e055ed6222eb4d07207554fa5a3c6c4c3f71a31bad36d175ff0d1b7.e-tehFiLj550rzzAnfHN_PYWaPaJ6xY-SoyTEsh13Igscenes-other-org-member-invites--current-user-is-member--dark:- hash: v1.k794b7964.af41eb78ac89bb88c3f4483a0f84cee1452b66073ee1217f01d2f7408ad41264.FvnzvArTVE3KaNXRABCHEB0xducmMrNaE28H7skThZw+ hash: v1.k794b7964.58226432dd0ed2765a0b201f20f8acb39020cc4c061f220e9fbd22bab41c3a29.xyHX7llsiBU9sd85Aw-3OYE4wJu0PefER3hLJ_lSIgIscenes-other-org-member-invites--current-user-is-member--light:- hash: v1.k794b7964.4b0d6e296b5fe1a8ddaac383d0bfddf79b5105eaf1f691df55efa3c5cb883b3b.QnB1fUol6OqGAVeZbcjggsB6pC1WfzadqDOX-Km9fAQ+ hash: v1.k794b7964.dae20b7048e8c12bcbcacfbc28f55392d5060dea52d77fe59d299d467c93918a.xwc5o443ePKPkczb-BSgUnF2TvpneW7QP9NFG4aRklMscenes-other-org-member-invites--current-user-is-owner--dark:- hash: v1.k794b7964.0f4584049163a792877d9d5fb25efb8f188acef5695b45d05ee77008a94a9991.zcPQoYTJNTdvT80yx7ZypRWHsnzW-3uNhsBsmIAWyfY+ hash: v1.k794b7964.ec53183f80d7e83191a0e4dd75d07e2e8711744e44e6e0f8c0f0e418a34f7f06.a3CB3mN1YwlYU9zbszIi_QLBM8SruNyLKd1oTwPH-oIscenes-other-org-member-invites--current-user-is-owner--light:- hash: v1.k794b7964.fdd9cd835d1826ac61a70e03aa12302c7b3a814cb38b15602ba3858ea6fef45c.waPD8vz-TR9z3Eh2uOfB_eCOhY5WFSlfLIB35H2F3y4+ hash: v1.k794b7964.b2d0b70d2e055ed6222eb4d07207554fa5a3c6c4c3f71a31bad36d175ff0d1b7.O7gZlrxBwBy7o4DG5vAx-R4mku8UtyRPtWAJpM3kq54scenes-other-organization-deactivated--deactivated--dark:hash: v1.k794b7964.c97f1ed943259f5567c27813c96bbb0566aca0adbf84459ee7d56b2ebea36b57.SgcQHuoYp4dLjnk797pwVsGonoLU6rH2XdLf0lrzefkscenes-other-organization-deactivated--deactivated--light:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex cf2016b151d2..36f30eeb0c27 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -427,7 +427,6 @@ export const FEATURE_FLAGS = {ONBOARDING_WIZARD_SIDEBAR: 'onboarding-wizard-sidebar', // owner: @fercgomes #team-growth multivariate=control,test — gates the installation status item in the sidebar footerONBOARDING_WIZARD_SYNC: 'onboarding-wizard-sync', // owner: @fercgomes #team-growth multivariate=control,test — gates the live wizard sync progress panelONBOARDING_WIZARD_SYNC_MODE: 'onboarding-wizard-sync-mode', // owner: @fercgomes #team-growth multivariate=sse,polling — how the wizard sync panel pulls run updates (SSE stream vs REST polling); payload carries polling_interval_secs- ORG_NOTIFICATION_GOVERNANCE: 'org-notification-governance', // owner: @yasen-posthog #team-platform-features, lets org admins set members' email notification settingsOWNER_ONLY_BILLING: 'owner-only-billing', // owner: @pawelcebula #team-billingPAGE_REPORTS_AVERAGE_PAGE_VIEW: 'page-reports-average-page-view', // owner: @jordanm-posthog #team-web-analyticsPAGE_REPORTS_RANKED_URL_SEARCH: 'page-reports-ranked-url-search', // owner: @jordanm-posthog #team-web-analyticsdiff --git a/frontend/src/mocks/fixtures/_billing_platform_addons.tsx b/frontend/src/mocks/fixtures/_billing_platform_addons.tsxindex 7b2e36ecea48..20bc7fef26de 100644--- a/frontend/src/mocks/fixtures/_billing_platform_addons.tsx+++ b/frontend/src/mocks/fixtures/_billing_platform_addons.tsx@@ -95,6 +95,11 @@ const organizationSecuritySettings = feature('Organization security settings','Configure security permissions for organization members.')+const memberGovernance = feature(+ 'member_governance',+ 'Member governance',+ 'Give admins more control over the members of your organization.'+)const sessionReplayDataRetention = (months: number): AddonPlanFeature =>feature('session_replay_data_retention',@@ -188,6 +193,7 @@ const TEAMS_FEATURES: AddonPlanFeature[] = [dataColorThemes,organizationInviteSettings,organizationSecuritySettings,+ memberGovernance,sessionReplayDataRetention(12),highFrequencyAlerts,]@@ -205,6 +211,7 @@ const BOOST_FEATURES: AddonPlanFeature[] = [supportResponseTime('48 hours'),organizationInviteSettings,organizationSecuritySettings,+ memberGovernance,sessionReplayDataRetention(12),highFrequencyAlerts,]@@ -226,6 +233,7 @@ const SCALE_FEATURES: AddonPlanFeature[] = [supportResponseTime('24 hours'),organizationInviteSettings,organizationSecuritySettings,+ memberGovernance,sessionReplayDataRetention(12),highFrequencyAlerts,realTimeAlerts,@@ -254,6 +262,7 @@ const ENTERPRISE_FEATURES: AddonPlanFeature[] = [supportResponseTime('8 hours'),organizationInviteSettings,organizationSecuritySettings,+ memberGovernance,prioritySupport('Target response time 8 hours'),saml,approvals,diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsxindex f2727b092df8..f40f8a711953 100644--- a/frontend/src/scenes/settings/SettingsMap.tsx+++ b/frontend/src/scenes/settings/SettingsMap.tsx@@ -2142,8 +2142,7 @@ export const SETTINGS_MAP: SettingSection[] = [description:'Choose which email notifications your members receive. Anything you set here they cannot change back themselves.',component: <NotificationGovernanceSetting />,- flag: 'ORG_NOTIFICATION_GOVERNANCE',- allowForTeam: (t) => (t?.effective_membership_level ?? 0) >= OrganizationMembershipLevel.Admin,+ organizationAdminOnly: true,keywords: ['notification', 'email', 'member', 'lock', 'digest', 'pipeline'],},],diff --git a/frontend/src/scenes/settings/organization/NotificationGovernanceSetting.tsx b/frontend/src/scenes/settings/organization/NotificationGovernanceSetting.tsxindex 39971485ccd3..4097eccf5198 100644--- a/frontend/src/scenes/settings/organization/NotificationGovernanceSetting.tsx+++ b/frontend/src/scenes/settings/organization/NotificationGovernanceSetting.tsx@@ -17,13 +17,10 @@ export function NotificationGovernanceSetting(): JSX.Element {// PayGateMini falls through to its children when billing carries no metadata for the feature,// so the entitlement is checked here too. Otherwise the list below mounts and its first// request comes back as a payment prompt.- const entitled = hasAvailableFeature(AvailableFeature.ORGANIZATION_SECURITY_SETTINGS)+ const entitled = hasAvailableFeature(AvailableFeature.MEMBER_GOVERNANCE)return (- <PayGateMini- feature={AvailableFeature.ORGANIZATION_SECURITY_SETTINGS}- featureDetail="organization-member-notifications"- >+ <PayGateMini feature={AvailableFeature.MEMBER_GOVERNANCE} featureDetail="organization-member-notifications">{entitled ? <MemberNotifications /> : null}</PayGateMini>)diff --git a/frontend/src/scenes/settings/settingsLogic.ts b/frontend/src/scenes/settings/settingsLogic.tsindex 088970c3efea..ef2070c88915 100644--- a/frontend/src/scenes/settings/settingsLogic.ts+++ b/frontend/src/scenes/settings/settingsLogic.ts@@ -233,7 +233,8 @@ export interface settingsLogicMeta {sections: SettingSection[],doesMatchFlags: (flagDefinition: Pick<Setting, 'flag'>) => boolean,preflight: PreflightStatus | null,- currentTeam: TeamPublicType | TeamType | null+ currentTeam: TeamPublicType | TeamType | null,+ isAdminOrOwner: boolean | null) => Setting[]selectedSetting: (settings: Setting[], selectedSettingId: SettingId | null) => Setting | nulldoesMatchFlags: (featureFlags: FeatureFlagsSet) => (flagDefinition: Pick<Setting, 'flag'>) => boolean@@ -244,7 +245,8 @@ export interface settingsLogicMeta {sections: SettingSection[],doesMatchFlags: (flagDefinition: Pick<Setting, 'flag'>) => boolean,preflight: PreflightStatus | null,- currentTeam: TeamPublicType | TeamType | null+ currentTeam: TeamPublicType | TeamType | null,+ isAdminOrOwner: boolean | null) => GlobalSearchFusesearchResults: (searchTerm: string, globalSearchIndex: GlobalSearchFuse) => SearchResultGroup[]filteredLevels: (@@ -497,6 +499,9 @@ export const settingsLogic = kea<settingsLogicType>([if (setting.allowForTeam && !setting.allowForTeam(currentTeam)) {return false}+ if (setting.organizationAdminOnly && !isAdminOrOwner) {+ return false+ }return true}@@ -641,6 +646,7 @@ export const settingsLogic = kea<settingsLogicType>([s.doesMatchFlags,s.preflight,s.currentTeam,+ s.isAdminOrOwner,],(selectedLevel: SettingLevelId,@@ -649,7 +655,8 @@ export const settingsLogic = kea<settingsLogicType>([sections: SettingSection[],doesMatchFlags: (flagDefinition: Pick<Setting, 'flag'>) => boolean,preflight: null | import('../../types').PreflightStatus,- currentTeam: null | import('../../types').TeamPublicType | import('../../types').TeamType+ currentTeam: null | import('../../types').TeamPublicType | import('../../types').TeamType,+ isAdminOrOwner: boolean | null): Setting[] => {const effectiveSectionId = selectedSectionId ?? defaultSectionId@@ -673,6 +680,9 @@ export const settingsLogic = kea<settingsLogicType>([if (x.hideWhenNoSection && !effectiveSectionId) {return false}+ if (x.organizationAdminOnly && !isAdminOrOwner) {+ return false+ }if (x.allowForTeam) {return x.allowForTeam(currentTeam)}@@ -728,12 +738,13 @@ export const settingsLogic = kea<settingsLogicType>([isSearching: [(s) => [s.searchTerm], (searchTerm: string): boolean => searchTerm.trim().length > 0],globalSearchIndex: [- (s) => [s.sections, s.doesMatchFlags, s.preflight, s.currentTeam],+ (s) => [s.sections, s.doesMatchFlags, s.preflight, s.currentTeam, s.isAdminOrOwner],(sections: SettingSection[],doesMatchFlags: (flagDefinition: Pick<Setting, 'flag'>) => boolean,preflight: null | import('../../types').PreflightStatus,- currentTeam: null | import('../../types').TeamPublicType | import('../../types').TeamType+ currentTeam: null | import('../../types').TeamPublicType | import('../../types').TeamType,+ isAdminOrOwner: boolean | null): GlobalSearchFuse => {const isSettingVisible = (setting: Setting): boolean => {if (!doesMatchFlags(setting)) {@@ -742,6 +753,9 @@ export const settingsLogic = kea<settingsLogicType>([if (preflight?.realm && setting.hideOn?.includes(preflight.realm)) {return false}+ if (setting.organizationAdminOnly && !isAdminOrOwner) {+ return false+ }return !setting.allowForTeam || setting.allowForTeam(currentTeam)}diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.tsindex 3dad234807f7..5776b805a27a 100644--- a/frontend/src/scenes/settings/types.ts+++ b/frontend/src/scenes/settings/types.ts@@ -336,6 +336,12 @@ export type Setting = {*/allowForTeam?: (team: TeamType | TeamPublicType | null) => boolean+ /**+ * Shows the setting only to organization admins and owners.+ * Use it for an organization-scoped API, because a project admin can be an ordinary organization member.+ */+ organizationAdminOnly?: boolean+/*** If true, this setting will be hidden when viewing all settings (no specific section selected),* but will still appear when viewing its specific section directlydiff --git a/frontend/src/types.ts b/frontend/src/types.tsindex ae3331f2c5eb..469fec264399 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -240,6 +240,7 @@ export enum AvailableFeature {DATA_COLOR_THEMES = 'data_color_themes',ORGANIZATION_INVITE_SETTINGS = 'organization_invite_settings',ORGANIZATION_SECURITY_SETTINGS = 'organization_security_settings',+ MEMBER_GOVERNANCE = 'member_governance',TOOLBAR_HEATMAPS = 'toolbar_heatmaps',}diff --git a/posthog/api/organization_notification_locks.py b/posthog/api/organization_notification_locks.pyindex 05326ac529b8..e1c6d5ec1398 100644--- a/posthog/api/organization_notification_locks.py+++ b/posthog/api/organization_notification_locks.py@@ -18,7 +18,7 @@ from posthog.models.organization_notification_lock import (LOCKABLE_NOTIFICATION_SETTINGS,OrganizationMemberNotificationLock,)-from posthog.permissions import OrganizationAdminReadPermissions, PostHogFeatureFlagPermission, PremiumFeaturePermission+from posthog.permissions import OrganizationAdminReadPermissions, PremiumFeaturePermissionfrom products.notifications.backend.facade.api import (NotificationData,@@ -28,8 +28,6 @@ from products.notifications.backend.facade.api import (create_notification,)-ORG_NOTIFICATION_GOVERNANCE_FLAG = "org-notification-governance"-# Bounds one save. Far above what the page can produce, since it renders one control per member# and lockable setting.MAX_CHANGES_PER_REQUEST = 2000@@ -116,9 +114,8 @@ def _notify(user: User, organization: Organization, change_count: int) -> None:@extend_schema(extensions={"x-product": "core"})class OrganizationNotificationLockViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):scope_object = "INTERNAL"- permission_classes = [OrganizationAdminReadPermissions, PremiumFeaturePermission, PostHogFeatureFlagPermission]- premium_feature = AvailableFeature.ORGANIZATION_SECURITY_SETTINGS- posthog_feature_flag = ORG_NOTIFICATION_GOVERNANCE_FLAG+ permission_classes = [OrganizationAdminReadPermissions, PremiumFeaturePermission]+ premium_feature = AvailableFeature.MEMBER_GOVERNANCEpagination_class = None@extend_schema(diff --git a/posthog/api/test/test_organization_notification_locks.py b/posthog/api/test/test_organization_notification_locks.pyindex 658dc949c09c..31ee252adc32 100644--- a/posthog/api/test/test_organization_notification_locks.py+++ b/posthog/api/test/test_organization_notification_locks.py@@ -15,22 +15,12 @@ from posthog.models.organization_notification_lock import ()from posthog.tasks.email import NotificationSetting, get_members_to_notify, should_send_pipeline_error_notification-GOVERNANCE_FLAG = "org-notification-governance"---def _governance_flag(flag: str, *args, **kwargs) -> bool:- return flag == GOVERNANCE_FLAG---def _no_flags(flag: str, *args, **kwargs) -> bool:- return False-class TestOrganizationNotificationLocks(APIBaseTest):def setUp(self) -> None:super().setUp()self.organization.available_product_features = [- {"key": AvailableFeature.ORGANIZATION_SECURITY_SETTINGS, "name": "Organization security settings"}+ {"key": AvailableFeature.MEMBER_GOVERNANCE, "name": "Member governance"}]self.organization.save()self.organization_membership.level = OrganizationMembership.Level.ADMIN@@ -44,30 +34,19 @@ class TestOrganizationNotificationLocks(APIBaseTest):def _post(self, *changes) -> HttpResponse:return self.client.post(f"{self.url}bulk_update/", {"changes": list(changes)})- @parameterized.expand([("list",), ("bulk_update",)])- @patch("posthoganalytics.feature_enabled", side_effect=_no_flags)- def test_requires_the_feature_flag(self, action: str, _mock_flag) -> None:- response = (- self.client.get(self.url) if action == "list" else self._post(self._change(setting="discussions_mentioned"))- )- assert response.status_code == status.HTTP_403_FORBIDDEN-- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_requires_the_entitlement(self, _mock_flag) -> None:+ def test_requires_the_entitlement(self) -> None:self.organization.available_product_features = []self.organization.save()assert self.client.get(self.url).status_code == status.HTTP_402_PAYMENT_REQUIRED- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_requires_organization_admin(self, _mock_flag) -> None:+ def test_requires_organization_admin(self) -> None:self.organization_membership.level = OrganizationMembership.Level.MEMBERself.organization_membership.save()assert self.client.get(self.url).status_code == status.HTTP_403_FORBIDDEN- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_admin_cannot_change_an_owner(self, _mock_flag) -> None:+ def test_admin_cannot_change_an_owner(self) -> None:owner = self._create_user("[email protected]", level=OrganizationMembership.Level.OWNER)response = self._post(self._change(user_id=owner.id, setting="discussions_mentioned"))@@ -91,13 +70,11 @@ class TestOrganizationNotificationLocks(APIBaseTest):),])- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_rejects_an_invalid_rule(self, _name: str, overrides: dict, _mock_flag) -> None:+ def test_rejects_an_invalid_rule(self, _name: str, overrides: dict) -> None:assert self._post(self._change(**overrides)).status_code == status.HTTP_400_BAD_REQUESTassert OrganizationMemberNotificationLock.objects.count() == 0- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_rule_overrides_the_members_setting_without_changing_it(self, _mock_flag) -> None:+ def test_a_rule_overrides_the_members_setting_without_changing_it(self) -> None:self.member.partial_notification_settings = {"discussions_mentioned": True}self.member.save()@@ -107,8 +84,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert self.member.partial_notification_settings == {"discussions_mentioned": True}assert effective_notification_settings(self.member)["discussions_mentioned"] is False- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_removing_a_rule_restores_the_members_setting(self, _mock_flag) -> None:+ def test_removing_a_rule_restores_the_members_setting(self) -> None:self.member.partial_notification_settings = {"discussions_mentioned": True}self.member.save()self._post(self._change(setting="discussions_mentioned", locked_value=False))@@ -116,8 +92,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert self._post(self._change(setting="discussions_mentioned", locked_value=None)).status_code == 200assert effective_notification_settings(self.member)["discussions_mentioned"] is True- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_project_rule_only_covers_its_own_project(self, _mock_flag) -> None:+ def test_a_project_rule_only_covers_its_own_project(self) -> None:other = Team.objects.create(organization=self.organization, name="Other")self._post(@@ -128,8 +103,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert settings["project_weekly_digest_disabled"] == {str(self.team.id): True}assert str(other.id) not in settings["project_weekly_digest_disabled"]- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_rule_does_not_reach_another_organization(self, _mock_flag) -> None:+ def test_a_rule_does_not_reach_another_organization(self) -> None:# discussions_mentioned is stored once per user, so without scoping this organization's# rule would silence the member everywhere else they work too.other_org = Organization.objects.create(name="Other org")@@ -145,8 +119,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):m.user_id for m in get_members_to_notify(other_team, NotificationSetting.DISCUSSIONS_MENTIONED.value)]- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_project_rule_decides_pipeline_failure_emails(self, _mock_flag) -> None:+ def test_a_project_rule_decides_pipeline_failure_emails(self) -> None:# Stored per pipeline, governed per project, so this path is resolved separately.self._post(self._change(setting="pipeline_notifications_disabled", scope_id=str(self.team.id), locked_value=True)@@ -155,8 +128,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert should_send_pipeline_error_notification(self.member, team_id=self.team.id) is Falseassert should_send_pipeline_error_notification(self.member, team_id=self.team.id + 5000) is True- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_member_cannot_change_a_setting_a_rule_decides(self, _mock_flag) -> None:+ def test_a_member_cannot_change_a_setting_a_rule_decides(self) -> None:self._post(self._change(setting="discussions_mentioned", locked_value=False))self.client.force_login(self.member)@@ -171,8 +143,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert self.member.notification_settings["discussions_mentioned"] is Trueassert effective_notification_settings(self.member)["discussions_mentioned"] is False- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_a_member_can_still_change_everything_else(self, _mock_flag) -> None:+ def test_a_member_can_still_change_everything_else(self) -> None:self._post(self._change(setting="discussions_mentioned", locked_value=False))self.client.force_login(self.member)@@ -187,8 +158,7 @@ class TestOrganizationNotificationLocks(APIBaseTest):self.member.refresh_from_db()assert self.member.notification_settings["error_tracking_issue_assigned"] is False- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_one_bad_change_saves_none_of_the_batch(self, _mock_flag) -> None:+ def test_one_bad_change_saves_none_of_the_batch(self) -> None:response = self._post(self._change(setting="discussions_mentioned"),self._change(setting="project_weekly_digest_disabled", scope_id="99999"),@@ -197,22 +167,19 @@ class TestOrganizationNotificationLocks(APIBaseTest):assert response.status_code == status.HTTP_400_BAD_REQUESTassert OrganizationMemberNotificationLock.objects.count() == 0- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_rejects_a_batch_over_the_limit(self, _mock_flag) -> None:+ def test_rejects_a_batch_over_the_limit(self) -> None:changes = [self._change(setting="discussions_mentioned")] * (MAX_CHANGES_PER_REQUEST + 1)assert self._post(*changes).status_code == status.HTTP_400_BAD_REQUESTassert OrganizationMemberNotificationLock.objects.count() == 0- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_rejects_a_user_outside_the_organization(self, _mock_flag) -> None:+ def test_rejects_a_user_outside_the_organization(self) -> None:_, _, outsider = User.objects.bootstrap("Other org", "[email protected]", "password")assert self._post(self._change(user_id=outsider.id, setting="discussions_mentioned")).status_code == 400@patch("posthog.api.organization_notification_locks.create_notification")- @patch("posthoganalytics.feature_enabled", side_effect=_governance_flag)- def test_notifies_each_affected_member_once_per_save(self, _mock_flag, mock_create_notification) -> None:+ def test_notifies_each_affected_member_once_per_save(self, mock_create_notification) -> None:second = self._create_user("[email protected]")response = self._post(diff --git a/posthog/constants.py b/posthog/constants.pyindex 8525129d4b28..75748b422642 100644--- a/posthog/constants.py+++ b/posthog/constants.py@@ -52,6 +52,7 @@ class AvailableFeature(StrEnum):ORGANIZATION_INVITE_SETTINGS = "organization_invite_settings"TWO_FACTOR_ENFORCEMENT = "2fa_enforcement"ORGANIZATION_SECURITY_SETTINGS = "organization_security_settings"+ MEMBER_GOVERNANCE = "member_governance"ORGANIZATION_APP_QUERY_CONCURRENCY_LIMIT = "organization_app_query_concurrency_limit"SESSION_REPLAY_DATA_RETENTION = "session_replay_data_retention"PRODUCT_ANALYTICS_DATA_RETENTION = "product_analytics_data_retention"