01The problem
A bug report would describe a symptom. By the time it reached us, the state that caused it was gone. Crashlytics only helps when something crashes, and even then not every crash reached it. We'd try to reproduce the problem on our own devices, fail, and end up guessing.
02The design
Instead of guessing, record what happened. The log captures the things that change state or cross a boundary:
- Data changes at the repository level: every change to orders, items and their values.
- Network traffic: requests and responses, success or failure.
- User actions: every interaction during a shift.
- Hardware: what was printed and to which printer, by readable name rather than an internal ID.
A POS runs all day, so the log has a hard cap: five rotating 5MB files, 25MB in total. When the cap is reached, the oldest file goes. The device never fills up, and the most recent history is always there, which is the part a bug report needs.
Getting logs off the device matters as much as writing them:
- On demand. From the POS settings, each file is zipped and uploaded to Firebase Storage.
- After a crash. The app flags itself and uploads its logs on the next start, along with an export of the local database and preferences. That gives us the state as well as the history.
- Offline. If the upload fails because the device is offline, the flag stays set and it retries on the next start.
03How the work was split
I owned the design: what to capture, where the boundaries are, how the files behave, and how logs leave the device. Two junior engineers on my team implemented it, using AI to apply the instrumentation across the codebase. They followed my direction and I reviewed the work. I use AI again at the other end, during triage, because a long log is much easier to work through when I can ask questions of it.
04Result
Bugs that used to stall at "can't reproduce" now come with a record of the changes, network traffic and user actions that led up to them, plus the database state when it matters.
The operations team later started using the logs to flag suspicious user activity. I hadn't built it for that, and I take it as a sign the log captures the right things.