Skip to content

Commit

Permalink
ref(utils): Simplify console instrumentation (#4533)
Browse files Browse the repository at this point in the history
Apply changes from #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.
  • Loading branch information
AbhiPrasad committed Feb 10, 2022
1 parent ebba343 commit ff5595c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/utils/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
});
Expand Down

0 comments on commit ff5595c

Please sign in to comment.