diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 8ce021fdbea8..a986062a8148 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -83,6 +83,8 @@ export abstract class BaseClient implements ClientLike { protected _eventProcessors: EventProcessor[] = []; + protected _lastException?: unknown; + /** * Initializes this client instance. * @@ -125,6 +127,14 @@ export abstract class BaseClient implements ClientLike { * @inheritDoc */ public captureException(exception: unknown, captureContext: CaptureContext = {}): string | undefined { + // Drop two consecutive events originating from the same source (eg. browser Wrap integrations) + if (this._lastException && this._lastException === captureContext.hint?.originalException) { + delete this._lastException; + return; + } else { + this._lastException = captureContext.hint?.originalException; + } + // TODO: This is broken. a) we dont pass event_id in hint anymore, b) its sync value assigned in async callback let eventId = captureContext.hint?.event_id; const scope = this._getEventScope(captureContext); @@ -166,6 +176,14 @@ export abstract class BaseClient implements ClientLike { * @inheritDoc */ public captureEvent(event: SentryEvent, captureContext: CaptureContext = {}): string | undefined { + // Drop two consecutive events originating from the same source (eg. browser Wrap integrations) + if (this._lastException && this._lastException === captureContext.hint?.originalException) { + delete this._lastException; + return; + } else { + this._lastException = captureContext.hint?.originalException; + } + let eventId = captureContext.hint?.event_id; const scope = this._getEventScope(captureContext); diff --git a/packages/integration-browser-globalhandlers/src/onerror.ts b/packages/integration-browser-globalhandlers/src/onerror.ts index 6e34e7721bbb..a50380f58a33 100644 --- a/packages/integration-browser-globalhandlers/src/onerror.ts +++ b/packages/integration-browser-globalhandlers/src/onerror.ts @@ -19,11 +19,6 @@ export class OnError implements Integration { addInstrumentationHandler({ callback: ({ msg, url, line, column, error }) => { - // TODO: Restore this functinality based on some error metadata - // if (shouldIgnoreOnError()) { - // return; - // } - if (error?.__sentry_own_request__) { return; } diff --git a/packages/integration-browser-globalhandlers/src/onunhandledrejection.ts b/packages/integration-browser-globalhandlers/src/onunhandledrejection.ts index e6baccb0c1e0..1535cc50a25f 100644 --- a/packages/integration-browser-globalhandlers/src/onunhandledrejection.ts +++ b/packages/integration-browser-globalhandlers/src/onunhandledrejection.ts @@ -33,11 +33,6 @@ export class OnUnhandledRejection implements Integration { // no-empty } - // TODO: Restore this functinality based on some error metadata - // if (shouldIgnoreOnError()) { - // return; - // } - if (error?.__sentry_own_request__) { return; } diff --git a/packages/integration-browser-wrap/src/wrap.ts b/packages/integration-browser-wrap/src/wrap.ts index 61073896169d..db01d615960d 100644 --- a/packages/integration-browser-wrap/src/wrap.ts +++ b/packages/integration-browser-wrap/src/wrap.ts @@ -48,9 +48,6 @@ export function wrap(fn: WrappedFunction, mechanism?: Mechanism): any { // is expected behavior and NOT indicative of a bug with sentry.javascript. return fn.apply(this, wrappedArguments); } catch (ex) { - // TODO: Fix ignoring next error (read metadata from the ex value itself like we do with `__sentry_own_request__`?) - // ignoreNextOnError(); - withScope(scope => { scope.addEventProcessor((event: SentryEvent) => { const processedEvent = { ...event }; @@ -68,7 +65,7 @@ export function wrap(fn: WrappedFunction, mechanism?: Mechanism): any { return processedEvent; }); - captureException(ex); + captureException(ex, { hint: { originalException: ex } }); }); throw ex;