Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(organization): default new EU orgs to AI training opt-out (#60070)

Paul D'Ambra7a3019d2da88
diff --git a/posthog/models/organization.py b/posthog/models/organization.py
index 145741179a6b..d481839dbac9 100644
--- a/posthog/models/organization.py
+++ b/posthog/models/organization.py
@@ -93,6 +93,8 @@ class OrganizationManager(models.Manager):
# Set default_anonymize_ips based on deployment if not explicitly provided
if "default_anonymize_ips" not in kwargs:
kwargs["default_anonymize_ips"] = default_anonymize_ips()
+ if "is_ai_training_opted_in" not in kwargs:
+ kwargs["is_ai_training_opted_in"] = default_is_ai_training_opted_in()
return create_with_slug(super().create, *args, **kwargs)
def bootstrap(
@@ -109,6 +111,8 @@ class OrganizationManager(models.Manager):
# Set default_anonymize_ips based on deployment if not explicitly provided
if "default_anonymize_ips" not in kwargs:
kwargs["default_anonymize_ips"] = default_anonymize_ips()
+ if "is_ai_training_opted_in" not in kwargs:
+ kwargs["is_ai_training_opted_in"] = default_is_ai_training_opted_in()
organization = Organization.objects.create(**kwargs)
_, team = Project.objects.create_with_team(
initiating_user=user, organization=organization, team_fields=team_fields
@@ -134,6 +138,11 @@ def default_anonymize_ips():
return getattr(settings, "CLOUD_DEPLOYMENT", None) == "EU"
+def default_is_ai_training_opted_in():
+ """Default to False (opted out) for EU cloud deployments to comply with stricter privacy requirements"""
+ return getattr(settings, "CLOUD_DEPLOYMENT", None) != "EU"
+
+
class Organization(ModelActivityMixin, UUIDTModel): # type: ignore[django-manager-missing]
class Meta:
constraints = [
diff --git a/posthog/models/test/test_organization_model.py b/posthog/models/test/test_organization_model.py
index 75624651f446..f1b89ecf9ecd 100644
--- a/posthog/models/test/test_organization_model.py
+++ b/posthog/models/test/test_organization_model.py
@@ -99,6 +99,22 @@ class TestOrganization(BaseTest):
)
self.assertFalse(explicit_org.default_anonymize_ips)
+ @parameterized.expand(
+ [
+ ("eu_defaults_to_opted_out", "EU", None, False),
+ ("us_defaults_to_opted_in", "US", None, True),
+ ("unset_deployment_defaults_to_opted_in", None, None, True),
+ ("explicit_value_overrides_eu_default", "EU", True, True),
+ ]
+ )
+ def test_default_is_ai_training_opted_in_based_on_deployment(
+ self, _name, cloud_deployment, explicit_value, expected
+ ):
+ with self.settings(CLOUD_DEPLOYMENT=cloud_deployment):
+ extra_kwargs = {} if explicit_value is None else {"is_ai_training_opted_in": explicit_value}
+ org, _, _ = Organization.objects.bootstrap(self.user, name=_name, **extra_kwargs)
+ self.assertEqual(org.is_ai_training_opted_in, expected)
+
def test_update_available_product_features_ignored_if_usage_info_exists(self):
with self.is_cloud(False):
new_org, _, _ = Organization.objects.bootstrap(self.user)