MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / setUser

Method setUser

packages/core/src/scope.ts:268–284  ·  view source on GitHub ↗

* Set the user for this scope. * Set to `null` to unset the user.

(user: User | null)

Source from the content-addressed store, hash-verified

266 * Set to `null` to unset the user.
267 */
268 public setUser(user: User | null): this {
269 // If null is passed we want to unset everything, but still define keys,
270 // so that later down in the pipeline any existing values are cleared.
271 this._user = user || {
272 email: undefined,
273 id: undefined,
274 ip_address: undefined,
275 username: undefined,
276 };
277
278 if (this._session) {
279 updateSession(this._session, { user });
280 }
281
282 this._notifyScopeListeners();
283 return this;
284 }
285
286 /**
287 * Get the user from this scope.

Callers 15

index.test.tsFile · 0.80
middleware.test.tsFile · 0.80
setConnInfoAttributesFunction · 0.80
scope.test.tsFile · 0.80
client.test.tsFile · 0.80
internal.test.tsFile · 0.80
internal.test.tsFile · 0.80
utils.test.tsFile · 0.80
setUserFunction · 0.80

Calls 2

_notifyScopeListenersMethod · 0.95
updateSessionFunction · 0.90

Tested by

no test coverage detected