Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- [node] feat: Transactions handling for RequestHandler in Express/Hapi
- [node] feat: Allow requestHandler to be configured
- [node] feat: Make node transactions a pluggable integration with tests
- [core] feat: getRequestheaders should handle legacy DSNs
- [core] fix: correct sampleRate behaviour

## 4.0.6

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement

const { beforeSend, sampleRate } = this.getOptions();

if (typeof sampleRate === 'number' && sampleRate > Math.random()) {
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as i know Math.random() is not a valid random generator
i think better to use some kind of the https://github.com/ckknight/random-js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it's not security-grade randomness, but it'll do just fine for sampling :)

return {
status: Status.Skipped,
};
Expand Down