Skip to content

Commit 04d76e7

Browse files
committed
fix
1 parent 36dd061 commit 04d76e7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/addons/consoleCatcher.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
* @file Module for intercepting console logs with stack trace capture
33
*/
44

5-
import { ConsoleLogEvent } from "@hawk.so/types/build/src/base/event/addons/javascript";
5+
import type { ConsoleLogEvent } from '@hawk.so/types/build/src/base/event/addons/javascript';
66

77
const MAX_LOGS = 20;
88
const consoleOutput: ConsoleLogEvent[] = [];
99

1010
let isInitialized = false;
1111

1212
export function initConsoleCatcher(): void {
13-
if (isInitialized) return;
13+
if (isInitialized) { return };
1414
isInitialized = true;
1515

16-
const consoleMethods = ["log", "warn", "error", "info", "debug"];
16+
const consoleMethods = ['log', 'warn', 'error', 'info', 'debug'];
1717

1818
consoleMethods.forEach((method) => {
19-
if (typeof window.console[method] !== "function") return;
19+
if (typeof window.console[method] !== 'function') { return };
2020

2121
const oldFunction = window.console[method].bind(window.console);
2222

@@ -25,38 +25,38 @@ export function initConsoleCatcher(): void {
2525
consoleOutput.shift();
2626
}
2727

28-
const stack = new Error().stack?.split("\n").slice(2).join("\n") || "";
28+
const stack = new Error().stack?.split('\n').slice(2).join('\n') || '';
2929

3030
const logEvent: ConsoleLogEvent = {
3131
method,
3232
timestamp: new Date(),
3333
type: method,
3434
message: args
35-
.map((arg) => (typeof arg === "string" ? arg : JSON.stringify(arg)))
35+
.map((arg) => (typeof arg === 'string' ? arg : JSON.stringify(arg)))
3636
.join(" "),
3737
stack,
38-
fileLine: stack.split("\n")[0]?.trim(),
38+
fileLine: stack.split('\n')[0]?.trim(),
3939
};
4040

4141
consoleOutput.push(logEvent);
4242
oldFunction(...args);
4343
};
4444
});
4545

46-
window.addEventListener("error", function (event) {
46+
window.addEventListener('error', function (event) {
4747
if (consoleOutput.length >= MAX_LOGS) {
4848
consoleOutput.shift();
4949
}
5050

5151
const logEvent: ConsoleLogEvent = {
52-
method: "error",
52+
method: 'error',
5353
timestamp: new Date(),
54-
type: event.error?.name || "Error",
54+
type: event.error?.name || 'Error',
5555
message: event.error?.message || event.message,
56-
stack: event.error?.stack || "",
56+
stack: event.error?.stack || '',
5757
fileLine: event.filename
5858
? `${event.filename}:${event.lineno}:${event.colno}`
59-
: "",
59+
: '',
6060
};
6161

6262
consoleOutput.push(logEvent);

src/catcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ export default class Catcher {
512512
}
513513

514514
if (consoleLogs.length > 0) {
515-
addons.consoleOutput = consoleLogs;
515+
addons.consoleOutput = consoleLogs;
516516
}
517517

518518
return addons;

0 commit comments

Comments
 (0)