From f044a28865853174d82e550e9333e9b877c5e18f Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 14 Apr 2022 11:21:41 -0400 Subject: [PATCH] ref(node): Remove raven-node backward-compat code Removes functionality around syncing context from domain. --- .../src/integrations/onunhandledrejection.ts | 37 ++++--------------- .../node/test/onunhandledrejection.test.ts | 10 ----- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/packages/node/src/integrations/onunhandledrejection.ts b/packages/node/src/integrations/onunhandledrejection.ts index 19f733b1f908..2ba9a3d8f205 100644 --- a/packages/node/src/integrations/onunhandledrejection.ts +++ b/packages/node/src/integrations/onunhandledrejection.ts @@ -46,36 +46,15 @@ export class OnUnhandledRejection implements Integration { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any public sendUnhandledPromise(reason: any, promise: any): void { const hub = getCurrentHub(); - - if (!hub.getIntegration(OnUnhandledRejection)) { - this._handleRejection(reason); - return; - } - - /* eslint-disable @typescript-eslint/no-unsafe-member-access */ - const context = (promise.domain && promise.domain.sentryContext) || {}; - - hub.withScope((scope: Scope) => { - scope.setExtra('unhandledPromiseRejection', true); - - // Preserve backwards compatibility with raven-node for now - if (context.user) { - scope.setUser(context.user); - } - if (context.tags) { - scope.setTags(context.tags); - } - if (context.extra) { - scope.setExtras(context.extra); - } - - hub.captureException(reason, { - originalException: promise, - data: { mechanism: { handled: false, type: 'onunhandledrejection' } }, + if (hub.getIntegration(OnUnhandledRejection)) { + hub.withScope((scope: Scope) => { + scope.setExtra('unhandledPromiseRejection', true); + hub.captureException(reason, { + originalException: promise, + data: { mechanism: { handled: false, type: 'onunhandledrejection' } }, + }); }); - }); - /* eslint-disable @typescript-eslint/no-unsafe-member-access */ - + } this._handleRejection(reason); } diff --git a/packages/node/test/onunhandledrejection.test.ts b/packages/node/test/onunhandledrejection.test.ts index 5d8d498079e5..8588c9edddd6 100644 --- a/packages/node/test/onunhandledrejection.test.ts +++ b/packages/node/test/onunhandledrejection.test.ts @@ -1,4 +1,3 @@ -import { Scope } from '@sentry/core'; import { Hub } from '@sentry/hub'; import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection'; @@ -35,10 +34,6 @@ describe('unhandled promises', () => { }; const captureException = jest.spyOn(Hub.prototype, 'captureException'); - const setUser = jest.spyOn(Scope.prototype, 'setUser'); - const setExtra = jest.spyOn(Scope.prototype, 'setExtra'); - const setExtras = jest.spyOn(Scope.prototype, 'setExtras'); - const setTags = jest.spyOn(Scope.prototype, 'setTags'); integration.sendUnhandledPromise('bla', promise); @@ -46,10 +41,5 @@ describe('unhandled promises', () => { mechanism: { handled: false, type: 'onunhandledrejection' }, }); expect(captureException.mock.calls[0][0]).toBe('bla'); - expect(setUser.mock.calls[0][0]).toEqual({ id: 1 }); - expect(setExtra.mock.calls[0]).toEqual(['unhandledPromiseRejection', true]); - - expect(setExtras.mock.calls[0]).toEqual([{ extra: '1' }]); - expect(setTags.mock.calls[0]).toEqual([{ tag: '2' }]); }); });