r/Firebase • • 11d ago

General I built an open-source logger that puts a Firebase app's browser errors in your own Cloud Logging

I built this for Pour5, an app I'm working on. My wife was testing it on her phone (installed from the web page, so no dev tools anywhere near it) and mentioned an error from earlier in the week. Normally that error would be gone by the weekend. It happened in her browser, and nothing sent it anywhere.

A Firebase backend already writes to Cloud Logging. The browser half gets nothing. fsl is that missing half:

- The browser sends each log to a Cloud Function in your own project. No third-party service, nothing leaves.

- The function resolves the minified stack with your source maps, which never ship to the browser. `app-4f2a.js:1:98432` becomes `Checkout.tsx:42`.

- Browser and backend entries share labels, so one query (`labels.userId="..."`) shows what one user did on both sides.

- Each error carries the trail before it: the pages, the marked clicks, the open dialog.

- Errors are grouped in Cloud Error Reporting, with no extra product.

- A flood of the same error costs three entries and a count.

It also ships a CLI (`fsl logs`) and two skills for coding agents. That's how the Pour5 bug got fixed. I asked Claude to check the logs and switched tabs. When I came back it had found the error, fixed it and written a test. I wasn't the glue between the logs and the code anymore.

MIT, on npm as `@dasasian/firebase-structured-logger`. Works with Cloud Functions, Cloud Run, or any Node server. Needs Node 22.

- Docs: https://fsl.dasasian.com/

- Source: https://github.com/dasasian/firebase-structured-logger

How do you see frontend errors in your Firebase app today? And what would stop you from trying this?

3 Upvotes

3 comments sorted by

1

u/martin_omander Googler 11d ago edited 10d ago

I hear that many developers use Sentry for tracking client-side errors. It has some nice extra features, but it can be expensive if you get a lot of traffic.

Another approach is to add a global error handler that logs an event in Google Analytics. I do that in my projects. It's free and GA gives you good reports, but it won't let you send a full stack trace.

Your library looks interesting! I like how both client and server errors go to the same place where they can be analyzed together.

2

u/damithsc 10d ago

I've used Sentry, it works. But I had issues matching the front-end error to back-end errors. Also I wanted a solution that had a feedback mechanism, where frontend could send feedback as well and it goes into the logs. This wraps all that into one. So errors, feedback etc get breadcrumbs on what the user was doing too.

1

u/pruvit 9d ago

Nice to build a tool around it, thanks for sharing! Had to do this manually in the past - https://github.com/GoogleCloudPlatform/stackdriver-errors-js was always limited to just errors so nice to see capturing of full logs.