Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Notify user when event failed to deliver because of digestion pipeline issue #2416

Merged
merged 1 commit into from
Feb 18, 2020
Merged
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
66 changes: 32 additions & 34 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,45 +394,43 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement

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);
resolve(finalEvent);
const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true;
if (isInternalException || !beforeSend) {
this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
return;
}

const beforeSendResult = beforeSend(prepared, hint);
// tslint:disable-next-line:strict-type-predicates
if (typeof beforeSendResult === 'undefined') {
logger.error('`beforeSend` method has to return `null` or a valid event.');
} else if (isThenable(beforeSendResult)) {
this._handleAsyncBeforeSend(beforeSendResult as PromiseLike<Event | null>, resolve, reject);
} else {
finalEvent = beforeSendResult as Event | null;

if (finalEvent === null) {
logger.log('`beforeSend` returned `null`, will not send event.');
resolve(null);
return;
}

const beforeSendResult = beforeSend(prepared, hint);
// tslint:disable-next-line:strict-type-predicates
if (typeof beforeSendResult === 'undefined') {
logger.error('`beforeSend` method has to return `null` or a valid event.');
} else if (isThenable(beforeSendResult)) {
this._handleAsyncBeforeSend(beforeSendResult as PromiseLike<Event | null>, resolve, reject);
} else {
finalEvent = beforeSendResult as Event | null;

if (finalEvent === null) {
logger.log('`beforeSend` returned `null`, will not send event.');
resolve(null);
return;
}

// From here on we are really async
this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
}
} catch (exception) {
this.captureException(exception, {
data: {
__sentry__: true,
},
originalException: exception as Error,
});
reject('`beforeSend` threw an error, will not send event.');
// From here on we are really async
this._getBackend().sendEvent(finalEvent);
resolve(finalEvent);
}
})
.then(null, () => {
reject('`beforeSend` threw an error, will not send event.');
.then(null, reason => {
this.captureException(reason, {
data: {
__sentry__: true,
},
originalException: reason as Error,
});
reject(
`Event processing pipeline threw an error, original event will not be sent. Details has been sent as a new event.\nReason: ${reason}`,
);
});
});
}
Expand Down