Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike {
const { beforeSend, sampleRate } = this.getOptions();
if (!this._isEnabled()) {
return SyncPromise.reject('SDK not enabled, will not send event.');
}
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
return SyncPromise.reject('This event has been sampled, will not send event.');
}
return new SyncPromise((resolve, reject) => {
this._prepareEvent(event, scope, hint)
.then(prepared => {
if (prepared === null) {
reject('An event processor returned null, will not send event.');
return;
}
protected _processEvent(event: Event, hint?: EventHint, scope?: Scope): PromiseLike {
const { beforeSend, sampleRate } = this.getOptions();
if (!this._isEnabled()) {
return SyncPromise.reject('SDK not enabled, will not send event.');
}
// 1.0 === 100% events are sent
// 0.0 === 0% events are sent
if (typeof sampleRate === 'number' && Math.random() > sampleRate) {
return SyncPromise.reject('This event has been sampled, will not send event.');
}
return new SyncPromise((resolve, reject) => {
this._prepareEvent(event, scope, hint)
.then(prepared => {
if (prepared === null) {
reject('An event processor returned null, will not send event.');
return;
}
let finalEvent: Event | null = prepared;
try {
const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true;
if (isInternalException || !beforeSend) {
this._getBackend().sendEvent(finalEvent);