Skip to main content
@squasher-ai/browser-logger sends each console.error call in the browser to Squasher. It does nothing else: it does not capture uncaught errors, Web Vitals, or session replays. For those, use the Browser SDK. This page is tested with version 0.4.0.

Install the logger

To get your ingest key and project ID, see Create an ingest key. The key is visible to anyone who opens your site. An ingest key can send events to your project, but it cannot read data.

Start the logger

Start the logger once, when the page loads.
src/main.ts
From now on, each console.error call still writes to the console, and it also goes to Squasher.

What each event contains

For this call, the event gets:
  • The message Checkout failed Card declined {"cartId":"cart_123"}: all arguments, joined with spaces.
  • The error type and the stack trace of the first Error argument.
  • The page URL and the browser user agent.
  • All arguments, as JSON, in the console_arguments extra field.
The logger sends every argument of every console.error call, and the full page URL. Do not log tokens, card data, or personal data, and do not put them in URLs on pages that load the logger.

Send a test error

Run this in the browser console of your running site, or from a button handler:
The logger sends events in batches, every 5 seconds or when 10 events are queued. When the page is hidden or closed, it sends the rest. Then select Issues in the sidebar of your project. If the error does not appear, see Troubleshooting.

Options

init returns the logger. flush() sends the queued events now, and close() sends them and restores the original console.error.

Limits

  • The logger has no environment or release option, so its events have no environment. Automatic AI triage runs only on production issues. To triage one of these issues, select Run triage in the Squasher triage card on the issue page.
  • init throws when apiKey or projectId is empty, and when you call it a second time.
  • When a send fails, the logger keeps the events and tries again at the next send.
  • Stack traces from a minified bundle point at the minified files. Upload source maps for the release so the issue page shows the original files.

Next steps

Browser SDK

Capture uncaught errors, Web Vitals, and session replays.

Troubleshooting

Find out why an event does not appear.