utils.ts 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import type {Organization} from 'sentry/types/organization';
  2. import {DOMAIN_VIEW_MODULES} from 'sentry/views/insights/pages/settings';
  3. import type {DomainView} from 'sentry/views/insights/pages/useFilters';
  4. import {MODULE_FEATURE_MAP} from 'sentry/views/insights/settings';
  5. import type {ModuleName} from 'sentry/views/insights/types';
  6. export const isModuleEnabled = (module: ModuleName, organization: Organization) => {
  7. const moduleFeatures: string[] | undefined = MODULE_FEATURE_MAP[module];
  8. if (!moduleFeatures) {
  9. return false;
  10. }
  11. return moduleFeatures.every(feature => organization.features.includes(feature));
  12. };
  13. export const getModuleView = (module: ModuleName): DomainView => {
  14. if (DOMAIN_VIEW_MODULES.backend.includes(module)) {
  15. return 'backend';
  16. }
  17. if (DOMAIN_VIEW_MODULES.frontend.includes(module)) {
  18. return 'frontend';
  19. }
  20. if (DOMAIN_VIEW_MODULES.mobile.includes(module)) {
  21. return 'mobile';
  22. }
  23. if (DOMAIN_VIEW_MODULES.ai.includes(module)) {
  24. return 'ai';
  25. }
  26. return 'backend';
  27. };