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.

fix(error-tracking): attribute rule create/edit/delete analytics to the acting user (#75381)

posthog[bot]8cecf577c912
diff --git a/products/error_tracking/backend/presentation/views/assignment_rules.py b/products/error_tracking/backend/presentation/views/assignment_rules.py
index b9f39fe15bbb..eb4c6a223caa 100644
--- a/products/error_tracking/backend/presentation/views/assignment_rules.py
+++ b/products/error_tracking/backend/presentation/views/assignment_rules.py
@@ -159,6 +159,7 @@ class ErrorTrackingAssignmentRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Generi
raise NotFound()
posthoganalytics.capture(
"error_tracking_assignment_rule_edited",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response({"ok": True}, status=status.HTTP_204_NO_CONTENT)
@@ -182,6 +183,7 @@ class ErrorTrackingAssignmentRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Generi
raise NotFound()
posthoganalytics.capture(
"error_tracking_assignment_rule_deleted",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(status=status.HTTP_204_NO_CONTENT)
@@ -202,6 +204,7 @@ class ErrorTrackingAssignmentRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Generi
raise ValidationError(str(err)) from err
posthoganalytics.capture(
"error_tracking_assignment_rule_created",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(self.get_serializer(rule).data, status=status.HTTP_201_CREATED)
diff --git a/products/error_tracking/backend/presentation/views/bypass_rules.py b/products/error_tracking/backend/presentation/views/bypass_rules.py
index a13dcbf22b14..6586a292b964 100644
--- a/products/error_tracking/backend/presentation/views/bypass_rules.py
+++ b/products/error_tracking/backend/presentation/views/bypass_rules.py
@@ -112,6 +112,7 @@ class ErrorTrackingBypassRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericVie
raise NotFound()
posthoganalytics.capture(
"error_tracking_bypass_rule_edited",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response({"ok": True}, status=status.HTTP_204_NO_CONTENT)
@@ -135,6 +136,7 @@ class ErrorTrackingBypassRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericVie
raise NotFound()
posthoganalytics.capture(
"error_tracking_bypass_rule_deleted",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(status=status.HTTP_204_NO_CONTENT)
@@ -151,6 +153,7 @@ class ErrorTrackingBypassRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericVie
raise ValidationError(str(err)) from err
posthoganalytics.capture(
"error_tracking_bypass_rule_created",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(self.get_serializer(rule).data, status=status.HTTP_201_CREATED)
diff --git a/products/error_tracking/backend/presentation/views/grouping_rules.py b/products/error_tracking/backend/presentation/views/grouping_rules.py
index b3e078f5600f..305838048bfe 100644
--- a/products/error_tracking/backend/presentation/views/grouping_rules.py
+++ b/products/error_tracking/backend/presentation/views/grouping_rules.py
@@ -169,6 +169,7 @@ class ErrorTrackingGroupingRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericV
raise NotFound()
posthoganalytics.capture(
"error_tracking_grouping_rule_edited",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response({"ok": True}, status=status.HTTP_204_NO_CONTENT)
@@ -192,6 +193,7 @@ class ErrorTrackingGroupingRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericV
raise NotFound()
posthoganalytics.capture(
"error_tracking_grouping_rule_deleted",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(status=status.HTTP_204_NO_CONTENT)
@@ -212,6 +214,7 @@ class ErrorTrackingGroupingRuleViewSet(TeamAndOrgViewSetMixin, viewsets.GenericV
raise ValidationError(str(err)) from err
posthoganalytics.capture(
"error_tracking_grouping_rule_created",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(self.get_serializer(rule).data, status=status.HTTP_201_CREATED)
diff --git a/products/error_tracking/backend/presentation/views/suppression_rules.py b/products/error_tracking/backend/presentation/views/suppression_rules.py
index b6f129f0f0f3..7a6a3aad9380 100644
--- a/products/error_tracking/backend/presentation/views/suppression_rules.py
+++ b/products/error_tracking/backend/presentation/views/suppression_rules.py
@@ -120,6 +120,7 @@ class ErrorTrackingSuppressionRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Gener
raise NotFound()
posthoganalytics.capture(
"error_tracking_suppression_rule_edited",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response({"ok": True}, status=status.HTTP_204_NO_CONTENT)
@@ -143,6 +144,7 @@ class ErrorTrackingSuppressionRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Gener
raise NotFound()
posthoganalytics.capture(
"error_tracking_suppression_rule_deleted",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(status=status.HTTP_204_NO_CONTENT)
@@ -165,6 +167,7 @@ class ErrorTrackingSuppressionRuleViewSet(TeamAndOrgViewSetMixin, viewsets.Gener
raise ValidationError(str(err)) from err
posthoganalytics.capture(
"error_tracking_suppression_rule_created",
+ distinct_id=request.user.pk,
groups=groups(self.team.organization, self.team),
)
return Response(self.get_serializer(rule).data, status=status.HTTP_201_CREATED)