Skip to content

setUser from main does not accessible from renderer #1258

@shay8el

Description

@shay8el

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Electron SDK Version

7.2.0

Electron Version

35.0.3

What platform are you using?

MacOS

Link to Sentry event

No response

Steps to Reproduce

  1. trigger Sentry.setUser(user) from @sentry/electron/main
  2. access user data in beforeSendLogs of @sentry/electron/main that way:
const scope = Sentry.getGlobalScope()
const user = scope.getUser()

events sent with user data ✅
3. try to do the same on @sentry/electron/renderer
4. scope.getUser() is empty 🛑
5. setting the user from renderer - Sentry.setUser(user) from @sentry/electron/renderer
6. scope.getUser() is still empty 🛑

Expected Result

  • ideally, logs will be sent with user identifier
  • because it's not exists, had to use beforeSendLog, and manually enrich the log attributes with user
  • I would like to set user once (in fact, for captureError seems like the error and breadcrumbs are user identified)
  • If I already need to set it twice, I could set it with Sentry.setUser(user) without had to fetch scope

Actual Result

eventually wasn't ideal but it worked:

  • setting the user (2nd time) from renderer that way:
const globalScope = getGlobalScope()
globalScope.setUser(user)
  • accessing it the same way as before:
const scope = Sentry.getGlobalScope()
const user = scope.getUser()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions