parsePercent.tsx 372 B

1234567891011121314
  1. import {clampPercentRate} from 'sentry/views/settings/dynamicSampling/utils/clampNumer';
  2. export function parsePercent(value: string | undefined | null, fallback: number = 0) {
  3. if (!value) {
  4. return fallback;
  5. }
  6. const numericValue = parseFloat(value);
  7. if (Number.isNaN(numericValue)) {
  8. return fallback;
  9. }
  10. return clampPercentRate(numericValue / 100);
  11. }