Skip to content

Using sentry_set_user but no users show up in dashboards #911

Closed
getsentry/sentry-docs
#8661

Description

@connorjclark

Description

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: windows, mac, linux
  • Compiler: msvc/clang
  • CMake version and config: [e.g. 3.17.2, SENTRY_BACKEND=inproc]

Steps To Reproduce

I have roughly this code:

sentry_init(options);
// ...
sentry_value_t user = sentry_value_new_object();
sentry_value_set_by_key(user, "ip_address", sentry_value_new_string("{{auto}}"));
sentry_set_user(user);

(full context here)

My interpretation based on the docs is that this should create a unique user for this user, at least until their IP address changes. However, I get 0 users in the various surfaces in the dashboard that deal with user related stuff. Sessions work just fine, but no user information.

Am I using this API incorrectly?

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Nov 28, 2023
  2. changed the title [-]Using `sentry_set_user` but not users show up in dashboards[/-] [+]Using `sentry_set_user` but no users show up in dashboards[/+] on Nov 28, 2023
  3. supervacuus commented on Nov 28, 2023

    @supervacuus
    Collaborator

    Thanks for the report, @connorjclark. The API usage is okay, and I expect events to be shown with an IP address representing users and counting them accordingly.

    Can someone look at the events(@kahest, @markushi, @Swatinem)? There is a DSN in the referenced "context". Could this be PII settings related?

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Nov 28, 2023
  5. kahest commented on Nov 29, 2023

    @kahest
    Contributor

    @connorjclark do you have storing of IP addresses enabled for the project on sentry.io? See the docs:

    To opt out of storing users' IP addresses in your event data, you can go to your project settings, click on "Security & Privacy", and enable "Prevent Storing of IP Addresses"

    This setting is used on the backend to determine whether IP addresses should be resolved and stored for incoming events where ip_address is set to {{auto}}.

  6. connorjclark commented on Nov 29, 2023

    @connorjclark
    Author

    Yes, that was on.

    Prevent Storing of IP Addresses
        Preventing IP addresses from being stored for new events
    

    I naively thought this would scrub the PII from the individual events/any long term data storage, but retain a unique identifier for purposes of user counting. I've turned it off now, hopefully I'll start to see user counts soon.

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Nov 29, 2023
  8. kahest commented on Nov 29, 2023

    @kahest
    Contributor

    @connorjclark got it, please let us know if that solved your issue. This is something we could communicate on the docs more clearly I feel.

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Nov 29, 2023
  10. connorjclark commented on Nov 29, 2023

    @connorjclark
    Author

    I'm seeing user / ip information on individual error events, so that is working.

    Should I be seeing user count information on views such as https://zeldaclassic.sentry.io/releases/?display=users&project=6563738&sort=date ? I can't seem to find any view into how many users (active or otherwise) a particular release has (or all releases in total), which is really what I'm after. Do I need to wait for a certain critical threshold for a graph to show here?

    I'm concerned that sentry is only getting user information for error events, but not getting a signal for when a user launches a program - no error happens - they close it. Is that a different API?

    Note, sessions track just fine. I see a graph of relative usage for each release over time.

  11. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Nov 29, 2023
  12. kahest commented on Dec 1, 2023

    @kahest
    Contributor

    @connorjclark thanks for reporting back - this should work, we'll need to investigate

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Dec 1, 2023
  14. kahest commented on Dec 4, 2023

    @kahest
    Contributor

    @connorjclark for User stats in Release Health, at least one of id, email or username of the user need to be set:

    sentry_value_t did = sentry_value_get_by_key(user, "id");
    if (sentry_value_is_null(did)) {
    did = sentry_value_get_by_key(user, "email");
    }
    if (sentry_value_is_null(did)) {
    did = sentry_value_get_by_key(user, "username");
    }
    sentry_value_decref(session->distinct_id);
    sentry_value_incref(did);
    session->distinct_id = did;

    Apologies for the confusion, I see that this is not clearly communicated in the docs and we'll look to improve this.

  15. supervacuus commented on Dec 4, 2023

    @supervacuus
    Collaborator

    Thanks, @kahest. Can I ask for further clarification? Since the page is part of the "common" docs and should be the same for all SDKs, I don't understand whether this is an undocumented requirement of the API (i.e., "Each of these is optional, but one must be present for the Sentry SDK to capture the user" is not entirely accurate) or whether the Native SDK could/should set the value of the ip_address as its session's distinct_id? Would the backend understand that?

  16. kahest commented on Dec 5, 2023

    @kahest
    Contributor

    @supervacuus yep I'm clarifying this internally and will follow up with docs updates and GH issues if necessary

  17. self-assigned this
    on Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions