Skip to content

Commit

Permalink
ref(core): Steamline parseSampleRate utility function (#12024)
Browse files Browse the repository at this point in the history
Just noticed that there's not really a reason to have the two separate
warnings. Let's save some bytes.
  • Loading branch information
Lms24 authored and andreiborza committed May 16, 2024
1 parent c0dabd9 commit babc55d
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions packages/core/src/utils/parseSampleRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function parseSampleRate(sampleRate: unknown): number | undefined {
}

const rate = typeof sampleRate === 'string' ? parseFloat(sampleRate) : sampleRate;
if (typeof rate !== 'number' || isNaN(rate)) {
if (typeof rate !== 'number' || isNaN(rate) || rate < 0 || rate > 1) {
DEBUG_BUILD &&
logger.warn(
`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
Expand All @@ -24,11 +24,5 @@ export function parseSampleRate(sampleRate: unknown): number | undefined {
return undefined;
}

if (rate < 0 || rate > 1) {
DEBUG_BUILD &&
logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`);
return undefined;
}

return rate;
}

0 comments on commit babc55d

Please sign in to comment.