You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): Improve safeJoin usage in console logging integration (#16658)
resolves#16657
## Background
In the `consoleLoggingIntegration` (which sends logs to Sentry from
console calls), we use a utility called `safeJoin` to join together the
console args.
https://github.com/getsentry/sentry-javascript/blob/b94f65279c8341a7176fe68186feef58af57e2cb/packages/core/src/utils/string.ts#L68-L94
This utility calls `String(value)` to convert items to a string, which
results in objects and arrays being turned into the dreaded `[Object
Object]` or `[Array]`.
https://github.com/getsentry/sentry-javascript/blob/b94f65279c8341a7176fe68186feef58af57e2cb/packages/core/src/utils/string.ts#L86
A user wrote in with feedback that this was annoying, and I agree!
## Solution
Instead of using `String(value)` I chose to create a new helper that
uses `JSON.stringify(normalize(X))`, which should result in the entire
object or array being properly shown. This required me to grab
`normalizeDepth` and `normalizeMaxBreadth` from the client options, but
that feels fine because it's easily explainable to users.
I added tests to validate this.
## Next Steps
We should really refactor our overall `safeJoin` usage. This should be
safe in breadcrumbs, but will be a breaking change in `capture-console`
as it'll cause issue grouping changes if console calls are being
captured as messages/errors.
0 commit comments