In a note-taking phone app, which breadcrumbs, custom keys and non-fatal errors should crash reports carry, and what must stay out of them?
answer
- the stack says where, not how
- typed events in a ring buffer
- state as of the crash
- caught failures, sampled and capped
- ids and counts, never note text
basics
~10 sBreadcrumbs of recent screens, sync steps and network outcomes; keys for flag values, experiment variant and sync state; sampled reports of caught failures. Never note text, titles, attachment names or search queries.
solid answer
~50 sThe stack shows where the app died; context shows how it got there. **Breadcrumbs** are a ring buffer of recent typed events — screen changes, sync steps with their outcome, HTTP status codes, memory warnings, moves to the background — held where the crash handler can copy them. **Custom keys** are current state, updated as it changes: flag values, experiment variant, pending sync operations, editor mode. **Non-fatal reports** send a stack and the same context for a failure the app caught, such as a merge that left a note unsynced; they are sampled, with the rate recorded, and capped per session so one looping bug cannot flood the pipeline. Everything is built from an allow-list of typed fields holding ids, counts and enums, never free text, so note content cannot reach a report even by accident.
code
pseudocode · 18 linessample_rate = 0.10 # assumption
cap_per_issue_per_session = 3 # assumption
function report_non_fatal(error_code, issue_signature):
seen = session_counts[issue_signature] or 0
if seen >= cap_per_issue_per_session:
dropped_counts[issue_signature] += 1 # still counted, sent with the next batch
return
session_counts[issue_signature] = seen + 1
if random() >= sample_rate:
unsampled_counts[issue_signature] += 1
return
report = new_report(kind = "non_fatal", code = error_code) # a code, never the message text
report.stack = current_stack()
report.breadcrumbs = breadcrumb_ring.copy()
report.keys = custom_keys.copy()
report.sample_rate = sample_rate
disk_queue.append(report)go deeper
Recall the three kinds of context: breadcrumbs for recent events, custom keys for current state, non-fatal reports for caught failures, and that note content never goes in any of them.
Explain how the ring buffer reaches a dying process, why keys are updated as state changes, and why non-fatals are sampled with the rate recorded and capped per session.
Show how a typed allow-list keeps content out structurally, how parser and database messages leak data, and how a silent data-loss bug surfaces only through non-fatal reports per version.
Set the shared rule for what any team may put in a report, who approves a new breadcrumb type, and how that list stays in step with what the store disclosure declares.
## Why the stack is not enough A stack trace tells you **where** the app died. In a note-taking app with background sync, that is often a generic place — a merge function, a database write, a list adapter — reached from a dozen paths. What makes a crash fixable is **how** the app got there and **what state** it was in. Three kinds of context supply that, each with its own rules. ## Breadcrumbs: the recent past A **breadcrumb** is a small, typed record of something that just happened, kept in a ring buffer of, say, the last 100 entries (the size is this design's assumption). The crash handler copies the buffer into the report, so it must already sit in memory, or in a memory-mapped file, when the crash comes. Useful kinds in a note-taking app: - **navigation**: note list opened, editor opened, widget tapped; - **sync steps**: push started, merge found conflicts on 3 notes, pull finished — each with its outcome; - **network outcomes**: method, route template, HTTP status, duration — never a request or response body; - **lifecycle**: moved to the background, returned, memory warning received; - **storage**: database migration step reached, save failed because the disk is full. Each is a type plus a few fields of ids, counts and enums. "Merge conflict on note `7f3c…`" with a random note id is useful; the same breadcrumb carrying the note's title is a leak. ## Custom keys: the present state **Custom keys** are a small map of current values that the report carries as of the moment of the crash. They are updated whenever the value changes, not set once at launch, or they describe a state the app left long ago. | Key | Example value | Question it answers | |---|---|---| | `flag.new_editor` | `on` | does the crash appear only with the new editor? | | `experiment.toolbar` | `variant_b` | is one variant crashing more? | | `sync.pending_ops` | `42` | does a large offline backlog trigger it? | | `sync.state` | `merging` | which phase of sync was running? | | `editor.mode` | `rich_text` | which editing path was active? | | `storage.free_bucket` | `under_100mb` | is a nearly full disk involved? | Buckets such as "under 100 MB" instead of exact values keep a key useful without making each device's report unique. ## Non-fatal errors as signals A **non-fatal report** sends a stack and the same context for a failure the app caught and survived: a merge that failed and left a note unsynced, a corrupt record skipped on load. In a note-taking app these matter because the worst bug, silent data loss, never crashes at all. The rules: 1. **Report failures that mean the app is wrong**, not expected conditions: losing the network on a phone is normal operation, not an error. 2. **Sample** at a rate the design chooses and **record the rate in each report**, so the server can re-weight counts into estimates. 3. **Cap** reports per issue per session, so one bug firing in a loop cannot flood the pipeline or spend the user's battery and data. 4. **Queue them on disk and upload in batches**, like crash reports; they are not urgent. Non-fatals are grouped into issues exactly like crashes, so a rising caught failure shows up per version next to the crashes. ## Keeping note content out Scrubbing on the server is too late: by then the text has left the phone and sits in someone's storage. The structural fix is on the device: - breadcrumbs and keys come from an **allow-list of types with typed fields**, so there is no free-text field to fill; - error messages from parsers and the database, which can echo the data they failed on, are reduced to a code before they reach a report; - identifiers are random ids, never email addresses or names; - collection stops when the user withdraws permission for diagnostics, and queued reports from that point are dropped. Both stores require an app to disclose the data it collects, including what its SDKs send, and one store lists crash logs and diagnostics as data types to declare. The design has to know exactly what a report contains, so that the disclosure matches it. Whether consent is needed, and where, is a legal decision with its own owner; the client's job is to gate collection on that decision. ## Not the same as analytics events Breadcrumbs look like product events but are not. They live on the device, are overwritten constantly, and leave the phone only inside a crash or non-fatal report. Product events have their own schema, queue and upload pipeline, and are counted for product questions rather than for debugging one failure.
- Why not attach the app's full debug log to each crash report instead of typed breadcrumbs?Free-text log lines carry whatever developers interpolated into them: note titles, server error bodies, file names, ids that identify a person. They are also large, which costs data and storage on every upload. A bounded ring of typed breadcrumbs gives the sequence of events with nothing in it that a reviewer has not approved.
- A caught sync failure is sampled at 10 percent; how do you still report how many users hit it?Each sampled report carries its sample rate, so the server multiplies counts back into an estimate. For an exact count, the app keeps a cheap local counter per issue and sends the totals, including the unsampled and capped occurrences, in the next batch; only the expensive part, the stack and context, is sampled.
- Breadcrumbs should record what the user typed so the crash can be reproduced.
- A caught exception is handled, so it never needs to be reported.
- Reporting every caught error, uncapped, costs nothing worth worrying about.
- Scrubbing note text on the server is enough, because uploads use TLS.
- Custom keys can be set once at launch and left alone.