From 00fa8d9bc0ffaf84069515809ecb4522beda205d Mon Sep 17 00:00:00 2001 From: nikbenesh <39644153+nikbenesh@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:46:54 +0300 Subject: [PATCH] Update logger.ts I suggest add more strict typeification. I have replaced 'any' with 'unknown' type --- src/utils/logger.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 0f4f1b2..6d1318a 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -3,14 +3,14 @@ import { captureException } from '@sentry/nextjs'; import { config } from '../consts/config'; export const logger = { - debug: (...args: any[]) => console.debug(...args), - info: (...args: any[]) => console.info(...args), - warn: (...args: any[]) => console.warn(...args), - error: (message: string, err: any, ...args: any[]) => { + debug: (...args: unknown[]) => console.debug(...args), + info: (...args: unknown[]) => console.info(...args), + warn: (...args: unknown[]) => console.warn(...args), + error: (message: string, err: Error, ...args: unknown[]) => { console.error(message, err, ...args); if (!config.isDevMode) { const filteredArgs = args.filter(isSafeSentryArg); - const extra = filteredArgs.reduce((acc, arg, i) => ({ ...acc, [`arg${i}`]: arg }), {}); + const extra = filteredArgs.reduce((acc, arg, i) => ({ ...acc, [arg${i}]: arg }), {}); extra['message'] = message; captureException(err, { extra }); } @@ -18,8 +18,8 @@ export const logger = { }; // First line of defense. Scrubbing is also configured in sentry.config.* files -function isSafeSentryArg(arg: any) { - if (typeof arg == 'number') return true; - if (typeof arg == 'string') return arg.length < 1000; +function isSafeSentryArg(arg: unknown): boolean { + if (typeof arg === 'number') return true; + if (typeof arg === 'string') return arg.length < 1000; return false; }