Skip to main content

set_user

Function set_user 

Source
pub fn set_user(user: HashMap<String, Value>)
Expand description

Manually attaches an affected user to whatever gets reported from here on, on this thread (an explicit capture_error/capture_error_with_class call with no user argument, or a panic the installed hook catches): there’s no way to automatically detect “the current user” the way a server-side web framework with its own session/auth middleware can, so call this yourself, e.g. right after sign-in. id/email/username are all independently optional; call with an empty map to clear whatever was set, e.g. on sign-out. See this crate’s own CURRENT_USER thread-local (in the source) for why this is thread-local, and the real caveat that comes with that choice under an async runtime.