Skip to content

Commit 0d96d2d

Browse files
committed
update sample check
1 parent b8e7ef7 commit 0d96d2d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/signals/signals/src/core/signals/settings.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class SignalGlobalSettings {
3333
ingestClient: SignalsIngestSettingsConfig
3434
network: NetworkSettingsConfig
3535

36-
private sampleRate = 0
36+
private sampleSuccess = false
3737
private signalsDebug = new SignalsDebugSettings()
3838

3939
constructor(settings: SignalsSettingsConfig) {
@@ -58,7 +58,7 @@ export class SignalGlobalSettings {
5858
if (this.signalsDebug.getSignalsDebug()) {
5959
return true
6060
}
61-
if (Math.random() > this.sampleRate) {
61+
if (!this.sampleSuccess) {
6262
return false
6363
}
6464
return false
@@ -99,7 +99,9 @@ export class SignalGlobalSettings {
9999
Boolean(val)
100100
)
101101
)
102-
this.sampleRate = sampleRate
102+
if (Math.random() <= sampleRate) {
103+
this.sampleSuccess = true
104+
}
103105
}
104106
}
105107

0 commit comments

Comments
 (0)