feat(browser): breadcrumb trail on errors, console forwarding to logs - #1151
Conversation
An error arrived with no record of what led to it unless the session was sampled into replay, which is the only path that captured console output. - The last 50 clicks, inputs, navigations and console lines are kept in memory for every session. Nothing leaves the page until an error is recorded; then the trail is exported as OTel log records linked to the error's span (maple.browser.breadcrumb events, and console lines as ordinary logs at their severity). Each breadcrumb is sent once. - logs.captureConsole exports chosen console levels as logs as they happen, instead of only as breadcrumbs. - Clicks, inputs and navigations come from the session event sink, which gains a small onSessionEvent listener hook (on globalThis like the sink). Console lines come from the SDK's own capture, which runs whether or not replay records; @maple/browser-session exports its console capture for it. - All of it lives in the deferred chunk. errors.ts reaches it through a hook, so the eager bundle is unchanged. breadcrumbs: false turns it off.
|
Warning Review limit reachedNext included review available in 58 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Maple reviewConfidence 3/5 · needs attention Warning This review ended early; what follows is what it established. Adds an in-memory breadcrumb trail (clicks, inputs, navigations, console lines) exported as OTel log records linked to the recorded error's span, plus a
FindingsWarning · F1 · Second console wrapper loses the breadcrumb wrapper on replay suspendcorrectness ·
What was checked
Files not reviewed (1)The review ended before it read these diffs, so nothing above vouches for them.
Copy all findings (1)
|
…eardown Breadcrumbs and replay both wrap console.*. Tearing one down restored the method it had captured at install, so replay suspending on a hidden tab could remove the breadcrumb wrapper for the rest of the page. Teardown now only restores when its own wrapper is still the installed one, and a torn down wrapper left inside another's chain just forwards.
Maple reviewConfidence 4/5 · likely safe to merge Adds an in-memory breadcrumb trail (clicks, inputs, navigations, console lines) exported as OTel logs linked to the error's span on
What was checked
Observability coverage: 3 of 3 changes observable
|
Maple reviewConfidence 4/5 · likely safe to merge Adds an in-memory breadcrumb trail (clicks, inputs, navigations, console) exported as OTel logs linked to an error's span, plus
What was checked
Observability coverage: 2 of 2 changes observable
|
Part 5 of the browser SDK stack. Based on the Web Vitals PR.
An error arrived with no record of what led to it unless the session happened to be sampled into replay, the only path that captured console output.
What changes
breadcrumbs, default true): the last 50 clicks, inputs, navigations and console lines are kept in memory for every session. Nothing leaves the page until an error is recorded; then the trail is exported as OTel log records linked to the error's span:maple.browser.breadcrumbevents withmaple.breadcrumb.type,maple.breadcrumb.target(short selector, never an input value) andurl.full;maple.breadcrumb.type: "console".Each breadcrumb is sent once; the next error gets the trail since the last one.
logs.captureConsole(default none): console levels exported as logs as they happen (maple.log.source: "console"), instead of only as breadcrumbs.How
onSessionEventlistener hook, kept onglobalThislike the sink itself so every bundled copy of@maple/browser-sessionsees the same listeners.@maple/browser-sessionexports its bounded console formatter (./console) for it. In replay-sampled sessions the console is wrapped twice; the formatter is bounded, and one owner for both paths wasn't worth the coupling.errors.tsreaches it through a hook, so the eager bundle is unchanged (moving it there saved ~0.9 kB eager). Collection starts a moment afterinit().Testing
Browser tests through the real
init()path: trail exported and linked to the error span; each crumb sent once and nothing without an error;breadcrumbs: false;captureConsoleforwarding without duplicating as a crumb.packages/browser-sessionsuite still green.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.