useModuleTitle.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import useOrganization from 'sentry/utils/useOrganization';
  2. import {MODULE_TITLE as AI_MODULE_TITLE} from 'sentry/views/llmMonitoring/settings';
  3. import {
  4. MODULE_TITLE as RESOURCES_MODULE_TITLE,
  5. PERFORMANCE_MODULE_TITLE as PERFORMANCE_RESOURCES_MODULE_TITLE,
  6. } from 'sentry/views/performance/browser/resources/settings';
  7. import {MODULE_TITLE as VITALS_MODULE_TITLE} from 'sentry/views/performance/browser/webVitals/settings';
  8. import {MODULE_TITLE as CACHE_MODULE_TITLE} from 'sentry/views/performance/cache/settings';
  9. import {MODULE_TITLE as DB_MODULE_TITLE} from 'sentry/views/performance/database/settings';
  10. import {MODULE_TITLE as HTTP_MODULE_TITLE} from 'sentry/views/performance/http/settings';
  11. import {MODULE_TITLE as APP_STARTS_MODULE_TITLE} from 'sentry/views/performance/mobile/appStarts/settings';
  12. import {MODULE_TITLE as SCREEN_LOADS_MODULE_TITLE} from 'sentry/views/performance/mobile/screenload/settings';
  13. import {MODULE_TITLE as MOBILE_UI_MODULE_TITLE} from 'sentry/views/performance/mobile/ui/settings';
  14. import {MODULE_TITLE as QUEUE_MODULE_TITLE} from 'sentry/views/performance/queues/settings';
  15. import {ModuleName} from 'sentry/views/starfish/types';
  16. export const MODULE_TITLES: Record<ModuleName, string> = {
  17. [ModuleName.DB]: DB_MODULE_TITLE,
  18. [ModuleName.HTTP]: HTTP_MODULE_TITLE,
  19. [ModuleName.CACHE]: CACHE_MODULE_TITLE,
  20. [ModuleName.QUEUE]: QUEUE_MODULE_TITLE,
  21. [ModuleName.SCREEN_LOAD]: SCREEN_LOADS_MODULE_TITLE,
  22. [ModuleName.APP_START]: APP_STARTS_MODULE_TITLE,
  23. [ModuleName.VITAL]: VITALS_MODULE_TITLE,
  24. [ModuleName.RESOURCE]: RESOURCES_MODULE_TITLE,
  25. [ModuleName.AI]: AI_MODULE_TITLE,
  26. [ModuleName.MOBILE_UI]: MOBILE_UI_MODULE_TITLE,
  27. [ModuleName.OTHER]: '',
  28. [ModuleName.ALL]: '',
  29. };
  30. type ModuleNameStrings = `${ModuleName}`;
  31. type TitleableModuleNames = Exclude<ModuleNameStrings, '' | 'other'>;
  32. export function useModuleTitle(moduleName: TitleableModuleNames) {
  33. const organization = useOrganization({allowNull: true});
  34. const isInsightsEnabled = organization?.features?.includes('performance-insights');
  35. if (!isInsightsEnabled && moduleName === ModuleName.RESOURCE) {
  36. return PERFORMANCE_RESOURCES_MODULE_TITLE;
  37. }
  38. return MODULE_TITLES[moduleName];
  39. }