From 0d96d2df209e58a146d74ca300f2a1e3b8300d99 Mon Sep 17 00:00:00 2001 From: Daniel Jackins Date: Thu, 10 Oct 2024 21:17:46 -0600 Subject: [PATCH] update sample check --- packages/signals/signals/src/core/signals/settings.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/signals/signals/src/core/signals/settings.ts b/packages/signals/signals/src/core/signals/settings.ts index 4b455ab01..7efc53e7d 100644 --- a/packages/signals/signals/src/core/signals/settings.ts +++ b/packages/signals/signals/src/core/signals/settings.ts @@ -33,7 +33,7 @@ export class SignalGlobalSettings { ingestClient: SignalsIngestSettingsConfig network: NetworkSettingsConfig - private sampleRate = 0 + private sampleSuccess = false private signalsDebug = new SignalsDebugSettings() constructor(settings: SignalsSettingsConfig) { @@ -58,7 +58,7 @@ export class SignalGlobalSettings { if (this.signalsDebug.getSignalsDebug()) { return true } - if (Math.random() > this.sampleRate) { + if (!this.sampleSuccess) { return false } return false @@ -99,7 +99,9 @@ export class SignalGlobalSettings { Boolean(val) ) ) - this.sampleRate = sampleRate + if (Math.random() <= sampleRate) { + this.sampleSuccess = true + } } }