diff --git a/package.json b/package.json index 894332a..66f74b1 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "dependencies": { "@hawk.so/types": "^0.1.20", "error-stack-parser": "^2.1.4", + "safe-stringify": "^1.1.1", "vite-plugin-dts": "^4.2.4" } } diff --git a/src/addons/consoleCatcher.ts b/src/addons/consoleCatcher.ts index fc8fa13..18708aa 100644 --- a/src/addons/consoleCatcher.ts +++ b/src/addons/consoleCatcher.ts @@ -3,6 +3,7 @@ */ import type { ConsoleLogEvent } from '@hawk.so/types'; +import safeStringify from 'safe-stringify'; const createConsoleCatcher = (): { initConsoleCatcher: () => void; @@ -69,7 +70,7 @@ const createConsoleCatcher = (): { method, timestamp: new Date(), type: method, - message: args.map((arg) => typeof arg === 'string' ? arg : JSON.stringify(arg)).join(' '), + message: args.map((arg) => typeof arg === 'string' ? arg : safeStringify(arg)).join(' '), stack, fileLine: stack.split('\n')[0]?.trim(), }; diff --git a/yarn.lock b/yarn.lock index a3a87c2..cf1e367 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2619,6 +2619,11 @@ safe-regex-test@^1.0.3: es-errors "^1.3.0" is-regex "^1.1.4" +safe-stringify@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/safe-stringify/-/safe-stringify-1.1.1.tgz#f4240f506d041f58374d6106e2a5850f6b1ce576" + integrity sha512-YSzQLuwp06fuvJD1h6+vVNFYZoXmDs5UUNPUbTvQK7Ap+L0qD4Vp+sN434C+pdS3prVVlUfQdNeiEIgxox/kUQ== + semver@^6.3.1: version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"