MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / parseSampleRate

Function parseSampleRate

packages/core/src/utils/parseSampleRate.ts:8–19  ·  view source on GitHub ↗
(sampleRate: unknown)

Source from the content-addressed store, hash-verified

6 * Any invalid sample rate will return `undefined`.
7 */
8export function parseSampleRate(sampleRate: unknown): number | undefined {
9 if (typeof sampleRate === 'boolean') {
10 return Number(sampleRate);
11 }
12
13 const rate = typeof sampleRate === 'string' ? parseFloat(sampleRate) : sampleRate;
14 if (typeof rate !== 'number' || isNaN(rate) || rate < 0 || rate > 1) {
15 return undefined;
16 }
17
18 return rate;
19}

Callers 7

_processEventFunction · 0.90
sampleSpanFunction · 0.90
_startRootSpanFunction · 0.90
shouldSampleMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected