Theme
Identity
Identity is two fields. deviceId is the anonymous id, generated and persisted for you by the client SDKs, kept for the lifetime of a browser or an app install. userId is the known person, once you have one.
The rule that makes history work: keep sending the same deviceId after sign-in. The anonymous events from before the person signed in then join to the person. identify() does not change the device id, which is exactly what allows that join.
reset() is the logout call. It clears the user id and starts a new device id, so the next person on the same machine is not merged into the last one. Calling it on a page navigation instead of a logout silently fragments every user's history.
On a server, identity is per call, not per client. identify() sets a process-wide subject — right for a CLI or a worker, wrong in a request handler, where concurrent requests overwrite each other and events land on the wrong person. Pass the user id with each event instead.
Per-SDK reference
Each page's §6 covers anonymous ids, identify, what happens to history at sign-in, reset on logout, and the exact consequence of getting each one wrong.
React: see React §3 for the module-scope client, and Browser §6 for the identity semantics it inherits.