Design a client-side analytics SDK like Google Analytics or Segment: a tiny async loader, an event pipeline with consent, sampling, and PII scrubbing, batching, delivery that survives page unload, and an SDK that never breaks or slows the host page.
"Design an analytics SDK that websites can drop in to track page views and events." (Candidates report Google asking a version of this.)
It sounds small, but an SDK runs inside other people's websites, which changes every priority.
Functional
page(): record page views, including client-side navigations in single-page apps.track(event, properties): custom events ("Signed Up", "Added to Cart").identify(userId, traits): link events to a known user after sign-in.Non-functional (where the real design is)
Out of scope: the collection backend, storage, and dashboards. We'll treat the collector as an HTTPS endpoint.