useTruncatedRelease.tsx 770 B

1234567891011121314151617181920
  1. import {MAX_CHART_RELEASE_CHARS} from 'sentry/views/performance/mobile/constants';
  2. import {useReleaseSelection} from 'sentry/views/starfish/queries/useReleases';
  3. import {formatVersionAndCenterTruncate} from 'sentry/views/starfish/utils/centerTruncate';
  4. function useTruncatedReleaseNames(truncation?: number) {
  5. const {primaryRelease, secondaryRelease} = useReleaseSelection();
  6. const truncatedPrimaryRelease = formatVersionAndCenterTruncate(
  7. primaryRelease ?? '',
  8. truncation ?? MAX_CHART_RELEASE_CHARS
  9. );
  10. const truncatedSecondaryRelease = formatVersionAndCenterTruncate(
  11. secondaryRelease ?? '',
  12. truncation ?? MAX_CHART_RELEASE_CHARS
  13. );
  14. return {truncatedPrimaryRelease, truncatedSecondaryRelease};
  15. }
  16. export default useTruncatedReleaseNames;