Browse Source

fix(issues): Add analytics for search suggestion, various fixes (#51565)

- Move analytics to a function that makes more sense
- Fix error.unhandled not moving onto the next item
- Switch release from release.version to release
Scott Cooper 1 year ago
parent
commit
7b628f38a6

+ 12 - 11
static/app/components/smartSearchBar/index.tsx

@@ -1664,17 +1664,6 @@ class SmartSearchBar extends Component<DefaultProps & Props, State> {
 
     const cursorToken = this.cursorToken;
 
-    if (item.kind === FieldKind.FIELD || item.kind === FieldKind.TAG) {
-      trackAnalytics('search.key_autocompleted', {
-        organization: this.props.organization,
-        search_operator: replaceText,
-        search_source: this.props.searchSource,
-        item_name: item.title ?? item.value?.split(':')[0],
-        item_kind: item.kind,
-        search_type: this.props.savedSearchType === 0 ? 'issues' : 'events',
-      });
-    }
-
     if (!cursorToken) {
       this.updateQuery(`${query}${replaceText}`);
       return;
@@ -1780,6 +1769,18 @@ class SmartSearchBar extends Component<DefaultProps & Props, State> {
       return;
     }
 
+    if (item.kind === FieldKind.FIELD || item.kind === FieldKind.TAG) {
+      trackAnalytics('search.key_autocompleted', {
+        organization: this.props.organization,
+        search_operator: replaceText,
+        search_source: this.props.searchSource,
+        item_name: item.title ?? item.value?.split(':')[0],
+        item_kind: item.kind,
+        item_type: item.type,
+        search_type: this.props.savedSearchType === 0 ? 'issues' : 'events',
+      });
+    }
+
     this.onAutoCompleteFromAst(replaceText, item);
   };
 

+ 1 - 0
static/app/utils/analytics/searchAnalyticsEvents.tsx

@@ -40,6 +40,7 @@ export type SearchEventParameters = {
     item_kind: string;
     item_name: string | undefined;
     search_operator: string;
+    item_type?: string;
   };
   'search.operator_autocompleted': SearchEventBase & {search_operator: string};
   'search.pin': {

+ 2 - 2
static/app/views/issueList/searchBar.tsx

@@ -109,7 +109,7 @@ function IssueListSearchBar({organization, tags, ...props}: Props) {
         type: ItemType.RECOMMENDED,
         title: t('Release'),
         desc: t('Filter by release version.'),
-        value: 'release.version:',
+        value: 'release:',
       },
       {
         type: ItemType.RECOMMENDED,
@@ -127,7 +127,7 @@ function IssueListSearchBar({organization, tags, ...props}: Props) {
         type: ItemType.RECOMMENDED,
         title: t('Unhandled'),
         desc: t('Filter by unhandled events.'),
-        value: 'error.unhandled:true',
+        value: 'error.unhandled:true ',
       },
       {
         type: ItemType.RECOMMENDED,