setUser not work after upgade to 8.54.0
Platform
iOS
Environment
Production
Installed
Swift Package Manager
Version
8.54.0
Xcode Version
16.4.0
Did it work on previous versions?
No response
Steps to Reproduce
be sure to set SentrySDK.setUser(user) after SentrySDK.start
Expected Result
SentrySDK.setUser(user) work
Actual Result
no date set successfully
Are you willing to submit a PR?
No response
@kingnight, do I understand correctly that you call setUser before SentrySDK.start, and it doesn't work, and you expect it to work? If yes, that's kind of per design. You have to start the SDK before interacting with it.
@philipphofmann no, my code calling sequence has not changed,first SentrySDK.start,then setUser, only update sdk version.
By the way, in order to speed up launch time ,I call SentrySDK.start on non-main thread, but when call setUser , SentrySDK.start has finished, this point has checked
OK, I don't understand what exactly you mean by
no date set successfully
Please explain in more detail, @kingnight
That indicates that after upgrading the SDK from version 8.48.0 to 8.54.0, the Sentry backend fails to detect the custom user data I added using setUser. When using SDK version 8.48.0, this worked fine. Can I downgrade the SDK version in the production app ? Will the downgrade cause any database issues within the SDK?
Can I downgrade the SDK version in the production app ?
Yes, between these versions, it should be possible without issues.
I just tried this with one of our sample apps, and it works correctly.
let user = User(userId: "philipp")
user.email = "[email protected]"
SentrySDK.setUser(user)
I'm unsure what the problem is. Please be a bit more specific and tell us how exactly you call the API, what info you put on there, and what worked before and what doesn't work anymore, ideally with screenshots, @kingnight.
@philipphofmann I have find out the reason ,
If I use 'SentrySDK.start` in no-main thread( in order to speed up launch time )
DispatchQueue.global(qos: .utility).async{
SentrySDK.start { options in
// code
print("SentrySDK.start finished")
}
}
Then call
print("SentrySDK.setUser")
SentrySDK.setUser(user)
console log out
SentrySDK.start finished
....
SentrySDK.setUser
setUser will not be set succefully.
But if I use it on the main thread "SentrySDK.start ", then call SentrySDK.setUser(user),it 's ok
Or delay several seconds, then call SentrySDK.setUser(user),it 's ok too
The main reason remains the issue of timing for setUser(user) .
Ah there's a race condition happening in that case. Yes, we need to fix this. Thanks for the info, @kingnight.
@philipphofmann Thank you for your patience.