: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
fix(activity-logs): keep private team attributes out of change diffs (#109534)
posthog[bot]ff1252ffb8b6
diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.pyindex 7f0e1d371b41..cf37f8d4b863 100644--- a/posthog/models/activity_logging/activity_log.py+++ b/posthog/models/activity_logging/activity_log.py@@ -817,7 +817,6 @@ field_exclusions: dict[AuditableScope, list[str]] = {"id","secret_api_token","secret_api_token_backup",- "_old_api_token",],"Project": ["id", "created_at"],"DataWarehouseExpression": ["deleted_at"],@@ -1183,7 +1182,9 @@ def dict_changes_between(previous = previous or {}new = new or {}- fields = set(list(previous.keys()) + list(new.keys()))+ # Callers pass a model's `__dict__`, which also holds private attributes set by signal+ # handlers (for example a snapshot of the old API token). They are not fields, and can be secrets.+ fields = {field for field in [*previous.keys(), *new.keys()] if not str(field).startswith("_")}if use_field_exclusions:fields = fields - set(field_exclusions.get(model_type, [])) - set(common_field_exclusions)diff --git a/posthog/models/test/test_activity_logging.py b/posthog/models/test/test_activity_logging.pyindex 57ee0d6bedc5..f49810a32919 100644--- a/posthog/models/test/test_activity_logging.py+++ b/posthog/models/test/test_activity_logging.py@@ -13,7 +13,7 @@ class TeatActivityLog(TestCase):changes = dict_changes_between(model_type="Plugin",previous={"change_field": "foo", "delete_field": "foo"},- new={"change_field": "bar", "new_field": "bar"},+ new={"change_field": "bar", "new_field": "bar", "_fp_loaded_team_api_token": "phc_fake_token"},)self.assertEqual(len(changes), 3)