getsentry/sentry-cocoa

ID missing after setting username field

Opened this issue · 2 comments

Platform

iOS

Environment

Production, Develop

Installed

Swift Package Manager

Version

8.10.0

Xcode Version

15.1

Did it work on previous versions?

No response

Steps to Reproduce

iOS SDK and android SDK have difference in terms of setting username. ID dissapears from webinterface after setting username on iOS, but staying on android. Example:

Android:
Снимок экрана 2024-06-04 в 23 40 40

iOS:
Снимок экрана 2024-06-04 в 23 41 12

There is ID field missing on iOS, and naming of fields is different after setting username. As i suppose if ID not set, we have fallback to installationID (which not work for some reason on iOS?..)

Expected Result

ID field still present, after setting username or other User fields.

Actual Result

ID field missing.

Are you willing to submit a PR?

No response

That's a good catch, @trst74 💯 . Thanks, for pointing this out.

I think it would make sense to change the logic to set a userID if no userID is set here to align with Android.

- (void)setUserIdIfNoUserSet:(SentryEvent *)event
{
// We only want to set the id if the customer didn't set a user so we at least set something to
// identify the user.
if (event.user == nil) {
SentryUser *user = [[SentryUser alloc] init];
user.userId = [SentryInstallation idWithCacheDirectoryPath:self.options.cacheDirectoryPath];
event.user = user;
}
}

Strictly speaking, this is a breaking change, as some people could rely on the current behavior. The next major will happen soon, so we can include it there.

Thanks a lot ! We'll be waiting :)