← Files RivetARCHIVED FILE
node_modules/@sentry/core/build/cjs/utils/parseSampleRate.js
753 Bytes · Nov 7, 2026 · 13:16 UTC
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/**
* Parse a sample rate from a given value.
* This will either return a boolean or number sample rate, if the sample rate is valid (between 0 and 1).
* If a string is passed, we try to convert it to a number.
*
* Any invalid sample rate will return `undefined`.
*/
function parseSampleRate(sampleRate) {
if (typeof sampleRate === 'boolean') {
return Number(sampleRate);
}
const rate = typeof sampleRate === 'string' ? parseFloat(sampleRate) : sampleRate;
if (typeof rate !== 'number' || isNaN(rate) || rate < 0 || rate > 1) {
return undefined;
}
return rate;
}
exports.parseSampleRate = parseSampleRate;
//# sourceMappingURL=parseSampleRate.js.map
SHA-256: 45d01422cecc9c5d99c9d0dec08dda0d2cfa6e8e23f20d6bea1a9291e4772f5a