Skip to content

Commit babc55d

Browse files
Lms24andreiborza
authored andcommitted
ref(core): Steamline parseSampleRate utility function (#12024)
Just noticed that there's not really a reason to have the two separate warnings. Let's save some bytes.
1 parent c0dabd9 commit babc55d

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

packages/core/src/utils/parseSampleRate.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function parseSampleRate(sampleRate: unknown): number | undefined {
1414
}
1515

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

27-
if (rate < 0 || rate > 1) {
28-
DEBUG_BUILD &&
29-
logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`);
30-
return undefined;
31-
}
32-
3327
return rate;
3428
}

0 commit comments

Comments
 (0)