Skip to content

User ID is left blank on Android #3302

Closed

Description

@espenrl

Package

Sentry.Maui

.NET Flavor

.NET

.NET Version

8.0.4

OS

Android

SDK Version

4.4.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

Setup a MAUI project configured for Sentry. Do not override user configuration - hence standard behavior is to be expected with regards to user information in Sentry events.

Expected Result

According to https://docs.sentry.io/platforms/dotnet/guides/maui/enriching-events/identify-user/#id

If you don't provide an id, the SDK falls back to installationId, which the SDK randomly generates once during an app's installation.

Actual Result

User ID is left blank/null in Sentry events.

On iOS the user ID is set to a randomly generated guid and hence works according to documentation.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 15, 2024
  2. bitsandfoxes commented on Apr 15, 2024

    @bitsandfoxes
    Contributor

    Hi @espenrl, thanks for raising this. Looks like a bug - the behaviour should indeed be the same on all platforms.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 15, 2024
  4. added
    Bug
    on Apr 15, 2024
  5. espenrl commented on Apr 16, 2024

    @espenrl
    Author
  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 16, 2024
  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 16, 2024
  8. jamescrosswell commented on Jun 17, 2024

    @jamescrosswell
    Collaborator

    This should be picked up here:

    get => _user ??= new SentryUser
    {
    PropertyChanged = UserChanged
    };
    set
    {
    if (_user != value)
    {
    _user = value;
    if (_user is not null)
    {
    _user.PropertyChanged = UserChanged;
    }
    UserChanged.Invoke(_user);
    }
    }

    And here:

    public string? Id
    {
    get => _id;
    set
    {
    if (_id != value)
    {
    _id = value;
    PropertyChanged?.Invoke(this);
    }
    }
    }

    However that's only the .NET side of the sync, which ensures that any changes made in the .NET SDK will be reflected in the Java SDK. Potentially the opposite (Java syncing with .NET) is not setup. Probably need to check if the JavaSDK has any observer/notifier capability around this that we could leverage.

    If not, another possibility would be to imitate this functionality inside the .NET SDK... that'd be a little bit fiddly - we'd need to someone refactor this so that it could be leveraged via a null coalescing operator in the getter for the user id.

  9. jamescrosswell commented on Jun 17, 2024

    @jamescrosswell
    Collaborator

    However that's only the .NET side of the sync, which ensures that any changes made in the .NET SDK will be reflected in the Java SDK. Potentially the opposite (Java syncing with .NET) is not setup. Probably need to check if the JavaSDK has any observer/notifier capability around this that we could leverage.

    @adinauer does this look familiar to you (syncing scope data between the SDKs)? Do you know if there is any functionality in the Java SDK to sync scope data when it changes in the Java SDK?

    In this particular case, the Java SDK sets the User.Id, but it's not being reflected up in the .NET layer before events get sent to Sentry.

  10. adinauer commented on Jun 18, 2024

    @adinauer
    Member
  11. jamescrosswell commented on Jun 18, 2024

    @jamescrosswell
    Collaborator

    Hey @jamescrosswell we do have IScopeObserver, which can be registered in options via addScopeObserver.

    Awesome, thanks @adinauer !

    @bitsandfoxes I'm not sure we can use though (due to the issues around our enrichers). Maybe best to catch up for a chat about this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugFramework: MAUI

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions