Browse Source

feat(mobile): Makes device.class searchable in issues stream frontend (#46700)

Makes device.class searchable and appear in the dropdown for issue
search
edwardgou-sentry 1 year ago
parent
commit
88b7635ff8

+ 5 - 1
static/app/stores/tagStore.tsx

@@ -163,7 +163,7 @@ const storeConfig: TagStoreDefinition = {
    * Get all tags including builtin issue tags and issue attributes
    */
   getIssueTags(org: Organization) {
-    return {
+    const issueTags = {
       ...BUILTIN_TAGS,
       ...SEMVER_TAGS,
       // State tags should overwrite built ins.
@@ -171,6 +171,10 @@ const storeConfig: TagStoreDefinition = {
       // We want issue attributes to overwrite any built in and state tags
       ...this.getIssueAttributes(org),
     };
+    if (!org.features.includes('device-classification')) {
+      delete issueTags[FieldKey.DEVICE_CLASS];
+    }
+    return issueTags;
   },
 
   getState() {

+ 1 - 0
static/app/utils/fields/index.ts

@@ -968,6 +968,7 @@ export const ISSUE_FIELDS = [
   FieldKey.BOOKMARKS,
   FieldKey.DEVICE_ARCH,
   FieldKey.DEVICE_BRAND,
+  FieldKey.DEVICE_CLASS,
   FieldKey.DEVICE_FAMILY,
   FieldKey.DEVICE_LOCALE,
   FieldKey.DEVICE_LOCALE,

+ 11 - 1
static/app/views/issueList/searchBar.tsx

@@ -5,7 +5,12 @@ import {fetchTagValues} from 'sentry/actionCreators/tags';
 import SmartSearchBar from 'sentry/components/smartSearchBar';
 import {Organization, SavedSearchType, Tag, TagCollection} from 'sentry/types';
 import {getUtcDateString} from 'sentry/utils/dates';
-import {FieldKind, getFieldDefinition} from 'sentry/utils/fields';
+import {
+  DEVICE_CLASS_TAG_VALUES,
+  FieldKind,
+  getFieldDefinition,
+  isDeviceClass,
+} from 'sentry/utils/fields';
 import useApi from 'sentry/utils/useApi';
 import usePageFilters from 'sentry/utils/usePageFilters';
 import withIssueTags, {WithIssueTagsProps} from 'sentry/utils/withIssueTags';
@@ -64,6 +69,11 @@ function IssueListSearchBar({organization, tags, ...props}: Props) {
 
   const getTagValues = useCallback(
     async (tag: Tag, query: string): Promise<string[]> => {
+      // device.class is stored as "numbers" in snuba, but we want to suggest high, medium,
+      // and low search filter values because discover maps device.class to these values.
+      if (isDeviceClass(tag.key)) {
+        return DEVICE_CLASS_TAG_VALUES;
+      }
       const values = await tagValueLoader(tag.key, query);
       return values.map(({value}) => value);
     },