config.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* global process */
  2. /**
  3. * This module is used to define the look and feels for charts rendered via the
  4. * backend chart rendering service Chartcuterie.
  5. *
  6. * Be careful what you import into this file, as it will end up being bundled
  7. * into the configuration file loaded by the service.
  8. */
  9. // eslint-disable-next-line import/no-named-default
  10. import {default as worldMap} from 'sentry/data/world.json';
  11. import {discoverCharts} from './discover';
  12. import {metricAlertCharts} from './metricAlert';
  13. import {ChartcuterieConfig, ChartType, RenderConfig, RenderDescriptor} from './types';
  14. /**
  15. * All registered style descriptors
  16. */
  17. const renderConfig: RenderConfig<ChartType> = new Map();
  18. /**
  19. * Chartcuterie configuration object
  20. */
  21. const config: ChartcuterieConfig = {
  22. version: process.env.COMMIT_SHA!,
  23. init: echarts => {
  24. echarts.registerMap('sentryWorld', worldMap);
  25. },
  26. renderConfig,
  27. };
  28. /**
  29. * Register a style descriptor
  30. */
  31. const register = (renderDescriptor: RenderDescriptor<ChartType>) =>
  32. renderConfig.set(renderDescriptor.key, renderDescriptor);
  33. discoverCharts.forEach(register);
  34. metricAlertCharts.forEach(register);
  35. export default config;