From fc5132aa1a2c7277d990743e5c8203c37f5620c5 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Mon, 6 Nov 2023 20:41:08 -0800 Subject: [PATCH] feat(feedback): hide feedback issues by default if not filtered on --- src/sentry/search/snuba/executors.py | 3 +- tests/snuba/search/test_backend.py | 92 +++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/sentry/search/snuba/executors.py b/src/sentry/search/snuba/executors.py index ca00cf4d6201bc..2b0a401a069cb0 100644 --- a/src/sentry/search/snuba/executors.py +++ b/src/sentry/search/snuba/executors.py @@ -424,6 +424,8 @@ def snuba_search( 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 @@ def query( 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") diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index d58be7d37eab14..29a6fb25a83062 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -14,6 +14,7 @@ from sentry.exceptions import InvalidSearchQuery from sentry.issues.grouptype import ( ErrorGroupType, + FeedbackGroup, NoiseConfig, PerformanceNPlusOneGroupType, PerformanceRenderBlockingAssetSpanGroupType, @@ -1965,7 +1966,6 @@ def test_regressed_in_release(self): 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 @@ def test_rejected_filters(self): == [] ) + 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