Skip to content

Commit 6269bfd

Browse files
committed
fix: SampleRate and BeforeSend for Transaction
1 parent de78c96 commit 6269bfd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [apm] fix: Improve bundle size by moving span status to @sentry/apm #2589
1818
- [apm] feat: No longer discard transactions instead mark them deadline exceeded #2588
1919
- [apm] feat: Introduce `Sentry.startTransaction` and `Transaction.startChild` #2600
20+
- [apm] feat: Transactions no longer go through `beforeSend` #2600
2021

2122
## 5.15.5
2223

packages/core/src/baseclient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,11 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
392392
return SyncPromise.reject('SDK not enabled, will not send event.');
393393
}
394394

395+
const isTransaction = event.type === 'transaction';
395396
// 1.0 === 100% events are sent
396397
// 0.0 === 0% events are sent
397-
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
398+
// Sampling for transaction happens somewhere else
399+
if (!isTransaction && typeof sampleRate === 'number' && Math.random() > sampleRate) {
398400
return SyncPromise.reject('This event has been sampled, will not send event.');
399401
}
400402

@@ -409,7 +411,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
409411
let finalEvent: Event | null = prepared;
410412

411413
const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true;
412-
if (isInternalException || !beforeSend) {
414+
// We skip beforeSend in case of transactions
415+
if (isInternalException || !beforeSend || isTransaction) {
413416
this._getBackend().sendEvent(finalEvent);
414417
resolve(finalEvent);
415418
return;

0 commit comments

Comments
 (0)