Skip to content

Sentry scope's getUser() function returns a different result than the _user property on the scope itself (scope is out of date or not in sync) #15875

Open
@yashsway

Description

@yashsway

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

^9.4.0

Framework Version

^17.0.2

Link to Sentry event

n/a

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Call getCurrentScope().setUser({ name, email }) with some details of the authenticated user like the name and email
  2. Call getCurrentScope() immediately after but elsewhere in the code and inspect the _user property of the entire object. it will be out of date.
  3. Call getCurrentScope().getUser() in the same location - the value will be the most recent value and will conflict with _user from step 2.
  4. Initialize the feedbackIntegration() using useSentryUser set to { name: 'name', email: 'email' }. The default feedback dialog will not pre-populate the name and email fields with those properties from the scope because at time of initialization, they didn't get set.

Expected Result

The scope should update immediately everywhere and the properties on the scope object fetched from using getCurrentScope() should match the result of the getUser() method on the scope object itself.

Actual Result

see results of the following code in the screenshot below:

    const scope = getCurrentScope();

    console.log(scope, scope.getUser());

Image

the feedback integration dialog's input values are empty because of this I think
Image

it's really difficult to debug the feedback integration overall though. and its frustrating that you can't set a fallback value or another value for these inputs in the feedback integration constructor function - you're forced to rely on the scope which sucks.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    • Status

      Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions