searchAnalyticsEvents.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {ShortcutType} from 'sentry/components/smartSearchBar/types';
  2. type SearchEventBase = {
  3. query: string;
  4. search_type: string;
  5. search_source?: string;
  6. };
  7. type OpenEvent = {};
  8. type SelectEvent = {result_type: string; source_type: string; query?: string};
  9. type QueryEvent = {query: string};
  10. type ProjectSelectorEvent = {path: string};
  11. export type SearchEventParameters = {
  12. 'command_palette.open': OpenEvent;
  13. 'command_palette.query': QueryEvent;
  14. 'command_palette.select': SelectEvent;
  15. 'organization_saved_search.selected': {
  16. id: number;
  17. search_type: string;
  18. };
  19. 'projectselector.clear': ProjectSelectorEvent;
  20. 'projectselector.direct_selection': ProjectSelectorEvent;
  21. 'projectselector.multi_button_clicked': ProjectSelectorEvent & {
  22. button_type: 'all' | 'my';
  23. };
  24. 'projectselector.toggle': ProjectSelectorEvent & {
  25. action: 'added' | 'removed';
  26. };
  27. 'projectselector.update': ProjectSelectorEvent & {
  28. count: number;
  29. multi: boolean;
  30. };
  31. 'search.invalid_field': Omit<SearchEventBase, 'query'> & {attempted_field_name: string};
  32. 'search.operator_autocompleted': SearchEventBase & {search_operator: string};
  33. 'search.pin': {
  34. action: 'pin' | 'unpin';
  35. search_type: string;
  36. query?: string;
  37. };
  38. 'search.search_with_invalid': SearchEventBase;
  39. 'search.searched': SearchEventBase & {search_source?: string};
  40. 'search.shortcut_used': SearchEventBase & {
  41. shortcut_method: 'hotkey' | 'click';
  42. shortcut_type: ShortcutType;
  43. search_source?: string;
  44. };
  45. 'settings_search.open': OpenEvent;
  46. 'settings_search.query': QueryEvent;
  47. 'settings_search.select': SelectEvent;
  48. 'sidebar_help.open': OpenEvent;
  49. 'sidebar_help.query': QueryEvent;
  50. 'sidebar_help.select': SelectEvent;
  51. };
  52. export type SearchEventKey = keyof SearchEventParameters;
  53. export const searchEventMap: Record<SearchEventKey, string | null> = {
  54. 'search.searched': 'Search: Performed search',
  55. 'search.operator_autocompleted': 'Search: Operator Autocompleted',
  56. 'search.shortcut_used': 'Search: Shortcut Used',
  57. 'search.search_with_invalid': 'Search: Attempted Invalid Search',
  58. 'search.invalid_field': 'Search: Unsupported Field Warning Shown',
  59. 'organization_saved_search.selected':
  60. 'Organization Saved Search: Selected saved search',
  61. 'settings_search.open': 'settings_search Open',
  62. 'command_palette.open': 'command_palette Open',
  63. 'sidebar_help.open': 'sidebar_help Open',
  64. 'settings_search.select': 'settings_search Select',
  65. 'command_palette.select': 'command_palette Select',
  66. 'sidebar_help.select': 'sidebar_help Select',
  67. 'settings_search.query': 'settings_search Query',
  68. 'command_palette.query': 'command_palette Query',
  69. 'sidebar_help.query': 'sidebar_help Query',
  70. 'projectselector.direct_selection': 'Project Selector: Direct Selection',
  71. 'projectselector.update': 'Project Selector: Update',
  72. 'projectselector.clear': 'Project Selector: Clear',
  73. 'projectselector.toggle': 'Project Selector: Toggle',
  74. 'projectselector.multi_button_clicked': 'Project Selector: Multi Button Clicked',
  75. 'search.pin': 'Search: Pin',
  76. };