ref(browser): Extract browser-specific normalize code into registerable util#21172
ref(browser): Extract browser-specific normalize code into registerable util#21172mydea wants to merge 6 commits into
normalize code into registerable util#21172Conversation
size-limit report 📦
|
3ed69bb to
9729b8a
Compare
9729b8a to
fbe2a21
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fbe2a21. Configure here.
| } catch { | ||
| output.push('[value cannot be serialized]'); | ||
| } | ||
| output.push(normalize(value)); |
There was a problem hiding this comment.
safeJoin with normalize breaks Error and null/undefined stringification
High Severity
Replacing String(value) with normalize(value) in safeJoin causes normalize to return non-string types (objects, null, undefined) that are then passed to .join(). For Error objects, normalize returns {message, name, stack} which .join() renders as "[object Object]" instead of "Error: message". For null/undefined, .join() produces empty strings instead of "null"/"undefined". This degrades console breadcrumb messages in the browser SDK where safeJoin(handlerData.args, ' ') is used directly without pre-filtering Errors.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit fbe2a21. Configure here.
| type, | ||
| target, | ||
| currentTarget, | ||
| ...(detail ? { detail } : {}), |
There was a problem hiding this comment.
Falsy detail values dropped from CustomEvent serialization
Low Severity
The spread ...(detail ? { detail } : {}) drops valid falsy detail values (like 0, "", or false) from CustomEvents. The previous implementation always included detail for CustomEvent instances regardless of truthiness. Since detail is a prototype getter (not an own property), it won't be recovered by the ...getOwnProperties(value) spread either.
Reviewed by Cursor Bugbot for commit fbe2a21. Configure here.


Today, we have some browser-specific code in
corethat runs for all runtimes. Mainly this is around (browser)Event, which can havetargetandcurrentTargetdefined which are HTML elements. We have some code in place handling this in a custom way.This PR moves this code into
browser-utilsand changes it so this only runs in browser environments. There are two callsites:extractExceptionKeysForMessage- this is easy because we can just use the browser-utils implementation in the browser package, and use an implementation without Event support in core.normalize- this is harder because this is called from other core code, mainlyprepareEvent.To solve 2, this PR adds a
addNormalizeUnpackermethod that can be called to register a custom normalize unpacking function. So in core, nothing runs, while in browser this is called to register an additional unpacker for events.