Design an Error SDK Breadcrumb Trail
Design the client SDK component that records a bounded trail of recent app events and attaches it to error reports.
You are building part of an error-monitoring client SDK that an application embeds. When the application hits an error, the SDK captures it and sends an error report to a backend. Design the breadcrumbs feature: a trail of the recent things that happened in the application before an error, attached to the error report so a developer can see what led up to it. For this exercise, assume the following product facts. A breadcrumb has a timestamp, a category (for example navigation, http, ui.click, or console), a level (debug, info, warning, or error), an optional message, and optional small key-value data. Breadcrumbs come from two places: automatic integrations that the application enables when it starts the SDK, which record navigation changes, log calls, outgoing HTTP requests, and UI clicks; and explicit calls from application code. The SDK keeps only the most recent breadcrumbs, up to a limit set at start-up (default 100); when the trail is full, adding a breadcrumb drops the oldest one. The application may register one before-breadcrumb callback that can change a breadcrumb or drop it before it is stored. When an error is captured, the report carries a copy of the trail, oldest first. Capturing does not clear the trail, so a later report can include the same earlier breadcrumbs. The SDK must never break the host application: a failure inside an integration or the callback must not crash the app or stop the call being observed, and if the callback itself fails, the SDK keeps the breadcrumb as it was before the callback ran. For the main design, assume one application instance used by one person at a time, such as a browser page or a mobile app. Out of scope: the backend that receives reports, network sending and retries, sampling, and the developer-facing UI. No code is required: produce the requirements, object model, contracts, and one walkthrough, then extend the design in the follow-up.