Browse Source

feat(search): Improve analytics source tracking (#27363)

Evan Purkhiser 3 years ago
parent
commit
27a26c49d9

+ 1 - 0
static/app/components/dashboards/widgetQueriesForm.tsx

@@ -97,6 +97,7 @@ class WidgetQueriesForm extends React.Component<Props> {
             >
               <SearchConditionsWrapper>
                 <StyledSearchBar
+                  searchSource="widget_builder"
                   organization={organization}
                   projectIds={selection.projects}
                   query={widgetQuery.conditions}

+ 14 - 4
static/app/components/smartSearchBar/index.tsx

@@ -186,6 +186,10 @@ type Props = WithRouterProps & {
    * the current org
    */
   savedSearchType?: SavedSearchType;
+  /**
+   * Indicates the usage of the search bar for analytics
+   */
+  searchSource?: string;
   /**
    * Get a list of tag values for the passed tag
    */
@@ -391,13 +395,19 @@ class SmartSearchBar extends React.Component<Props, State> {
   async doSearch() {
     this.blur();
 
-    if (!this.hasValidSearch && this.hasImprovedSearch) {
+    if (this.hasImprovedSearch && !this.hasValidSearch) {
       return;
     }
 
     const query = removeSpace(this.state.query);
-    const {onSearch, onSavedRecentSearch, api, organization, savedSearchType} =
-      this.props;
+    const {
+      onSearch,
+      onSavedRecentSearch,
+      api,
+      organization,
+      savedSearchType,
+      searchSource,
+    } = this.props;
 
     trackAnalyticsEvent({
       eventKey: 'search.searched',
@@ -405,7 +415,7 @@ class SmartSearchBar extends React.Component<Props, State> {
       organization_id: organization.id,
       query,
       search_type: savedSearchType === 0 ? 'issues' : 'events',
-      search_source: 'main_search',
+      search_source: searchSource,
     });
 
     callIfFunction(onSearch, query);

+ 1 - 0
static/app/views/alerts/incidentRules/ruleConditionsFormForWizard.tsx

@@ -242,6 +242,7 @@ class RuleConditionsFormForWizard extends React.PureComponent<Props, State> {
             {({onChange, onBlur, onKeyDown, initialData, model}) => (
               <SearchContainer>
                 <StyledSearchBar
+                  searchSource="alert_builder"
                   defaultQuery={initialData?.query ?? ''}
                   omitTags={['event.type']}
                   disabled={disabled}

+ 1 - 0
static/app/views/eventsV2/results.tsx

@@ -435,6 +435,7 @@ class Results extends React.Component<Props, State> {
               <Top fullWidth>
                 {this.renderError(error)}
                 <StyledSearchBar
+                  searchSource="eventsv2"
                   organization={organization}
                   projectIds={eventView.project}
                   query={query}

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

@@ -127,6 +127,7 @@ class IssueListSearchBar extends React.Component<Props, State> {
 
     return (
       <SmartSearchBar
+        searchSource="main_search"
         hasRecentSearches
         maxSearchItems={5}
         savedSearchType={SavedSearchType.ISSUE}

+ 1 - 0
static/app/views/performance/landing/content.tsx

@@ -266,6 +266,7 @@ class LandingContent extends Component<Props, State> {
       <Fragment>
         <SearchContainer>
           <SearchBar
+            searchSource="performance_landing"
             organization={organization}
             projectIds={eventView.project}
             query={filterString}

+ 1 - 0
static/app/views/performance/transactionSummary/content.tsx

@@ -342,6 +342,7 @@ class SummaryContent extends React.Component<Props, State> {
                 onChangeFilter={onChangeFilter}
               />
               <StyledSearchBar
+                searchSource="transaction_summary"
                 organization={organization}
                 projectIds={eventView.project}
                 query={query}

+ 1 - 0
static/app/views/performance/trends/content.tsx

@@ -231,6 +231,7 @@ class TrendsContent extends React.Component<Props, State> {
             <DefaultTrends location={location} eventView={eventView}>
               <StyledSearchContainer>
                 <StyledSearchBar
+                  searchSource="trends"
                   organization={organization}
                   projectIds={trendView.project}
                   query={query}

+ 1 - 0
static/app/views/performance/vitalDetail/vitalDetailContent.tsx

@@ -216,6 +216,7 @@ class VitalDetailContent extends React.Component<Props, State> {
           <Layout.Main fullWidth>
             <StyledDescription>{description}</StyledDescription>
             <StyledSearchBar
+              searchSource="performance_vitals"
               organization={organization}
               projectIds={eventView.project}
               query={query}

+ 1 - 0
static/app/views/projectDetail/projectFilters.tsx

@@ -37,6 +37,7 @@ function ProjectFilters({query, tagValueLoader, onSearch}: Props) {
 
   return (
     <SmartSearchBar
+      searchSource="project_filters"
       query={query}
       placeholder={t('Search by release version')}
       maxSearchItems={5}

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