From a7b1d25262bef97a756e9dc928cc703cc31b6796 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 9 Feb 2022 15:51:07 -0500 Subject: [PATCH] ref(utils): Simplify console instrumentation Apply changes from https://github.com/getsentry/sentry-javascript/pull/4505 that applied to `CaptureConsole` integration to the `instrumentConsole` func in `@sentry/utils`. It's important to note that the logic in utils, in `CaptureConsole` and the node `Console` integration is very similar, perhaps we can refactor to combine them. --- packages/utils/src/instrument.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/instrument.ts b/packages/utils/src/instrument.ts index 1b8b55d988e1..ec24bc828b60 100644 --- a/packages/utils/src/instrument.ts +++ b/packages/utils/src/instrument.ts @@ -116,13 +116,13 @@ function instrumentConsole(): void { return; } - fill(global.console, level, function (originalConsoleLevel: () => any): Function { + fill(global.console, level, function (originalConsoleMethod: () => any): Function { return function (...args: any[]): void { triggerHandlers('console', { args, level }); // this fails for some browsers. :( - if (originalConsoleLevel) { - Function.prototype.apply.call(originalConsoleLevel, global.console, args); + if (originalConsoleMethod) { + originalConsoleMethod.call(global.console, args); } }; });