diff --git a/src/sentry/analytics/events/notifications_sent.py b/src/sentry/analytics/events/notifications_sent.py deleted file mode 100644 index 985ed50ba56e40..00000000000000 --- a/src/sentry/analytics/events/notifications_sent.py +++ /dev/null @@ -1,14 +0,0 @@ -from sentry import analytics - - -class NotificationSent(analytics.Event): - type = "notifications.sent" - - attributes = ( - analytics.Attribute("organization_id"), - analytics.Attribute("project_id"), - analytics.Attribute("category"), - ) - - -analytics.register(NotificationSent) diff --git a/src/sentry/analytics/events/notifications_settings_updated.py b/src/sentry/analytics/events/notifications_settings_updated.py index 06ce3e182f4ea3..9367224b14c233 100644 --- a/src/sentry/analytics/events/notifications_settings_updated.py +++ b/src/sentry/analytics/events/notifications_settings_updated.py @@ -4,7 +4,10 @@ class NotificationSettingsUpdated(analytics.Event): type = "notifications.settings_updated" - attributes = (analytics.Attribute("target_type"),) + attributes = ( + analytics.Attribute("target_type"), + analytics.Attribute("actor_id"), + ) analytics.register(NotificationSettingsUpdated) diff --git a/src/sentry/integrations/slack/analytics.py b/src/sentry/integrations/slack/analytics.py index 4a23e74b5244a1..7af787efd3f330 100644 --- a/src/sentry/integrations/slack/analytics.py +++ b/src/sentry/integrations/slack/analytics.py @@ -17,5 +17,17 @@ class SlackIntegrationStatus(analytics.Event): ) +class SlackIntegrationNotificationSent(analytics.Event): + type = "integrations.slack.notification_sent" + + attributes = ( + analytics.Attribute("organization_id"), + analytics.Attribute("project_id"), + analytics.Attribute("category"), + analytics.Attribute("actor_id"), + ) + + analytics.register(SlackIntegrationAssign) +analytics.register(SlackIntegrationNotificationSent) analytics.register(SlackIntegrationStatus) diff --git a/src/sentry/integrations/slack/notifications.py b/src/sentry/integrations/slack/notifications.py index 74fd1b96095c41..ac134ce6177f9a 100644 --- a/src/sentry/integrations/slack/notifications.py +++ b/src/sentry/integrations/slack/notifications.py @@ -168,10 +168,11 @@ def send_notification_as_slack( }, ) analytics.record( - "notifications.sent", + "integrations.slack.notification_sent", organization_id=notification.organization.id, project_id=notification.project.id, category=notification.get_category(), + actor_id=recipient.actor_id, ) key = get_key(notification) diff --git a/src/sentry/notifications/manager.py b/src/sentry/notifications/manager.py index a141c0254a168d..0e1dc0240bbe20 100644 --- a/src/sentry/notifications/manager.py +++ b/src/sentry/notifications/manager.py @@ -109,9 +109,11 @@ def update_settings( * Updating a user's per-project preferences * Updating a user's per-organization preferences """ + target_id = get_target_id(user, team) analytics.record( "notifications.settings_updated", target_type="user" if user else "team", + actor_id=target_id, ) # A missing DB row is equivalent to DEFAULT. @@ -129,8 +131,6 @@ def update_settings( raise Exception(f"value '{value}' is not valid for type '{type}'") scope_type, scope_identifier = get_scope(user, team, project, organization) - target_id = get_target_id(user, team) - self._update_settings(provider, type, value, scope_type, scope_identifier, target_id) def remove_settings( @@ -354,4 +354,5 @@ def update_settings_bulk( analytics.record( "notifications.settings_updated", target_type="user" if user else "team", + actor_id=target_id, )