Browse Source

feat(digest): New Digest notification title (#34871)

Objective:
We want a more descriptive title than Digest Report. Also wrote a test for Digest Notifications in Slack.
NisanthanNanthakumar 2 years ago
parent
commit
5529ab0665

+ 3 - 1
src/sentry/integrations/slack/notifications.py

@@ -144,6 +144,7 @@ def _notify_recipient(
     attachments: List[SlackAttachment],
     channel: str,
     integration: Integration,
+    shared_context: Mapping[str, Any],
 ) -> None:
     with sentry_sdk.start_span(op="notification.send_slack", description="notify_recipient"):
         # Make a local copy to which we can append.
@@ -164,7 +165,7 @@ def _notify_recipient(
             "link_names": 1,
             "unfurl_links": False,
             "unfurl_media": False,
-            "text": notification.get_notification_title(),
+            "text": notification.get_notification_title(shared_context),
             "attachments": json.dumps(local_attachments),
         }
 
@@ -213,6 +214,7 @@ def send_notification_as_slack(
                     attachments=attachments,
                     channel=channel,
                     integration=integration,
+                    shared_context=shared_context,
                 )
 
     metrics.incr(

+ 1 - 1
src/sentry/notifications/notifications/activity/assigned.py

@@ -61,7 +61,7 @@ class AssignedActivityNotification(GroupActivityNotification):
     def get_description(self) -> tuple[str, Mapping[str, Any], Mapping[str, Any]]:
         return "{author} assigned {an issue} to {assignee}", {"assignee": self.get_assignee()}, {}
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         assignee = self.get_assignee()
 
         if not self.activity.user:

+ 1 - 1
src/sentry/notifications/notifications/activity/base.py

@@ -131,7 +131,7 @@ class GroupActivityNotification(ActivityNotification, abc.ABC):
             "referrer": self.__class__.__name__,
         }
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         description, params, _ = self.get_description()
         return self.description_as_text(description, params, True)
 

+ 1 - 1
src/sentry/notifications/notifications/activity/new_processing_issues.py

@@ -54,7 +54,7 @@ class NewProcessingIssuesActivityNotification(ActivityNotification):
     def title(self) -> str:
         return self.get_subject()
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         project_url = absolute_uri(
             f"/settings/{self.organization.slug}/projects/{self.project.slug}/processing-issues/"
         )

+ 1 - 1
src/sentry/notifications/notifications/activity/note.py

@@ -21,7 +21,7 @@ class NoteActivityNotification(GroupActivityNotification):
         author = self.activity.user.get_display_name()
         return f"New comment by {author}"
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         return self.title
 
     def get_message_description(self, recipient: Team | User) -> Any:

+ 1 - 1
src/sentry/notifications/notifications/activity/regression.py

@@ -34,7 +34,7 @@ class RegressionActivityNotification(GroupActivityNotification):
 
         return message, params, html_params
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         text = "Issue marked as regression"
         if self.version:
             text += f" in release {self.version_parsed}"

+ 1 - 1
src/sentry/notifications/notifications/activity/release.py

@@ -134,7 +134,7 @@ class ReleaseActivityNotification(ActivityNotification):
     def title(self) -> str:
         return self.get_subject()
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         projects_text = ""
         if len(self.projects) == 1:
             projects_text = " for this project"

+ 1 - 1
src/sentry/notifications/notifications/activity/resolved_in_release.py

@@ -31,7 +31,7 @@ class ResolvedInReleaseActivityNotification(GroupActivityNotification):
             )
         return "{author} marked {an issue} as resolved in an upcoming release", {}, {}
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         data = self.activity.data
         author = self.activity.user.get_display_name()
         release = data["version"] if data.get("version") else "an upcoming release"

+ 1 - 1
src/sentry/notifications/notifications/activity/unassigned.py

@@ -12,7 +12,7 @@ class UnassignedActivityNotification(GroupActivityNotification):
     def get_description(self) -> tuple[str, Mapping[str, Any], Mapping[str, Any]]:
         return "{author} unassigned {an issue}", {}, {}
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
         user = self.activity.user
         if user:
             author = user.name or user.email

+ 2 - 1
src/sentry/notifications/notifications/base.py

@@ -80,7 +80,8 @@ class BaseNotification(abc.ABC):
         # Basically a noop.
         return {**extra_context}
 
-    def get_notification_title(self) -> str:
+    def get_notification_title(self, context: Mapping[str, Any] | None = None) -> str:
+        """The subject line when sending this notifications as a chat notification."""
         raise NotImplementedError
 
     def get_title_link(self, recipient: Team | User) -> str | None:

Some files were not shown because too many files changed in this diff