Browse Source

feat(feedback): hide feedback issues by default if not filtered on (#59505)

Previously: https://github.com/getsentry/sentry/pull/57528

Instead of trying to control the display of feedbacks, lets just hide
them by default unless they are filtered on.

Aspirationally, we'd like to eventually have our own feedbacks endpoint
that only displays feedbacks, and have feedbacks hidden from issues
search entirely, but I do not see a good way of doing this without it
being either extremely hacky, or a lot of work.
Josh Ferge 1 year ago
parent
commit
678abe885a
2 changed files with 93 additions and 2 deletions
  1. 2 1
      src/sentry/search/snuba/executors.py
  2. 91 1
      tests/snuba/search/test_backend.py

+ 2 - 1
src/sentry/search/snuba/executors.py

@@ -424,6 +424,8 @@ class AbstractQueryExecutor(metaclass=ABCMeta):
                 if gc != GroupCategory.PROFILE.value
                 or features.has("organizations:issue-platform", organization, actor=actor)
             }
+            # if we're not searching for feedbacks, then hide them by default
+            group_categories.discard(GroupCategory.FEEDBACK.value)
 
         if not features.has("organizations:performance-issues-search", organization):
             group_categories.discard(GroupCategory.PERFORMANCE.value)
@@ -1228,7 +1230,6 @@ class CdcPostgresSnubaQueryExecutor(PostgresSnubaQueryExecutor):
         actor: Optional[Any] = None,
         aggregate_kwargs: Optional[PrioritySortWeights] = None,
     ) -> CursorResult[Group]:
-
         if not validate_cdc_search_filters(search_filters):
             raise InvalidQueryForExecutor("Search filters invalid for this query executor")
 

+ 91 - 1
tests/snuba/search/test_backend.py

@@ -14,6 +14,7 @@ from sentry.api.issue_search import convert_query_values, issue_search_config, p
 from sentry.exceptions import InvalidSearchQuery
 from sentry.issues.grouptype import (
     ErrorGroupType,
+    FeedbackGroup,
     NoiseConfig,
     PerformanceNPlusOneGroupType,
     PerformanceRenderBlockingAssetSpanGroupType,
@@ -1965,7 +1966,6 @@ class EventsSnubaSearchTestCases(EventsDatasetTestSetup):
         assert set(results) == {group_2}
 
     def test_first_release(self):
-
         # expect no groups within the results since there are no releases
 
         results = self.make_query(search_filter_query="first_release:%s" % "fake")
@@ -3684,6 +3684,96 @@ class EventsGenericSnubaSearchTest(TestCase, SharedSnubaMixin, OccurrenceTestMix
                 == []
             )
 
+    def test_feedback_category_hidden_default(self):
+        with self.feature(
+            ["organizations:issue-platform", FeedbackGroup.build_visible_feature_name()]
+        ):
+            event_id_1 = uuid.uuid4().hex
+            _, group_info = process_event_and_issue_occurrence(
+                self.build_occurrence_data(
+                    **{
+                        "id": uuid.uuid4().hex,
+                        "project_id": 1,
+                        "event_id": event_id_1,
+                        "fingerprint": ["c" * 32],
+                        "issue_title": "User Feedback",
+                        "subtitle": "it was bad",
+                        "culprit": "api/123",
+                        "resource_id": "1234",
+                        "evidence_data": {"Test": 123},
+                        "evidence_display": [
+                            {"name": "hi", "value": "bye", "important": True},
+                            {"name": "what", "value": "where", "important": False},
+                        ],
+                        "type": FeedbackGroup.type_id,
+                        "detection_time": datetime.now().timestamp(),
+                        "level": "info",
+                    }
+                ),
+                {
+                    "event_id": event_id_1,
+                    "project_id": self.project.id,
+                    "title": "some problem",
+                    "platform": "python",
+                    "tags": {"my_tag": "1"},
+                    "timestamp": before_now(minutes=1).isoformat(),
+                    "received": before_now(minutes=1).isoformat(),
+                },
+            )
+            results = self.make_query(
+                date_from=self.base_datetime,
+                date_to=self.base_datetime + timedelta(days=10),
+            )
+            assert set(results) == set()
+
+    def test_feedback_category_show_when_filtered_on(self):
+        with self.feature(
+            [
+                "organizations:issue-platform",
+                FeedbackGroup.build_visible_feature_name(),
+                FeedbackGroup.build_ingest_feature_name(),
+            ]
+        ):
+            event_id_1 = uuid.uuid4().hex
+            _, group_info = process_event_and_issue_occurrence(
+                self.build_occurrence_data(
+                    **{
+                        "id": uuid.uuid4().hex,
+                        "project_id": 1,
+                        "event_id": event_id_1,
+                        "fingerprint": ["c" * 32],
+                        "issue_title": "User Feedback",
+                        "subtitle": "it was bad",
+                        "culprit": "api/123",
+                        "resource_id": "1234",
+                        "evidence_data": {"Test": 123},
+                        "evidence_display": [
+                            {"name": "hi", "value": "bye", "important": True},
+                            {"name": "what", "value": "where", "important": False},
+                        ],
+                        "type": FeedbackGroup.type_id,
+                        "detection_time": datetime.now().timestamp(),
+                        "level": "info",
+                    }
+                ),
+                {
+                    "event_id": event_id_1,
+                    "project_id": self.project.id,
+                    "title": "some problem",
+                    "platform": "python",
+                    "tags": {"my_tag": "1"},
+                    "timestamp": before_now(minutes=1).isoformat(),
+                    "received": before_now(minutes=1).isoformat(),
+                },
+            )
+            results = self.make_query(
+                search_filter_query="issue.category:feedback",
+                date_from=self.base_datetime,
+                date_to=self.base_datetime + timedelta(days=10),
+            )
+            assert group_info is not None
+            assert list(results) == [group_info.group]
+
 
 class CdcEventsSnubaSearchTest(TestCase, SharedSnubaMixin):
     @property