Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet code setting User.id not showing up in iOS events #3621

Open
gywright opened this issue Sep 20, 2024 · 8 comments
Open

dotnet code setting User.id not showing up in iOS events #3621

gywright opened this issue Sep 20, 2024 · 8 comments
Labels
Bug Something isn't working Platform: iOS

Comments

@gywright
Copy link

Package

Sentry

.NET Flavor

.NET

.NET Version

8.0.6 (and some on versions from 8.0.0 to 8.0.7, error still seen in all)

OS

iOS

SDK Version

4.4

Self-Hosted Sentry Version

No response

Steps to Reproduce

Image attached describes code used to set User.Id and User.Username. This provides values for Android devices, but not for iOS devices. This code block comes directly after Sentry .init block. Localhost testing and logging show id does have value just before code block for iOS device tested.

Image

Expected Result

Expected to see User.Id and User.Username values for both Android and iOS.

Actual Result

No values for iOS devices. Customer believes this did work during initial testing, but no values seen in the last 90 days given code used (shown above).

@jamescrosswell
Copy link
Collaborator

@gywright when you initialise Sentry, are you setting EnableScopeSync = true?

/// <summary>
/// If true, the SDK's scope will be synced with the observed scope.
/// </summary>
public bool EnableScopeSync { get; set; }

@bitsandfoxes
Copy link
Contributor

@jamescrosswell afaik EnableScopeSync cannot be opted-out ouf:

// Set options for the managed SDK that depend on the Cocoa SDK. (The user will not be able to modify these.)
options.AddEventProcessor(new CocoaEventProcessor());
options.CrashedLastRun = () => SentryCocoaSdk.CrashedLastRun;
options.EnableScopeSync = true;

I gave this a try locally and I do get the user reported correctly on events captured through sentry.cocoa.dotnet.
At this point we'll need more information to repro or, ideally, a repro itself to dig into this deeper.

@bitsandfoxes bitsandfoxes added Bug Something isn't working Platform: iOS Question Further information is requested labels Sep 23, 2024
@jamescrosswell jamescrosswell added Needs Reproduction and removed Question Further information is requested labels Sep 25, 2024
@jamescrosswell
Copy link
Collaborator

Closing this as we can't reproduce. Please reopen if you're able to describe how we can reproduce this problem.

@espenrl
Copy link

espenrl commented Nov 8, 2024

@jamescrosswell I'm experiencing this problem. I have an ISentryEventProcessor which sole purpose is to set SentryEvent.User to a new SentryUser with details. On Android all events has the user details set. On iOS there are no user details.

I don't know which SDK treats the events differently (dotnet / cocoa / native). It could even be Sentry Cloud for that matter (ingestion / processing / view).

I can tell you that events generated from SentrySdk.CaptureException(e) does not have user details on iOS. So that should be the dotnet SDK, right?

Lately I've been having issues in MAUI that stuff stops working in published builds, while working as they should in development. There seems to be a lot of AOT issues lately. Seems like when libraries are preparing themselves for .NET 9 and AOT they break AOT compatibility on .NET 8. So that could also be an issue.

@jamescrosswell
Copy link
Collaborator

@bricefriha would you be able to try to reproduce this based on the steps @espenrl describes above?

@espenrl
Copy link

espenrl commented Nov 19, 2024

@jamescrosswell @bricefriha I've done some more in-depth testing. In most cases the SentryUser is set on the event using a custom ISentryEventProcessor. Using CauseCrash I discovered that the user details are missing on native crashes only. Perhaps my custom event processor never gets the chance to run before the unhandled native crash, I don't know.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 19, 2024
@bricefriha
Copy link
Contributor

thanks @espenrl,
That's super useful, I'll take a look at this today

@bricefriha
Copy link
Contributor

bricefriha commented Nov 19, 2024

I also noticed that events on unhandled crashes, as a whole (when setting the user detail in a custom scope), don't have user details. So yeah, I think we can identify the issue quite consistently now

Perhaps my custom event processor never gets the chance to run before the unhandled native crash, I don't know

@espenrl I checked that, and the event processor seems to run before the event is sent. So, the scope data are being ignored. I will confirm that with other scope-related tests (like adding attachments etc) to confirm

Update

I tested adding other attachments, and they are indeed not considered either. It seems to be related to the same problem, so we won't need to create a separate issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Platform: iOS
Projects
Status: Done
Status: No status
Development

No branches or pull requests

5 participants